charles
2024-07-29 a78f6ae9b480f1f86f1a07d551585f5f0cac07fd
src/views/dmx/knowledgeLib/index.vue
@@ -8,7 +8,7 @@
            :placeholder="$t('cardList.searchInput.placeholder')"
            style="width: 130px;"
          />
          <addKnow></addKnow>
          <addKnow @knowledgeData="knowledgeData"></addKnow>
        </div>
        <div class="lf-container-down">
          <div class="tabs">
@@ -20,6 +20,15 @@
              :class="{ 'active': selectedTab === index }"
            >
              {{ tab.name }}
              <a-popover position="bl">
                <icon-more  :style="{position: 'absolute',top:'10px',right:'20px'}"/>
                <template #content>
                  <a-popconfirm content="确定删除吗?" @ok="deleteKnowledge(tab.id)" type="warning">
                    <span style="cursor: pointer;color: #0960bd;font-size: 12px"><icon-delete />删除</span>
                  </a-popconfirm>
                </template>
              </a-popover>
            </div>
          </div>
        </div>
@@ -44,7 +53,7 @@
                            style="width: 200px;margin-right: 10px"
                          />
                          <!--            新建-->
                          <add />
                          <add :kbobj="kbobj" @changeFetchData="changeFetchData"/>
                        </a-col>
                      </a-row>
                    </a-form>
@@ -154,55 +163,57 @@
<!--                    </span>-->
                    {{record.name}}
                  </template>
                  <template #staue="{ record }">
                    <a-switch :model-value="record.staue"/>
                  <template #create_time="{ record }">
                    <span>{{parseTime(record.create_time)}}</span>
                  </template>
                  <template #status="{ record }">
                    <a-switch v-model="record.status"  checked-value="0" unchecked-value="1"/>
                  </template>
                  <template #run="{ record }">
                    <div style="display: flex;align-items: center;">
                      <div style="width: 100px">
                        <a-popover title="Title">
                          <a-tag :color="'blue'" border>{{$t('dmx.list.complete')}}</a-tag>
                        <a-popover title="Title" v-if="record.run == '3'">
                          <a-tag  :loading="record.loading" :color="'blue'" border>{{$t('dmx.list.complete')}}</a-tag>
                          <template #content>
                            <p>Here is the text content</p>
                          </template>
                        </a-popover>
                        <a-popover title="Title">
                          <a-tag :color="'gold'" border>{{$t('dmx.list.cancel')}}</a-tag>
                        <a-popover title="Title" v-if="record.run == '2'">
                          <a-tag :loading="record.loading"  :color="'blue'" border>{{$t('dmx.list.complete')}}</a-tag>
                          <template #content>
                            <p>Here is the text content</p>
                          </template>
                        </a-popover>
                        <a-popover title="Title">
                          <a-tag :color="'green'" border>{{$t('dmx.list.NotStarted')}}</a-tag>
                        <a-popover title="Title" v-if="record.run == '1'">
                          <a-tag :loading="record.loading"  :color="'gold'" border>{{$t('dmx.list.cancel')}}</a-tag>
                          <template #content>
                            <p>Here is the text content</p>
                          </template>
                        </a-popover>
                        <a-popover title="Title" v-if="record.run == '0'">
                          <a-tag :loading="record.loading"  :color="'green'" border>{{$t('dmx.list.NotStarted')}}</a-tag>
                          <template #content>
                            <p>Here is the text content</p>
                          </template>
                        </a-popover>
                      </div>
                      <div>
                        <a-button type="text" size="large">
                      <div >
                        <a-button type="text" size="large" @click="run(record)" :loading="record.loading">
                          <template #icon>
                            <icon-sync />
                          </template>
                        </a-button>
                        <a-button type="text" size="large">
                          <template #icon>
                            <icon-sync style="color: green" />
                          </template>
                        </a-button>
                        <a-button type="text" size="large">
                          <template #icon>
                            <icon-play-circle style="color: green" />
                            <icon-sync  v-if="record.run == '3'"/>
                            <icon-sync  v-if="record.run == '2'"/>
                            <icon-sync style="color: green"  v-if="record.run == '1'"/>
                            <icon-play-circle style="color: green"  v-if="record.run == '0'"/>
                          </template>
                        </a-button>
                      </div>
                    </div>
                  </template>
                  <template #operations="{ record }" >
                  <template #action="{ record }" >
                    <tool/>
                    <edit/>
                    <a-popconfirm :content="t('dmx.list.EnsureDelete')" type="warning" @ok="deleteItem(record)">
                      <a-button v-permission="['admin']" type="text" size="small">
                    <edit :item="record" @upTabdateItem="upTabdateItem"/>
                    <a-popconfirm :content="t('确定删除吗')" type="warning" @ok="deleteItem(record)">
                      <a-button  type="text" size="small">
                        <template #icon>
                          <icon-delete />
                        </template>
@@ -274,7 +285,15 @@
import { computed, ref, reactive, watch, nextTick, onBeforeMount } from "vue";
  import { useI18n } from 'vue-i18n';
  import useLoading from '@/hooks/loading';
import { queryKbList, PolicyRecord, PolicyParams, queryKbDocumentList } from "@/api/kbList";
import {
  queryKbList,
  PolicyRecord,
  PolicyParams,
  queryKbDocumentList,
  deleteKnow,
  queryKbdetail,
  queryKbtenantInfo, kbdocumentrm, kbdocumentchangeparser, kbdocumentrun
} from "@/api/kbList";
  import { Pagination } from '@/types/global';
  import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface';
  import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
@@ -288,6 +307,8 @@
  import tool from '@/views/dmx/knowledgeLib/tool.vue'
  import addDetails from '@/views/dmx/knowledgeLib/addDetails.vue'
  import { deleteAccount } from "@/api/account";
import { Message } from "@arco-design/web-vue";
import { parseTime } from "@/utils";
  type SizeProps = 'mini' | 'small' | 'medium' | 'large';
  type Column = TableColumnData & { checked?: true };
  const account = ref(null)
@@ -305,20 +326,22 @@
  const { t } = useI18n();
  const renderData = ref([]);
  const formModel = ref(generateFormModel());
  const cloneColumns = ref<Column[]>([]);
  const cloneColumns = ref([]);
  const showColumns = ref<Column[]>([]);
  const size = ref<SizeProps>('medium');
  let visible = ref(false)
  let detailsShow = ref(false)
  let selectedTab = ref(0)
  let kbobj = reactive({})
  let tabs = ref([])
  const  selectTab = (index,item) => {
    selectedTab.value= index;
    console.log(item.id);
    kbobj= item
    fetchData({
      kb_id: item.id,
      kb_id: kbobj.id,
      page: 1,
      page_size: 20
    })
@@ -357,36 +380,36 @@
    },
    {
      title: t('分快数'),
      dataIndex: 'contentType',
      dataIndex: 'chunk_num',
    },
    {
      title: t('dmx.column.UploadTime'),
      dataIndex: 'filterType',
      dataIndex: 'create_time',
      slotName: 'create_time',
      width:200
    },
    {
      title: t('dmx.column.Founder'),
      dataIndex: 'count',
      title: t('解析方法'),
      dataIndex: 'parser_id',
      slotName: 'parser_id',
    },
    {
      title: t('dmx.column.Status'),
      dataIndex: 'createdTime',
    },
    {
      title: t('dmx.column.Enable'),
      dataIndex: 'staue',
      slotName: 'staue',
    },
    {
      title: t('dmx.column.ParseState'),
      title: t('启用'),
      dataIndex: 'status',
      slotName: 'status',
      slotName: 'status',
    },
    {
      title: t('解析状态'),
      dataIndex: 'run',
      slotName: 'run',
    },
    {
      title: t('dmx.column.Operate'),
      dataIndex: 'operations',
      slotName: 'operations',
      dataIndex: 'action',
      slotName: 'action',
      width: 150,
      minWidth: 100,
      minWidth: 150,
    },
  ]);
  const contentTypeOptions = computed<SelectOptionData[]>(() => [
@@ -430,8 +453,26 @@
      console.log(data, 'data');
      if(data.code=='0'){
        renderData.value = data.data.docs||[];
        renderData.value = renderData.value.map((item) => {
          return {
            ...item,
            loading: false,
          };
        });
        console.log(renderData.value, 'renderData.value');
        pagination.current = params.page;
        pagination.total = data.data.total;
        //   查询知识库详情
        const  kbdetail  = await queryKbdetail({
          kb_id:params.kb_id,
        });
        //   详情
        // const  kbtenantInfo  = await queryKbtenantInfo();
      }
    } catch (err) {
      // you can report use errorHandler or other
@@ -441,10 +482,11 @@
  };
  const search = () => {
    fetchData({
      ...basePagination,
      ...formModel.value,
    });
    alert(1)
    // fetchData({
    //   ...basePagination,
    //   ...formModel.value,
    // });
  };
  const handleClick = ()=>{
@@ -465,8 +507,9 @@
      tabs.value = data;
      console.log(tabs.value, 'tabs');
      if(tabs.value.length>0 && tabs.value[0]){
        kbobj = tabs.value[0]
        fetchData({
          kb_id: tabs.value[0].id,
          kb_id: kbobj.id,
          page: 1,
          page_size: 20
        })
@@ -482,6 +525,15 @@
    }
  };
  const deleteKnowledge = async (id) => {
    let data = await deleteKnow({
      kb_id:id
    })
    if(data.code == 0){
      Message.success('删除成功');
      knowledgeData()
    }
  }
  const reset = () => {
    formModel.value = generateFormModel();
  };
@@ -549,17 +601,57 @@
    detailsShow.value = false
  }
  const   deleteItem =  async (row)=>{
    console.log(row);
    // let data = await deleteAccount({id: row.number})
    account.value.$messageSuccess('删除成功')
    //
    // if(data.code == 200){
    //   this.$messageSuccess('删除成功')
    // }
  function upTabdateItem(id, newName) {
    console.log(id, newName);
    const itemToUpdate = renderData.value.find(item => item.id === id);
    if (itemToUpdate) {
      itemToUpdate.name = newName;
    }
  }
const   deleteItem =  async (row)=>{
    console.log(row);
    let data = await kbdocumentrm({doc_id: row.id})
    if(data.code == 0){
      Message.success('删除成功');
      console.log(kbobj, 'kbobj');
      fetchData({
        kb_id: kbobj.id,
        page: 1,
        page_size: 20
      })
    }
  }
const   run =  async (row)=>{
  console.log(row);
  row.loading = true;
  let data = await kbdocumentrun({
    doc_ids: [row.id],
    run: '1'
  })
  // let data = await kbdocumentchangeparser({
  //   parser_id: row.parser_id,
  //   doc_id: row.id,
  //   parser_config: row.parser_config,
  // })
  if(data.code == 0){
    Message.success('解析成功');
    row.run = '3';
  }else{
    Message.error('解析失败');
    row.run = '1';
  }
  row.loading = false;
}
const   changeFetchData =  async (row)=>{
  fetchData({
    kb_id: kbobj.id,
    page: 1,
    page_size: 20
  })
}
  watch(
    () => columns.value,
    (val) => {