Pārlūkot izejas kodu

关联下拉回显修改

sql715 2 mēneši atpakaļ
vecāks
revīzija
e2aca484e7

+ 27 - 18
zkqy-ui/node_modules/k-form-design/packages/components/KFormDesign/module/formItemProperties.vue

@@ -18,13 +18,10 @@
             </el-option>
           </el-select>
         </a-form-item>
-        <!-- 其中,selectItem.tableName是下拉框的value,有一个监听change的方法getListName(selectItem),
-            下拉框的数据从formList.formName中获取,现在来梳理这些数据都做了什么,
-      -->
         <!-- +++ -->
         <a-form-item v-if="isDefined(options.jsTableFlag) && !hideModel && isDefined(selectItem.model)" label="关联表字段">
           <el-select v-model="options.mainTableCondition" placeholder="请选择关联表字段" filterable>
-            <el-option v-for="item in this.formList.listName" :key="item.value" :label="item.label" :value="item.value"
+            <el-option v-for="item in formList.listName" :key="item.value" :label="item.label" :value="item.value"
               @change="getOptionsGLZD(options)">
               <span class="discribe" style="float: left">{{ item.label }}</span>
               <span style="float: right; color: #8492a6; font-size: 13px">{{ item.fieldDescription }}</span>
@@ -42,7 +39,7 @@
         </a-form-item>
         <a-form-item v-if="isDefined(options.jsTableFlag) && !hideModel && isDefined(selectItem.model)" label="条件表字段">
           <el-select v-model="options.joinTableCondition" placeholder="请选择条件表字段" filterable>
-            <el-option v-for="item in this.formList2.listName" :key="item.value" :label="item.label" :value="item.value"
+            <el-option v-for="item in formList2.listName" :key="item.value" :label="item.label" :value="item.value"
               @change="getOptionsGLZD(options)">
               <span class="discribe" style="float: left">{{ item.label }}</span>
               <span style="float: right; color: #8492a6; font-size: 13px">{{ item.fieldDescription }}</span>
@@ -631,13 +628,13 @@ export default {
       console.log('glzd----', options)
     },
     delectTableColumns(item) {
-      console.log('item00000000', item)
+      // console.log('item00000000', item)
       this.options.tableColumns = this.options.tableColumns.filter(column => column.prop !== item);
 
-      console.log('------0000', this.options.tableColumns); // 输出更新后的 tableColumns 数组
+      // console.log('------0000', this.options.tableColumns); // 输出更新后的 tableColumns 数组
     },
     addTableColumns(item) {
-      console.log('add---', item)
+      // console.log('add---', item)
 
       this.options.tableColumns = item
 
@@ -698,9 +695,9 @@ export default {
         ... this.$store.state.user.dataSource
       }
       let res = await getUncommonTable()
+      console.log('getUncommonTable', res)
       this.formList.formName = res
       this.formList2.formName = res
-      console.log
     },
     getListName(item = {}) {
       let notNeedColumnList = ['batch', 'selectInputList'];
@@ -714,10 +711,9 @@ export default {
       } else {
         item.model = ''
       }
-      if (this.options) {
-        this.options.mainTableCondition = '';
-      }
-
+      // if (this.options) {
+      //  
+      // }
       let par2 = {
         ... this.$store.state.user.dataSource,
         'tableName': this.selectItem.tableName
@@ -730,9 +726,16 @@ export default {
             fieldDescription: item.fieldDescription
           }
         });
+        let x = this.formList.listName.filter(item => item.value == this.options?.mainTableCondition)
+        if (!(x.length > 0)) {
+          this.options.mainTableCondition = '';
+        }
+
       })
+
     },
     getListName2(item = {}) {
+      console.log('getListName2被调用', this.options.joinTableCondition)
       let notNeedColumnList = ['batch', 'selectInputList'];
       let flag = notNeedColumnList.includes(item.type);
       if (flag) {
@@ -742,10 +745,10 @@ export default {
       } else {
         item.model = '';
       }
-      // 清空条件表字段
-      if (this.options) {
-        this.options.joinTableCondition = '';
-      }
+      // // 清空条件表字段
+      // if (this.options) {
+      //   this.options.joinTableCondition = '';
+      // }
       let par2 = {
         ...this.$store.state.user.dataSource,
         tableName: this.selectItem.joinTableName // 注意:这里使用 tableName2
@@ -759,16 +762,22 @@ export default {
             fieldDescription: item.fieldDescription
           };
         });
+        let x = this.formList2.listName.filter(item => item.value == this.options?.joinTableCondition)
+        if (!(x.length > 0)) {
+          this.options.joinTableCondition = '';
+        }
       });
+
     }
   },
   mounted() {
     this.getFormList();
-    console.log('this.selectItem', this.selectItem);
     if (this.selectItem.tableName) {
+      console.log('this.selectItem---tableName存在的情况', this.selectItem.tableName);
       this.getListName()
     }
     if (this.selectItem.joinTableName) {
+      console.log('this.selectItem---joinTableName存在的情况', this.selectItem.joinTableName);
       this.getListName2();
     }
   },