liudong
2024-08-24 7067723946f837d0468814c28fe4971b7c331d11
src/views/dmx/knowledgeLib/index.vue
@@ -298,6 +298,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 +309,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 +436,7 @@
                          type="text"
                          size="large"
                          @click="run(record)"
                          v-hasPermi="'/kb/data_analysis'"
                          :loading="record.loading"
                        >
                          <template #icon>
@@ -465,37 +464,55 @@
                    </div>
                  </template>
                  <template #action="{ record }">
                    <tool
                      :kbtenantInfo="kbtenantInfo"
                    <a-tooltip content="解析方法">
                      <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>
                    </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-button
                      type="text"
                      size="small"
                      :disabled="record.run == '1'"
                      @click="onDownloadDocument(record)"
                    >
                      <template #icon>
                        <icon-download />
                      </template>
                    </a-button>
                    </a-tooltip>
                    <!-- <a-button
                      type="text"
@@ -512,7 +529,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 +542,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' }"
@@ -580,19 +605,26 @@
      <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, onBeforeUnmount
} from "vue";
  import {
    computed,
    ref,
    reactive,
    watch,
    nextTick,
    onBeforeMount,
    onMounted,
    onBeforeUnmount,
  } from 'vue';
  import { useI18n } from 'vue-i18n';
  import useLoading from '@/hooks/loading';
  import {
@@ -629,6 +661,7 @@
  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 +684,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 +704,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,9 +719,7 @@
    parser_idObj: {},
  });
  let tabs = ref([]);
  let timer = null;// 定时器
  let timer = null; // 定时器
  const selectTab = (index, item) => {
    selectedTab.value = index;
@@ -700,6 +733,12 @@
      ...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 = {
@@ -831,19 +870,21 @@
        pagination.current = params.page;
        pagination.total = data.data.total;
        if(timer){
        if (timer) {
          clearInterval(timer);
        }
        // 定时器查询文档
        timer = setInterval(async () => {
          let params = { ...basePagination, kb_id: kbobj.id }
          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;
            }, {});
            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 || [];
@@ -857,8 +898,6 @@
            // console.log(renderData.value, 'renderData');
          }
        }, 10000);
      }
    } catch (err) {
      // you can report use errorHandler or other
@@ -876,8 +915,9 @@
    });
  };
  const handleClick = () => {
    visible.value = true;
  const handleClick = (data) => {
    Object.assign(setObj, data);
    toolForm.value.handleClick(data);
  };
  const onPageChange = (current: number) => {
@@ -1198,9 +1238,6 @@
        kb_id: tabs.value[selectedTab.value].id,
        ...basePagination,
      });
    } else {
      // Message.error('解析失败');
      // row.run = '1';
@@ -1239,7 +1276,7 @@
  });
  onBeforeUnmount(() => {
    clearInterval(timer);
  })
  });
</script>
<style scoped lang="less">