From 1c180d70f0445fa804b40df106e1fdbb50508c55 Mon Sep 17 00:00:00 2001 From: yinbangzhong <zhongbangyin@126.com> Date: 星期一, 02 九月 2024 09:22:33 +0800 Subject: [PATCH] 单文档 --- src/views/sessionManager/index.vue | 132 ++++++++++++++++++++++++++++++++++++------- 1 files changed, 110 insertions(+), 22 deletions(-) diff --git a/src/views/sessionManager/index.vue b/src/views/sessionManager/index.vue index b90966c..a7332b5 100644 --- a/src/views/sessionManager/index.vue +++ b/src/views/sessionManager/index.vue @@ -291,18 +291,20 @@ /> </template> <template #content> - <a-textarea - readonly - auto-size - v-model="displayedText" - :class="{ chatItemAnswer: theme === 'light' }" - :style="{ - backgroundColor: - theme === 'light' ? '#ffffff' : '#000000', - }" - style="border: none" - > - </a-textarea> + <a-spin :loading="chartLoading" dot style="width: 100%"> + <a-textarea + readonly + auto-size + v-model="displayedText" + :class="{ chatItemAnswer: theme === 'light' }" + :style="{ + backgroundColor: + theme === 'light' ? '#ffffff' : '#000000', + }" + style="border: none" + > + </a-textarea> + </a-spin> </template> <template #actions> @@ -382,9 +384,11 @@ ></updataFile> <!-- <uploadFile ref="fileInput" - :sessionId="activeSessionId" + :handleRemove="handleRemove" + :typeXLse="false" @selectFileCallback="selectFileCallback" ></uploadFile> --> + <a-button :disabled="chatDis" @click="sentClick" @@ -543,6 +547,9 @@ getSessionDetailsApi, sessionListApi, uploadWithoutKb, + uploadAndParse, + chatInfos, + chatRm, } from '@/api/session'; import { getAuthorization } from '@/utils/auth'; import { queryCanvasList } from '@/api/Agent'; @@ -574,6 +581,7 @@ const modalObj = reactive({ add: false }); const dialogId = ref(''); const chatDis = ref(false); + const chartLoading = ref(false); const loading = ref(false); const agentType = ref('1'); const agentTitle = ref('鏈懡鍚嶄細璇�'); @@ -765,9 +773,76 @@ // formRef.value.resetFields(); }; - const selectFileCallback = (data) => { - console.log(data, 'selectFileCallback'); + const selectFileCallback = (data,conversation_id) => { uploaditemList.value = [...uploaditemList.value, ...data]; + activeSessionId.value = conversation_id; + }; + + //涓婁紶 + // const selectFileCallback = async (resData, file) => { + // console.log(111); + // try { + // const formData = new FormData(); + // uploaditemList.value = resData; + // uploaditemList.value.map((item) => { + // if (item.name == file[0].file.name) { + // item.onFileSelectedLoading = true; + // item.textName = '涓婁紶涓�'; + // } + // return item; + // }); + // debugger; + // if (!activeSessionId.value) { + // await createSession(resData); + // } + + // // onFileSelectedLoading.value = true; + // // textName.value = '涓婁紶涓�'; + + // formData.append('files', file[0].file); + // formData.append('conversation_id', activeSessionId.value); + + // console.log(formData, 'formData'); + // const { data, code } = await uploadAndParse(formData); + // if (code === 200) { + // uploaditemList.value.map((item: any) => { + // item.onFileSelectedLoading = false; + // item.textName = '涓婁紶鎴愬姛'; + // return item; + // }); + // getInfo(data); + // // onFileSelectedLoading.value = false; + // // textName.value = '涓婁紶鎴愬姛'; + // } + // } catch (err) { + // uploaditemList.value.map((item: any) => { + // item.onFileSelectedLoading = false; + // item.textName = '涓婁紶澶辫触'; + // return item; + // }); + // // onFileSelectedLoading.value = false; + // // textName.value = '涓婁紶澶辫触'; + // Message.error('涓婁紶澶辫触'); + // } + // }; + + //涓婁紶鎴愬姛瑙f瀽getinfo + const getInfo = async (id) => { + const { code, data } = await chatInfos({ + doc_ids: activeSessionId.value, + }); + if (code === 200) { + uploaditemList.value = data; + } + }; + //鍒犻櫎涓婁紶鏂囨。 + const deleteUpload = async (id) => { + const { code, data } = await chatRm({ + doc_id: id, + }); + if (code === 200) { + getInfo(); + } }; let onFileSelectedLoading = ref(false); @@ -775,6 +850,7 @@ const deleteFile = (item) => { console.log(uploaditemList.value); uploaditemList.value.splice(item.index, 1); + // EventBus.emit('queryAgent', item); }; const { toClipboard } = useClipboard(); @@ -844,7 +920,7 @@ console.log(name, '鏂板缓浼氳瘽鍚嶇О'); const res = await addSessionApi({ - dialog_id: id, + dialog_id: '', conversation_desc: name, }); // console.log(res, "res"); @@ -925,6 +1001,7 @@ const startChat = async (valMsg) => { chatDis.value = true; loading.value = true; + chartLoading.value = true; toStop = false; sessionDetailList.value.push({ content: valMsg, @@ -968,6 +1045,7 @@ if (typeof d !== 'boolean') { // console.info("data:", d); streamStr.value = d.content; + chartLoading.value = false; startDisplayStr(); } } catch (e) { @@ -976,6 +1054,7 @@ if (done) { console.info('done'); displayedText.value = ''; + chartLoading.value = false; if (isStopChat.value) { setChatDataMeg(chatDataMeg); } else { @@ -1118,9 +1197,10 @@ activeSessionId.value = ''; }); onMounted(() => { + document.getElementsByTagName; let container = document.getElementById('container'); container.addEventListener('click', () => { - fileInput.value.cancel(); + // fileInput.value.cancel(); }); EventBus.on('newChat', () => { agentType.value = '1'; @@ -1226,11 +1306,11 @@ } } } - .uploadFileDis { - :deep(.arco-upload-list-type-text) { - display: none; - } - } + // .uploadFileDis { + // :deep(.arco-upload-list-type-text) { + // display: none; + // } + // } .prompt { ul { margin: 0; @@ -1386,6 +1466,11 @@ } } } + .uploadFileDis { + :deep(.arco-upload-list-type-text) { + display: none; + } + } .chat-item { padding: 10px 0; @@ -1427,6 +1512,9 @@ margin-left: 10px; } } + :deep(.arco-spin-loading .arco-spin-mask-icon) { + left: 10%; + } } .right { -- Gitblit v1.8.0