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 +++++++++++++++++++++++++++++++-
 1 files changed, 63 insertions(+), 3 deletions(-)

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