|
|
@@ -353,6 +353,7 @@
|
|
|
</div>
|
|
|
|
|
|
<tool ref="toolForm" :kbtenantInfo="kbtenantInfo" :item="setObj" :kbdetail="kbdetail" />
|
|
|
+ <DeleteModal :visible.sync="delete_visible" @ok="deleteModalOk" @cancel="delete_visible = false" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -373,17 +374,13 @@ import {
|
|
|
} from '../../../../apis/rgflow-dify';
|
|
|
import { toSyncOwnKnowledge } from './asyc.js';
|
|
|
import cloneDeep from 'lodash/cloneDeep';
|
|
|
-// import Sortable from 'sortablejs';
|
|
|
import add from './add.vue';
|
|
|
import edit from './edit.vue';
|
|
|
-import addKnow from './addKnow.vue';
|
|
|
import config from './config.vue';
|
|
|
import test from './test.vue';
|
|
|
import tool from './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 { Message, Modal } from '@arco-design/web-vue';
|
|
|
+import DeleteModal from '../../../../components/DeleteModal.vue';
|
|
|
+import { Message } from '@arco-design/web-vue';
|
|
|
import { documentHeight, parseTime, getTableColumns } from './utils';
|
|
|
|
|
|
const props = defineProps({
|
|
|
@@ -417,7 +414,6 @@ let visible = ref(false);
|
|
|
let listloading = ref(false);
|
|
|
let keywords = ref('');
|
|
|
let activeKey = ref('1');
|
|
|
-let detailsShow = ref(false);
|
|
|
let checkedAll = ref(false);
|
|
|
let checkedArr = ref([]);
|
|
|
let selectedTab = ref(0);
|
|
|
@@ -425,7 +421,6 @@ let testForm = ref(null);
|
|
|
let configForm = ref(null);
|
|
|
let documenttype = ref('docx');
|
|
|
let previewSrc = ref('');
|
|
|
-let kbId = ref('');
|
|
|
let kbobj = reactive({});
|
|
|
let kbdetail = reactive({});
|
|
|
let parser_ids = reactive({});
|
|
|
@@ -445,13 +440,13 @@ let kbtenantInfo = reactive({
|
|
|
parser_idObj: {}
|
|
|
});
|
|
|
let tabs = ref([]);
|
|
|
-let timer = null; // 定时器
|
|
|
+
|
|
|
+const delete_visible = ref(false); // 删除模态框
|
|
|
|
|
|
const selectTab = (item) => {
|
|
|
// selectedTab.value = index;
|
|
|
checkedArr.value = [];
|
|
|
kbobj = item;
|
|
|
- kbId = kbobj.id;
|
|
|
basePagination.page = 1;
|
|
|
fetchData({
|
|
|
kb_id: kbobj.id,
|
|
|
@@ -467,12 +462,6 @@ const toTargetKnowledge = () => {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
-const getAut = (val) => {
|
|
|
- // const roleData = JSON.parse(getUserResources());
|
|
|
- // const roleBtn = roleData.map((item: any) => item.component);
|
|
|
- // return roleBtn.includes(val);
|
|
|
- return true;
|
|
|
-};
|
|
|
|
|
|
const basePagination = {
|
|
|
page: 1,
|
|
|
@@ -499,87 +488,10 @@ const densityList = computed(() => [
|
|
|
value: 'large'
|
|
|
}
|
|
|
]);
|
|
|
-// const columns = computed(() => [
|
|
|
-// {
|
|
|
-// title: '名称',
|
|
|
-// dataIndex: 'name',
|
|
|
-// slotName: 'name',
|
|
|
-// width: 300
|
|
|
-// },
|
|
|
-// {
|
|
|
-// title: '分快数',
|
|
|
-// dataIndex: 'chunk_num',
|
|
|
-// width: 90
|
|
|
-// },
|
|
|
-// {
|
|
|
-// title: '上传时间',
|
|
|
-// dataIndex: 'create_time',
|
|
|
-// slotName: 'create_time',
|
|
|
-// width: 200
|
|
|
-// },
|
|
|
-// {
|
|
|
-// title: '解析方法',
|
|
|
-// dataIndex: 'parser_id',
|
|
|
-// slotName: 'parser_id',
|
|
|
-// width: 150
|
|
|
-// },
|
|
|
-// {
|
|
|
-// title: '启用',
|
|
|
-// dataIndex: 'status',
|
|
|
-// slotName: 'status',
|
|
|
-// width: 100
|
|
|
-// },
|
|
|
-// {
|
|
|
-// title: '解析状态',
|
|
|
-// dataIndex: 'run',
|
|
|
-// slotName: 'run',
|
|
|
-// width: 100
|
|
|
-// },
|
|
|
-// {
|
|
|
-// title: '操作',
|
|
|
-// dataIndex: 'action',
|
|
|
-// slotName: 'action',
|
|
|
-// width: 200,
|
|
|
-// minWidth: 200
|
|
|
-// }
|
|
|
-// ]);
|
|
|
const columns = computed(() => {
|
|
|
return getTableColumns(t);
|
|
|
});
|
|
|
-const contentTypeOptions = computed(() => [
|
|
|
- {
|
|
|
- label: '图文',
|
|
|
- value: 'img'
|
|
|
- },
|
|
|
- {
|
|
|
- label: '横版短视频',
|
|
|
- value: 'horizontalVideo'
|
|
|
- },
|
|
|
- {
|
|
|
- label: '竖版小视频',
|
|
|
- value: 'verticalVideo'
|
|
|
- }
|
|
|
-]);
|
|
|
-const filterTypeOptions = computed(() => [
|
|
|
- {
|
|
|
- label: '人工筛选',
|
|
|
- value: 'artificial'
|
|
|
- },
|
|
|
- {
|
|
|
- label: '规则筛选',
|
|
|
- value: 'rules'
|
|
|
- }
|
|
|
-]);
|
|
|
-const statusOptions = computed(() => [
|
|
|
- {
|
|
|
- label: '已上线',
|
|
|
- value: 'online'
|
|
|
- },
|
|
|
- {
|
|
|
- label: '已下线',
|
|
|
- value: 'offline'
|
|
|
- }
|
|
|
-]);
|
|
|
+
|
|
|
const fetchData = async (params) => {
|
|
|
setLoading(true);
|
|
|
try {
|
|
|
@@ -602,7 +514,6 @@ const fetchData = async (params) => {
|
|
|
pagination.page = params.page;
|
|
|
pagination.current = params.page;
|
|
|
pagination.total = data.data.total;
|
|
|
-
|
|
|
// 定时器查询文档
|
|
|
documentList();
|
|
|
}
|
|
|
@@ -612,25 +523,35 @@ const fetchData = async (params) => {
|
|
|
setLoading(false);
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
const documentList = async () => {
|
|
|
- let params = { ...basePagination, kb_id: kbobj.id };
|
|
|
- const data = await queryKbDocumentList(params);
|
|
|
- if (data.retcode == '0') {
|
|
|
- parser_ids = kbtenantInfo.parser_ids.split(',').reduce((acc, pair) => {
|
|
|
- const [key, value] = pair.split(':');
|
|
|
- acc[key] = value;
|
|
|
- return acc;
|
|
|
- }, {});
|
|
|
- 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]
|
|
|
- };
|
|
|
- });
|
|
|
+ try {
|
|
|
+ let params = { ...basePagination, kb_id: kbobj.id };
|
|
|
+ const data = await queryKbDocumentList(params);
|
|
|
+ if (data.retcode == '0') {
|
|
|
+ parser_ids = kbtenantInfo.parser_ids.split(',').reduce((acc, pair) => {
|
|
|
+ const [key, value] = pair.split(':');
|
|
|
+ acc[key] = value;
|
|
|
+ return acc;
|
|
|
+ }, {});
|
|
|
+ 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]
|
|
|
+ };
|
|
|
+ });
|
|
|
+ // 当renderData中有文档正在解析,则开启定时器
|
|
|
+ const hasRunningDocs = renderData.value.length && renderData.value.some((item) => item.run == '1');
|
|
|
+ if (hasRunningDocs) {
|
|
|
+ setTimeout(() => {
|
|
|
+ documentList();
|
|
|
+ }, 3000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -666,16 +587,11 @@ const knowledgeData = async (params = { page: 1, page_size: 10 }) => {
|
|
|
const { data } = await queryKbList(params);
|
|
|
tabs.value = data;
|
|
|
if (tabs.value.length > 0 && tabs.value[0]) {
|
|
|
- // kbobj = tabs.value[0];
|
|
|
- // kbId = kbobj.id;
|
|
|
- // activeKey.value = '1';
|
|
|
- // basePagination.page = 1;
|
|
|
fetchData({
|
|
|
kb_id: props.kb_id,
|
|
|
...basePagination
|
|
|
});
|
|
|
toTargetKnowledge();
|
|
|
- // getKbdetail(kbobj.id);
|
|
|
getKbdetail(props.kb_id);
|
|
|
} else {
|
|
|
}
|
|
|
@@ -696,48 +612,6 @@ const getKbdetail = async (kb_id) => {
|
|
|
configForm.value.changekbObj(kbdetail);
|
|
|
};
|
|
|
|
|
|
-const getknowledge = async (id) => {
|
|
|
- setLoading(true);
|
|
|
- try {
|
|
|
- const { data } = await queryKbList({ page: 1, page_size: 10 });
|
|
|
- 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) {
|
|
|
- // you can report use errorHandler or other
|
|
|
- } finally {
|
|
|
- setLoading(false);
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
-const deleteKnowledge = (id) => {
|
|
|
- Modal.confirm({
|
|
|
- title: '提示信息',
|
|
|
- content: '确认删除吗',
|
|
|
- okText: '确定',
|
|
|
- cancelText: '取消',
|
|
|
- hideTitle: true,
|
|
|
- onOk: async () => {
|
|
|
- let data = await deleteKnow({
|
|
|
- kb_id: id
|
|
|
- });
|
|
|
- if (data.retcode == 0) {
|
|
|
- Message.success('删除成功');
|
|
|
- knowledgeData();
|
|
|
- }
|
|
|
- },
|
|
|
- onCancel: () => {}
|
|
|
- });
|
|
|
-};
|
|
|
-const reset = () => {
|
|
|
- formModel.value = generateFormModel();
|
|
|
-};
|
|
|
-
|
|
|
function handleTabChange(key) {
|
|
|
activeKey.value = key;
|
|
|
}
|
|
|
@@ -749,11 +623,6 @@ const handleSelectDensity = (val, e) => {
|
|
|
const cancleConfig = () => {
|
|
|
activeKey.value = '1';
|
|
|
let id = tabs.value[selectedTab.value].id;
|
|
|
- // basePagination.page = 1;
|
|
|
- // fetchData({
|
|
|
- // kb_id: id,
|
|
|
- // ...basePagination,
|
|
|
- // });
|
|
|
};
|
|
|
|
|
|
const saveConfig = async () => {
|
|
|
@@ -777,7 +646,7 @@ const enableDisable = async (type) => {
|
|
|
});
|
|
|
})
|
|
|
).then(() => {
|
|
|
- Message.success('更新成功');
|
|
|
+ Message.success(t('management.edit_success'));
|
|
|
getKbList();
|
|
|
});
|
|
|
};
|
|
|
@@ -804,24 +673,24 @@ const addBlock = async (type) => {
|
|
|
// row.run = '1';
|
|
|
}
|
|
|
} else {
|
|
|
- //批量删除
|
|
|
- Modal.confirm({
|
|
|
- title: '提示信息',
|
|
|
- content: '确认删除吗',
|
|
|
- okText: '确定',
|
|
|
- cancelText: '取消',
|
|
|
- hideTitle: true,
|
|
|
- onOk: async () => {
|
|
|
- let data = await kbdocumentrm({ doc_id: checkedArr.value });
|
|
|
- if (data.retcode == 0) {
|
|
|
- Message.success('删除成功');
|
|
|
- getKbList();
|
|
|
- // 同步数据
|
|
|
- toSyncOwnKnowledge(props.kb_id);
|
|
|
- }
|
|
|
- },
|
|
|
- onCancel: () => {}
|
|
|
- });
|
|
|
+ delete_visible.value = true;
|
|
|
+ }
|
|
|
+};
|
|
|
+const deleteModalOk = async () => {
|
|
|
+ try {
|
|
|
+ let data = await kbdocumentrm({ doc_id: checkedArr.value });
|
|
|
+ if (data.retcode == 0) {
|
|
|
+ Message.success(t('management.delete_success'));
|
|
|
+ getKbList();
|
|
|
+ // 同步数据
|
|
|
+ toSyncOwnKnowledge(props.kb_id);
|
|
|
+ } else {
|
|
|
+ Message.error(data.retmsg);
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ } finally {
|
|
|
+ delete_visible.value = false;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -851,11 +720,13 @@ function upTabdateItem(id, newName) {
|
|
|
const deleteItem = async (row) => {
|
|
|
let data = await kbdocumentrm({ doc_id: row.id });
|
|
|
if (data.retcode == 0) {
|
|
|
- Message.success('删除成功');
|
|
|
+ Message.success(t('management.delete_success'));
|
|
|
fetchData({
|
|
|
kb_id: kbobj.id,
|
|
|
...basePagination
|
|
|
});
|
|
|
+ } else {
|
|
|
+ Message.error(t('management.delete_fail'));
|
|
|
}
|
|
|
};
|
|
|
const onDownloadDocument = async (record) => {
|
|
|
@@ -891,7 +762,9 @@ const handleChangeStatus = async (row) => {
|
|
|
status: row.status
|
|
|
});
|
|
|
if (data.retcode == 0) {
|
|
|
- Message.success('操作成功');
|
|
|
+ Message.success(t('management.edit_success'));
|
|
|
+ } else {
|
|
|
+ Message.error(t('management.edit_fail'));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -962,9 +835,6 @@ onBeforeMount(async () => {
|
|
|
onMounted(() => {
|
|
|
knowledgeData();
|
|
|
});
|
|
|
-onBeforeUnmount(() => {
|
|
|
- clearInterval(timer);
|
|
|
-});
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="css">
|