From 09db9d662b70649e2b378d2599dfe7f7a2bd93ab Mon Sep 17 00:00:00 2001 From: liudong <liudong> Date: 星期四, 22 八月 2024 16:19:43 +0800 Subject: [PATCH] agent会话停止功能 --- src/views/dmx/knowledgeLib/index.vue | 280 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 224 insertions(+), 56 deletions(-) diff --git a/src/views/dmx/knowledgeLib/index.vue b/src/views/dmx/knowledgeLib/index.vue index dcf6bcd..4f8fefc 100644 --- a/src/views/dmx/knowledgeLib/index.vue +++ b/src/views/dmx/knowledgeLib/index.vue @@ -88,6 +88,32 @@ type="text" class="button" style="color: #2a2a2b" + @click="enableDisable(1)" + > + <template #icon> + <icon-play-circle /> + </template> + 鍚敤 + </a-button> + </p> + <p> + <a-button + type="text" + class="button" + style="color: #2a2a2b" + @click="enableDisable(0)" + > + <template #icon> + <icon-record color="" /> + </template> + 绂佺敤 + </a-button> + </p> + <p> + <a-button + type="text" + class="button" + style="color: #2a2a2b" @click="addBlock(1)" > <template #icon> @@ -289,7 +315,21 @@ >{{ $t('dmx.list.complete') }}</a-tag > <template #content> - <p></p> + <p>娴佺▼寮�濮嬩簬锛歿{ record.process_begin_at }}</p> + <p + >杩囩▼鎸佺画鏃堕棿:{{ + record.process_duation.toFixed(2) + }}</p + > + <div> + <p + >杩涘害娑堟伅锛�<span + v-html=" + record.progress_msg.replace(/\n/g, '<br/>') + " + ></span + ></p> + </div> </template> </a-popover> <a-popover title="" v-if="record.run == '3'"> @@ -300,7 +340,21 @@ >{{ $t('dmx.list.complete') }}</a-tag > <template #content> - <p></p> + <p>娴佺▼寮�濮嬩簬锛歿{ record.process_begin_at }}</p> + <p + >杩囩▼鎸佺画鏃堕棿:{{ + record.process_duation.toFixed(2) + }}</p + > + <div> + <p + >杩涘害娑堟伅锛�<span + v-html=" + record.progress_msg.replace(/\n/g, '<br/>') + " + ></span + ></p> + </div> </template> </a-popover> <a-popover title="" v-if="record.run == '1'"> @@ -311,7 +365,21 @@ >瑙f瀽涓�...</a-tag > <template #content> - <p></p> + <p>娴佺▼寮�濮嬩簬锛歿{ record.process_begin_at }}</p> + <p + >杩囩▼鎸佺画鏃堕棿:{{ + record.process_duation.toFixed(2) + }}</p + > + <div> + <p + >杩涘害娑堟伅锛�<span + v-html=" + record.progress_msg.replace(/\n/g, '<br/>') + " + ></span + ></p> + </div> </template> </a-popover> <a-popover title="" v-if="record.run == '2'"> @@ -322,7 +390,21 @@ >{{ $t('dmx.list.cancel') }}</a-tag > <template #content> - <p></p> + <p>娴佺▼寮�濮嬩簬锛歿{ record.process_begin_at }}</p> + <p + >杩囩▼鎸佺画鏃堕棿:{{ + record.process_duation.toFixed(2) + }}</p + > + <div> + <p + >杩涘害娑堟伅锛�<span + v-html=" + record.progress_msg.replace(/\n/g, '<br/>') + " + ></span + ></p> + </div> </template> </a-popover> <a-popover title="" v-if="record.run == '0'"> @@ -333,7 +415,21 @@ >{{ $t('dmx.list.NotStarted') }} </a-tag> <template #content> - <p></p> + <p>娴佺▼寮�濮嬩簬锛歿{ record.process_begin_at }}</p> + <p + >杩囩▼鎸佺画鏃堕棿锛歿{ + record.process_duation.toFixed(2) + }}</p + > + <div> + <p + >杩涘害娑堟伅锛�<span + v-html=" + record.progress_msg.replace(/\n/g, '<br/>') + " + ></span + ></p> + </div> </template> </a-popover> </div> @@ -369,11 +465,16 @@ </div> </template> <template #action="{ record }"> - <tool - :kbtenantInfo="kbtenantInfo" - :item="record" - :kbdetail="kbdetail" - /> + <a-button + type="text" + :disabled="record.run == '1'" + @click="handleClick(record)" + size="small" + > + <template #icon> + <icon-tool /> + </template> + </a-button> <edit :item="record" @upTabdateItem="upTabdateItem" /> <a-popconfirm :content="'纭畾鍒犻櫎鍚�'" @@ -484,19 +585,25 @@ <excel v-if="documenttype == 'excel'" :previewSrc="previewSrc"></excel> <txtPdf v-if="documenttype == 'txtPdf'" :previewSrc="previewSrc"></txtPdf> </a-modal> + <tool + ref="toolForm" + :kbtenantInfo="kbtenantInfo" + :item="setObj" + :kbdetail="kbdetail" + /> </div> </template> <script lang="ts" setup> - import { - computed, - ref, - reactive, - watch, - nextTick, - onBeforeMount, - onMounted, - } from 'vue'; +import { + computed, + ref, + reactive, + watch, + nextTick, + onBeforeMount, + onMounted, onBeforeUnmount +} from "vue"; import { useI18n } from 'vue-i18n'; import useLoading from '@/hooks/loading'; import { @@ -513,6 +620,7 @@ kbdocumentchangeStatus, downloadFile, chunkSwitch, + changeStatus, } from '@/api/kbList'; import { Pagination } from '@/types/global'; import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface'; @@ -554,6 +662,7 @@ const formModel = ref(generateFormModel()); const cloneColumns = ref([]); const showColumns = ref<Column[]>([]); + let setObj = reactive({}); const size = ref<SizeProps>('medium'); let visible = ref(false); @@ -573,6 +682,7 @@ let kbdetail = reactive({}); let parser_ids = reactive({}); let seeObj = reactive({}); + let toolForm = ref(null); let kbtenantInfo = reactive({ asr_id: 'paraformer-realtime-8k-v1', embd_id: 'BAAI/bge-large-zh-v1.5', @@ -587,23 +697,27 @@ parser_idObj: {}, }); let tabs = ref([]); + let timer = null;// 瀹氭椂鍣� + + const selectTab = (index, item) => { selectedTab.value = index; + checkedArr.value = []; // console.log(item.id); kbobj = item; kbId = kbobj.id; + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 20, + ...basePagination, }); getKbdetail(kbobj.id); }; const basePagination: Pagination = { - current: 1, - pageSize: 20, + page: 1, + page_size: 10, }; const pagination = reactive({ ...basePagination, @@ -631,10 +745,12 @@ title: t('dmx.column.name'), dataIndex: 'name', slotName: 'name', + width: 300, }, { title: t('鍒嗗揩鏁�'), dataIndex: 'chunk_num', + width: 90, }, { title: t('dmx.column.UploadTime'), @@ -646,16 +762,19 @@ title: t('瑙f瀽鏂规硶'), dataIndex: 'parser_id', slotName: 'parser_id', + width: 150, }, { title: t('鍚敤'), dataIndex: 'status', slotName: 'status', + width: 100, }, { title: t('瑙f瀽鐘舵��'), dataIndex: 'run', slotName: 'run', + width: 100, }, { title: t('dmx.column.Operate'), @@ -721,8 +840,38 @@ }); // console.log(renderData.value, 'renderData'); + pagination.page = params.page; pagination.current = params.page; pagination.total = data.data.total; + + if(timer){ + clearInterval(timer); + } + // 瀹氭椂鍣ㄦ煡璇㈡枃妗� + timer = setInterval(async () => { + let params = { ...basePagination, kb_id: kbobj.id } + const data = await queryKbDocumentList(params); + if (data.code == '0') { + parser_ids = kbtenantInfo.parser_ids.split(',').reduce((acc, pair) => { + const [key, value] = pair.split(':'); + acc[key] = value; + return acc; + }, {}); + // console.log(parser_ids, 'parser_ids'); + kbtenantInfo.parser_idObj = parser_ids; + renderData.value = data.data.docs || []; + renderData.value = renderData.value.map((item) => { + return { + ...item, + loading: false, + parser_id: parser_ids[item.parser_id], + }; + }); + // console.log(renderData.value, 'renderData'); + } + }, 10000); + + } } catch (err) { // you can report use errorHandler or other @@ -732,20 +881,22 @@ }; const search = () => { + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 20, + ...basePagination, keywords: keywords.value, }); }; - const handleClick = () => { - visible.value = true; + const handleClick = (data) => { + Object.assign(setObj, data); + toolForm.value.handleClick(data); }; const onPageChange = (current: number) => { - fetchData({ ...basePagination, current }); + basePagination.page = current; + fetchData({ ...basePagination, kb_id: kbobj.id }); }; const selectTabAll = (val) => { @@ -757,7 +908,7 @@ checkedArr.value = val; }; - const knowledgeData = async (params = { page: 1, page_size: 20 }) => { + const knowledgeData = async (params = { page: 1, page_size: 10 }) => { listloading.value = true; try { const { data } = await queryKbList(params); @@ -768,10 +919,10 @@ kbobj = tabs.value[0]; kbId = kbobj.id; activeKey.value = '1'; + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 20, + ...basePagination, }); getKbdetail(kbobj.id); } else { @@ -800,7 +951,7 @@ const getknowledge = async (id) => { setLoading(true); try { - const { data } = await queryKbList({ page: 1, page_size: 20 }); + const { data } = await queryKbList({ page: 1, page_size: 10 }); console.log(data, '鏌ヨ鐭ヨ瘑搴撳垪琛�'); tabs.value = data; if (tabs.value.length > 0) { @@ -855,24 +1006,37 @@ const cancleConfig = () => { activeKey.value = '1'; let id = tabs.value[selectedTab.value].id; - fetchData({ - kb_id: id, - page: 1, - page_size: 20, - }); + // basePagination.page = 1; + // fetchData({ + // kb_id: id, + // ...basePagination, + // }); }; const saveConfig = async () => { activeKey.value = '1'; let id = tabs.value[selectedTab.value].id; - const { data } = await queryKbList({ page: 1, page_size: 20 }); + const { data } = await queryKbList({ page: 1, page_size: 10 }); tabs.value = data; fetchData({ kb_id: id, - page: 1, - page_size: 20, + ...basePagination, }); getKbdetail(id); // 鑾峰彇璇︽儏 + }; + + const enableDisable = async (type) => { + Promise.all( + checkedArr.value.map(async (item) => { + await changeStatus({ + doc_id: item, + status: type, + }); + }) + ).then(() => { + Message.success('鏇存柊鎴愬姛'); + getKbList(); + }); }; //鎵归噺鍚敤鍒犻櫎绂佺敤 @@ -891,11 +1055,7 @@ } }); }); - fetchData({ - kb_id: tabs.value[selectedTab.value].id, - page: 1, - page_size: 20, - }); + getKbList(); } else { // Message.error('瑙f瀽澶辫触'); // row.run = '1'; @@ -912,16 +1072,19 @@ let data = await kbdocumentrm({ doc_id: checkedArr.value }); if (data.code == 0) { Message.success('鍒犻櫎鎴愬姛'); - fetchData({ - kb_id: tabs.value[selectedTab.value].id, - page: 1, - page_size: 20, - }); + getKbList(); } }, onCancel: () => {}, }); } + }; + + const getKbList = async () => { + await fetchData({ + kb_id: tabs.value[selectedTab.value].id, + ...basePagination, + }); }; const exchangeArray = <T extends Array<any>>( @@ -981,8 +1144,7 @@ // console.log(kbobj, 'kbobj'); fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 20, + ...basePagination, }); } }; @@ -1045,11 +1207,14 @@ run: run, }); if (data.code == 0) { + // 瀹氭椂鍣ㄦ煡璇㈠綋鍓嶅垪琛� fetchData({ kb_id: tabs.value[selectedTab.value].id, - page: 1, - page_size: 20, + ...basePagination, }); + + + } else { // Message.error('瑙f瀽澶辫触'); // row.run = '1'; @@ -1059,10 +1224,10 @@ }; const changeFetchData = async (row) => { + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 20, + ...basePagination, }); }; watch( @@ -1086,6 +1251,9 @@ onMounted(() => { knowledgeData(); }); + onBeforeUnmount(() => { + clearInterval(timer); + }) </script> <style scoped lang="less"> -- Gitblit v1.8.0