Browse Source

关联主题

CzRger 7 months ago
parent
commit
67f7334256

+ 11 - 0
src/api/modules/manage/index.ts

@@ -63,3 +63,14 @@ export const sysIndexExport = (params: any) => handle({
   method: 'get',
   params
 })
+// 关联主题-保存
+export const sysIndexSaveThemeInfo = (params: any) => handle({
+  url: `/${suffix}/sys-index/saveThemeInfo`,
+  method: 'post',
+  params
+})
+// 关联主题-查询
+export const sysIndexGetThemeByIndex = (id: any) => handle({
+  url: `/${suffix}/sys-index/getThemeByIndex/${id}`,
+  method: 'get',
+})

+ 1 - 1
src/router/index.ts

@@ -58,7 +58,7 @@ export const initMainRouter = async () => {
         })
         await Promise.all([
             getCurrentUser(),
-        ]).then(async ([user, config]) => {
+        ]).then(async ([user, theme]) => {
             userInfo = user.data
             userInfo.isAdmin = true
             if (userInfo?.isAdmin) {

+ 21 - 0
src/style/cus.scss

@@ -278,6 +278,27 @@
     }
   }
 }
+.__cus-title_1 {
+  width: 100%;
+  height: 32px;
+  font-size: 14px;
+  font-family: PingFang SC-Regular, PingFang SC;
+  font-weight: 400;
+  color: var(--cus-main-color);
+  display: flex;
+  align-items: center;
+  position: relative;
+  padding-left: 10px;
+  box-sizing: border-box;
+  &:before {
+    content: '';
+    position: absolute;
+    left: 0;
+    width: 2px;
+    height: 14px;
+    background-color: var(--cus-main-color);
+  }
+}
 
 em {
   color: red;

+ 1 - 0
src/views/manage/index/text-detail.vue

@@ -75,6 +75,7 @@
           :max="999"
         />
         <div class="text-table" v-if="state.form.fieldType === 'text'">
+          <div class="__cus-title_1">分词器</div>
           <CusTable
             :data="state.textTable.data"
             :table-head="state.textTable.tableHead"

+ 45 - 60
src/views/manage/index/theme.vue

@@ -52,12 +52,9 @@ import {computed, getCurrentInstance, nextTick, reactive, ref, watch} from "vue"
 import {useDictionaryStore} from "@/stores";
 import {ElMessage, ElMessageBox} from "element-plus";
 import {
-  sysIndexFieldList,
-  sysIndexFieldSaveOrUpdate,
-  sysIndexGetDetail,
-  sysIndexSaveOrUpdate
+  sysIndexFieldList, sysIndexGetThemeByIndex, sysIndexSaveThemeInfo
 } from "@/api/modules/manage";
-import {sysThemeFind, sysThemeGetPageTheme} from "@/api/modules/manage/theme";
+import {sysThemeGetPageTheme} from "@/api/modules/manage/theme";
 
 const emit = defineEmits(['update:show', 'refresh'])
 const {proxy} = getCurrentInstance()
@@ -86,34 +83,28 @@ const titleCpt = computed(() => {
 })
 const onSubmit = () => {
   ref_form.value.submit().then(() => {
-    if (state.form.fieldType === 'text' && state.textTable.data.length === 0) {
-      ElMessage({
-        message: '请至少选择一个分词器!',
-        grouping: true,
-        type: 'warning',
-      })
-    } else {
-      ElMessageBox.confirm("是否提交?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning",
-      } as any).then(() => {
-        state.loading = true
-        if (state.form.fieldType === 'text') {
-          state.form.fieldAnalyzer = JSON.stringify(state.textTable.data)
+    ElMessageBox.confirm("是否提交?", "提示", {
+      confirmButtonText: "确定",
+      cancelButtonText: "取消",
+      type: "warning",
+    } as any).then(() => {
+      state.loading = true
+      const params = {
+        indexId: props.transfer.id,
+        themeId: state.form.themeId,
+        themeField: JSON.stringify(state.textTable.data)
+      }
+      sysIndexSaveThemeInfo(params).then(res => {
+        if (res.code === 200) {
+          ElMessage.success('保存成功!')
+          emit('update:show', false)
+          emit('refresh')
+        } else {
+          ElMessage.error(res.msg)
         }
-        sysIndexFieldSaveOrUpdate(state.form).then(res => {
-          if (res.code === 200) {
-            ElMessage.success(props.transfer.mode === 'add' ? '新增成功!' : '编辑成功!')
-            emit('update:show', false)
-            emit('refresh')
-          } else {
-            ElMessage.error(res.msg)
-          }
-          state.loading = false
-        })
-      }).catch(() => {})
-    }
+        state.loading = false
+      })
+    }).catch(() => {})
   }).catch((e) => {
     ElMessage({
       message: e[0].message,
@@ -123,37 +114,20 @@ const onSubmit = () => {
   })
 }
 const initTheme = () => {
-  // sysThemeGetPageTheme('page=1&size=1000&themeType=2&themeState=1').then(res => {
-  //   if (res.code === 200) {
-  //     state.themeOptions = res.data.totalElements
-  //   } else {
-  //     ElMessage.error(res.msg)
-  //   }
-  // })
-  state.themeOptions = [
-    {
-      "themeId": "7",
-      "themeName": "测试档案",
-      "themeType": "2",
-      "themeState": "1",
-      "themeUrl": "/web/archive",
-      "themeParam": "p1,p2,p3,p4",
-      "themeStyle": null,
-      "createTime": "2024-09-10 01:45:48",
-      "createBy": "1",
-      "updateTime": "2024-09-10 01:45:48",
-      "updateBy": "1"
+  sysThemeGetPageTheme('page=1&size=1000&themeType=2&themeState=1').then(res => {
+    if (res.code === 200) {
+      state.themeOptions = res.data.content
+    } else {
+      ElMessage.error(res.msg)
     }
-  ]
+  })
 }
 const handleSelect = (obj) => {
   if (obj.themeParam) {
-    obj.themeParam.split(',').forEach(v => {
-      state.textTable.data.push({
-        themeParam: v,
-        fieldParam: '',
-      })
-    })
+    state.textTable.data = obj.themeParam.split(',').map(v => ({
+      themeParam: v,
+      fieldParam: '',
+    }))
   }
 }
 const initText = () => {
@@ -167,10 +141,21 @@ const initText = () => {
     }
   })
 }
+const initDetail = () => {
+  state.loading = true
+  sysIndexGetThemeByIndex(props.transfer.id).then(res => {
+    if (res.code === 200) {
+      state.form = res.data || {}
+      state.loading = false
+    } else {
+      ElMessage.error(res.msg)
+    }
+  })
+}
 watch(() => props.show, (n) => {
   if (n) {
     initDictionary()
-    state.form = {}
+    initDetail()
     initTheme()
     initText()
     nextTick(() => {

+ 10 - 0
src/views/manage/theme/index.vue

@@ -43,6 +43,9 @@
         <template #themeState-column-value="{scope}">
           {{DictionaryStore.themeStatusMap.get(scope.row.themeState)}}
         </template>
+        <template #themeUrl-column-value="{scope}">
+          {{formatUrl(scope.row)}}
+        </template>
         <template #do-column-value="{scope}">
           <CusButton type="table-edit" @click="onEdit(scope.row)"/>
           <CusButton type="table-del" @click="onDel(scope.row)"/>
@@ -191,6 +194,13 @@ const onDel = (row) => {
     })
   }).catch(() => {})
 }
+const formatUrl = (row) => {
+  let str = `${row.themeUrl}`
+  if (row.themeParam) {
+    str += '?' + row.themeParam.split(',').map(v => `${v}=value`).join('&')
+  }
+  return str
+}
 const initDictionary = () => {
   DictionaryStore.initDict('theme_type')
   DictionaryStore.initDict('theme_status')

+ 2 - 2
src/views/manage/theme/relation-detail.vue

@@ -70,7 +70,7 @@
           v-model:param="state.form.relationDescription"
         />
         <el-col :span="12">
-          <div class="table-title">索引条件</div>
+          <div class="__cus-title_1">索引条件</div>
           <CusTable
             :data="state.conditionTable.data"
             :table-head="state.conditionTable.tableHead"
@@ -110,7 +110,7 @@
           </CusTable>
         </el-col>
         <el-col :span="12" style="padding-left: 20px">
-          <div class="table-title">索引排序</div>
+          <div class="__cus-title_1">索引排序</div>
           <CusTable
             :data="state.sortTable.data"
             :table-head="state.sortTable.tableHead"