From 247dacca9784396eeaf17ef3e85c7ae646b786e4 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Wed, 28 Aug 2024 15:56:50 +0800 Subject: [PATCH] Merge branch 'feature_1.0' --- src/views/list/road.vue | 184 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 146 insertions(+), 38 deletions(-) diff --git a/src/views/list/road.vue b/src/views/list/road.vue index cec8579..ebdfce7 100644 --- a/src/views/list/road.vue +++ b/src/views/list/road.vue @@ -53,6 +53,15 @@ ></a-table> </div> <div class="left-three" style="margin-top: 20px"> + <a-button type="primary" style="margin-left: 10px" @click="reosurce" + >������������������</a-button + > + <a-button + type="primary" + style="margin-left: 10px" + @click="showAllPolygon" + >������������������</a-button + > <a-button v-show="upa === ''" type="primary" @@ -223,7 +232,7 @@ RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length) ); - for (var k in o) + for (let k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace( RegExp.$1, @@ -240,7 +249,7 @@ enableMapClick: false, //������������������ }); // ������������������������������������ - var point = new BMapGL.Point(116.404, 39.915); + let point = new BMapGL.Point(116.404, 39.915); this.map.centerAndZoom("���������", 15); this.map.enableScrollWheelZoom(true); // ������������������������������������������������������s this.drawingManager = new BMapGLLib.DrawingManager(this.map, { @@ -308,7 +317,7 @@ private opRender(text: string, record: any, index: number) { return ( - <div style="width:180px"> + <div style="width:180px;text-align:left"> <a onClick={() => this.handleEditModalVisible(record)}> ������ </a> <a-divider type="vertical" /> <a onClick={() => this.handleEditbatch(record)}> ������������ </a> @@ -321,6 +330,12 @@ > <a href="#">������</a> </a-popconfirm> + <br></br> + <a onClick={() => this.canvasbatch(record)}> ������������������ </a> + <a-divider type="vertical" /> + <a onClick={() => this.handleEditCanves(record)}> ������������ </a> + <br></br> + <a onClick={() => this.handleShowPolygon(record)}> ������������ </a> </div> ); } @@ -337,27 +352,11 @@ private batchid: any = 0; private batchshow: boolean = false; private handleEditbatch(record: any) { - let ptsWithin = turf.pointsWithinPolygon(this.multiPt, this.turfPolygon); - console.log("ptsWithin", ptsWithin); - let data: { flylon: number; flylat: number }[] = []; - turf.coordEach(ptsWithin, (currentCoord) => { - data.push({ - flylon: currentCoord[0], - flylat: currentCoord[1], - }); - }); - console.log("data", data); this.check = false; this.startstate = "batch"; - post("coordinateDetail/batch", { - coordinateId: record.coordinateId, - list: data, - mac: this.carvalue, - }).then((res) => { - console.log(res); - this.$message.success(res.data.message); - // this.selectCar() - }); + this.batchshow = true; + // this.selectCar(); + this.batchid = record.coordinateId; } private handlebatch() { // this.selectCar() @@ -372,6 +371,9 @@ console.log("this.starttime", this.starttime); console.log("this.starttime", this.endtime); post("coordinateDetail/batch", { + type: "0", + time1: this.starttime, + time2: this.endtime, coordinateId: this.batchid, mac: this.carvalue, }).then((res) => { @@ -379,6 +381,78 @@ this.$message.success(res.data.message); this.starttime = ""; this.endtime = ""; + // this.selectCar() + }); + } + // ������������������ + showAllPolygon() { + let macType = null; + if (this.carvalue !== "������������������") { + macType = this.carvalue; + } + get("coordinate/selectCruiserRoad", { + name: "", + mac: macType, + }).then((res) => { + res.data.data.forEach((item: any) => { + if (item.bdValues) { + let pointList = item.bdValues.map((item: any) => { + return new BMapGL.Point(item.lng, item.lat); + }); + let polygon = new BMapGL.Polygon([...pointList]); + console.log("polygon", polygon); + this.map.addOverlay(polygon); + } + }); + }); + } + // ������������ + handleShowPolygon(record: any) { + console.log(record); + if (record.bdValues) { + let pointList = record.bdValues.map((item: any) => { + return new BMapGL.Point(item.lng, item.lat); + }); + let polygon = new BMapGL.Polygon([...pointList]); + console.log("polygon", polygon); + this.map.addOverlay(polygon); + } + } + // ������������ + private handleEditCanves(record: any) { + console.log("this.turfPolygon", this.turfPolygon); + if (this.roadbaiduPolygon.length > 0) { + post("coordinate/updateCruiserRoad", { + coordinateId: record.coordinateId, + bdValue: this.roadbaiduPolygon, + value: this.road84Polygon, + }).then((res) => { + this.$message.success("������������"); + this.selectLu(); + }); + } else { + this.$message.warning("���������������"); + } + } + private canvasbatch(record: any) { + let ptsWithin = turf.pointsWithinPolygon(this.multiPt, this.turfPolygon); + let data: { flylon: number; flylat: number }[] = []; + turf.coordEach(ptsWithin, (currentCoord) => { + data.push({ + flylon: currentCoord[0], + flylat: currentCoord[1], + }); + }); + this.check = false; + this.startstate = "batch"; + post("coordinateDetail/batch", { + type: "1", + coordinateId: record.coordinateId, + list: data, + mac: this.carvalue, + }).then((res) => { + console.log(res); + this.$message.success(res.data.message); // this.selectCar() }); } @@ -491,7 +565,20 @@ // console.log(this.carDate,'this.carDate'); this.carDate = []; this.pointshow = false; + this.map.removeOverlay(); this.setMarker(res); + }); + } + reosurce() { + console.log("this.timevalue", this.timevalue); + post("coordinateDetail/queryAll", { + mac: this.carvalue, + time1: this.timevalue[0], + time2: this.timevalue[1], + }).then((res) => { + console.log(res.data.data, "res"); + this.$message.success("������������"); + // console.log(this.carDate,'this.carDate'); }); } private markerdata: any = []; @@ -522,9 +609,20 @@ }; private actNav: String = ""; private clearPolygon() { + //������������overlays + let overlays = this.map.getOverlays(); this.drawingManager.clearOverlays(); + //���������Marker������������Label������ + overlays.forEach((overlay: any) => { + if (overlay.toString() === "Polygon") { + this.map.removeOverlay(overlay); + } + }); + // this.map.clearOverlays(); } private turfPolygon: any = null; + private roadbaiduPolygon: any = []; + private road84Polygon: any = []; private draw(drawingType: String) { console.log("new BMapGLLib", this.drawingManager); this.actNav = drawingType; @@ -544,13 +642,15 @@ const polygon = e.overlay; // ��������������������������� const polygonPoints = polygon.getPath(); - console.log("polygonPoints1", polygonPoints); + this.roadbaiduPolygon = polygonPoints; let transformationPoints = polygonPoints.map((coord: any) => { const [x, y] = [coord.lng, coord.lat]; const [lng1, lat1] = coordtransform.bd09togcj02(x, y); const [lng2, lat2] = coordtransform.gcj02towgs84(lng1, lat1); return { lng: lng2, lat: lat2 }; }); + + this.road84Polygon = transformationPoints; console.log("polygonPoints2", transformationPoints); this.turfPolygon = turf.polygon([ transformationPoints.map((item: any) => [item.lng, item.lat]), @@ -564,12 +664,12 @@ that.carDataList = []; let pointSlint = []; - for (var i = 0; i < res.data.data.rsData.length; i++) { + for (let i = 0; i < res.data.data.rsData.length; i++) { that.carDate.push(res.data.data.rsData[i]); pointSlint.push(res.data.data.rsData[i].data.split("_").map(Number)); } this.multiPt = turf.points([...pointSlint]); - for (var i = 0; i < res.data.data.data.length; i++) { + for (let i = 0; i < res.data.data.data.length; i++) { that.carDataList.push(res.data.data.data[i]); } that.map.clearOverlays(); @@ -578,17 +678,17 @@ if (res.status === 200) { for (let i = 0; i < that.carDate.length; i++) { //������������point - var myIcon = new BMapGL.Icon( + let myIcon = new BMapGL.Icon( require("@/assets/723cd95f31481a502d495b2d814d658.png"), new BMapGL.Size(50, 50), {} ); - var startIcon = new BMapGL.Icon( + let startIcon = new BMapGL.Icon( require("@/assets/start.png"), new BMapGL.Size(50, 50), {} ); - var endIcon = new BMapGL.Icon( + let endIcon = new BMapGL.Icon( require("@/assets/end.png"), new BMapGL.Size(50, 50), {} @@ -599,28 +699,34 @@ ); bPoints.push(statePoint); if (i === 0) { - that.marker[i] = new BMapGL.Marker(statePoint, { icon: startIcon }); + that.marker[i] = new BMapGL.Marker(statePoint, { + icon: startIcon, + }); that.marker[i].customData = { data: that.carDate[i].data, state: that.carDate[i].state, }; that.marker[i].iconPng = "startIcon"; } else if (i === that.carDate.length - 1) { - that.marker[i] = new BMapGL.Marker(statePoint, { icon: endIcon }); + that.marker[i] = new BMapGL.Marker(statePoint, { + icon: endIcon, + }); that.marker[i].customData = { data: that.carDate[i].data, state: that.carDate[i].state, }; that.marker[i].iconPng = "endIcon"; } else { - that.marker[i] = new BMapGL.Marker(statePoint, { icon: myIcon }); + that.marker[i] = new BMapGL.Marker(statePoint, { + icon: myIcon, + }); that.marker[i].customData = { data: that.carDate[i].data, state: that.carDate[i].state, }; that.marker[i].iconPng = "myIcon"; } - var infoWindow = ""; + let infoWindow = ""; //that.marker[i].name = that.carDate[i].time; that.marker[i].on("mouseover", function(e) { infoWindow = new BMapGL.InfoWindow( @@ -693,7 +799,7 @@ for (let i = 0; i < that.carDataList.length; i++) { // console.log(that.carDataList[i],'that.carDataList[i]'); //������������point - var myIcon = new BMapGL.Icon( + let myIcon = new BMapGL.Icon( require("@/assets/fb259ce2e368f6853a58b91d6f6b293.png"), new BMapGL.Size(50, 50) ); @@ -704,7 +810,9 @@ // console.log(statePoint,'statePoint'); aPoints.push(statePoint); //���marker���������data��������� ������������������ - that.markerdata[i] = new BMapGL.Marker(statePoint, { icon: myIcon }); + that.markerdata[i] = new BMapGL.Marker(statePoint, { + icon: myIcon, + }); that.markerdata[i].customData = { data: that.carDataList[i].code, state: that.carDataList[i].state, @@ -767,14 +875,14 @@ } private setZoom(bPoints: any) { - var view = this.map.getViewport(eval(bPoints)); - var mapZoom = view.zoom; - var centerPoint = view.center; + let view = this.map.getViewport(eval(bPoints)); + let mapZoom = view.zoom; + let centerPoint = view.center; this.map.centerAndZoom(centerPoint, mapZoom); } private selectLuName: any = null; private selectLu() { - var macType = null; + let macType = null; if (this.carvalue !== "������������������") { macType = this.carvalue; } -- Gitblit v1.8.0