Commit 38a5c420 by zhangxw
2 parents ffbe18c8 01990e91
......@@ -23,7 +23,7 @@
<div class="ibox-content scrollbar" style="padding: 30px 20px;">
<el-form ref="fenceForm" :model="form" :rules="rules" :inline="false" size="mini" label-width="100px" class="fence_form" align="left">
<el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" placeholder="请输入围栏名称" maxlength="200" show-word-limit :disabled="readonlyStatus"></el-input>
<el-input v-model.trim="form.fenceName" placeholder="请输入围栏名称" minlength="2" maxlength="200" show-word-limit :disabled="readonlyStatus"></el-input>
</el-form-item>
<el-form-item label="监控类型" prop="triggerType">
<el-select v-model="form.triggerType" placeholder="请选择" size="small">
......@@ -101,7 +101,7 @@
<div class="links_group">
<div>已关联{{tableData.length}}个设备</div>
<div>
<el-button v-if="!readonlyStatus" type="primary" @click="userDate" size="small" :loading="submitting">关联用户</el-button>
<el-button v-if="!readonlyStatus" type="primary" @click="userDate" size="small" :loading="submitting">关联设备</el-button>
<el-button size="small" :disabled="!selectedIds || selectedIds.length<=0" @click="batchRemove">批量删除</el-button>
</div>
</div>
......@@ -286,7 +286,7 @@ export default {
rules: {
fenceName: [
{ required: true, message: "请输入围栏名称", trigger: "blur" },
{ pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
{ min:2,max:200, message: "至少2字", trigger: "blur" },
// {validator: checkFenceName, trigger: 'blur'}
],
triggerType: [
......@@ -523,6 +523,7 @@ export default {
if (form.shapeType == 1) {
oParams.radius = form.radius;
oParams.lnglat = `${form.lng},${form.lat}`;
oParams.analysisAddress = form.analysisAddress
}
// 多边形围栏
......@@ -687,6 +688,9 @@ export default {
obj.lng = lnglat[0];
obj.lat = lnglat[1];
}
if(obj.areaCode){
obj.areaCode = [obj.areaCode]
}
_this.form = obj;
mapData.fenceType = _typeList[obj.shapeType];
......
......@@ -38,7 +38,10 @@
<div class="radio_cell">
<el-radio :label="1" v-model="form.shapeType">圆形</el-radio>
<el-form-item label="" prop="radius">
<el-input v-model.trim="form.radius" style="width: 80px;" maxlength="200" @change="changeRadius"></el-input>米
<el-input v-model.trim="form.radius" style="width:120px" maxlength="200">
<template slot="append">米</template>
</el-input>
<el-button type="primary" class="btn" :disabled="!form.radius" @click="changeRadius">更新</el-button>
</el-form-item>
</div>
<div class="radio_cell">
......@@ -217,14 +220,14 @@ export default {
mounted() {
//store.dispatch("setFullsize", true);
},
// watch: {
// "form.shapeType": {
// handler: function (n, o) {
// this.changeShapeType(n);
// },
// immediate: true,
// },
// },
watch: {
"form.shapeType": {
handler: function (n, o) {
this.changeShapeType(n);
},
immediate: true,
},
},
methods: {
// 初始化地图
initMap() {
......@@ -428,7 +431,7 @@ export default {
// 多边形围栏
if (o.shapeType == 3) {
oParams.lnglat = this.polygonPath;
oParams.lnglat = this.polygonPath.join("|");
}
// 行政区域围栏
......@@ -457,20 +460,16 @@ export default {
},
// 监听圆形半径更改
changeRadius(e) {
changeRadius() {
let reg = /^\d+$/;
let e = this.form.radius;
if (!reg.test(e) || e > 10000) {
showToast({
message: "请输入1-10000间的整数",
});
return false;
}
this.$refs.fenceMap.updateFence({
fenceType: "circle",
lng: this.form.lng,
lat: this.form.lat,
radius: this.form.radius,
});
EventBus.$emit("uiMap.fence.updateFenceRadius", { fenceType:'circle',radius: e });
},
},
};
......
......@@ -300,6 +300,7 @@ export default {
}
}, 100);
},
// 更新围栏信息
updateFence(data) {
let _this = this;
let mapInterval = setInterval(function () {
......
......@@ -186,6 +186,7 @@ import { CONSTANT } from "@/constant";
import MapControll from "./MapControll.vue";
import { exportExcel } from "@/utils";
import { GET_MONITOR_ONLINELIST } from "@/api/services/monitor";
import AMapLoader from "@amap/amap-jsapi-loader";
export default {
data() {
let checkFilename = (rule, vaule, cb) => {
......@@ -639,12 +640,9 @@ export default {
}
};
},
// 搜索车架号、设备号、工单号
searchSubmit() {
/* this.addMonitor({
sn: '75108160001'
})
return */
//if(!this.searchText) return;
switch (this.searchType) {
case "1":
case "2":
......@@ -704,6 +702,8 @@ export default {
}
}); */
},
// 根据搜索条件查询组织树结构
querySearch() {
let _this = this;
//this.autocompleteHide = true
......@@ -718,22 +718,14 @@ export default {
if (!list || list.length <= 0) {
return false;
}
for (var i = 0, len = list.length; i < len; i++) {
_this.handleSelect(list[i]);
}
//cb(res.data)
// if(!res.data.length) {
// cb([{
// tip: '无数据'
// }])
// }
//this.autocompleteHide = false
});
}
},
// 查询树node
// 查询树node层级
handleSelect(item) {
if (!item.tip) {
MONITOR_SERVICE.getVehicleTree({
......@@ -750,11 +742,15 @@ export default {
// 展开树节点
expandTreeItems(arr, isDevice) {
let _this = this;
arr.forEach((item) => {
if (isDevice) {
this.$refs.tree.setCheckedKeys(
this.$refs.tree.getCheckedKeys().concat(item.id)
);
console.log(item.id)
let keys = _this.$refs.tree.getCheckedKeys()
console.log('keys',keys)
//_this.$refs.tree.setCheckedKeys(keys);
_this.checkedKeys.push(item.id);
console.log(_this.checkedKeys)
this.addMonitor({
sn: item.label,
name: item.label1,
......@@ -1211,17 +1207,17 @@ export default {
},
},
created() {
if (window.AMap) {
this.initMap();
} else {
remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => {
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
() => {
this.initMap();
}
);
});
}
// if (window.AMap) {
// this.initMap();
// } else {
// remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => {
// remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
// () => {
// this.initMap();
// }
// );
// });
// }
this.keyupSubmit();
EventBus.$on("uiMap.monitor.drawDone", this.drawDoneCb);
EventBus.$on("uiMap.monitor.changeELocate", this.changeELocate);
......@@ -1229,6 +1225,17 @@ export default {
this.getTreeData();
},
mounted(){
let _this = this;
AMapLoader.load({
key: CONSTANT.MAP_KEY,
version: "1.4.2",
plugins: CONSTANT.MAP_PLUGINS,
}).then((AMap) => {
window.AMap = AMap;
_this.initMap();
});
},
beforeDestroy() {
document.onkeydown = null;
EventBus.$emit("uiMap.monitor.destroy");
......
<template>
<v-full-layout>
<v-full-layout class="full_wrap_layout">
<template slot="breadcrumb">
<el-breadcrumb-item>车辆监控</el-breadcrumb-item>
</template>
......
......@@ -22,9 +22,10 @@ const fence = {
});
EventBus.$on('uiMap.fence.updateFenceRadius', (data) => {
this.circle.setRadius(data * 1);
mapService.setFitView()
console.log('监听围栏更新',data)
this.updateFenceInfo(data)
});
//this.circle.setRadius(data * 1);
EventBus.$on('uiMap.fence.createFenceMarker', (data) => {
this.createFenceMarker(data)
......@@ -122,42 +123,57 @@ const fence = {
});
},
createFenceCircle(data) {
let _this = this
const MAP = mapService.map;
this.destroy();
this.circle = new AMap.Circle({
map: MAP,
center: mapService.getLngLat(data.lng, data.lat),
radius: data.radius * 1,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
zIndex: 0,
});
this.circleEditor = new AMap.CircleEditor(MAP, this.circle);
this.circleEditor.on('adjust', function (e) {
//log.info('触发事件:adjust')
EventBus.$emit('uiMap.fence.onFenceRadiusChange', e.radius / 1)
})
this.circleEditor.on('move', function (e) {
EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng: e.lnglat.lng,
lat: e.lnglat.lat
});
})
if (this.isEditMode) {
this.circleEditor.open();
} else {
this.circleEditor.close();
}
_this.destroy();
let mapInterval = setInterval(() => {
if (MAP) {
clearInterval(mapInterval)
console.log(data)
let lng = data.lng || _this.lng
let lat = data.lat || _this.lat
if (data.lng) {
_this.lng = data.lng
}
if (data.lat) {
_this.lat = data.lat
}
_this.circle = new AMap.Circle({
map: MAP,
center: mapService.getLngLat(lng, lat),
radius: data.radius * 1,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
zIndex: 0,
});
_this.circleEditor = new AMap.CircleEditor(MAP, _this.circle);
_this.circleEditor.on('adjust', function (e) {
console.log('监听圆心改变', e)
EventBus.$emit('uiMap.fence.onFenceRadiusChange', e.radius / 1)
})
_this.circleEditor.on('move', function (e) {
EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng: e.lnglat.lng,
lat: e.lnglat.lat
});
})
if (_this.isEditMode) {
_this.circleEditor.open();
} else {
_this.circleEditor.close();
}
mapService.setFitView()
MAP.setZoom(14);
_this.bindContextMenu()
}
}, 100);
mapService.setFitView()
MAP.setZoom(14);
},
createFenceMarker(data) {
......@@ -279,6 +295,94 @@ const fence = {
item && window.clearTimeout(item);
});
this.timeoutIds = []
},
// 地图增加右键功能
bindContextMenu() {
const self = this;
const MAP = mapService.map;
var contextMenu = new AMap.ContextMenu();
contextMenu.addItem(
"设置围栏中心",
function () {
self.moveCenter();
},
0
);
//地图绑定鼠标右击事件——弹出右键菜单
MAP.on("rightclick", function (e) {
contextMenu.open(MAP, e.lnglat);
self.contextMenuPositon = e.lnglat;
});
},
// 改变圆心
moveCenter() {
this.lng = this.contextMenuPositon.lng;
this.lat = this.contextMenuPositon.lat;
let center = mapService.getLngLat(this.lng, this.lat);
this.circle.setCenter(center);
EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng: this.lng,
lat: this.lat,
});
},
// 更新围栏
updateFenceInfo(data) {
let _this = this;
const MAP = mapService.map;
let mapInterval = setInterval(function () {
if (MAP) {
clearInterval(mapInterval);
MAP.clearMap();
_this.fenceType = data.fenceType;
_this.polyEditor && _this.polyEditor.close();
_this.mouseTool && _this.mouseTool.close();
// 更新圆形围栏
if (data.fenceType == 'circle') {
_this.fenceCircle = null;
if (data.lng) {
_this.lng = data.lng;
}
if (data.lat) {
_this.lat = data.lat;
}
if (data.radius) {
_this.radius = Number(data.radius);
}
console.log(data)
_this.createFenceCircle(data);
return false;
}
// 更新行政区域围栏
if (data.fenceType === "area") {
_this.areaCode = data.areaCode;
_this.drawDistrict(data);
return false
}
// 更新多边形围栏
if (data.fenceType === "polygon") {
if (data) {
if (Array.isArray(data)) {
this.polygonPath = data;
this.isEditMode = true;
} else if (('isEdit' in data) && !data.isEdit) {
this.polygonPath = data.path;
this.isEditMode = false;
}
}
_this.drawPolygon();
}
mapService.setFitView()
MAP.setZoom(14);
}
}, 100);
}
}
......
......@@ -60,7 +60,7 @@ export const Util = {
Message({
message: options.message || '提示',
type: options.type || 'error',
duration: options.time || 2000,
duration: options.duration||options.time || 2000,
onClose: options.onClose || '',
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!