whj vor 1 Jahr
Ursprung
Commit
ca5d0aa702
1 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen
  1. 16 6
      src/views/custom/form/modules/BaseForm.vue

+ 16 - 6
src/views/custom/form/modules/BaseForm.vue

@@ -70,10 +70,10 @@
         :labelCol="BaseTool.Constant.labelCol"
         :wrapperCol="BaseTool.Constant.wrapperCol"
       >
-        <a-checkbox-group v-model="formValue.queryFields" @change="onChange">
+        <a-checkbox-group v-model="queryFields" @change="handleQueryFieldsChange">
           <a-row>
-            <a-col :span="8" v-for="item in queryFields" :key="item.fieldName">
-              <a-checkbox :value="item">
+            <a-col :span="8" v-for="item in queryFieldList" :key="item.fieldName">
+              <a-checkbox :value="item.fieldName">
                 {{ item.comments }}
               </a-checkbox>
             </a-col>
@@ -103,12 +103,18 @@ export default {
       // 下拉框map
       categoryMap: {},
       typeMap: {},
-      formValue: {},
-      formComponentConfig: {}
+      formValue: {
+        queryFields: []
+      },
+      queryFields: [],
+      formComponentConfig: {
+        components: []
+      }
     }
   },
+
   computed: {
-    queryFields () {
+    queryFieldList () {
       return this.formComponentConfig.components.map(item => {
         return {
           comments: item.label,
@@ -137,6 +143,7 @@ export default {
       const { form: { setFieldsValue } } = this
       // 日期处理
       this.formValue = record
+      this.queryFields = this.formValue.queryFields.map(item => item.fieldName)
       this.$nextTick(() => {
         setFieldsValue(Object.assign(pick(record, [
           'id',
@@ -180,6 +187,9 @@ export default {
         this.current--
       }
     },
+    handleQueryFieldsChange () {
+      this.formValue.queryFields = this.queryFieldList.filter(item => this.queryFields.includes(item.fieldName))
+    },
     save () {
       this.confirmLoading = true
       // 日期处理