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