CzRger 2 mesi fa
parent
commit
5023d367e1

+ 5 - 3
src/api/interceptors.ts

@@ -114,9 +114,11 @@ export class Interceptors {
         h(
           'div',
           { class: 'mt-2 overflow-y-auto', style: 'max-height: 50vh;' },
-          typeof res.data.data === 'string'
-            ? res.data.data
-            : JSON.stringify(res.data.data),
+          res.data.data
+            ? typeof res.data.data === 'string'
+              ? res.data.data
+              : JSON.stringify(res.data.data)
+            : '',
         ),
       ]),
       type: 'error',

+ 1 - 1
src/api/modules/knowledge/document.ts

@@ -9,7 +9,7 @@ export const datasetsDocumentsDealView = (params) =>
 // 知识库文档获取处理状态
 export const datasetsDocumentsDealStatus = (params) =>
   post(`/datasets/documents/deal/status`, params, {})
-// 知识库文档修改名称
+// 知识库文档重命名
 export const documentUpdateFileName = (params) =>
   get(`/document/updateFileName`, params, {})
 // 知识库文档添加分段

+ 10 - 0
src/api/modules/knowledge/qa.ts

@@ -0,0 +1,10 @@
+import { get, post, put, del } from '@/api/request'
+
+// 知识库问答分页
+export const qaGetQaPage = (params) => post(`/qa/getQaPage`, params, {})
+// 知识库问答重命名
+export const qaRename = (params) => get(`/qa/rename`, params, {})
+// 知识库问答详情
+export const qaDetail = (id) => get(`/qa/${id}`, {}, {})
+// 知识库问答新增
+export const qaCreatQa = (params) => post(`/qa/creatQa`, params, {})

BIN
src/out/file/QA问答导入模板.xlsx


+ 18 - 12
src/views/manage/knowledge/documents/document/detail.vue

@@ -22,7 +22,7 @@
           required
           :span="24"
           label="分段内容"
-          v-model:param="state.form.remark"
+          v-model:param="state.form.context"
           type="textarea"
           :rows="14"
           placeholder="请输入分段内容,支持输入多个,通过换行区分"
@@ -44,6 +44,7 @@ import {
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { useDialogStore, useDictionaryStore } from '@/stores'
 import { useRouter } from 'vue-router'
+import { documentAddSegment } from '@/api/modules/knowledge/document'
 
 const router = useRouter()
 const DictionaryStore = useDictionaryStore()
@@ -79,20 +80,15 @@ watch(
   () => props.show,
   (n) => {
     if (n) {
-      initDictionary()
       state.form = {}
-      if (props.transfer.mode !== 'add') {
-        initData()
-      }
+
       nextTick(() => {
         ref_form.value.reset()
       })
     }
   },
 )
-const initDictionary = () => {}
-const initData = () => {}
-const onSubmit = (isImport) => {
+const onSubmit = () => {
   ref_form.value
     .submit()
     .then(() => {
@@ -100,10 +96,20 @@ const onSubmit = (isImport) => {
         content: `请确认是否提交?`,
         onSubmit: () => {
           state.loading = true
-          ElMessage.success(`${titleCpt.value}成功!`)
-          emit('update:show', false)
-          emit('refresh')
-          state.loading = false
+          documentAddSegment({
+            ...state.form,
+            datasetId: props.transfer.ID,
+            documentType: 'TEXT_FILE',
+          })
+            .then(() => {
+              ElMessage.success(`${titleCpt.value}成功!`)
+              emit('update:show', false)
+              emit('refresh')
+            })
+            .catch(() => {})
+            .finally(() => {
+              state.loading = false
+            })
         },
       })
     })

+ 5 - 4
src/views/manage/knowledge/documents/document/index.vue

@@ -51,9 +51,9 @@
                 class="__czr-table-form-column"
                 :span="24"
                 label-width="0px"
-                v-model:param="state.query.form.tag"
+                v-model:param="state.query.form.p1"
                 link="select"
-                :options="DictionaryStore.knowledgeTags.list"
+                :options="[]"
                 placeholder="审核状态"
               />
               <CzrFormColumn
@@ -135,6 +135,7 @@
 
 <script setup lang="ts">
 import {
+  computed,
   getCurrentInstance,
   inject,
   onMounted,
@@ -173,7 +174,7 @@ const state: any = reactive({
         label: '状态',
         show: true,
         width: 100,
-        dictList: DictionaryStore.indexingStatusList,
+        dictList: computed(() => DictionaryStore.indexingStatusList),
       },
       { value: 'p1', label: '召回次数(无)', show: true },
       {
@@ -181,7 +182,7 @@ const state: any = reactive({
         label: '启用/停用',
         show: true,
         width: 100,
-        dictList: DictionaryStore.documentUseList,
+        dictList: computed(() => DictionaryStore.documentUseList),
       },
       { value: 'checkStatus', label: '审核状态', show: true, width: 100 },
       { value: 'p1', label: '关联应用(无)', show: true },

+ 30 - 8
src/views/manage/knowledge/documents/qa/detail.vue

@@ -16,7 +16,7 @@
           required
           :span="24"
           label="问题"
-          v-model:param="state.form.name"
+          v-model:param="state.form.question"
           type="textarea"
           :rows="4"
         />
@@ -24,7 +24,7 @@
           required
           :span="24"
           label="回答"
-          v-model:param="state.form.remark"
+          v-model:param="state.form.answer"
           type="textarea"
           :rows="10"
         />
@@ -45,6 +45,7 @@ import {
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { useDialogStore, useDictionaryStore } from '@/stores'
 import { useRouter } from 'vue-router'
+import { qaCreatQa, qaDetail } from '@/api/modules/knowledge/qa'
 
 const router = useRouter()
 const DictionaryStore = useDictionaryStore()
@@ -92,8 +93,18 @@ watch(
   },
 )
 const initDictionary = () => {}
-const initData = () => {}
-const onSubmit = (isImport) => {
+const initData = () => {
+  state.loading = true
+  qaDetail(props.transfer.id)
+    .then(({ data }: any) => {
+      state.form = data
+    })
+    .catch(() => {})
+    .finally(() => {
+      state.loading = false
+    })
+}
+const onSubmit = () => {
   ref_form.value
     .submit()
     .then(() => {
@@ -101,10 +112,21 @@ const onSubmit = (isImport) => {
         content: `请确认是否提交?`,
         onSubmit: () => {
           state.loading = true
-          ElMessage.success(`${titleCpt.value}成功!`)
-          emit('update:show', false)
-          emit('refresh')
-          state.loading = false
+          if (props.transfer.mode === 'add') {
+            qaCreatQa({
+              ...state.form,
+              datasetId: props.transfer.ID,
+            })
+              .then(() => {
+                ElMessage.success(`${titleCpt.value}成功!`)
+                emit('update:show', false)
+                emit('refresh')
+              })
+              .catch(() => {})
+              .finally(() => {
+                state.loading = false
+              })
+          }
         },
       })
     })

+ 38 - 38
src/views/manage/knowledge/documents/qa/index.vue

@@ -43,9 +43,6 @@
           @handlePage="onPage"
           v-model:selected="state.query.selected"
         >
-          <template #importAndExportType-column-value="{ scope }">
-            <!--            <dict-tag :options="import_and_export_type" :value="scope.row.importAndExportType"/>-->
-          </template>
           <template #caozuo-column-value="{ scope }">
             <div class="__czr-table-operations">
               <CzrButton
@@ -99,6 +96,7 @@ import { ElMessage } from 'element-plus'
 import detailCom from './detail.vue'
 import renameCom from './rename.vue'
 import knowledgeSelectCom from '../document/knowledge-select.vue'
+import { qaGetQaPage } from '@/api/modules/knowledge/qa'
 
 const DialogStore = useDialogStore()
 const DictionaryStore = useDictionaryStore()
@@ -111,11 +109,24 @@ const ID = inject('ID')
 const state: any = reactive({
   text: '',
   query: {
+    init: false,
     loading: false,
     head: [
-      { value: 'p1', label: '问答名称', show: true },
-      { value: 'p1', label: '创建时间', show: true },
-      { value: 'p1', label: '更新时间', show: true },
+      { value: 'name', label: '文件名称', show: true },
+      {
+        value: 'createTime',
+        label: '创建时间',
+        show: true,
+        width: 180,
+        datetime: true,
+      },
+      {
+        value: 'updateTime',
+        label: '更新时间',
+        show: true,
+        width: 180,
+        datetime: true,
+      },
       {
         value: 'caozuo',
         label: '操作',
@@ -162,18 +173,24 @@ watch(
 watch(
   () => state.query.form,
   (n) => {
-    onSearch()
+    if (state.query.init) {
+      onSearch()
+    }
   },
   { deep: true },
 )
 const onPage = (pageNum, pageSize) => {
+  setTimeout(() => {
+    state.query.init = true
+  }, 100)
   state.query.page = {
     pageNum: pageNum,
     pageSize: pageSize,
   }
   const params = {
-    pageNum: state.query.page.pageNum,
-    pageSize: state.query.page.pageSize,
+    datasetId: ID,
+    page: state.query.page.pageNum,
+    size: state.query.page.pageSize,
   }
   //  添加表单参数
   for (const [k, v] of Object.entries(state.query.formReal)) {
@@ -182,34 +199,15 @@ const onPage = (pageNum, pageSize) => {
     }
   }
   state.query.loading = true
-  setTimeout(() => {
-    state.query.result.total = 100
-    const arr: any = []
-    for (let i = 1; i <= params.pageSize; i++) {
-      const n = (params.pageNum - 1) * params.pageSize + i
-      arr.push({
-        id: i + '',
-        p1: '文件' + n + '.md',
-      })
-    }
-    state.query.result.data = arr
-    // setTimeout(() => {
-    //   state.query.selected = [arr[1], arr[5]]
-    // })
-    state.query.loading = false
-  }, 1000)
-  // state.query.loading = true
-  // listRuleLogisticsDataSubscribeInfo(params).then(res => {
-  //   if (res.code == 200) {
-  //     state.query.result.total = res.total
-  //     state.query.result.data = res.rows
-  //     state.query.loading = false
-  //   } else {
-  //     ElMessage.error(res.msg)
-  //   }
-  // }).catch(() => {
-  //   state.query.loading = false
-  // })
+  qaGetQaPage(params)
+    .then(({ data }: any) => {
+      state.query.result.total = data.totalElements
+      state.query.result.data = data.content
+    })
+    .catch(() => {})
+    .finally(() => {
+      state.query.loading = false
+    })
 }
 const onSearch = () => {
   state.query.selected = []
@@ -227,6 +225,7 @@ const onReset = () => {
 const onAdd = () => {
   state.detail.transfer = {
     mode: 'add',
+    ID: ID,
   }
   state.detail.show = true
 }
@@ -264,7 +263,8 @@ const onDel = (row: any = null) => {
 }
 const onRename = (row) => {
   state.rename.transfer = {
-    row: JSON.parse(JSON.stringify(row)),
+    id: row.id,
+    name: JSON.parse(JSON.stringify(row.name)),
   }
   state.rename.show = true
 }

+ 19 - 17
src/views/manage/knowledge/documents/qa/rename.vue

@@ -12,8 +12,8 @@
         <CzrFormColumn
           required
           :span="24"
-          label="问答名称"
-          v-model:param="state.form.p1"
+          label="名称"
+          v-model:param="state.name"
         />
       </CzrForm>
     </div>
@@ -32,6 +32,7 @@ import {
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { useDialogStore, useDictionaryStore } from '@/stores'
 import { useRouter } from 'vue-router'
+import { qaRename } from '@/api/modules/knowledge/qa'
 
 const router = useRouter()
 const DictionaryStore = useDictionaryStore()
@@ -44,29 +45,21 @@ const props = defineProps({
 })
 const state: any = reactive({
   loading: false,
-  form: {},
+  name: '',
 })
 const ref_form = ref()
 watch(
   () => props.show,
   (n) => {
     if (n) {
-      initDictionary()
-      state.form = {}
-      if (props.transfer.mode !== 'add') {
-        initData()
-      }
+      state.name = props.transfer.name
       nextTick(() => {
         ref_form.value.reset()
       })
     }
   },
 )
-const initDictionary = () => {}
-const initData = () => {
-  state.form = props.transfer.row
-}
-const onSubmit = (isImport) => {
+const onSubmit = () => {
   ref_form.value
     .submit()
     .then(() => {
@@ -74,10 +67,19 @@ const onSubmit = (isImport) => {
         content: `请确认是否重命名问答?`,
         onSubmit: () => {
           state.loading = true
-          ElMessage.success(`重命名成功!`)
-          emit('update:show', false)
-          emit('refresh')
-          state.loading = false
+          qaRename({
+            id: props.transfer.id,
+            name: state.name,
+          })
+            .then(() => {
+              ElMessage.success(`重命名成功!`)
+              emit('update:show', false)
+              emit('refresh')
+            })
+            .catch(() => {})
+            .finally(() => {
+              state.loading = false
+            })
         },
       })
     })

+ 9 - 1
src/views/manage/knowledge/upload/index.vue

@@ -72,9 +72,11 @@
             </template>
             <template v-else-if="state.uploadType == UploadTypeEnum.QA">
               <div class="flex">
-                1、点击下载对应模版并完善信息<CzrButton
+                1、点击下载对应模版并完善信息
+                <CzrButton
                   type="table"
                   title="下载Excel模板"
+                  @click="onDownload"
                 />
               </div>
               <div>
@@ -671,6 +673,12 @@ const initTask = () => {
     })
   }
 }
+const onDownload = () => {
+  window.open(
+    `/${import.meta.env.VITE_BASE}/file/QA问答导入模板.xlsx`,
+    '_blank',
+  )
+}
 onMounted(() => {
   initDetail()
   initDictionary()