From bad2a73fd798991d64cbb22efef2dfd448450e3a Mon Sep 17 00:00:00 2001
From: guanqb <18720758508@163.com>
Date: Fri, 28 Oct 2022 17:52:00 +0800
Subject: [PATCH] 设备模块数据联动

---
 src/views/home/index.vue                     |   66 +++++++++++++++++++++++++++++++-
 src/views/home/components/rightContainer.vue |   44 ++++++++++------------
 2 files changed, 83 insertions(+), 27 deletions(-)

diff --git a/src/views/home/components/rightContainer.vue b/src/views/home/components/rightContainer.vue
index 326fd44..997d126 100644
--- a/src/views/home/components/rightContainer.vue
+++ b/src/views/home/components/rightContainer.vue
@@ -290,37 +290,33 @@
             let arr3 = housingDate
 
             let areaArr = []
-            let housingArr = []
             let jurisdictionData = [{
                 label: '全部',
                 children: []
             }]
-            arr1.forEach((item1, index1) => {
-                console.log(item1.policeStationName)
-                if (item1.policeStationName != '全部') {
-                    let policeArr = [{
-                        label: '全部',
-                        children: areaArr
-                    }]
-                    let item1Obj = { label: item1.policeStationName, id: item1.policeStationId, children: policeArr }
-                    arr2.forEach((item2, index2) => {
-                        if (item2.policeStationName == item1.policeStationName) {
-                            item2.areaCheckOptions.forEach((item3, index3) => {
-                                if (item3.areaCheckName != '全部') {
-                                    let policeArr = [{
-                                        label: '全部',
-                                        children: areaArr
-                                    }]
-                                    let item3Obj = { label: item3.areaCheckName, id: item3.areaCheckId, childern: housingArr }
+            // arr1.forEach((item1, index1) => {
+            //     console.log(item1.policeStationName)
+            //     if (item1.policeStationName != '全部') {
 
-                                }
-                            })
-                        }
-                    })
-                }
+            //         let item1Obj = { label: item1.policeStationName, id: item1.policeStationId, children: policeArr }
+            //         arr2.forEach((item2, index2) => {
+            //             if (item2.policeStationName == item1.policeStationName) {
+            //                 item2.areaCheckOptions.forEach((item3, index3) => {
+            //                     if (item3.areaCheckName != '全部') {
+            //                         let policeArr = [{
+            //                             label: '全部',
+            //                             children: housingArr
+            //                         }]
+            //                         let item3Obj = { label: item3.areaCheckName, id: item3.areaCheckId, childern: housingArr }
+
+            //                     }
+            //                 })
+            //             }
+            //         })
+            //     }
 
 
-            })
+            // })
 
         }
     }
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index c045280..6af94cd 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -342,6 +342,34 @@
 import rightContainer from './components/rightContainer'
 import bottomContainer from './components/bottomContainer'
 
+let treeData = [
+    {
+        label: '全部',
+        id: '1',
+        children: [{
+            label: '车站派出所',
+            id: '2',
+            children: [{
+                label: '责任区1',
+                id: '4',
+            }, {
+                label: '责任区2',
+                id: '5',
+            }]
+        }, {
+            label: '沙溪派出所',
+            id: '3',
+            children: [{
+                label: '责任区1',
+                id: '6',
+            }, {
+                label: '责任区2',
+                id: '7',
+            }]
+        }]
+    }
+]
+
 export default {
     data () {
         return {
@@ -487,13 +515,11 @@
             document.querySelector('.dc-container .dc-zoom-controller').classList.add('homebottom')
             document.querySelector('.dc-container .dc-location-bar').classList.add('homebottom')
             document.querySelector('.screen-full-btn').classList.add('homebottom')
-
             this.setDomStyle()
         })
-
         // axios.get('/user/getUserList').then((res) => {
         //     console.log(res, 999)
-        // })
+        // }}
 
         window.addEventListener('resize', this.setDomStyle)
     },
@@ -502,6 +528,29 @@
     },
 
     methods: {
+        searchName (name, arr) {
+            let obj = {}
+            let flag = false
+            arr.forEach(item => {
+                if (item.label == name) {
+                    flag = true
+                    obj = item
+                }
+                // console.log(item.label, name, flag)
+            })
+
+            if (flag) {
+                return obj
+            } else {
+                arr.forEach(item => {
+                    if (item.children) {
+                        obj = this.searchName(name, item.children)
+                    }
+                })
+                return obj
+            }
+        },
+
         policeStationSelect (item) {
             this.policeStationCheckValue = item.policeStationName
             if (item.policeStationName == "全部") {
@@ -527,6 +576,8 @@
                 cylinderLayer.clear()
             }
             this.$refs.leftContainer.selectPoliceChangeData(item.policeStationName)
+
+
         },
 
         areaSelect (item) {
@@ -1017,6 +1068,15 @@
             this.phoneArrShow = booleans[2]
             this.saveArr = arr
             this.showArr = arr
+            // 动态改变树形控件数据
+            this.jurisdictionData = [this.searchName(this.policeStationCheckValue, treeData)]
+            let arr1 = []
+            this.saveArr.some((item1) => {
+                if (item1.policeStation == this.policeStationCheckValue) {
+                    arr1.push(item1)
+                }
+            })
+            this.showArr = arr1
         },
 
         showkeypersondetail (name, arr) {

--
Gitblit v1.9.3