Compare commits

..

3 Commits

@ -1,17 +1,14 @@
<template> <template>
<el-dialog title="电子围栏" :close-on-click-modal="false" :visible="true" top="10vh" width="90%" append-to-body <el-dialog :title="title" :close-on-click-modal="false" :visible="true" top="10vh" width="90%" append-to-body
modal-append-to-body :before-close="handleClose" class="my-dialog"> modal-append-to-body :before-close="handleClose" class="my-dialog">
<div class="cont"> <div class="cont">
<div class="tips"> <div class="tips">
<p>1绘制鼠标左键点击及移动即可绘制图形; &nbsp;&nbsp; 2结束绘制鼠标左键双击即可结束绘制折线多边形会自动闭合圆形矩形椭圆单击即可结束;&nbsp;&nbsp; <p>1绘制鼠标左键点击及移动即可绘制图形; &nbsp;&nbsp; 2结束绘制鼠标左键双击即可结束绘制折线多边形会自动闭合圆形矩形椭圆单击即可结束</p>
3中断绘制过程中按下esc键可中断该过程</p>
</div> </div>
<div class="addpolygon"> <div class="addpolygon">
<div id="mapFencecontainer"> <div id="mapFencecontainer">
<div class="mapBtn"> <div class="mapBtn">
<el-button size="small" type="danger" @click="clearOverlays()"></el-button>
<el-button size="small" type="primary" @click="sendLngLat"></el-button> <el-button size="small" type="primary" @click="sendLngLat"></el-button>
<el-button size="small" type="primary" @click="sendMsg"></el-button>
</div> </div>
</div> </div>
<div class="loadMap" v-if="loadMapFlag">...</div> <div class="loadMap" v-if="loadMapFlag">...</div>
@ -22,15 +19,14 @@
</template> </template>
<script> <script>
let marker, polygon, drawingManager, lngLat,ap, map; let marker, polygon, drawingManager, lngLat,ap, map, MultiPolygon;
let path = [];// let path = [];//
import axios from 'axios' import axios from 'axios'
// let map, marker, polygon, drawingManager, lngLat; // // let map, marker, polygon, drawingManager, lngLat; //
let overlaysArray = []; // , let overlaysArray = []; // ,
let path4 = [];//
// //
export default { export default {
props: ['position', 'areaMapInfo'], props: ['position', 'areaMapInfo', 'mode'],
data() { data() {
return { return {
longitude: '', longitude: '',
@ -48,9 +44,16 @@ export default {
} }
], ],
editor: null, editor: null,
loadMapFlag: true loadMapFlag: true,
targetAreaPath: []
}; };
}, },
computed: {
title() {
const str = this.mode == 'add' ? '新建电子围栏' : '编辑电子围栏'
return str
}
},
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
// this.init(); // this.init();
@ -62,19 +65,16 @@ export default {
this.$emit('areaVisibleChange', false) this.$emit('areaVisibleChange', false)
}, },
clearOverlays() { clearOverlays() {
polyline.setMap(null); polygon.setMap(null);
}, },
sendLngLat() { sendLngLat() {
this.$emit('areaVisibleChange', false, this.targetAreaPath)
},
sendMsg() {
}, },
/** /**
* // * //
*/ */
getMyLocation() { getMyLocation() {
var geolocation = new qq.maps.Geolocation('U24BZ-7UECT-ZSNXI-L3GJD-GZD3E-3YFF6', '易回收后台'); const geolocation = new qq.maps.Geolocation('U24BZ-7UECT-ZSNXI-L3GJD-GZD3E-3YFF6', '易回收后台');
geolocation.getLocation(this.showPosition, this.showErr); geolocation.getLocation(this.showPosition, this.showErr);
}, },
showPosition(position) { showPosition(position) {
@ -94,64 +94,38 @@ export default {
* 位置信息在地图上展示 * 位置信息在地图上展示
*/ */
setMapData() { setMapData() {
var myLatlng = new qq.maps.LatLng(this.position.latitude, this.position.longitude); const myLatlng = new qq.maps.LatLng(this.position.latitude, this.position.longitude);
console.log("当前位置:"+this.position.latitude, this.position.longitude, myLatlng) console.log("当前位置:"+this.position.latitude, this.position.longitude, myLatlng)
var myOptions = { const myOptions = {
zoom: 16, zoom: 16,
center: myLatlng, center: myLatlng,
mapTypeId: qq.maps.MapTypeId.ROADMAP mapTypeId: qq.maps.MapTypeId.ROADMAP
} }
console.log(myOptions)
//dom //dom
map = new qq.maps.Map(document.getElementById('mapFencecontainer'), myOptions) map = new qq.maps.Map(document.getElementById('mapFencecontainer'), myOptions)
// //
marker = new qq.maps.Marker({ marker = new qq.maps.Marker({
position: myLatlng, position: myLatlng,
map: map, map: map,
draggable: false
}) })
this.mouseClick()
/**绘制围栏 */
this.addpolygon();
// //
this.getAllPolygons() this.getAllPolygons()
}, },
/**
* 鼠标点击获取标记位置事件
*/
mouseClick () {
const _this = this
qq.maps.event.addListener(map, 'click', function (event) {
if(!marker) {
marker=new qq.maps.Marker({
position: event.latLng,
map:map
})
return
}
marker.setPosition(event.latLng)
console.log("鼠标点击位置:"+event.latLng)
_this.position.latitude = event.latLng.getLat();
_this.position.longitude = event.latLng.getLng();
_this.existsPolygon();
})
},
/**绘制围栏 */ /**绘制围栏 */
addpolygon() { addpolygon() {
const _this = this const _this = this
const drawingControl = this.mode == 'add' ? true : false
drawingManager = new window.qq.maps.drawing.DrawingManager({ drawingManager = new window.qq.maps.drawing.DrawingManager({
drawingMode: window.qq.maps.drawing.OverlayType.null, // drawingMode: window.qq.maps.drawing.OverlayType.null, //
drawingControl: true, drawingControl: drawingControl,
drawingControlOptions: { drawingControlOptions: {
position: window.qq.maps.ControlPosition.TOP_CENTER, position: window.qq.maps.ControlPosition.TOP_CENTER,
// //
drawingModes: [ drawingModes: [
// window.qq.maps.drawing.OverlayType.MARKER, // window.qq.maps.drawing.OverlayType.MARKER,
// window.qq.maps.drawing.OverlayType.CIRCLE, window.qq.maps.drawing.OverlayType.POLYGON,
window.qq.maps.drawing.OverlayType.POLYGON, ]
// window.qq.maps.drawing.OverlayType.POLYLINE,
window.qq.maps.drawing.OverlayType.RECTANGLE
]
}, },
markerOptions: { markerOptions: {
visible: false visible: false
@ -163,30 +137,39 @@ export default {
fillColor: new window.qq.maps.Color(202, 67, 58, 0.1), fillColor: new window.qq.maps.Color(202, 67, 58, 0.1),
clickable: false clickable: false
}, },
// //
// circleOptions: {
// fillColor: new window.qq.maps.Color(255, 208, 70, 0.3),
// strokeColor: new window.qq.maps.Color(88, 88, 88, 1),
// strokeWeight: 3,
// clickable: false
// }
}); });
drawingManager.setMap(map); drawingManager.setMap(map);
window.qq.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) { window.qq.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) {
console.log('overlaycomplete', event) console.log('overlaycomplete', event)
// clearOverlays(overlaysArray) // polygon.setMap(null);
lngLat = []; const lngLat = [];
// overlaysArray.push(event.overlay); for (const item of event.overlay.getPath().elems) {
// for (const item of event.overlay.getPath().elems) { const lng = item.getLng();
// const lng = item.getLng(); const lat = item.getLat();
// const lat = item.getLat(); lngLat.push({
// lngLat.push({ lat: lat,
// lat: lat, lng: lng
// lng: lng });
// }); }
// } console.log("绘图后获得的:",JSON.stringify(lngLat,null,4), polygon); //
console.log("绘图后获得的:"+JSON.stringify(lngLat,null,4)); // _this.showPolygons(lngLat, true)
}); });
//
window.qq.maps.event.addListener(polygon, 'adjustNode',function (event) {
console.log(99999, event)
const lngLat = [];
for (const item of event.path.elems) {
const lng = item.getLng();
const lat = item.getLat();
lngLat.push({
lat: lat,
lng: lng
});
}
this.targetAreaPath = lngLat
console.log("adjustNode后获得的"+JSON.stringify(lngLat,null,4)); //
})
}, },
/** /**
* 获取所有围栏 * 获取所有围栏
@ -250,7 +233,16 @@ export default {
] ]
} }
] ]
if (this.mode == 'add') {
_this.polygonPath = _this.polygonPath.filter(e => !e.editable)
}
_this.showArrayPolygon() _this.showArrayPolygon()
/**绘制围栏 */
this.addpolygon();
}, },
/**循环调用显示围栏方法 */ /**循环调用显示围栏方法 */
showArrayPolygon(){ showArrayPolygon(){
@ -263,6 +255,16 @@ export default {
_this.showpolygons(path, polygonpath.editable) _this.showpolygons(path, polygonpath.editable)
} }
}, },
showMultiPolygons(path, editable) {
const _this = this
MultiPolygon = new TMap.MultiPolygon({
map: map,
editable,
strokeColor: new qq.maps.Color(202, 67, 58, 0.8),
fillColor: new qq.maps.Color(202, 67, 58, 0.1)
});
MultiPolygon.setPath(path);
},
/** /**
* 显示围栏 * 显示围栏
*/ */
@ -275,31 +277,10 @@ export default {
fillColor: new qq.maps.Color(202, 67, 58, 0.1) fillColor: new qq.maps.Color(202, 67, 58, 0.1)
}); });
polygon.setPath(path); polygon.setPath(path);
}, // if (editable && this.mode == 'add') {
/** // polygon.setMap(map);
* 当前位置是否在围栏中 // }
*/ }
existsPolygon() {
const _this = this;
// console.log(":"+ _this.position.latitude,_this.position.longitude)
axios.post(url.url + "/v1/polygons/existPolygons", {
lng: _this.position.longitude, //getMyLocation obj.longitudeobj.latitude
lat: _this.position.latitude,
}).then(function (response) {
// response.datahttp or https
if(response.data.indexOf("http") == 0){
window.location.href = response.data;
} else {
_this.$notify({
title: '定位失败',
message: '经度: '+ _this.position.longitude + ", 纬度:" + _this.position.latitude + "" + "信息:" + response.data,
type: 'success'
})
}
}).catch(function (error) {
console.error(error);
});
},
} }
}; };
</script> </script>

@ -101,7 +101,7 @@
<!-- 表单结束 --> <!-- 表单结束 -->
</template> </template>
</el-form> </el-form>
<area-dialog :position="position" :areaMapInfo="dataForm.areaMapInfo" v-if="areaVisible" @areaVisibleChange="handleAreaVisibleChange" /> <area-dialog :mode="mode" :position="position" :areaMapInfo="dataForm.areaMapInfo" v-if="areaVisible" @areaVisibleChange="handleAreaVisibleChange" />
<!-- <SelectDialog v-if="selectDialogVisible" :config="currTableConf" :formData="dataForm" <!-- <SelectDialog v-if="selectDialogVisible" :config="currTableConf" :formData="dataForm"
ref="selectDialog" @select="addForSelect" @close="selectDialogVisible=false"/> --> ref="selectDialog" @select="addForSelect" @close="selectDialogVisible=false"/> -->
</el-row> </el-row>
@ -122,7 +122,7 @@
import { thousandsFormat } from "@/components/Generator/utils/index" import { thousandsFormat } from "@/components/Generator/utils/index"
export default { export default {
components: { areaDialog }, components: { areaDialog },
props: [], props: ['mode'],
data() { data() {
return { return {
position: {}, position: {},
@ -258,8 +258,11 @@
this.areaVisible = true this.areaVisible = true
// this.getPosition() // this.getPosition()
}, },
handleAreaVisibleChange(areaVisible) { handleAreaVisibleChange(areaVisible, targetAreaPath) {
this.areaVisible = areaVisible this.areaVisible = areaVisible
if (targetAreaPath) {
this.dataForm.areaMapInfo = targetAreaPath
}
}, },
prev() { prev() {
this.index-- this.index--

@ -142,7 +142,7 @@
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData"/> <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData"/>
</div> </div>
</div> </div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh"/> <JNPF-Form :mode="mode" v-if="formVisible" ref="JNPFForm" @refresh="refresh"/>
<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download"/> <ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download"/>
@ -222,6 +222,7 @@
sidx: "", sidx: "",
}, },
formVisible: false, formVisible: false,
mode: '',
flowVisible: false, flowVisible: false,
flowListVisible: false, flowListVisible: false,
flowList: [], flowList: [],
@ -485,6 +486,8 @@
this.initData() this.initData()
}, },
addOrUpdateHandle(row, isDetail) { addOrUpdateHandle(row, isDetail) {
const mode = row ? 'edit' : 'add'
this.mode = mode
let id = row?row.id:"" let id = row?row.id:""
this.formVisible = true this.formVisible = true
this.$nextTick(() => { this.$nextTick(() => {

@ -9,7 +9,6 @@ function resolve(dir) {
} }
const name = defaultSettings.title || '易回收' // page title const name = defaultSettings.title || '易回收' // page title
// If your port is set to 80, // If your port is set to 80,
// use administrator privileges to execute the command line. // use administrator privileges to execute the command line.
// For example, Mac: sudo npm run // For example, Mac: sudo npm run

Loading…
Cancel
Save