|
@@ -17,6 +17,7 @@
|
|
|
{{ suggestion }}<icon-arrow-right />
|
|
{{ suggestion }}<icon-arrow-right />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+
|
|
|
<div class="dialog-list" v-if="dialogList.length > 0" :key="randomKey">
|
|
<div class="dialog-list" v-if="dialogList.length > 0" :key="randomKey">
|
|
|
<div :class="['dialog-item', isSetting ? '' : 'dialog-absolute']" v-for="(item, key) in dialogList"
|
|
<div :class="['dialog-item', isSetting ? '' : 'dialog-absolute']" v-for="(item, key) in dialogList"
|
|
|
:key="item.key">
|
|
:key="item.key">
|
|
@@ -97,9 +98,11 @@
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</section>
|
|
</section>
|
|
|
|
|
+
|
|
|
<p v-if="type === 'knowledge' && item.answer" style="margin-top: 10px; font-size: 18px; font-weight: bold">
|
|
<p v-if="type === 'knowledge' && item.answer" style="margin-top: 10px; font-size: 18px; font-weight: bold">
|
|
|
答案生成结果
|
|
答案生成结果
|
|
|
</p>
|
|
</p>
|
|
|
|
|
+
|
|
|
<p v-if="item.answer" :style="{ 'margin-top': type === 'knowledge' ? '12px' : '0' }">
|
|
<p v-if="item.answer" :style="{ 'margin-top': type === 'knowledge' ? '12px' : '0' }">
|
|
|
<span v-if="type === 'paper'" class="paper-wrap">
|
|
<span v-if="type === 'paper'" class="paper-wrap">
|
|
|
<img src="@/assets/question/word.svg" />
|
|
<img src="@/assets/question/word.svg" />
|
|
@@ -115,6 +118,7 @@
|
|
|
<div class="dialog-footer" v-else>
|
|
<div class="dialog-footer" v-else>
|
|
|
<span v-html="getHTML(item.answer)"></span>
|
|
<span v-html="getHTML(item.answer)"></span>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+
|
|
|
<!-- 处理来源 -->
|
|
<!-- 处理来源 -->
|
|
|
<div v-if="(type === 'knowledge' || type === 'knowledgeQuiz') && item.reference && item.reference.length > 0"
|
|
<div v-if="(type === 'knowledge' || type === 'knowledgeQuiz') && item.reference && item.reference.length > 0"
|
|
|
class="knowledge-wrap">
|
|
class="knowledge-wrap">
|
|
@@ -123,10 +127,11 @@
|
|
|
<!-- TODO详情暂时注释 -->
|
|
<!-- TODO详情暂时注释 -->
|
|
|
<!-- <p @click="goKnowledge">查看全部关联 ></p> -->
|
|
<!-- <p @click="goKnowledge">查看全部关联 ></p> -->
|
|
|
</header>
|
|
</header>
|
|
|
|
|
+
|
|
|
<section>
|
|
<section>
|
|
|
<div v-for="(knowledge, knowledgeIndex) in item.reference" :key="knowledgeIndex">
|
|
<div v-for="(knowledge, knowledgeIndex) in item.reference" :key="knowledgeIndex">
|
|
|
<a-popover :title="knowledge.doc_name" position="left">
|
|
<a-popover :title="knowledge.doc_name" position="left">
|
|
|
- <div>
|
|
|
|
|
|
|
+ <div @click="openDocuementPage(knowledge)">
|
|
|
<span>{{ knowledgeIndex + 1 }}</span>
|
|
<span>{{ knowledgeIndex + 1 }}</span>
|
|
|
<span>{{ knowledge.doc_name }}</span>
|
|
<span>{{ knowledge.doc_name }}</span>
|
|
|
</div>
|
|
</div>
|
|
@@ -153,8 +158,8 @@
|
|
|
</div>
|
|
</div>
|
|
|
</section>
|
|
</section>
|
|
|
</div>
|
|
</div>
|
|
|
- <!-- 如果有图片 -->
|
|
|
|
|
|
|
|
|
|
|
|
+ <!-- 如果有图片 -->
|
|
|
<div v-if="item?.image_url">
|
|
<div v-if="item?.image_url">
|
|
|
<a-image width="500" :src="item?.image_url" />
|
|
<a-image width="500" :src="item?.image_url" />
|
|
|
</div>
|
|
</div>
|
|
@@ -222,6 +227,8 @@ import { defineComponent, ref, onBeforeUnmount, onMounted, reactive, nextTick, i
|
|
|
import formatAnwserString from './refference-effect/format-anwser-string';
|
|
import formatAnwserString from './refference-effect/format-anwser-string';
|
|
|
import applyRefferencePopover from './refference-effect/apply-refference-popover';
|
|
import applyRefferencePopover from './refference-effect/apply-refference-popover';
|
|
|
|
|
|
|
|
|
|
+import {getDocumentUrl} from '../ajax/document';
|
|
|
|
|
+
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
|
components: {
|
|
components: {
|
|
|
DialogFeedback
|
|
DialogFeedback
|
|
@@ -263,13 +270,16 @@ export default defineComponent({
|
|
|
let dialogIndex = dialogList.length;
|
|
let dialogIndex = dialogList.length;
|
|
|
const dialogScroll = ref("");
|
|
const dialogScroll = ref("");
|
|
|
const dialogConfig = ref({});
|
|
const dialogConfig = ref({});
|
|
|
|
|
+
|
|
|
const scrollToEnd = async () => {
|
|
const scrollToEnd = async () => {
|
|
|
await nextTick();
|
|
await nextTick();
|
|
|
if (dialogScroll.value) {
|
|
if (dialogScroll.value) {
|
|
|
dialogScroll.value.scrollTop = dialogScroll.value.scrollHeight;
|
|
dialogScroll.value.scrollTop = dialogScroll.value.scrollHeight;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
let answerInterval = null;
|
|
let answerInterval = null;
|
|
|
|
|
+
|
|
|
const stopWriting = () => {
|
|
const stopWriting = () => {
|
|
|
window.clearInterval(answerInterval);
|
|
window.clearInterval(answerInterval);
|
|
|
emit("set-readonly", false);
|
|
emit("set-readonly", false);
|
|
@@ -281,28 +291,26 @@ export default defineComponent({
|
|
|
scrollToEnd();
|
|
scrollToEnd();
|
|
|
dialogIndex += 1;
|
|
dialogIndex += 1;
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
const addData = (data) => {
|
|
const addData = (data) => {
|
|
|
dialogList.splice(dialogIndex, 1, data);
|
|
dialogList.splice(dialogIndex, 1, data);
|
|
|
randomKey.value = Math.random();
|
|
randomKey.value = Math.random();
|
|
|
scrollToEnd();
|
|
scrollToEnd();
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
const saveAnswer = (index) => {
|
|
const saveAnswer = (index) => {
|
|
|
if (!props.readonly) {
|
|
if (!props.readonly) {
|
|
|
menuList[index].save = !menuList[index].save;
|
|
menuList[index].save = !menuList[index].save;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
const openCapacity = (index) => {
|
|
const openCapacity = (index) => {
|
|
|
if (!props.readonly) {
|
|
if (!props.readonly) {
|
|
|
menuList[index].open = !menuList[index].open;
|
|
menuList[index].open = !menuList[index].open;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
- const openDocument = (index, documentIndex) => {
|
|
|
|
|
- if (menuList[index].documentOpenIndex === documentIndex) {
|
|
|
|
|
- menuList[index].documentOpenIndex = -1;
|
|
|
|
|
- } else {
|
|
|
|
|
- menuList[index].documentOpenIndex = documentIndex;
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
const feedbackAnswer = () => {
|
|
const feedbackAnswer = () => {
|
|
|
if (!props.readonly) {
|
|
if (!props.readonly) {
|
|
|
showFeedback.value = true;
|
|
showFeedback.value = true;
|
|
@@ -319,11 +327,13 @@ export default defineComponent({
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
const copyAnswer = (text) => {
|
|
const copyAnswer = (text) => {
|
|
|
if (!props.readonly) {
|
|
if (!props.readonly) {
|
|
|
helper.copyText(text, "复制成功");
|
|
helper.copyText(text, "复制成功");
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
const reQuestion = (text) => {
|
|
const reQuestion = (text) => {
|
|
|
if (!props.readonly) {
|
|
if (!props.readonly) {
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
@@ -331,9 +341,29 @@ export default defineComponent({
|
|
|
}, 200);
|
|
}, 200);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+ const openDocument = (index, documentIndex) => {
|
|
|
|
|
+ if (menuList[index].documentOpenIndex === documentIndex) {
|
|
|
|
|
+ menuList[index].documentOpenIndex = -1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ menuList[index].documentOpenIndex = documentIndex;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
const goKnowledge = () => {
|
|
const goKnowledge = () => {
|
|
|
- emit("go-document");
|
|
|
|
|
|
|
+ // emit("go-document");
|
|
|
};
|
|
};
|
|
|
|
|
+ // 点击文档,打开新页面
|
|
|
|
|
+ const openDocuementPage = (knowledge) => {
|
|
|
|
|
+ const doc_name = knowledge.doc_name;
|
|
|
|
|
+ const doc_id = knowledge.id;
|
|
|
|
|
+
|
|
|
|
|
+ // const pdf_url = `http://192.168.20.119:11080/v1/document/get/${doc_id}`;
|
|
|
|
|
+ const pdf_url = getDocumentUrl(doc_id);
|
|
|
|
|
+
|
|
|
|
|
+ window.open(pdf_url);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
const addLoading = (data) => {
|
|
const addLoading = (data) => {
|
|
|
const mockData = DOCUMENT_RESULT;
|
|
const mockData = DOCUMENT_RESULT;
|
|
|
data.capacity = {
|
|
data.capacity = {
|
|
@@ -388,6 +418,7 @@ export default defineComponent({
|
|
|
helper.webSocket.close();
|
|
helper.webSocket.close();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
scrollToEnd();
|
|
scrollToEnd();
|
|
|
/**
|
|
/**
|
|
@@ -395,20 +426,70 @@ export default defineComponent({
|
|
|
* 答案中 引用图标(感叹号)点击时,浮层显示引用内容
|
|
* 答案中 引用图标(感叹号)点击时,浮层显示引用内容
|
|
|
*/
|
|
*/
|
|
|
applyRefferencePopover(props.list);
|
|
applyRefferencePopover(props.list);
|
|
|
- // 如果是智能数据,则拿缓存里的数据开启对话
|
|
|
|
|
- if (helper.read("sendData") && helper.read("sendData").agent_id == 'basic_excel_talk') {
|
|
|
|
|
- const data = helper.read("sendData");
|
|
|
|
|
- helper.webSocket = ajax.message.create(helper.read("token"), data.agent_id, data.chat_id, props.type);
|
|
|
|
|
- // 创建对话之后清空缓存
|
|
|
|
|
- helper.write('sendData', {});
|
|
|
|
|
- } else {
|
|
|
|
|
- helper.webSocket = ajax.message.create(helper.read("token"), props.agentId, props.dialogId, props.type);
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // socket 消息队列
|
|
|
|
|
+ // TODO: 只允许保存一条消息
|
|
|
|
|
+ let msg_list = [];
|
|
|
|
|
+
|
|
|
|
|
+ function createSocket(){
|
|
|
|
|
+ const token = helper.read("token");
|
|
|
|
|
+ // 如果是智能数据,则拿缓存里的数据开启对话
|
|
|
|
|
+ if (helper.read("sendData") && helper.read("sendData").agent_id == 'basic_excel_talk') {
|
|
|
|
|
+ const data = helper.read("sendData");
|
|
|
|
|
+
|
|
|
|
|
+ helper.webSocket = ajax.message.create(token, data.agent_id, data.chat_id, props.type);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建对话之后清空缓存
|
|
|
|
|
+ helper.write('sendData', {});
|
|
|
|
|
+ } else {
|
|
|
|
|
+ helper.webSocket = ajax.message.create(token, props.agentId, props.dialogId, props.type);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 监听socket开启事件
|
|
|
|
|
+ // 当socket开启后,遍历消息,并发送
|
|
|
|
|
+ helper.webSocket.onopen = function(event){
|
|
|
|
|
+ msg_list.forEach(item => {
|
|
|
|
|
+ helper.webSocket.send(item);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 所有消息发送完成后,清空消息队列
|
|
|
|
|
+ msg_list = [];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 发送socket数据
|
|
|
|
|
+ function sendSocketMsg(dt){
|
|
|
|
|
+ // 判断socket是否开启
|
|
|
|
|
+ // 如果开启,则直接发送,如果没有开启,则将数据推入消息队列
|
|
|
|
|
+ if(helper.webSocket.readyState === 0){
|
|
|
|
|
+ msg_list.push(dt);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(helper.webSocket.readyState === 1){
|
|
|
|
|
+ helper.webSocket.send(dt);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(helper.webSocket.readyState === 2){
|
|
|
|
|
+ // 正在关闭
|
|
|
|
|
+ console.log('web socket正在关闭');
|
|
|
|
|
+ }
|
|
|
|
|
+ if(helper.webSocket.readyState === 3){
|
|
|
|
|
+ msg_list.push(dt);
|
|
|
|
|
+
|
|
|
|
|
+ // 已关闭: 重新开启socket
|
|
|
|
|
+ createSocket();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 创建socket链接
|
|
|
|
|
+ createSocket();
|
|
|
|
|
+
|
|
|
helper.webSocket.onmessage = (event) => {
|
|
helper.webSocket.onmessage = (event) => {
|
|
|
const { type, reference, step_message, files } = JSON.parse(event.data);
|
|
const { type, reference, step_message, files } = JSON.parse(event.data);
|
|
|
|
|
+
|
|
|
let { message } = JSON.parse(event.data);
|
|
let { message } = JSON.parse(event.data);
|
|
|
|
|
+
|
|
|
if (!loadingData.value) return;
|
|
if (!loadingData.value) return;
|
|
|
|
|
+
|
|
|
if (type === "stream") {
|
|
if (type === "stream") {
|
|
|
// 没解析完就一直loading
|
|
// 没解析完就一直loading
|
|
|
if (step_message == '文件上传完成,开始解析') {
|
|
if (step_message == '文件上传完成,开始解析') {
|
|
@@ -423,9 +504,11 @@ export default defineComponent({
|
|
|
addData(loadingData.value);
|
|
addData(loadingData.value);
|
|
|
} else {
|
|
} else {
|
|
|
answerData.value += step_message ? getHTML(step_message) + "</br>" : message
|
|
answerData.value += step_message ? getHTML(step_message) + "</br>" : message
|
|
|
|
|
+
|
|
|
if (answerData.value && !isLoaded.value) {
|
|
if (answerData.value && !isLoaded.value) {
|
|
|
answerLoaded();
|
|
answerLoaded();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
addAnswer(loadingData.value);
|
|
addAnswer(loadingData.value);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -458,17 +541,20 @@ export default defineComponent({
|
|
|
if (image_url) {
|
|
if (image_url) {
|
|
|
imageUrl.value = `http://${window.location.hostname}${port}${image_url}`
|
|
imageUrl.value = `http://${window.location.hostname}${port}${image_url}`
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (excel_url) {
|
|
if (excel_url) {
|
|
|
const file = {
|
|
const file = {
|
|
|
file_type: 'excel',
|
|
file_type: 'excel',
|
|
|
file_url: `http://${window.location.hostname}${port}${excel_url}`,
|
|
file_url: `http://${window.location.hostname}${port}${excel_url}`,
|
|
|
file_name: `${excel_name}.xlsx` || '点击下载',
|
|
file_name: `${excel_name}.xlsx` || '点击下载',
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
answerFile.value = file
|
|
answerFile.value = file
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (code) answerCode.value = getHTML(code);
|
|
if (code) answerCode.value = getHTML(code);
|
|
|
- if (sql) answerSql.value = getHTML(sql);
|
|
|
|
|
|
|
|
|
|
|
|
+ if (sql) answerSql.value = getHTML(sql);
|
|
|
}
|
|
}
|
|
|
if (props.type == 'question') {
|
|
if (props.type == 'question') {
|
|
|
const { file_url, filename, excel_name } = JSON.parse(event.data);
|
|
const { file_url, filename, excel_name } = JSON.parse(event.data);
|
|
@@ -486,11 +572,10 @@ export default defineComponent({
|
|
|
if (answerData.value && !isLoaded.value) {
|
|
if (answerData.value && !isLoaded.value) {
|
|
|
answerLoaded();
|
|
answerLoaded();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
addAnswer(loadingData.value);
|
|
addAnswer(loadingData.value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
if (type === "close") {
|
|
if (type === "close") {
|
|
|
if (!answerData.value) {
|
|
if (!answerData.value) {
|
|
|
answerLoaded();
|
|
answerLoaded();
|
|
@@ -502,6 +587,11 @@ export default defineComponent({
|
|
|
isLoaded.value = false;
|
|
isLoaded.value = false;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 所有数据的发送,统一走到这里
|
|
|
|
|
+ * 通过websocket进行发送
|
|
|
|
|
+ */
|
|
|
helper.$bus.on("send-message", (value) => {
|
|
helper.$bus.on("send-message", (value) => {
|
|
|
dialogConfig.value = helper.dialogConfig;
|
|
dialogConfig.value = helper.dialogConfig;
|
|
|
const question = props.type === "report" ? value.inputs.report_name : value;
|
|
const question = props.type === "report" ? value.inputs.report_name : value;
|
|
@@ -513,22 +603,30 @@ export default defineComponent({
|
|
|
: {
|
|
: {
|
|
|
message: value
|
|
message: value
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
if (props.type === 'doc') {
|
|
if (props.type === 'doc') {
|
|
|
sendData.doc_ids = [helper.read('docId')];
|
|
sendData.doc_ids = [helper.read('docId')];
|
|
|
}
|
|
}
|
|
|
- helper.webSocket.send(JSON.stringify(sendData));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const dt = JSON.stringify(sendData);
|
|
|
|
|
+
|
|
|
|
|
+ // 发送socket数据
|
|
|
|
|
+ sendSocketMsg(dt)
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
helper.$bus.on("clear-message", () => {
|
|
helper.$bus.on("clear-message", () => {
|
|
|
dialogList.splice(0);
|
|
dialogList.splice(0);
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
helper.$bus.on("stop-writing", () => {
|
|
helper.$bus.on("stop-writing", () => {
|
|
|
stopWriting();
|
|
stopWriting();
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
goKnowledge,
|
|
goKnowledge,
|
|
|
randomKey,
|
|
randomKey,
|
|
|
- openDocument,
|
|
|
|
|
|
|
+
|
|
|
showFeedback,
|
|
showFeedback,
|
|
|
copyAnswer,
|
|
copyAnswer,
|
|
|
dialogList,
|
|
dialogList,
|
|
@@ -546,7 +644,10 @@ export default defineComponent({
|
|
|
knowledgeList,
|
|
knowledgeList,
|
|
|
dialogConfig,
|
|
dialogConfig,
|
|
|
userName,
|
|
userName,
|
|
|
- downloadFile
|
|
|
|
|
|
|
+ downloadFile,
|
|
|
|
|
+
|
|
|
|
|
+ openDocument,
|
|
|
|
|
+ openDocuementPage
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|