Browse Source

修改表单组依赖字段与表单的逻辑关系

lph 1 năm trước cách đây
mục cha
commit
fb5abc025b
1 tập tin đã thay đổi với 76 bổ sung19 xóa
  1. 76 19
      zkqy-ui/src/views/system/formGroupMange/index.vue

+ 76 - 19
zkqy-ui/src/views/system/formGroupMange/index.vue

@@ -224,10 +224,10 @@
             @change="mainFormChange"
           >
             <el-option
-              v-for="item in formOptionList"
-              :key="item.formKey"
+              v-for="(item, index) in formOptionList"
+              :key="index"
               :label="item.dfNickname"
-              :value="item.formKey"
+              :value="item.dfTableName"
             >
               <span class="discribe" style="float: left">{{
                 item.dfNickname
@@ -282,10 +282,10 @@
               @change="subFormChangeHandler(scope.row)"
             >
               <el-option
-                v-for="item in formOptionList"
-                :key="item.formKey"
+                v-for="(item, index) in formOptionList"
+                :key="index"
                 :label="item.dfNickname"
-                :value="item.formKey"
+                :value="item.dfTableName"
               >
                 <span class="discribe" style="float: left">{{
                   item.dfNickname
@@ -413,7 +413,12 @@
 
     <!-- 条件弹窗 -->
     <el-dialog :title="conditionTitle" :visible.sync="queryShow">
-      <el-table :data="conditionTableData" border stripe>
+      <el-table
+        v-if="conditionTableShow"
+        :data="conditionTableData"
+        border
+        stripe
+      >
         <el-table-column type="index" width="50" />
         <el-table-column prop="fieldName" label="子表单键">
           <template slot-scope="scope">
@@ -663,6 +668,7 @@ export default {
           value: "relateValue",
         },
       ],
+      conditionTableShow: true,
       // end
     };
   },
@@ -714,6 +720,10 @@ export default {
               tableName: row.tableName,
             };
           });
+          this.conditionTableShow = false;
+          this.$nextTick(() => {
+            this.conditionTableShow = true;
+          });
         } catch (error) {
           console.error(error);
         }
@@ -887,14 +897,36 @@ export default {
       }
     },
     // 主表单变化回调
-    mainFormChange(formKey) {
-      let targetForm = this.getFormJson(formKey);
-      console.log("targetForm", targetForm);
-      if (targetForm) {
-        this.groupForm.mainFormItemOptions = getFormItems(
-          targetForm.dfVueTemplate
-        );
-        this.groupForm.mainFormTable = targetForm.dfTableName;
+    async mainFormChange(dfTableName) {
+      // let targetForm = this.getFormJson(formKey);
+      // console.log("targetForm", targetForm);
+      // if (targetForm) {
+      //   this.groupForm.mainFormItemOptions = getFormItems(
+      //     targetForm.dfVueTemplate
+      //   );
+      //   this.groupForm.mainFormTable = targetForm.dfTableName;
+      // }
+      let data = {
+        databaseName: this.databaseName,
+        databaseType: this.databaseType,
+        tableName: dfTableName,
+      };
+      try {
+        let res = await getListName(data);
+        this.groupForm.mainFormItemOptions = res.map((item) => {
+          return {
+            model: item.fieldName,
+            label: item.fieldDescription,
+            tableName: dfTableName,
+          };
+        });
+        this.groupForm.mainFormTable = dfTableName;
+        // this.conditionTableShow = false;
+        // this.$nextTick(() => {
+        //   this.conditionTableShow = true;
+        // });
+      } catch (error) {
+        console.error(error);
       }
     },
     // 获取fId对应的表单JSON数据
@@ -903,7 +935,19 @@ export default {
       return this.formOptionList.find((item) => item.formKey === formKey);
     },
     // 字表单变化回调
-    subFormChangeHandler(row) {
+    async subFormChangeHandler(row) {
+      // if (!row.formKey) {
+      //   Object.assign(row, {
+      //     dfTableName: "",
+      //     formItemList: [],
+      //     formItem: "",
+      //   });
+      // } else {
+      //   let targetForm = this.getFormJson(row.formKey);
+      //   if (targetForm) {
+      //     row.formItemList = getFormItems(targetForm.dfVueTemplate);
+      //   }
+      // }
       if (!row.formKey) {
         Object.assign(row, {
           dfTableName: "",
@@ -911,9 +955,22 @@ export default {
           formItem: "",
         });
       } else {
-        let targetForm = this.getFormJson(row.formKey);
-        if (targetForm) {
-          row.formItemList = getFormItems(targetForm.dfVueTemplate);
+        let data = {
+          databaseName: this.databaseName,
+          databaseType: this.databaseType,
+          tableName: row.formKey,
+        };
+        try {
+          let res = await getListName(data);
+          row.formItemList = res.map((item) => {
+            return {
+              model: item.fieldName,
+              label: item.fieldDescription,
+              tableName: row.formKey,
+            };
+          });
+        } catch (error) {
+          console.error(error);
         }
       }
     },