From 30c1eeca00527a1294c62b1c708edd32ba079b67 Mon Sep 17 00:00:00 2001 From: yinbangzhong <zhongbangyin@126.com> Date: 星期四, 29 八月 2024 17:35:47 +0800 Subject: [PATCH] select role --- src/views/dmx/knowledgeLib/index.vue | 209 ++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 146 insertions(+), 63 deletions(-) diff --git a/src/views/dmx/knowledgeLib/index.vue b/src/views/dmx/knowledgeLib/index.vue index 8d5be12..994f862 100644 --- a/src/views/dmx/knowledgeLib/index.vue +++ b/src/views/dmx/knowledgeLib/index.vue @@ -23,8 +23,9 @@ :class="{ active: selectedTab === index }" > {{ tab.name }} - <a-popover position="bl"> + <a-popover position="bl" > <icon-more + v-hasPermi="'/kb/delete'" :style="{ position: 'absolute', top: '10px', right: '10px' }" /> <template #content> @@ -34,6 +35,7 @@ <span style="cursor: pointer; color: #4977ba; font-size: 12px" @click="deleteKnowledge(tab.id)" + v-hasPermi="'/kb/delete'" ><icon-delete style="font-size: 14px" />鍒犻櫎</span > </template> @@ -88,6 +90,7 @@ type="text" class="button" style="color: #2a2a2b" + v-hasPermi="'/kb/data_status'" @click="enableDisable(1)" > <template #icon> @@ -101,6 +104,7 @@ type="text" class="button" style="color: #2a2a2b" + v-hasPermi="'/kb/data_status'" @click="enableDisable(0)" > <template #icon> @@ -114,6 +118,7 @@ type="text" class="button" style="color: #2a2a2b" + v-hasPermi="'/kb/data_analysis'" @click="addBlock(1)" > <template #icon> @@ -127,6 +132,7 @@ type="text" class="button" style="color: #2a2a2b" + v-hasPermi="'/kb/data_analysis'" @click="addBlock(2)" > <template #icon> @@ -140,6 +146,7 @@ <a-button type="text" class="button" + v-hasPermi="'/kb/data_delete'" style="color: #2a2a2b" @click="addBlock(3)" > @@ -298,6 +305,7 @@ <template #status="{ record }"> <a-switch v-model="record.status" + :disabled="!getAut('/kb/data_status')" size="small" checked-value="1" unchecked-value="0" @@ -308,11 +316,8 @@ <div style="display: flex; align-items: center"> <div style="width: 100px"> <a-popover title="" v-if="record.run == '4'"> - <a-tag - :loading="record.loading" - :color="'blue'" - border - >{{ $t('dmx.list.complete') }}</a-tag + <a-tag :loading="record.loading" :color="'red'" border + >澶辫触</a-tag > <template #content> <p>娴佺▼寮�濮嬩簬锛歿{ record.process_begin_at }}</p> @@ -438,6 +443,7 @@ type="text" size="large" @click="run(record)" + v-hasPermi="'/kb/data_analysis'" :loading="record.loading" > <template #icon> @@ -465,39 +471,57 @@ </div> </template> <template #action="{ record }"> - <tool - :kbtenantInfo="kbtenantInfo" + <a-tooltip content="瑙f瀽鏂规硶"> + <a-button + type="text" + :disabled="record.run == '1'" + @click="handleClick(record)" + 鏌� + size="small" + > + <template #icon> + <icon-tool /> + </template> + </a-button> + </a-tooltip> + <edit :item="record" - :kbdetail="kbdetail" + v-hasPermi="'/kb/rename'" + @upTabdateItem="upTabdateItem" /> - <edit :item="record" @upTabdateItem="upTabdateItem" /> <a-popconfirm :content="'纭畾鍒犻櫎鍚�'" type="warning" @ok="deleteItem(record)" > + <a-tooltip content="鍒犻櫎"> + <a-button + type="text" + size="small" + :disabled="record.run == '1'" + v-hasPermi="'/kb/data_delete'" + > + <template #icon> + <icon-delete /> + </template> + </a-button> + </a-tooltip> + </a-popconfirm> + <a-tooltip content="涓嬭浇"> <a-button type="text" size="small" + v-hasPermi="'/kb/data_download'" :disabled="record.run == '1'" + @click="onDownloadDocument(record)" > <template #icon> - <icon-delete /> + <icon-download /> </template> </a-button> - </a-popconfirm> + </a-tooltip> + <!-- <a-button - type="text" - size="small" - :disabled="record.run == '1'" - @click="onDownloadDocument(record)" - > - <template #icon> - <icon-download /> - </template> - </a-button> - - <!-- <a-button type="text" size="small" :disabled="record.run == '1'" @@ -512,7 +536,11 @@ </a-card> </a-scrollbar> </a-tab-pane> - <a-tab-pane key="2" :title="t('dmx.list.test')"> + <a-tab-pane + key="2" + :title="t('dmx.list.test')" + v-if="getAut('/kb/test')" + > <a-scrollbar class="rt-container-main" :style="{ height: documentHeight + 70 + 'px' }" @@ -521,7 +549,11 @@ <test ref="testForm"></test> </a-scrollbar> </a-tab-pane> - <a-tab-pane key="3" :title="t('dmx.list.disposition')"> + <a-tab-pane + key="3" + :title="t('dmx.list.disposition')" + v-if="getAut('/kb/update')" + > <a-scrollbar class="rt-container-main" :style="{ height: documentHeight + 70 + 'px' }" @@ -574,12 +606,18 @@ <!-- </div>--> </div> </div> - <a-modal title=" " v-model:visible="visible" :footer="false" fullscreen> - <!-- <docx previewSrc="http://192.168.20.116:1080/v1/document/get/405c3efa4d8c11ef97560242ac120006"></docx>--> - <docx v-if="documenttype == 'docx'" :previewSrc="previewSrc"></docx> - <excel v-if="documenttype == 'excel'" :previewSrc="previewSrc"></excel> - <txtPdf v-if="documenttype == 'txtPdf'" :previewSrc="previewSrc"></txtPdf> - </a-modal> + <!-- <a-modal title=" " v-model:visible="visible" :footer="false" fullscreen>--> + <!-- <!– <docx previewSrc="http://192.168.20.116:1080/v1/document/get/405c3efa4d8c11ef97560242ac120006"></docx>–>--> + <!-- <docx v-if="documenttype == 'docx'" :previewSrc="previewSrc"></docx>--> + <!-- <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> @@ -592,6 +630,7 @@ nextTick, onBeforeMount, onMounted, + onBeforeUnmount, } from 'vue'; import { useI18n } from 'vue-i18n'; import useLoading from '@/hooks/loading'; @@ -622,13 +661,14 @@ import config from '@/views/dmx/knowledgeLib/config.vue'; import test from '@/views/dmx/knowledgeLib/test.vue'; import tool from '@/views/dmx/knowledgeLib/tool.vue'; - import docx from '@/views/dmx/knowledgeLib/components/docx.vue'; - import excel from '@/views/dmx/knowledgeLib/components/excel.vue'; - import txtPdf from '@/views/dmx/knowledgeLib/components/txtPdf.vue'; + // import docx from '@/views/dmx/knowledgeLib/components/docx.vue'; + // import excel from '@/views/dmx/knowledgeLib/components/excel.vue'; + // import txtPdf from '@/views/dmx/knowledgeLib/components/txtPdf.vue'; import { Message, Modal } from '@arco-design/web-vue'; import { documentHeight, parseTime } from '@/utils'; import { deleteLlm } from '@/api/model'; import { userModelState } from '@/store'; + import { getUserResources } from '@/utils/auth'; let modelStore = userModelState(); const httpUrl = modelStore.hrefUrl; @@ -651,6 +691,7 @@ const formModel = ref(generateFormModel()); const cloneColumns = ref([]); const showColumns = ref<Column[]>([]); + let setObj = reactive({}); const size = ref<SizeProps>('medium'); let visible = ref(false); @@ -670,6 +711,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', @@ -684,6 +726,7 @@ parser_idObj: {}, }); let tabs = ref([]); + let timer = null; // 瀹氭椂鍣� const selectTab = (index, item) => { selectedTab.value = index; @@ -691,12 +734,18 @@ // 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); + }; + + const getAut = (val) => { + const roleData = JSON.parse(getUserResources()); + const roleBtn = roleData.map((item: any) => item.component); + return roleBtn.includes(val); }; const basePagination: Pagination = { @@ -729,10 +778,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 +795,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 +874,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,20 +914,22 @@ }; const search = () => { + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 10, + ...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, page: current, kb_id: kbobj.id }); + basePagination.page = current; + fetchData({ ...basePagination, kb_id: kbobj.id }); }; const selectTabAll = (val) => { @@ -866,10 +952,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 { @@ -899,12 +985,14 @@ setLoading(true); try { const { data } = await queryKbList({ page: 1, page_size: 10 }); + console.log(data, '鏌ヨ鐭ヨ瘑搴撳垪琛�'); tabs.value = data; if (tabs.value.length > 0) { // 瀹氫綅鍒版柊澧炵殑鐭ヨ瘑搴撳崟鍏� selectedTab.value = tabs.value.findIndex((item) => item.id == id); getKbdetail(id); // 鑾峰彇璇︽儏 + kbobj.id = id; activeKey.value = '3'; } } catch (err) { @@ -953,11 +1041,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 +1055,7 @@ tabs.value = data; fetchData({ kb_id: id, - page: 1, - page_size: 10, + ...basePagination, }); getKbdetail(id); // 鑾峰彇璇︽儏 }; @@ -1003,11 +1090,6 @@ } }); }); - // fetchData({ - // kb_id: tabs.value[selectedTab.value].id, - // page: 1, - // page_size: 20, - // }); getKbList(); } else { // Message.error('瑙f瀽澶辫触'); @@ -1036,8 +1118,7 @@ const getKbList = async () => { await fetchData({ kb_id: tabs.value[selectedTab.value].id, - page: 1, - page_size: 10, + ...basePagination, }); }; @@ -1098,8 +1179,7 @@ // console.log(kbobj, 'kbobj'); fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 10, + ...basePagination, }); } }; @@ -1162,10 +1242,10 @@ run: run, }); if (data.code == 0) { + // 瀹氭椂鍣ㄦ煡璇㈠綋鍓嶅垪琛� fetchData({ kb_id: tabs.value[selectedTab.value].id, - page: 1, - page_size: 10, + ...basePagination, }); } else { // Message.error('瑙f瀽澶辫触'); @@ -1176,10 +1256,10 @@ }; const changeFetchData = async (row) => { + basePagination.page = 1; fetchData({ kb_id: kbobj.id, - page: 1, - page_size: 10, + ...basePagination, }); }; watch( @@ -1203,6 +1283,9 @@ onMounted(() => { knowledgeData(); }); + onBeforeUnmount(() => { + clearInterval(timer); + }); </script> <style scoped lang="less"> -- Gitblit v1.8.0