liudong
2024-08-21 176b1538bb80fc65539f004a7ccbae94b7d8eafc
src/views/dmx/knowledgeLib/index.vue
@@ -322,7 +322,7 @@
                              }}</p
                            >
                            <div>
                               <p
                              <p
                                >进度消息:<span
                                  v-html="
                                    record.progress_msg.replace(/\n/g, '<br/>')
@@ -347,7 +347,7 @@
                              }}</p
                            >
                            <div>
                                <p
                              <p
                                >进度消息:<span
                                  v-html="
                                    record.progress_msg.replace(/\n/g, '<br/>')
@@ -397,7 +397,7 @@
                              }}</p
                            >
                            <div>
                               <p
                              <p
                                >进度消息:<span
                                  v-html="
                                    record.progress_msg.replace(/\n/g, '<br/>')
@@ -422,7 +422,7 @@
                              }}</p
                            >
                            <div>
                                <p
                              <p
                                >进度消息:<span
                                  v-html="
                                    record.progress_msg.replace(/\n/g, '<br/>')
@@ -465,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="'确定删除吗'"
@@ -580,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 {
@@ -651,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);
@@ -670,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',
@@ -684,6 +697,9 @@
    parser_idObj: {},
  });
  let tabs = ref([]);
  let timer = null;// 定时器
  const selectTab = (index, item) => {
    selectedTab.value = index;
@@ -691,17 +707,17 @@
    // 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,
@@ -729,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'),
@@ -744,16 +762,19 @@
      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'),
@@ -819,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
@@ -830,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, kb_id: kbobj.id });
    basePagination.page = current;
    fetchData({ ...basePagination, kb_id: kbobj.id });
  };
  const selectTabAll = (val) => {
@@ -855,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);
@@ -866,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 {
@@ -898,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) {
@@ -953,22 +1006,21 @@
  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); // 获取详情
  };
@@ -1003,11 +1055,6 @@
            }
          });
        });
        // fetchData({
        //   kb_id: tabs.value[selectedTab.value].id,
        //   page: 1,
        //   page_size: 20,
        // });
        getKbList();
      } else {
        // Message.error('解析失败');
@@ -1036,8 +1083,7 @@
  const getKbList = async () => {
    await fetchData({
      kb_id: tabs.value[selectedTab.value].id,
      page: 1,
      page_size: 20,
      ...basePagination,
    });
  };
@@ -1098,8 +1144,7 @@
      // console.log(kbobj, 'kbobj');
      fetchData({
        kb_id: kbobj.id,
        page: 1,
        page_size: 20,
        ...basePagination,
      });
    }
  };
@@ -1162,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('解析失败');
      // row.run = '1';
@@ -1176,10 +1224,10 @@
  };
  const changeFetchData = async (row) => {
    basePagination.page = 1;
    fetchData({
      kb_id: kbobj.id,
      page: 1,
      page_size: 20,
      ...basePagination,
    });
  };
  watch(
@@ -1203,6 +1251,9 @@
  onMounted(() => {
    knowledgeData();
  });
  onBeforeUnmount(() => {
    clearInterval(timer);
  })
</script>
<style scoped lang="less">