| | |
| | | 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> |
| | |
| | | <template #status="{ record }"> |
| | | <a-switch |
| | | v-model="record.status" |
| | | :disabled="!getAut('/kb/data_status')" |
| | | size="small" |
| | | checked-value="1" |
| | | unchecked-value="0" |
| | |
| | | >{{ $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'"> |
| | |
| | | >{{ $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'"> |
| | |
| | | >解析中...</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'"> |
| | |
| | | >{{ $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'"> |
| | |
| | | >{{ $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> |
| | |
| | | type="text" |
| | | size="large" |
| | | @click="run(record)" |
| | | v-hasPermi="'/kb/data_analysis'" |
| | | :loading="record.loading" |
| | | > |
| | | <template #icon> |
| | |
| | | </div> |
| | | </template> |
| | | <template #action="{ record }"> |
| | | <tool |
| | | :kbtenantInfo="kbtenantInfo" |
| | | <a-button |
| | | type="text" |
| | | :disabled="record.run == '1'" |
| | | @click="handleClick(record)" |
| | | v-hasPermi="'/kb/data_update'" |
| | | size="small" |
| | | > |
| | | <template #icon> |
| | | <icon-tool /> |
| | | </template> |
| | | </a-button> |
| | | <edit |
| | | :item="record" |
| | | :kbdetail="kbdetail" |
| | | v-hasPermi="'/kb/rename'" |
| | | @upTabdateItem="upTabdateItem" |
| | | /> |
| | | <edit :item="record" @upTabdateItem="upTabdateItem" /> |
| | | <a-popconfirm |
| | | :content="'确定删除吗'" |
| | | type="warning" |
| | |
| | | type="text" |
| | | size="small" |
| | | :disabled="record.run == '1'" |
| | | v-hasPermi="'/kb/data_delete'" |
| | | > |
| | | <template #icon> |
| | | <icon-delete /> |
| | |
| | | <a-button |
| | | type="text" |
| | | size="small" |
| | | v-hasPermi="'/kb/data_download'" |
| | | :disabled="record.run == '1'" |
| | | @click="onDownloadDocument(record)" |
| | | > |
| | |
| | | </template> |
| | | </a-button> |
| | | |
| | | <a-button |
| | | <!-- <a-button |
| | | type="text" |
| | | size="small" |
| | | :disabled="record.run == '1'" |
| | |
| | | <template #icon> |
| | | <icon-eye /> |
| | | </template> |
| | | </a-button> |
| | | </a-button> --> |
| | | </template> |
| | | </a-table> |
| | | </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' }" |
| | |
| | | <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' }" |
| | |
| | | <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> |
| | | |
| | |
| | | nextTick, |
| | | onBeforeMount, |
| | | onMounted, |
| | | onBeforeUnmount, |
| | | } from 'vue'; |
| | | import { useI18n } from 'vue-i18n'; |
| | | import useLoading from '@/hooks/loading'; |
| | |
| | | kbdocumentchangeStatus, |
| | | downloadFile, |
| | | chunkSwitch, |
| | | changeStatus, |
| | | } from '@/api/kbList'; |
| | | import { Pagination } from '@/types/global'; |
| | | import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface'; |
| | |
| | | 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; |
| | |
| | | const formModel = ref(generateFormModel()); |
| | | const cloneColumns = ref([]); |
| | | const showColumns = ref<Column[]>([]); |
| | | let setObj = reactive({}); |
| | | |
| | | const size = ref<SizeProps>('medium'); |
| | | let visible = ref(false); |
| | |
| | | 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', |
| | | img2txt_id: 'qwen-vl-max', |
| | | llm_id: 'qwen-plus', |
| | | name: 'wanghao‘s Kingdom', |
| | | name: 'wanghaos Kingdom', |
| | | parser_ids: |
| | | 'naive:General,qa:Q&A,resume:Resume,manual:Manual,table:Table,paper:Paper,book:Book,laws:Laws,presentation:Presentation,picture:Picture,one:One', |
| | | rerank_id: 'BAAI/bge-reranker-v2-m3', |
| | |
| | | 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 getAut = (val) => { |
| | | const roleData = JSON.parse(getUserResources()); |
| | | const roleBtn = roleData.map((item: any) => item.component); |
| | | return roleBtn.includes(val); |
| | | }; |
| | | |
| | | const basePagination: Pagination = { |
| | | current: 1, |
| | | pageSize: 20, |
| | | page: 1, |
| | | page_size: 10, |
| | | }; |
| | | const pagination = reactive({ |
| | | ...basePagination, |
| | |
| | | title: t('dmx.column.name'), |
| | | dataIndex: 'name', |
| | | slotName: 'name', |
| | | width: 300, |
| | | }, |
| | | { |
| | | title: t('分快数'), |
| | | dataIndex: 'chunk_num', |
| | | width: 90, |
| | | }, |
| | | { |
| | | title: t('dmx.column.UploadTime'), |
| | |
| | | title: t('解析方法'), |
| | | dataIndex: 'parser_id', |
| | | slotName: 'parser_id', |
| | | width: 150, |
| | | }, |
| | | { |
| | | title: t('启用'), |
| | | dataIndex: 'status', |
| | | slotName: 'status', |
| | | width: 100, |
| | | }, |
| | | { |
| | | title: t('解析状态'), |
| | | dataIndex: 'run', |
| | | slotName: 'run', |
| | | width: 100, |
| | | }, |
| | | { |
| | | title: t('dmx.column.Operate'), |
| | |
| | | }); |
| | | // 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 |
| | |
| | | }; |
| | | |
| | | 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) => { |
| | |
| | | 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); |
| | |
| | | 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 { |
| | |
| | | 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) { |
| | |
| | | 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(); |
| | | }); |
| | | }; |
| | | |
| | | //批量启用删除禁用 |
| | |
| | | } |
| | | }); |
| | | }); |
| | | fetchData({ |
| | | kb_id: tabs.value[selectedTab.value].id, |
| | | page: 1, |
| | | page_size: 20, |
| | | }); |
| | | getKbList(); |
| | | } else { |
| | | // Message.error('解析失败'); |
| | | // row.run = '1'; |
| | |
| | | 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>>( |
| | |
| | | // console.log(kbobj, 'kbobj'); |
| | | fetchData({ |
| | | kb_id: kbobj.id, |
| | | page: 1, |
| | | page_size: 20, |
| | | ...basePagination, |
| | | }); |
| | | } |
| | | }; |
| | | const onDownloadDocument = async (record) => { |
| | | console.log(record); |
| | | downloadFile({ |
| | | await downloadFile({ |
| | | url: `/api/v1/document/get/${record.id}`, |
| | | filename: record.name, |
| | | }); |
| | |
| | | run: run, |
| | | }); |
| | | if (data.code == 0) { |
| | | // 定时器查询当前列表 |
| | | fetchData({ |
| | | kb_id: tabs.value[selectedTab.value].id, |
| | | page: 1, |
| | | page_size: 20, |
| | | ...basePagination, |
| | | }); |
| | | } else { |
| | | // Message.error('解析失败'); |
| | |
| | | }; |
| | | |
| | | const changeFetchData = async (row) => { |
| | | basePagination.page = 1; |
| | | fetchData({ |
| | | kb_id: kbobj.id, |
| | | page: 1, |
| | | page_size: 20, |
| | | ...basePagination, |
| | | }); |
| | | }; |
| | | watch( |
| | |
| | | onMounted(() => { |
| | | knowledgeData(); |
| | | }); |
| | | onBeforeUnmount(() => { |
| | | clearInterval(timer); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="less"> |