Commit 6f07b14d by 前端

修复bug

1 parent dd69f937
......@@ -298,4 +298,7 @@
height: 16px;
margin-left:4px;
}
}
.draw_area{
margin-top:10px;
}
\ No newline at end of file
......@@ -7,11 +7,11 @@
class="map-container"
v-loading="mapLoading"
></div>
<div class="row_box_hide" v-if="hideRowBox" @click="onShow">
<div class="row_box_hide" v-show="hideRowBox" @click="onShow">
<glsx-image src="car.png" class="img img_normal" />
<glsx-image src="car_hover.png" class="img img_hover" />
</div>
<div class="row_box" v-else>
<div class="row_box" v-show="!hideRowBox">
<div class="hide_icon" @click="onShow">
<glsx-image src="hide.png" class="img" />
</div>
......@@ -30,8 +30,10 @@
<el-form
ref="form"
:model="form"
:rules="formRules"
class="el_form"
label-position="top"
hide-required-asterisk
>
<div v-show="menuId == 1">
<el-form-item label="详细地址">
......@@ -44,7 +46,7 @@
</el-form-item>
</div>
<div v-show="menuId == 2">
<el-form-item label="设备号">
<el-form-item label="设备号" prop="sn">
<div class="device_label" slot="label">
<span>设备号</span>
<!-- <el-tooltip
......@@ -71,14 +73,18 @@
maxlength="50"
placeholder="请输入您要查询的设备号"
/>
<el-button type="primary" class="btn" @click="getLocation"
<el-button
type="primary"
class="btn"
:disabled="!form.sn"
@click="getLocation"
>搜索</el-button
>
</div>
</el-form-item>
</div>
<el-form-item label="">
<div>
<div class="draw_area">
<el-button class="area_btn" @click="chooseArea"
>划定区域</el-button
>
......@@ -120,10 +126,7 @@
<span>已查询到设备共计</span>
<span class="cred">{{ deviceList.length }}</span>
<span>条</span>
<el-button
class="btn"
:loading="dloading"
@click="downloadExcel"
<el-button class="btn" :loading="dloading" @click="downloadExcel"
>导出</el-button
>
</div>
......@@ -155,20 +158,15 @@ import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js";
import AMapLoader from "@amap/amap-jsapi-loader";
import { CONSTANT } from "@/constant";
import CitySelect from "@/components/area";
import {
GER_REGIONAL_SEARCH,
GER_REGIONAL_EXPORT,
GER_REGIONAL_LOCATION
GER_REGIONAL_LOCATION,
} from "@/api/services/zooneCar";
// import { GET_DEVICEINFO_BYSNS } from "@/api/services/monitor";
import EventBus from "@/event-bus";
import { showToast, deepClone } from "@/utils/utils.js";
import { Validator } from "@/common/validator";
import { Validator,CHECK_NUMBER } from "@/common/validator";
export default {
components: {
CitySelect,
},
data() {
return {
menus: [
......@@ -179,6 +177,12 @@ export default {
map: null,
mapLoading: true,
form: {},
formRules: {
sn: [
{ required: true, message: "请输入设备号", trigger: "blur" },
{ validator: CHECK_NUMBER, trigger: "blur" },
],
},
rectangle: null,
rectangleEditor: null,
rectangleWidth: 0, // 矩形宽度
......@@ -207,6 +211,8 @@ export default {
drawDone: false,
location: {}, // 设备维度查询的位置点
autoCenterMarker: null,
mouseTool: null,
mapMass:null
};
},
mounted() {
......@@ -222,6 +228,8 @@ export default {
"AMap.LabelsLayer",
"AMap.LabelMarker",
"AMap.AutoComplete",
"AMap.MassMarks",
"AMap.MarkerCluster",
]);
if (window.AMap) {
window.AMap = null;
......@@ -251,7 +259,7 @@ export default {
})
.catch((error) => {
console.log(error);
window.location.reload();
//window.location.reload();
});
},
......@@ -266,6 +274,11 @@ export default {
});
return false;
}
if (_this.mouseTool) {
return false;
}
console.log(_zoom);
if (_zoom < 13) {
_this.map.setZoom(13);
......@@ -287,6 +300,7 @@ export default {
_this.rectangle = rectangle;
_this.calculateWidthHeight(rectangle.getOptions().bounds);
});
_this.mouseTool = mouseTool;
},
// 计算矩形宽度、高度
......@@ -332,6 +346,7 @@ export default {
this.rectangleWidth = 0;
this.form = {};
this.deviceList = [];
this.mouseTool = null;
},
// 展开
......@@ -409,7 +424,7 @@ export default {
});
return false;
}
this.dloading = true;
let res = await GER_REGIONAL_EXPORT(params);
this.dloading = false;
......@@ -437,48 +452,58 @@ export default {
// 切换类型
menuEvent(row) {
this.menuId = row.id;
this.$refs.form.clearValidate('sn')
},
// 设备号查车
async getLocation() {
getLocation() {
let _this = this;
let params = {};
this.clearMap();
if (!Validator.ISDECIMAL.test(this.form.sn)) {
showToast({
message: "设备号必须为纯数字",
});
return false;
}
params.sns = this.form.sn;
params.deviceCode = "gps";
let res = await GER_REGIONAL_LOCATION(params);
let list = res.data || [];
if (list.length <= 0) {
showToast({
message: "暂无车辆",
this.$refs.form.validate((valid) => {
if (!valid) {
return false;
}
GER_REGIONAL_LOCATION(params).then((res) => {
let list = res.data || [];
if (list.length <= 0) {
showToast({
message: "暂无车辆",
});
return false;
}
let arr = [];
list.forEach((item) => {
let o = deepClone(item || {});
let m = o.gpsLocation || {};
o.lng = m.elng;
o.lat = m.elat;
o.address = m.address;
o.type = 2;
o.time = m.dateTime;
o.standNo = item.standNo || item.vin;
o.isSource = item.source;
arr.push(o);
_this.location = o;
});
_this.addMarkers(arr);
});
return false;
}
let arr = [];
list.forEach((item) => {
let o = deepClone(item || {});
let m = o.gpsLocation || {};
o.lng = m.elng;
o.lat = m.elat;
o.address = m.address;
o.type = 2;
o.time = m.dateTime;
o.standNo = item.standNo || item.vin;
o.isSource = item.source;
arr.push(o);
// this.autoOpenLastInfoWindow = true;
// if (this.autoOpenLastInfoWindow) {
// this.autoOpenLastInfoWindow = false;
// }
//this.addLocation(o, this.autoOpenLastInfoWindow);
this.location = o;
});
this.addMarkers(arr);
// if (!this.form.sn) {
// showToast({
// message: "请输入设备号",
// });
// return false;
// }
// if (!Validator.ISDECIMAL.test(this.form.sn)) {
// showToast({
// message: "设备号必须为纯数字",
// });
// return false;
// }
},
// 区域查车
......@@ -494,6 +519,10 @@ export default {
}
_this.deviceList = [];
if(_this.mapMass){
_this.mapMass.clear()
_this.mapMass = null;
}
_this.loading = true;
let res = await GER_REGIONAL_SEARCH(params);
......@@ -515,49 +544,115 @@ export default {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
},
// 添加海量点
// 添加海量点 聚合点方式
// addMarkers3(arr) {
// let _this = this;
// let markers = [];
// let icon = {
// url: require("images/icon_car.png"),
// size: new AMap.Size(24, 15),
// offset: new AMap.Pixel(4, 4),
// };
// let renderMarker = function (context) {
// console.log(context.data);
// var content = '<div style="background-color: hsla(180, 100%, 50%, 0.3); height: 18px; width: 18px; border: 1px solid hsl(180, 100%, 40%); border-radius: 12px; box-shadow: hsl(180, 100%, 50%) 0px 0px 3px;"></div>';
// //context.marker.setIcon(require("images/icon_car.png"))
// context.marker.setContent(content)
// context.marker.setSize(24,15);
// // let m = new AMap.Marker({
// // icon: require("images/icon_car.png"),
// // position: context.data[0].lnglat,
// // });
// };
// for (let i = 0, len = arr.length; i < len; i++) {
// let k = arr[i];
// k.lnglat = [k.lng, k.lat];
// markers.push(k);
// }
// let params = {
// gridSize: 60,
// renderMarker: renderMarker,
// };
// let cluster = new AMap.MarkerCluster(_this.map, markers, params);
// },
// 添加海量点 (MassMarks方式)
addMarkers(arr) {
console.log(arr);
let _this = this;
let markers = [];
let icon = {
type: "image",
image: require("images/icon_car.png"),
url: require("images/icon_car.png"),
size: [24, 15],
anchor: "bottom-center",
anchor: new AMap.Pixel(4, 4),
};
this.drawDone = false;
var layer = new AMap.LabelsLayer({
zooms: [0, 20],
zIndex: 1000,
collision: false,
});
this.map.add(layer);
for (let i = 0, len = arr.length; i < len; i++) {
let k = arr[i];
let curData = {
position: [k.lng, k.lat],
icon,
extData: k,
};
let labelMarker = new AMap.LabelMarker(curData);
labelMarker.on("click", function (e) {
console.log(labelMarker.getExtData());
let _position = labelMarker.getExtData();
let infoWindow = mapService.createAraeInfowindow(_position);
infoWindow.open(_this.map);
});
markers.push(labelMarker);
k.lnglat = [k.lng, k.lat];
markers.push(k);
}
layer.add(markers);
console.log("画点结束", new Date().getTime());
var mass = new AMap.MassMarks(markers, {
opacity: 0.8,
zIndex: 111,
cursor: "pointer",
style: icon,
alwaysRender: false,
});
mass.on("click", function (e) {
console.log(e);
let infoWindow = mapService.createAraeInfowindow(e.data);
infoWindow.open(_this.map);
});
mass.setMap(_this.map);
this.drawDone = true;
this.map.setFitView();
this.mapMass = mass;
},
// 添加海量点 标记点方式
// addMarkers2(arr) {
// console.log(arr);
// let _this = this;
// let markers = [];
// let icon = {
// type: "image",
// image: require("images/icon_car.png"),
// size: [24, 15],
// anchor: "bottom-center",
// };
// this.drawDone = false;
// var layer = new AMap.LabelsLayer({
// zooms: [13, 20],
// zIndex: 1000,
// collision: true,
// });
// this.map.add(layer);
// for (let i = 0, len = arr.length; i < len; i++) {
// let k = arr[i];
// let curData = {
// position: [k.lng, k.lat],
// icon,
// extData: k,
// };
// let labelMarker = new AMap.LabelMarker(curData);
// labelMarker.on("click", function (e) {
// console.log(labelMarker.getExtData());
// let _position = labelMarker.getExtData();
// let infoWindow = mapService.createAraeInfowindow(_position);
// infoWindow.open(_this.map);
// });
// markers.push(labelMarker);
// }
// layer.add(markers);
// console.log("画点结束", new Date().getTime());
// //this.drawDone = true;
// //this.map.setFitView();
// },
},
};
</script>
......
......@@ -864,7 +864,7 @@ MapService.prototype = {
createAraeInfowindow(info){
let _div = `<h3 class="map-infowindow-title">${info.ownerName || '--'}/${info.vin || '--'}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn||'--'} (${info.sourccStr||'--'})</span>
<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn||'--'} (${info.sourceStr||'--'})</span>
<span class="battery" data-battery style="display:${info.battery?'block':'none'}">
<i class="fill"><i class="fill-percentage" data-battery-percentage style="width:${info.battery}%;"></i></i>
<i class="icon icon-battery_enough"></i>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!