Browse Source

重命名

CzRger 2 weeks ago
parent
commit
53fcfd665b

+ 2 - 1
src/api/interceptors.ts

@@ -75,7 +75,8 @@ export class Interceptors {
       let str = ''
       const arr = [
         `错误日期:${YMDHms(res.headers.date)}`,
-        `接口地址:${res.config.method.toUpperCase()} ${res.request.responseURL}`,
+        `请求方式:${res.config.method.toUpperCase()}`,
+        `接口地址:${res.request.responseURL}`,
         `接口状态:${res.status} ${res.statusText}`,
         `请求Token:${res.config.headers.Authorization}`,
         `请求参数:${res.config.data || ''}`,

+ 3 - 3
src/api/modules/global/login.ts

@@ -1,7 +1,7 @@
 import { get, post } from '@/api/request'
 // 验证码
-export const loginCaptcha = () => get('/login/captcha', {}, {})
+export const loginCaptcha = () => get(`/login/captcha`, {}, {})
 // 登录
-export const loginSubmit = (params) => post('/login/submit', params, {})
+export const loginSubmit = (params) => post(`/login/submit`, params, {})
 // 获取用户信息
-export const userInfo = () => get('/user/info', {}, {})
+export const userInfo = () => get(`/user/info`, {}, {})

+ 1 - 1
src/api/modules/global/upload.ts

@@ -2,4 +2,4 @@ import { get, post, upload } from '@/api/request'
 
 // 文件上传
 export const fileUploadFile = (params, onProcess) =>
-  upload('/file/uploadFile', params, {}, '', onProcess)
+  upload(`/file/uploadFile`, params, {}, '', onProcess)

+ 6 - 0
src/api/modules/knowledge/document.ts

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

+ 4 - 4
src/api/modules/knowledge/index.ts

@@ -2,14 +2,14 @@ import { del, get, post, put } from '@/api/request'
 
 // 知识库分页
 export const datasetsGetAllByPage = (params) =>
-  post('/datasets/getAllByPage', params, {})
+  post(`/datasets/getAllByPage`, params, {})
 // 知识库绑定标签
 export const datasetsTagsBinding = (params) =>
-  post('/datasets/tags/binding', params, {})
+  post(`/datasets/tags/binding`, params, {})
 // 创建知识库
-export const datasetsCreate = (params) => post('/datasets/create', params, {})
+export const datasetsCreate = (params) => post(`/datasets/create`, params, {})
 // 编辑知识库
-export const datasetsUpdate = (params) => put('/datasets/update', params, {})
+export const datasetsUpdate = (params) => put(`/datasets/update`, params, {})
 // 删除知识库
 export const datasetsDel = (id) => del(`/datasets/${id}`, {}, {})
 // 知识库详情

+ 6 - 6
src/api/modules/model/index.ts

@@ -3,21 +3,21 @@ import { del, get, post, put } from '@/api/request'
 const proxy = (import.meta as any).env.VITE_WORKFLOW_API_PROXY
 // 模型纳管分页
 export const pluginGetInstanceList = (params) =>
-  post('/plugin/get-instance-list', params, {}, proxy)
+  post(`/plugin/get-instance-list`, params, {}, proxy)
 // 获取模型类型
 export const pluginGetModelTypeList = () =>
-  get('/plugin/get-model-type-list', {}, {}, proxy)
+  get(`/plugin/get-model-type-list`, {}, {}, proxy)
 // 获取模型供应商
-export const pluginConfigs = () => get('/plugin/configs', {}, {}, proxy)
+export const pluginConfigs = () => get(`/plugin/configs`, {}, {}, proxy)
 // 根据类型获取对应模型
 export const pluginGetListByType = (params) =>
-  get('/plugin/get-list-by-type', params, {}, proxy)
+  get(`/plugin/get-list-by-type`, params, {}, proxy)
 // 新增模型纳管
 export const pluginAddInstance = (params) =>
-  post('/plugin/add-instance', params, {}, proxy)
+  post(`/plugin/add-instance`, params, {}, proxy)
 // 修改模型纳管
 export const pluginUpdateInstance = (params) =>
-  put('/plugin/update-instance', params, {}, proxy)
+  put(`/plugin/update-instance`, params, {}, proxy)
 // 模型纳管详情
 export const pluginDetail = (id) => get(`/plugin/${id}`, {}, {}, proxy)
 // 模型纳管状态修改

+ 45 - 3
src/components/czr-ui/CzrTableColumn.vue

@@ -21,7 +21,32 @@
         </template>
         <template v-else>
           <slot :name="`${item?.value}-column-value`" :scope="scope">
-            {{ scope?.row[item?.value] }}
+            <template v-if="dictMapCpt?.size > 0">
+              <template v-if="item?.dictSplit">
+                {{
+                  scope?.row[item?.value]
+                    .split(',')
+                    .map((v) => dictMapCpt.get(String(v)) || v)
+                }}.join(item.dictSplit)
+              </template>
+              <template v-else>
+                {{
+                  dictMapCpt.get(String(scope?.row[item?.value])) ||
+                  scope?.row[item?.value]
+                }}</template
+              >
+            </template>
+            <template v-else>
+              <template v-if="item.date">
+                {{ YMD(scope?.row[item?.value]) }}
+              </template>
+              <template v-else-if="item.datetime">
+                {{ YMDHms(scope?.row[item?.value]) }}
+              </template>
+              <template v-else>
+                {{ scope?.row[item?.value] }}
+              </template>
+            </template>
           </slot>
         </template>
       </template>
@@ -33,17 +58,34 @@
 </template>
 
 <script setup lang="ts">
+import { YMD, YMDHms } from '@/utils/czr-util'
+
 defineOptions({
   name: 'CzrTableColumn',
 })
-import { getCurrentInstance, reactive } from 'vue'
+import { computed, getCurrentInstance, reactive } from 'vue'
 
 const { proxy } = getCurrentInstance()
 const props = defineProps({
-  item: {
+  item: <any>{
     required: true,
   },
 })
+const dictMapCpt = computed(() => {
+  const map = new Map()
+  const labelKey = props.item?.dictLabel || 'label'
+  const valueKey = props.item?.dictValue || 'value'
+  if (props.item?.dictList) {
+    props.item.dictList.forEach((v) => {
+      map.set(String(v[valueKey]), v[labelKey])
+    })
+  } else if (props.item?.dictMap) {
+    props.item.dictMap.forEach((v, k) => {
+      map.set(String(v), k)
+    })
+  }
+  return map
+})
 </script>
 
 <style lang="scss" scoped></style>

+ 2 - 1
src/stores/modules/dictionary-define.ts

@@ -1,6 +1,7 @@
 export const dictionaryDefine = {
   //接口参数 : [ '字典数据list名', '字典数据Map名' ],
-  indexing_status: ['indexingStatusList', 'indexingStatusMap'], //  标签类型
+  indexing_status: ['indexingStatusList', 'indexingStatusMap'], //  索引状态
+  document_use: ['documentUseList', 'documentUseMap'], //  文档启停字典
 }
 
 const stateMap = {}

+ 40 - 12
src/views/manage/knowledge/documents/document/index.vue

@@ -84,7 +84,7 @@
               <div class="flex justify-center">
                 <CzrButton
                   type="table"
-                  :title="scope.row.p1"
+                  :title="scope.row.name"
                   @click="onStage(scope.row)"
                 />
               </div>
@@ -166,15 +166,39 @@ const state: any = reactive({
     init: false,
     loading: false,
     head: [
-      { value: 'name', label: '文件名称', show: true },
-      { value: 'wordCount', label: '字符数', show: true },
-      { value: 'indexingStatus', label: '状态', show: true },
-      { value: 'p1', label: '召回次数(NO)', show: true },
-      { value: 'isUse', label: '启用/停用', show: true },
-      { value: 'checkStatus', label: '审核状态', show: true },
-      { value: 'p1', label: '关联应用(NO)', show: true },
-      { value: 'createTime', label: '创建时间', show: true },
-      { value: 'updateTime', label: '更新时间', show: true },
+      { value: 'name', label: '文件名称', show: true, width: 200 },
+      { value: 'wordCount', label: '字符数', show: true, width: 100 },
+      {
+        value: 'indexingStatus',
+        label: '状态',
+        show: true,
+        width: 100,
+        dictList: DictionaryStore.indexingStatusList,
+      },
+      { value: 'p1', label: '召回次数(无)', show: true },
+      {
+        value: 'isUse',
+        label: '启用/停用',
+        show: true,
+        width: 100,
+        dictList: DictionaryStore.documentUseList,
+      },
+      { value: 'checkStatus', label: '审核状态', show: true, width: 100 },
+      { value: 'p1', label: '关联应用(无)', show: true },
+      {
+        value: 'createTime',
+        label: '创建时间',
+        show: true,
+        width: 180,
+        datetime: true,
+      },
+      {
+        value: 'updateTime',
+        label: '更新时间',
+        show: true,
+        width: 180,
+        datetime: true,
+      },
       {
         value: 'caozuo',
         label: '操作',
@@ -303,7 +327,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
 }
@@ -334,7 +359,10 @@ onMounted(() => {
   initDictionary()
   onReset()
 })
-const initDictionary = () => {}
+const initDictionary = () => {
+  DictionaryStore.initDict('document_use')
+  DictionaryStore.initDict('indexing_status')
+}
 </script>
 
 <style lang="scss" scoped>

+ 18 - 16
src/views/manage/knowledge/documents/document/rename.vue

@@ -13,7 +13,7 @@
           required
           :span="24"
           label="文件名称"
-          v-model:param="state.form.p1"
+          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 { documentUpdateFileName } from '@/api/modules/knowledge/document'
 
 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
+          documentUpdateFileName({
+            docId: props.transfer.id,
+            name: state.name,
+          })
+            .then(() => {
+              ElMessage.success(`重命名成功!`)
+              emit('update:show', false)
+              emit('refresh')
+            })
+            .catch(() => {})
+            .finally(() => {
+              state.loading = false
+            })
         },
       })
     })

+ 14 - 1
src/views/manage/knowledge/tags-select.vue

@@ -196,6 +196,7 @@ const state: any = reactive({
   valueMap: new Map(),
   showDialog: false,
   init: false,
+  isChange: false,
 })
 const onAdd = () => {
   tagsAdd({
@@ -271,11 +272,14 @@ watch(
   (n) => {
     if (state.init) {
       if (n) {
+        state.isChange = false
         state.text = ''
         document.addEventListener('mousedown', onMouseDown)
       } else {
         document.removeEventListener('mousedown', onMouseDown)
-        emit('onChange', Array.from(state.valueMap.keys()))
+        if (state.isChange) {
+          emit('onChange', Array.from(state.valueMap.keys()))
+        }
       }
     }
   },
@@ -294,6 +298,15 @@ watch(
   },
   { immediate: true },
 )
+watch(
+  () => state.valueMap,
+  (n) => {
+    if (state.show) {
+      state.isChange = true
+    }
+  },
+  { deep: true },
+)
 onBeforeMount(() => {
   DictionaryStore.initKnowledgeTags(AppStore.tenantInfo?.id)
 })