Browse Source

通用表单下拉事件添加字段

zhaoke 1 year ago
parent
commit
0e0fd963e3

+ 17 - 1
src/components/publicPageForm/index.vue

@@ -73,6 +73,8 @@
 import { Query } from "@/api/webApi"
 import uploadItem from './upload.vue'
 import JSEncrypt from "jsencrypt"
+import { mapGetters } from 'vuex'
+
 export default {
   name: 'PublicPageForm',
   components: { uploadItem },
@@ -114,6 +116,9 @@ export default {
       loading: false
     }
   },
+  computed: {
+    ...mapGetters(['authMsg']),
+  },
   watch: {
     formItem: {
       handler (array) {
@@ -227,7 +232,18 @@ export default {
       return typeof returnData == 'string' ? JSON.parse(returnData) : returnData
     },
     //获取表单下拉数据
-    changeSelect (code, item) { },
+    changeSelect (code) {
+      const ndata = this.authMsg.filter(item => item.labelcode && item.pagecode == code)
+      if (ndata?.length) {
+        const nitem = ndata[0]
+        const nval = this.tableForm[code]
+        const { dropdownlistlabel, labelcode, dropdownlistid } = nitem
+        const wdata = this.tableOptions[code].filter(item => item[dropdownlistid] == nval)
+        if (!wdata.length) return
+        const witem = wdata[0]
+        this.tableForm[labelcode] = witem[dropdownlistlabel]
+      }
+    },
     inputChangeHandler (data) {
       if (!this.tableForm[data]) this.tableForm[data] = null
     },

+ 1 - 0
src/views/dataAccessPage/components/accessPageForm.vue

@@ -194,6 +194,7 @@ export default {
         const nval = this.tableForm[code]
         const { dropdownlistlabel, labelcode, dropdownlistid } = nitem
         const wdata = this.selectSource.filter(item => item[dropdownlistid] == nval)
+        if (!wdata.length) return
         const witem = wdata[0]
         this.tableForm[labelcode] = witem[dropdownlistlabel]
       }