CzRger 7 månader sedan
förälder
incheckning
87a53c9f2a

+ 20 - 0
src/components/cus/CusTable.vue

@@ -46,6 +46,10 @@
                                       <slot :name="`${five.value}-column-value`" :scope="scope">
                                       </slot>
                                     </template>
+                                    <template #[`${five.value}-header-value`]="{scope}">
+                                      <slot :name="`${five.value}-header-value`" :scope="scope">
+                                      </slot>
+                                    </template>
                                   </CusTableColumn>
                                 </template>
                               </el-table-column>
@@ -60,6 +64,10 @@
                                   <slot :name="`${four.value}-column-value`" :scope="scope">
                                   </slot>
                                 </template>
+                                <template #[`${four.value}-header-value`]="{scope}">
+                                  <slot :name="`${four.value}-header-value`" :scope="scope">
+                                  </slot>
+                                </template>
                               </CusTableColumn>
                             </template>
                           </template>
@@ -75,6 +83,10 @@
                             <slot :name="`${three.value}-column-value`" :scope="scope">
                             </slot>
                           </template>
+                          <template #[`${three.value}-header-value`]="{scope}">
+                            <slot :name="`${three.value}-header-value`" :scope="scope">
+                            </slot>
+                          </template>
                         </CusTableColumn>
                       </template>
                     </template>
@@ -90,6 +102,10 @@
                       <slot :name="`${two.value}-column-value`" :scope="scope">
                       </slot>
                     </template>
+                    <template #[`${two.value}-header-value`]="{scope}">
+                      <slot :name="`${two.value}-header-value`" :scope="scope">
+                      </slot>
+                    </template>
                   </CusTableColumn>
                 </template>
               </template>
@@ -105,6 +121,10 @@
                 <slot :name="`${one.value}-column-value`" :scope="scope">
                 </slot>
               </template>
+              <template #[`${one.value}-header-value`]="{scope}">
+                <slot :name="`${one.value}-header-value`" :scope="scope">
+                </slot>
+              </template>
             </CusTableColumn>
           </template>
         </template>

+ 3 - 0
src/components/cus/CusTableColumn.vue

@@ -30,6 +30,9 @@
           </slot>
         </template>
       </template>
+      <template #header>
+        <slot :name="`${item?.value}-header-value`"/>
+      </template>
     </el-table-column>
   </slot>
 </template>

+ 1 - 0
src/stores/dictionary-define.ts

@@ -8,6 +8,7 @@ export const dictionaryDefine = {
 	default_model: ['defaultModelList', 'defaultModelMap'], //  默认模式
 	true_false: ['trueFalseList', 'trueFalseMap'], //  是否
 	fie_type: ['fieTypeList', 'fieTypeMap'], //  字段类型
+	analyzer: ['analyzerList', 'analyzerMap'], //  分词器
 }
 
 const stateMap = {}

+ 94 - 18
src/views/manage/index/text-detail.vue

@@ -5,6 +5,7 @@
     @onClose="$emit('update:show', false)"
     width="1000px"
     height="auto"
+    max-height="90%"
     @onSubmit="onSubmit"
     :loading="state.loading"
   >
@@ -73,6 +74,35 @@
           :min="1"
           :max="999"
         />
+        <div class="text-table" v-if="state.form.fieldType === 'text'">
+          <CusTable
+            :data="state.textTable.data"
+            :table-head="state.textTable.tableHead"
+            :no-page="true"
+          >
+            <template #value-column-value="{scope}">
+              <el-switch
+                v-model="scope.row.value"
+                active-value="1"
+                inactive-value="0"
+                :disabled="state.textTable.data.length < 2"
+              />
+            </template>
+            <template #do-header-value="{scope}">
+              <CusFormColumn
+                class="fcq"
+                :span="24"
+                v-model:param="state.textTable.fcqSelect"
+                link="select"
+                :options="DictionaryStore.analyzerList.filter(v => state.textTable.data.every(s => s.key !== v.dictValue))"
+                @change="handleChangeFcq"
+              />
+            </template>
+            <template #do-column-value="{scope}">
+              <CusButton type="table-del" @click="state.textTable.data.splice(scope.$index, 1)"/>
+            </template>
+          </CusTable>
+        </div>
         <CusFormColumn
           :span="24"
           label="备注"
@@ -100,7 +130,16 @@ const props = defineProps({
  })
 const state: any = reactive({
   form: {},
-  loading: false
+  loading: false,
+  textTable: {
+    tableHead: [
+      {value: "key", label: "分词器"},
+      {value: "value", label: "主要"},
+      {value: "do", label: "操作", width: 200, fixed: 'right'},
+    ],
+    data: [],
+    fcqSelect: ''
+  },
 })
 const ref_form = ref()
 const titleCpt = computed(() => {
@@ -115,23 +154,34 @@ const titleCpt = computed(() => {
 })
 const onSubmit = () => {
   ref_form.value.submit().then(() => {
-    ElMessageBox.confirm("是否提交?", "提示", {
-      confirmButtonText: "确定",
-      cancelButtonText: "取消",
-      type: "warning",
-    } as any).then(() => {
-      state.loading = true
-      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
+    if (state.form.fieldType === 'text' && state.textTable.data.length === 0) {
+      ElMessage({
+        message: '请至少选择一个分词器!',
+        grouping: true,
+        type: 'warning',
       })
-    }).catch(() => {})
+    } 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)
+        }
+        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(() => {})
+    }
   }).catch((e) => {
     ElMessage({
       message: e[0].message,
@@ -152,23 +202,49 @@ watch(() => props.show, (n) => {
       }
     } else {
       state.form = JSON.parse(JSON.stringify(props.transfer.row))
+      if (state.form.fieldAnalyzer) {
+        state.textTable.data = JSON.parse(state.form.fieldAnalyzer)
+      }
     }
     nextTick(() => {
       ref_form.value.reset()
     })
   }
 })
+const handleChangeFcq = (val) => {
+  if (val) {
+    state.textTable.data.push({
+      key: val, value: '1'
+    })
+    setTimeout(() => {
+      state.textTable.fcqSelect = ''
+    }, 100)
+  }
+}
 watch(() => state.form.searchShow, (n) => {
   if (n == 1) {
     state.form.fieldType = 'text'
   }
 })
-
 const initDictionary = () => {
   DictionaryStore.initDict('true_false')
   DictionaryStore.initDict('fie_type')
+  DictionaryStore.initDict('analyzer')
 }
 </script>
 
 <style lang="scss" scoped>
+:deep(.text-table) {
+  margin-bottom: 20px;
+  max-height: 400px;
+  width: 100%;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  .fcq {
+    .el-form-item {
+      margin-bottom: 0;
+    }
+  }
+}
 </style>