Selaa lähdekoodia

fix:优化创建子分类逻辑

liujiayin 3 vuotta sitten
vanhempi
sitoutus
173212c188
1 muutettua tiedostoa jossa 27 lisäystä ja 10 poistoa
  1. 27 10
      src/views/platform/cat/type/edit.vue

+ 27 - 10
src/views/platform/cat/type/edit.vue

@@ -212,6 +212,16 @@ export default {
       handler: function (val, oldVal) {
         this.dialogVisible = this.visible
         this.isPrivateLocal = this.isPrivate
+        this.type.authorityObject = JSON.parse(this.parentData.authorityName)
+      },
+      immediate: true
+    },
+    parentData: {
+      handler: function (val, oldVal) {
+        this.getRadioOptions()
+        this.type.authorityObject = JSON.parse(val.authorityName)
+        console.log('this.type.authorityObject', this.type.authorityObject)
+
       },
       immediate: true
     },
@@ -328,18 +338,25 @@ export default {
         this.isPrivateLocal = !((this.$utils.isEmpty(this.type.ownerId) || this.type.ownerId === '0'))
       }).catch(() => { })
     },
+    getRadioOptions() {
+      this.type.authorityObject.buMen = ''
+      let sql = `select * FROM  ibps_party_entity WHERE party_type_='position' AND PATH_ IN (${this.$store.getters.level.first})`
+      curdPost('sql', sql).then(res => {
+        let datas = res.variables.data
+        let treeDatas = this.buildTree(datas, 'ID_', 'PARENT_ID_')
+        for (let i in treeDatas) {
+          this.cascaderOptions.push(treeDatas[i])
+        }
+      })
+    },
     radioChangeHandle(h) {
-      this.type.authorityObject.buMen = JSON.parse(this.parentData.authorityName).buMen
-      if (h == '部门查阅' && this.cascaderOptions.length == 0) {
+      if (h == '部门查阅') {
+        this.type.authorityObject.buMen = JSON.parse(this.parentData.authorityName).buMen
+        if (this.cascaderOptions.length == 0) {
+          this.getRadioOptions()
+        }
+      } else {
         this.type.authorityObject.buMen = ''
-        let sql = `select * FROM  ibps_party_entity WHERE party_type_='position' AND PATH_ IN (${this.$store.getters.level.first})`
-        curdPost('sql', sql).then(res => {
-          let datas = res.variables.data
-          let treeDatas = this.buildTree(datas, 'ID_', 'PARENT_ID_')
-          for (let i in treeDatas) {
-            this.cascaderOptions.push(treeDatas[i])
-          }
-        })
       }
     },
     // 数据扁平化处理