From 15a5c13d70b67394a0a54f76d174a5a0129932a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Tue, 7 Nov 2023 10:23:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../electronicFence/editElectronicFence.vue | 65 +++++++++---------- ruoyi-ui/vue.config.js | 5 +- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/ruoyi-ui/src/views/business/electronicFence/editElectronicFence.vue b/ruoyi-ui/src/views/business/electronicFence/editElectronicFence.vue index f3d4498..722e8b0 100644 --- a/ruoyi-ui/src/views/business/electronicFence/editElectronicFence.vue +++ b/ruoyi-ui/src/views/business/electronicFence/editElectronicFence.vue @@ -194,12 +194,12 @@ export default { CircleEditor.setTarget(); CircleEditor.open() }, - setPolygon(val) { + setPolygon(val, id) { let e = val.map(r => { let [lng, lat] = wgs84togcj02(r[0], r[1]) return [lng, lat] }) - let thisPolygon = new AMap.Polygon({path: e}); + let thisPolygon = new AMap.Polygon({path: e, extData: {id: id}}); thisPolygon.on('dblclick', () => { polyEditor.setTarget(thisPolygon); polyEditor.open(); @@ -211,11 +211,11 @@ export default { map.add(thisPolygon) map.setFitView() }, - setCircle(val) { + setCircle(val, id) { let e = val let [lng, lat] = wgs84togcj02(val.center[0], val.center[1]) e.center = [lng, lat] - let thisCircle = new AMap.Circle({center: e.center, radius: e.radius}); + let thisCircle = new AMap.Circle({center: e.center, radius: e.radius, extData: {id: id}}); thisCircle.on('dblclick', () => { CircleEditor.setTarget(thisCircle); CircleEditor.open(); @@ -230,31 +230,39 @@ export default { getAreaData() { let polygons = map.getAllOverlays('polygon'); let circles = map.getAllOverlays('circle'); - let list = polygons.map(e => e._opts.path)//多边形 - let list1 = circles.map(e => {//圆形 + let list = polygons.map(e => { return { - center: Array.isArray(e._opts.center) ? e._opts.center : [e._opts.center.lng, e._opts.center.lat], - radius: e._opts.radius + coordinates: e._opts.path, + id: e._opts?.extData?.id || null } - }) - let params = [] - let params1 = [] - list.forEach((e, index) => { - e.forEach(val => { + })//多边形 + let params = list.map(e => { + let data = e.coordinates.map(val => { let [lng, lat] = gcj02towgs84(val[0], val[1]) - params.push({ + return { longitude: lng, latitude: lat, - index: index - }) + } }) + return { + coordinates: data, + fenceAreaId: e.id || null + } }) + let list1 = circles.map(e => {//圆形 + return { + center: Array.isArray(e._opts.center) ? e._opts.center : [e._opts.center.lng, e._opts.center.lat], + radius: e._opts.radius, + id: e._opts?.extData?.id || null + } + }) + let params1 = [] list1.forEach((e, index) => { let [lng, lat] = gcj02towgs84(e.center[0], e.center[1]) params1.push({ center: [lng, lat], radius: e.radius, - index: index + fenceAreaId: e.id || null }) }) @@ -278,27 +286,18 @@ export default { polygonAreaListArr.forEach(e1 => { let polygonAreaListJson = JSON.parse(e1); let polyJsonArr = JSON.parse(polygonAreaListJson["polyJsonArr"]); - let fenceAreaId = polygonAreaListJson["fenceAreaId"]; - polyJsonArr.forEach(e => { - if (polygonData1[e.index]) { - polygonData1[e.index].push([e.longitude, e.latitude]) - } else { - polygonData1[e.index] = [[e.longitude, e.latitude]] - } - }) - }) - Object.keys(polygonData1).forEach(e => { - polygonData[e] = polygonData1[e] - }) - polygonData.forEach(e => { - this.setPolygon(e) + let fenceAreaId = polygonAreaListJson["fenceAreaId"] || null; + console.log(polyJsonArr) + this.setPolygon(polyJsonArr.map(e => { + return [e.longitude, e.latitude] + }), fenceAreaId) }) circleAreaList.forEach(e => { - let fenceAreaId = e.fenceAreaId; + let fenceAreaId = e.fenceAreaId || null; let center = JSON.parse(e.center); let radius = e.radius; - this.setCircle({center, radius}) + this.setCircle({center, radius}, fenceAreaId) }) }); } else { diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 3a0bec9..f6824f8 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -35,9 +35,10 @@ module.exports = { proxy: { // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VUE_APP_BASE_API]: { - target: `http://127.0.0.1:9080`, - // target: `http://10.11.40.120:9080`, + // target: `http://127.0.0.1:9080`, + target: `http://10.11.40.120:9080`, // target: `http://10.11.43.111:8080`, + // target: `http://175.27.215.92:9080`, changeOrigin: true, pathRewrite: { ['^' + process.env.VUE_APP_BASE_API]: ''