From 37e2d4d559daef357188ae635fa70efdbeb76e21 Mon Sep 17 00:00:00 2001 From: liudong <liudong> Date: 星期二, 20 八月 2024 15:35:17 +0800 Subject: [PATCH] 知识库功能优化 --- src/views/dmx/knowledgeLib/index.vue | 109 ++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 73 insertions(+), 36 deletions(-) diff --git a/src/views/dmx/knowledgeLib/index.vue b/src/views/dmx/knowledgeLib/index.vue index 8d5be12..c3086fa 100644 --- a/src/views/dmx/knowledgeLib/index.vue +++ b/src/views/dmx/knowledgeLib/index.vue @@ -584,15 +584,15 @@ </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 { @@ -684,6 +684,9 @@ parser_idObj: {}, }); let tabs = ref([]); + let timer = null;// 瀹氭椂鍣� + + const selectTab = (index, item) => { selectedTab.value = index; @@ -691,10 +694,10 @@ // console.log(item.id); kbobj = item; kbId = kbobj.id; + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 10, + ...basePagination, }); getKbdetail(kbobj.id); }; @@ -729,10 +732,12 @@ title: t('dmx.column.name'), dataIndex: 'name', slotName: 'name', + width: 300, }, { title: t('鍒嗗揩鏁�'), dataIndex: 'chunk_num', + width: 90, }, { title: t('dmx.column.UploadTime'), @@ -744,16 +749,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'), @@ -820,7 +828,37 @@ // 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 @@ -830,10 +868,10 @@ }; const search = () => { + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 10, + ...basePagination, keywords: keywords.value, }); }; @@ -843,7 +881,8 @@ }; const onPageChange = (current: number) => { - fetchData({ ...basePagination, page: current, kb_id: kbobj.id }); + basePagination.page = current; + fetchData({ ...basePagination, kb_id: kbobj.id }); }; const selectTabAll = (val) => { @@ -866,10 +905,10 @@ kbobj = tabs.value[0]; kbId = kbobj.id; activeKey.value = '1'; + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 10, + ...basePagination, }); getKbdetail(kbobj.id); } else { @@ -953,11 +992,11 @@ const cancleConfig = () => { activeKey.value = '1'; let id = tabs.value[selectedTab.value].id; - fetchData({ - kb_id: id, - page: 1, - page_size: 10, - }); + // basePagination.page = 1; + // fetchData({ + // kb_id: id, + // ...basePagination, + // }); }; const saveConfig = async () => { @@ -967,8 +1006,7 @@ tabs.value = data; fetchData({ kb_id: id, - page: 1, - page_size: 10, + ...basePagination, }); getKbdetail(id); // 鑾峰彇璇︽儏 }; @@ -1003,11 +1041,6 @@ } }); }); - // fetchData({ - // kb_id: tabs.value[selectedTab.value].id, - // page: 1, - // page_size: 20, - // }); getKbList(); } else { // Message.error('瑙f瀽澶辫触'); @@ -1036,8 +1069,7 @@ const getKbList = async () => { await fetchData({ kb_id: tabs.value[selectedTab.value].id, - page: 1, - page_size: 10, + ...basePagination, }); }; @@ -1098,8 +1130,7 @@ // console.log(kbobj, 'kbobj'); fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 10, + ...basePagination, }); } }; @@ -1162,11 +1193,14 @@ run: run, }); if (data.code == 0) { + // 瀹氭椂鍣ㄦ煡璇㈠綋鍓嶅垪琛� fetchData({ kb_id: tabs.value[selectedTab.value].id, - page: 1, - page_size: 10, + ...basePagination, }); + + + } else { // Message.error('瑙f瀽澶辫触'); // row.run = '1'; @@ -1176,10 +1210,10 @@ }; const changeFetchData = async (row) => { + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 10, + ...basePagination, }); }; watch( @@ -1203,6 +1237,9 @@ onMounted(() => { knowledgeData(); }); + onBeforeUnmount(() => { + clearInterval(timer); + }) </script> <style scoped lang="less"> -- Gitblit v1.8.0