CzRger 5 mesi fa
parent
commit
fbe41d5908
1 ha cambiato i file con 14 aggiunte e 47 eliminazioni
  1. 14 47
      src/views/manage/theme/relation-column.vue

+ 14 - 47
src/views/manage/theme/relation-column.vue

@@ -8,22 +8,23 @@
     max-height="80%"
     :loading="state.loading"
   >
-    <template #foot>
-      <div class="__cus-dialog-foot_cancel __hover" @click="onReset">重置默认</div>
-    </template>
+<!--    <template #foot>-->
+<!--      <div class="__cus-dialog-foot_cancel __hover" @click="onReset">重置默认</div>-->
+<!--    </template>-->
     <div class="__cus-manage_content">
       <div class="__cus-manage_content-main" v-loading="state.query.loading">
         <CusTable
-          :data="state.query.result.data"
+          v-model:data="state.query.result.data"
           :table-head="state.query.tableHead"
           :no-page="true"
+          :dragable="true"
         >
           <template #sort-column-value="{scope}">
             {{scope.$index + 1}}
           </template>
-          <template #searchShow-column-value="{scope}">
+          <template #isShow-column-value="{scope}">
             <el-switch
-              v-model="scope.row.searchShow"
+              v-model="scope.row.isShow"
               active-value="1"
               inactive-value="0"
             />
@@ -60,30 +61,13 @@ const state: any = reactive({
       {value: "fieldName", label: "列名称"},
       {value: "fieldKey", label: "列英文名称"},
       {value: "sort", label: "排序"},
-      {value: "searchShow", label: "展示"},
+      {value: "isShow", label: "展示"},
     ],
     result: {
-      defaultShowIds: [],
       data: []
     }
   },
 })
-const initText = () => {
-  state.query.loading = true
-  sysIndexFieldList(proxy.$util.formatGetParam({
-    indexId: props.transfer.indexId,
-    type: props.transfer.type
-  })).then(res => {
-    state.query.result.data = res.data
-    if (props.transfer.type === 'inner_index') {
-      state.query.result.defaultShowIds = state.query.result.data.filter(v => v.searchShow == 1).map(v => v.id)
-    } else {
-      state.query.result.defaultShowIds = state.query.result.data.map(v => v.fieldKey)
-    }
-    state.query.loading = false
-    initRelation()
-  })
-}
 const initRelation = () => {
   state.query.loading = true
   sysThemeIndexGetIndexFields(proxy.$util.formatGetParam({
@@ -91,36 +75,20 @@ const initRelation = () => {
     indexId: props.transfer.indexId,
     type: props.transfer.type,
   })).then(res => {
-    state.query.result.data.forEach(v => {
-      if (props.transfer.type === 'inner_index') {
-        v.searchShow = res.data.some(s => s.fieldId == v.id) ? '1' : '0'
-      } else {
-        v.searchShow = res.data.some(s => s.fieldKey == v.fieldKey) ? '1' : '0'
-      }
-    })
+    state.query.result.data = res.data || []
     state.query.loading = false
   })
 }
-const onReset = () => {
-  state.query.result.data.forEach(v => {
-    v.searchShow = props.transfer.type == 'inner_index' ? (state.query.result.defaultShowIds.includes(v.id) ? '1' : '0') : (state.query.result.defaultShowIds.includes(v.fieldKey) ? '1' : '0')
-  })
-}
 const onSubmit = () => {
   ElMessageBox.confirm("是否提交?", "提示", {
     confirmButtonText: "确定",
     cancelButtonText: "取消",
     type: "warning",
   } as any).then(() => {
-    const arr = state.query.result.data.filter(v => v.searchShow == 1).map((v, i) => ({
-      themeId: props.transfer.themeId,
-      indexId: props.transfer.indexId,
-      type: props.transfer.type,
-      fieldId: v.id,
-      fieldName: v.fieldName,
-      fieldKey: v.fieldKey,
-      sort: i,
-    }))
+    const arr = state.query.result.data.map((v, i) => {
+      v.sort = i
+      return v
+    })
     state.loading = true
     sysThemeIndexSaveIndexFields(arr).then(res => {
       ElMessage.success('保存成功!')
@@ -132,11 +100,10 @@ const onSubmit = () => {
 }
 watch(() => props.show, (n) => {
   if (n) {
-    initText()
+    initRelation()
   }
 })
 const initDictionary = () => {
-  DictionaryStore.initDict('is_main_index')
 }
 </script>