Browse Source

专业设备位置类型数据处理

shaun-sheep 4 years ago
parent
commit
3518aa0894
2 changed files with 39 additions and 35 deletions
  1. 27 21
      src/views/legendLibrary/addForm.vue
  2. 12 14
      src/views/legendLibrary/index.vue

+ 27 - 21
src/views/legendLibrary/addForm.vue

@@ -109,7 +109,7 @@
                         tipPlace='top'
                         width='200'
                         style=' margin-right:48px;'
-                        :returnParentNode='true'
+                        :returnParentNode='false'
                         :isShowAllChoice='true'
                         :choseArea='true'
                         :data='deviceList'
@@ -439,27 +439,33 @@ export default {
 
         //位置/设备
         treeConfirmDevice(id, info) {
-            console.log(id)
-            // this.$set(this.ruleForm, 'InfoLocal', data)
-            let InfoSystem = []
-            let InfoLocal = []
-            if (info && info.length > 0) {
-                for (let i = 0; i < info.length; i++) {
-                    let type = info[i]
-                    if (type.name.includes('/')) {
-                        InfoLocal.push(type)
-                        //位置/设备
-                        this.$set(this.ruleForm, 'InfoLocal', InfoLocal)
-                    } else {
-                        InfoSystem.push(type)
-                        //专业
-                        this.$set(this.ruleForm, 'InfoSystem', InfoSystem)
+            let InfoSystem = [],
+                InfoSystems = [],
+                InfoLocal = []
+            this.deviceList.forEach(i => {
+                i.children.length > 0 &&
+                    i.children.forEach(j => {
+                        if (id.includes(j.id)) {
+                            InfoSystems.push(i)
+                        }
+                    })
+            })
+            InfoSystem = JSON.parse(JSON.stringify(InfoSystems))
+                .reduce((prev, element) => {
+                    if (!prev.find(el => el.id == element.id)) {
+                        prev.push(element)
                     }
-                }
-            } else {
-                this.$set(this.ruleForm, 'InfoLocal', [])
-                this.$set(this.ruleForm, 'InfoSystem', [])
-            }
+                    return prev
+                }, [])
+                .map(i => {
+                    if (i.children.length) {
+                        delete i.children
+                    }
+                    return i
+                })
+            InfoLocal = info
+            this.$set(this.ruleForm, 'InfoLocal', InfoLocal)
+            this.$set(this.ruleForm, 'InfoSystem', InfoSystem)
         },
         focusChange(status) {
             // //console.log('focusChange', status)

+ 12 - 14
src/views/legendLibrary/index.vue

@@ -51,7 +51,7 @@
                         width='280'
                         style='margin:0 12px'
                         :isShowAllChoice='true'
-                        :returnParentNode='true'
+                        :returnParentNode='false'
                         :choseArea='true'
                         :data='deviceList'
                         :lastStage='true'
@@ -497,21 +497,19 @@ export default {
         // },
         //位置/设备
         treeConfirmDevice(id, info) {
+            let InfoSystem = []
             this.InfoSystems = []
             this.InfoLocals = []
-            if (info) {
-                for (let i = 0; i < info.length; i++) {
-                    let type = info[i]
-                    if (type.name.includes('/')) {
-                        this.InfoLocals.push(type.id)
-                    } else {
-                        this.InfoSystems.push(type.id)
-                    }
-                }
-            } else {
-                this.InfoSystems = []
-                this.InfoLocals = []
-            }
+            this.deviceList.forEach(i => {
+                i.children.length > 0 &&
+                    i.children.forEach(j => {
+                        if (id.includes(j.id)) {
+                            InfoSystem.push(i.id)
+                        }
+                    })
+            })
+            this.InfoSystems = [...new Set(JSON.parse(JSON.stringify(InfoSystem)))]
+            this.InfoLocals = id
             this.getTableList()
         },
         //说明书位置