guanqb
2023-03-21 1a9b1084627e204ce3975f06cde8801e36f125b0
首页选择责任区逻辑修改
2 files modified
273 ■■■■■ changed files
src/views/home/index.vue 271 ●●●●● patch | view | raw | blame | history
vue.config.js 2 ●●● patch | view | raw | blame | history
src/views/home/index.vue
@@ -672,7 +672,6 @@
                if (type == 1) {
                    this.policeStationOptions = res.data.data
                    console.log('policeStationOptions',this.policeStationOptions );
                    this.policeStationOptions.unshift({
                        name: '全部',
@@ -701,34 +700,18 @@
                } else if (type == 2) {
                    this.areaOptions = res.data.data
                    console.log(type,2222);
                    this.initAreaOptionLayer()
                    this.areaOptions.unshift({
                        name: '全部',
                        id: 1
                    })
                } else {
                    this.housingOptions = res.data.data
                    this.housingOptions.lnegth > 0 && this.housingOptions.forEach(item => {
                        const positions = JSON.parse(item.position[0]).coordinates
                        this.$EventBus.$emit('layerPointAdd', {
                            layerName: 'polygonLayer',
                            type: 'billboard',
                            params: {
                                lng: Number(positions[0]),
                                lat: Number(positions[1]),
                                alt: 1,
                                url: '/img/icon/house.png',
                                id: item.id
                            },
                            incident: this.houseSiteClick,
                            distanceDisplayCondition: { "near": 0, "far": 200000 }
                        })
                    this.initHousingLayer ()
                    this.housingOptions.unshift({
                        name: '全部',
                        id: 1
                    })
                }
            })
        },
@@ -932,26 +915,18 @@
                this.housingCheckValue = '请选择小区'
                this.getPoliceStationTree(3, item.id)
                this.areaChecked = item
                this.initAreaOptionLayer()
            }
        },
        housingSelect (item) {
            this.housingCheckValue = item.name
            // if (item.housingsName == "全部") {
            //     this.initHousingLayer(this.areaChecked)
            // } else {
            //     this.initLivingLayer(item)
            // }
            const positions = JSON.parse(item.position[0]).coordinates
            this.$EventBus.$emit('toPosition', {
                siteJd: Number(positions[0]),
                siteWd: Number(positions[1]) - 0.0021,
                siteGd: 240,
                sitePitch: -45
            })
            if (item.name == "全部") {
                this.initHousingLayer(this.areaChecked)
            } else {
                this.initLivingLayer(item)
            }
        },
        getCenter (str) {
@@ -1189,33 +1164,33 @@
            }
        },
        // initAreaCheckoptions (areaArr) {
        //     areaArr.forEach((item, index) => {
        //         if (item.areaCheckName != '全部') {
        //             let str = ''
        //             item.position.forEach(it => {
        //                 str = str + `${it[0]},${it[1]},${it[2]};`
        //             })
        //             this.$EventBus.$emit('layerPolygonAdd', {
        //                 layerName: 'polygonLayer',
        //                 positions: str,
        //                 material: positionColor[index]
        //             })
        //             const center = this.getCenter(item.position)
        //             this.$EventBus.$emit('layerPointAdd', {
        //                 layerName: 'polygonLayer',
        //                 type: 'label',
        //                 params: {
        //                     lng: center[0],
        //                     lat: center[1],
        //                     alt: 0,
        //                     text: item.areaCheckName
        //                 },
        //                 distanceDisplayCondition: { "near": 0, "far": 200000 }
        //             })
        //         }
        //     })
        // },
        initAreaCheckoptions (areaArr) {
            areaArr.forEach((item, index) => {
                if (item.areaCheckName != '全部') {
                    let str = ''
                    item.position.forEach(it => {
                        str = str + `${it[0]},${it[1]},${it[2]};`
                    })
                    this.$EventBus.$emit('layerPolygonAdd', {
                        layerName: 'polygonLayer',
                        positions: str,
                        material: positionColor[index]
                    })
                    const center = this.getCenter(item.position)
                    this.$EventBus.$emit('layerPointAdd', {
                        layerName: 'polygonLayer',
                        type: 'label',
                        params: {
                            lng: center[0],
                            lat: center[1],
                            alt: 0,
                            text: item.areaCheckName
                        },
                        distanceDisplayCondition: { "near": 0, "far": 200000 }
                    })
                }
            })
        },
        initHousingOptions (housingArr) {
            housingArr.forEach((item, index) => {
@@ -1374,8 +1349,6 @@
                    const center = this.getRegionCenter(item.position)
                    this.$EventBus.$emit('layerPointAdd', {
                        layerName: 'areaPolygonLabel',
                        type: 'label',
@@ -1447,7 +1420,6 @@
        initAreaOptionLayer () {
            const that = this
            this.clearPolygonLayer()
            console.log(this.areaOptions,11122)
            this.areaOptions.forEach((item, index) => {
                item.position && item.position.forEach(sourceItem => {
@@ -1501,40 +1473,22 @@
            })
        },
        initHousingLayer (item) {
            this.clearPolygonLayer()
            let itPositionStr = item.position[0].replace(/MULTIPOLYGON\(\(\(/g, '')
            itPositionStr = itPositionStr.replace(/\)\)\)/g, '')
            itPositionStr = itPositionStr.replace(/,/g, ";")
            itPositionStr = itPositionStr.replace(/ /g, ",")
            let center = this.getCenter(item.position[0])
            this.$EventBus.$emit('layerPolygonAdd', {
                layerName: 'polygonLayer',
                positions: itPositionStr,
                material: positionColor[0],
            })
            this.$EventBus.$emit('toPosition', {
                siteJd: center[0],
                siteWd: center[1],
                siteGd: 6000,
                siteHeading: -3,
                sitePitch: -90
            })
        },
        initLivingLayer (item) {
            let center = this.getCenter(item.position)
        initHousingLayer () {
            let positionArr = JSON.parse(this.areaChecked.position).coordinates[0][0]
            let polygon = this.$turf.polygon([positionArr])
            let center = this.$turf.centroid(polygon)
            let centerPosition = [center.geometry.coordinates[0], center.geometry.coordinates[1]]
            this.clearPolygonLayer()
            this.$EventBus.$emit('toPosition', {
                siteJd: center[0],
                siteWd: center[1],
                siteGd: 18000,
                siteJd: centerPosition[0],
                siteWd: centerPosition[1],
                siteGd: 3000,
                siteHeading: -3,
                sitePitch: -90
            })
            let str = ''
            item.position.forEach(it => {
                str = str + `${it[0]},${it[1]},${it[2]};`
            positionArr.forEach(it => {
                str = str + `${it[0]},${it[1]};`
            })
            this.$EventBus.$emit('layerPolygonAdd', {
                layerName: 'polygonLayer',
@@ -1548,8 +1502,73 @@
                    lng: center[0],
                    lat: center[1],
                    alt: 1,
                    text: item.housingsName
                    text: this.areaChecked.name
                }
            })
            this.housingOptions.length > 0 && this.housingOptions.forEach(item => {
                  if(item.name == '全部') return
                  const positions = JSON.parse(item.position[0]).coordinates
                  this.$EventBus.$emit('layerPointAdd', {
                      layerName: 'polygonLayer',
                      type: 'billboard',
                      params: {
                          lng: Number(positions[0]),
                          lat: Number(positions[1]),
                          alt: 1,
                          url: '/img/icon/house.png',
                          id: item.id
                      },
                      incident: this.houseSiteClick,
                      distanceDisplayCondition: { "near": 0, "far": 200000 }
                  })
                  this.$EventBus.$emit('layerPointAdd', {
                    layerName: 'polygonLayer',
                    type: 'label',
                    params: {
                        lng: Number(positions[0]),
                        lat: Number(positions[1]),
                        alt: 1,
                        text: item.name
                    }
                  })
            })
        },
        initLivingLayer (item) {
            let positionArr = JSON.parse(item.position).coordinates
            this.clearPolygonLayer()
            this.$EventBus.$emit('toPosition', {
                siteJd: positionArr[0],
                siteWd: positionArr[1],
                siteGd: 3000,
                siteHeading: -3,
                sitePitch: -90
            })
            this.$EventBus.$emit('layerPointAdd', {
                layerName: 'polygonLayer',
                type: 'label',
                params: {
                    lng: positionArr[0],
                    lat: positionArr[1],
                    alt: 1,
                    text: item.name
                }
            })
            this.$EventBus.$emit('layerPointAdd', {
                layerName: 'polygonLayer',
                type: 'billboard',
                params: {
                    lng: positionArr[0],
                    lat: positionArr[1],
                    alt: 1,
                    url: '/img/icon/house.png',
                    id: item.id
                },
                incident: this.houseSiteClick,
                distanceDisplayCondition: { "near": 0, "far": 200000 }
            })
        },
@@ -1578,21 +1597,8 @@
            // cylinderLayer.clear()
        },
        getAreaCenter (name) {
            let center = []
            this.areaOptionData.some((item) => {
                if (this.policeStaionChecked.policeStationName == item.policeStationName && this.policeStaionChecked.policeStationName != "全部") {
                    item.areaCheckOptions.some((one) => {
                        if (name == one.areaCheckName) {
                            center = this.getCenter(one.position)
                        }
                    })
                }
            })
            return center
        },
        // 修改下拉容器的left
        setDomStyle () {
            const bodyWidth = document.body.clientWidth
            const domWidth = this.$refs.RegionSelect.offsetWidth
@@ -1685,7 +1691,6 @@
        getPoliceCameraEquimentPage (params) {
            getPoliceCameraEquimentPage(params).then(res => {
                console.log(res)
            })
        },
@@ -1862,52 +1867,6 @@
                }
            })
        },
        /**
         * 获取派出所和责任区数据
         */
        // getPoliceStationList () {
        //     getPoliceStationList().then(res => {
        //         if (res.data.code == 200) {
        //             let data = res.data.data
        //             console.log(data,111)
        //             data.forEach(policeStation => {
        //                 //派出所数据匹配
        //                 policeStation.policeStationName = policeStation.deptName
        //                 policeStation.policeStationId = policeStation.id
        //                 policeStation.position = convertStringToList(policeStation.positionString)
        //                 if (policeStation.children && policeStation.children.length > 0) {
        //                     //责任区数据匹配
        //                     policeStation.areaCheckOptions = policeStation.children
        //                     policeStation.areaCheckOptions.forEach(child => {
        //                         child.policeStationId = child.parentId
        //                         child.areaCheckId = child.id
        //                         child.areaCheckName = child.deptName
        //                         child.position = convertStringToList(child.positionString)
        //                         //小区数据匹配
        //                         if (child.housingArr && child.housingArr.length > 0) {
        //                             child.housingArr.forEach(community => {
        //                                 community.policeStationId = policeStation.id
        //                                 community.areaCheckId = child.id
        //                                 community.housingsId = community.id
        //                                 community.housingsName = community.name
        //                                 community.position = convertStringToList(community.position)
        //                             })
        //                             child.housingArr.unshift({ housingsName: '全部' })
        //                         }
        //                     })
        //                     policeStation.areaCheckOptions.unshift({ areaCheckName: '全部' })
        //                     policeStation.areaOptionArr = policeStation.areaCheckOptions
        //                 }
        //             })
        //             data.unshift({ policeStationName: '全部' })
        //             this.policeStationOptions = data
        //             this.areaOptionData = data
        //             this.housingDate = data
        //         }
        //     })
        // },
        indexMethod (index) {
            return index + 1
vue.config.js
@@ -158,7 +158,7 @@
            "/api": {
                // target用于配置你允许访问数据的计算机名称,即是你的api接口的服务器地址
                // target: "http://localhost:82",
                target: "http://192.168.0.126:82",
                target: "http://192.168.0.200:82",
                // target: "http://17.20.10.3:82",
                // target: "http://10.141.11.11:8081/api",
                // ws: true, //启用webSocket6566