Commit 8df86680 by 前端

新增v1.17.0版本需求

1 parent 39bd917e
import request from './request'
// 区域查车-查询车辆信息
export const GER_REGIONAL_SEARCH = function(params = {}){
return request(params, '/trialdrive/regional/search', 'get')
}
// 区域查车-导出excel
export const GER_REGIONAL_EXPORT = function(params = {}){
return request(params, '/trialdrive/regional/export', 'get')
}
\ No newline at end of file \ No newline at end of file
...@@ -393,6 +393,7 @@ ...@@ -393,6 +393,7 @@
.des { .des {
flex: 1; flex: 1;
word-break: break-all; word-break: break-all;
max-width: 160px;
} }
.icon { .icon {
......
.row_box_hide {
position: absolute;
top: 20px;
right: 20px;
z-index: 999;
width: 88px;
height: 88px;
cursor: pointer;
.img {
width: 100%;
height: 100%;
}
}
.row_box {
position: absolute;
top: 10px;
right: 10px;
width: 380px;
height: 396px;
background: #ffffff;
border-radius: 8px;
z-index: 999;
padding: 20px;
box-sizing: border-box;
.hide_icon {
position: absolute;
width: 24px;
height: 24px;
right: 20px;
top: 20px;
cursor: pointer;
z-index: 1000;
.img {
width: 100%;
height: 100%;
}
}
.row_head {
position: relative;
display: flex;
align-items: center;
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 16px;
color: #666666;
.cell {
position: relative;
padding: 8px 0;
cursor: pointer;
margin-right: 30px;
}
.cell:last-child {
margin-right: 0;
}
.active {
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 20px;
color: #333333;
}
.active:after {
display: block;
content: "";
height: 3px;
background: #2196F3;
border-radius: 2px;
position: absolute;
left: 0;
right: 0;
bottom: 0;
}
}
.row_content {
padding-top: 15px;
.el_form {
/deep/ .el-form-item {
margin-bottom: 15px;
.el-form-item__label {
line-height: 14px;
padding: 0;
margin-bottom: 10px;
}
.el_select {
width: 100%;
}
}
.area_btn {
width: 88px;
height: 36px;
background: #E8E8E8;
border-radius: 4px;
padding: 0;
}
.clear_link {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 16px;
color: #185EFE;
margin-left: 20px;
}
.tips_info {
color: #666666ff;
font-size: 16px;
font-weight: 400;
margin: 15px 0;
i {
color: #ee3040ff;
font-style: normal;
}
}
.btn_group {
.search_btn {
width: 100%;
height: 40px;
}
}
}
}
}
.bottom_list {
position: absolute;
left: 0;
right: 0;
bottom: 0;
background: #fff;
//height: 313px;
z-index: 999;
display: flex;
flex-direction: column;
.head {
flex-shrink: 0;
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
padding: 11px 15px;
.left {
font-weight: 400;
font-size: 16px;
color: #333333;
.cred {
color: #EE3040;
}
.btn {
width: 88px;
height: 32px;
background: #9999991a;
border: 1px solid #CCCCCC;
border-radius: 4px;
padding: 0;
box-sizing: border-box;
font-weight: 500;
font-size: 16px;
color: #666666;
// line-height: 32px;
cursor: pointer;
}
.btn:hover {
background: #2196f31a;
color: #2196F3;
border-color: #2196F3;
}
}
.right {
display: flex;
align-items: center;
.link {
width: 48px;
height: 24px;
text-align: center;
line-height: 24px;
font-weight: 400;
font-size: 16px;
color: #999999;
text-decoration: none;
}
.link:hover {
background: #2196f31a;
border-radius: 2px;
color: #2196F3;
}
}
}
.head:after {
position: absolute;
display: block;
content: "";
height: 1px;
background: #D2D2D2;
left: 0;
right: 0;
bottom: 0;
}
.content {
flex: 1;
overflow-y: auto;
}
}
.bottom_list_hide {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
width: 80px;
height: 24px;
border-radius: 4px 4px 0px 0px;
background: #fff;
z-index: 999;
right: 0;
bottom: 0;
cursor: pointer;
box-shadow: 0 -2px 10px 0 #0000001a;
i {
margin-right: 4px;
}
span {
font-weight: 400;
font-size: 14px;
color: #666666;
}
}
.bottom_list_hide:hover {
background: #185efe33;
i,
span {
color: #185EFE;
}
}
\ No newline at end of file \ No newline at end of file
...@@ -47,10 +47,10 @@ export default { ...@@ -47,10 +47,10 @@ export default {
created() { created() {
// 查询 // 查询
// console.log(store); // console.log(store);
let list = store.state.common.provinceList; // let list = store.state.common.provinceList;
if (!list || list.length <= 0) { // if (!list || list.length <= 0) {
this.getList(); // this.getList();
} // }
}, },
mounted() { mounted() {
//this.city = this.value; //this.city = this.value;
...@@ -144,24 +144,24 @@ export default { ...@@ -144,24 +144,24 @@ export default {
}, },
// 查询高德地图的省市区 // 查询高德地图的省市区
getList() { // getList() {
let oParams = {}; // let oParams = {};
oParams.key = CONSTANT.MAP_SERVICE_KEY; // oParams.key = CONSTANT.MAP_SERVICE_KEY;
oParams.subdistrict = 3; // oParams.subdistrict = 3;
oParams.keywords = "中国"; // oParams.keywords = "中国";
axios({ // axios({
url: "https://restapi.amap.com/v3/config/district", // url: "https://restapi.amap.com/v3/config/district",
params: oParams, // params: oParams,
}).then((res) => { // }).then((res) => {
console.log(res); // console.log(res);
let obj = res.data; // let obj = res.data;
let { districts } = obj; // let { districts } = obj;
let list = districts[0] ? districts[0].districts : []; // let list = districts[0] ? districts[0].districts : [];
console.log(list); // console.log(list);
this.cityList = list; // this.cityList = list;
store.commit('SET_AMAP_PROVINCE',list) // store.commit('SET_AMAP_PROVINCE',list)
}); // });
}, // },
}, },
}; };
</script> </script>
......
<template>
<v-full-layout ref="vFullLayout">
<template slot="main">
<div
ref="map"
id="map"
class="map-container"
v-loading="mapLoading"
></div>
<div class="row_box_hide" v-if="hideRowBox" @click="onShow">
<img src="@/assets/images/car.png" class="img" alt="" />
</div>
<div class="row_box" v-else>
<div class="hide_icon" @click="onShow">
<img src="@/assets/images/hide.png" class="img" alt="" />
</div>
<div class="row_head">
<div
class="cell"
:class="menuId == item.id ? 'active' : ''"
v-for="(item, index) in menus"
:key="`menu_${index}`"
@click="menuEvent(item)"
>
{{ item.name }}
</div>
</div>
<div class="row_content">
<el-form
ref="form"
:model="form"
class="el_form"
label-position="top"
>
<template v-if="menuId == 1">
<el-form-item label="行政区域">
<CitySelect
v-model="form.area"
class="el_select"
@change="onChange"
/>
</el-form-item>
<el-form-item label="详细地址">
<el-input v-model="form.address" placeholder="请输入详细地址" />
</el-form-item>
<el-form-item label="">
<div>
<el-button class="area_btn" @click="searchAddess"
>选择区域</el-button
>
<span class="clear_link" @click="clearMap">清除</span>
</div>
</el-form-item>
<div class="tips_info" v-if="rectangle">
<span
>长度:<i>{{ rectangleWidth }}</i
>m</span
>
<span
>宽度:<i>{{ rectangleHeight }}</i
>m</span
>
</div>
</template>
<template v-else>
<el-form-item label="设备号">
<el-input
v-model="form.sn"
placeholder="请输入您要查询的设备号"
/>
</el-form-item>
</template>
<div class="btn_group">
<el-button
type="primary"
class="search_btn"
:loading="loading"
@click="onSearch"
>查询</el-button
>
</div>
</el-form>
</div>
</div>
<!-- 底部 开始 -->
<div class="bottom_list_hide" v-if="hideFooter" @click="onHide">
<i class="el-icon-arrow-up"></i>
<span>显示</span>
</div>
<div class="bottom_list" :style="`height:${bHeight}px;`" v-else>
<div class="head">
<div class="left">
<span>已查询到设备共计</span>
<span class="cred">{{ deviceList.length }}</span>
<span>条</span>
<el-button
class="btn"
:loading="dloading"
:disabled="!deviceList || deviceList.length <= 0"
@click="downloadExcel"
>导出</el-button
>
</div>
<div class="right">
<a href="javascript:void(0)" class="link" @click="unfold">展开</a>
<a href="javascript:void(0)" class="link" @click="packUp">收起</a>
<a href="javascript:void(0)" class="link" @click="onHide">隐藏</a>
</div>
</div>
<div class="content">
<el-table :data="deviceList" size="small">
<el-table-column
label="业务工单号"
prop="workOrderNo"
show-overflow-tooltip
/>
<el-table-column
label="店面名称"
prop="shopName"
show-overflow-tooltip
/>
<el-table-column
label="姓名"
prop="ownerName"
show-overflow-tooltip
/>
<el-table-column label="车架号" prop="vin" show-overflow-tooltip />
<el-table-column label="设备号" prop="sn" show-overflow-tooltip />
<el-table-column
label="激活时间"
prop="activeDate"
show-overflow-tooltip
/>
<el-table-column
label="设备类型"
prop="deviceTypeStr"
show-overflow-tooltip
/>
<el-table-column
label="最后GPS定位时间"
prop="finalGpsTime"
show-overflow-tooltip
/>
</el-table>
</div>
</div>
<!-- 底部 end -->
</template>
</v-full-layout>
</template>
<script>
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,
} from "@/api/services/zooneCar";
import { GET_DEVICEINFO_BYSNS } from "@/api/services/monitor";
import EventBus from "@/event-bus";
import { showToast } from "@/utils/utils.js";
import moment from "moment";
export default {
components: {
CitySelect,
},
data() {
return {
menus: [
{ name: "区域查车", id: 1 },
{ name: "设备号查车", id: 2 },
],
menuId: 1,
map: null,
mapLoading: true,
form: {},
rectangle: null,
rectangleEditor: null,
rectangleWidth: 500, // 矩形宽度
rectangleHeight: 500, // 矩形高度
bHeight: 313,
hInterval: null,
hideRowBox: false,
hideFooter: true,
//rectangleInfo:{}, // 矩形坐标点信息
deviceList: [],
loading: false,
dloading: false,
autoOpenLastInfoWindow: false,
};
},
mounted() {
this.initMap();
},
methods: {
// 地图初始化
async initMap() {
let _this = this;
let plugins = CONSTANT.MAP_PLUGINS.concat([
"AMap.LngLat",
"AMap.Rectangle",
"AMap.RectangleEditor",
]);
let AMap = await AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: plugins, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
});
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map");
},
// 画矩形
drawRectangle(lnglat) {
let _this = this;
let lng = lnglat.southWest.lng;
let lat = lnglat.southWest.lat;
let nlng = lnglat.northEast.lng;
let nlat = lnglat.northEast.lat;
let southWest = new AMap.LngLat(lng, lat);
let northEast = new AMap.LngLat(nlng, nlat);
let rectangle = this.rectangle;
let rectangleEditor = this.rectangleEditor;
if (rectangle || rectangleEditor) {
//rectangleEditor.close();
// this.map.remove([rectangle, rectangleEditor]);
this.clearMap();
}
let bounds = new AMap.Bounds(southWest, northEast);
rectangle = new AMap.Rectangle({
bounds: bounds,
strokeColor: "#f00",
strokeWeight: 3,
strokeOpacity: 1,
strokeDasharray: [30, 10],
// strokeStyle还支持 solid
strokeStyle: "dashed",
fillColor: "blue",
fillOpacity: 0.2,
cursor: "pointer",
zIndex: 50,
});
this.map.add(rectangle);
this.map.setFitView();
this.map.setZooms([15, 30]);
rectangleEditor = new AMap.RectangleEditor(this.map, rectangle);
rectangleEditor.open();
rectangleEditor.on("adjust", function (event) {
_this.calculateWidthHeight(event.bounds);
});
// rectangle.on("dragend", function (event) {
// console.log("拖动:", event);
// });
this.rectangleEditor = rectangleEditor;
this.rectangle = rectangle;
},
/**
* 计算对应点的位置
* lng:中心点经度 lat:中心点维度 距离默认500m
* 垂直距离lath(所求点在已知点上方(北方)为正,否则为负)
* 水平距离longw(所求点在已知点右方(东方)为正,否则为负)
* lat = latitude + lath / (ARC * math.pi / 180);
* long = longitude + longw / (ARC * math.cos(latitude) * math.pi / 180);
*/
getLngLat(lng, lat, w) {
let ARC = 6371.393 * 1000;
let pi = Math.PI;
let num = w ? w / 2 : 500 / 2;
// 中心点-左边点的经纬度
let leftLng = lng - num / ((ARC * Math.cos(lat) * pi) / 180);
// let leftLat = lat;
// 中心点-下边点的经纬度
// let bottomLng = lng;
let bottomLat = lat - num / ((ARC * pi) / 180);
// 中心点-右边点经纬度
let rightLng = lng + num / ((ARC * Math.cos(lat) * pi) / 180);
// let rightLat = lat;
// 中心点-上边点经纬度
// let topLng = lng;
let topLat = lat + num / ((ARC * pi) / 180);
// 左下角 经纬度 leftLng bottomLat
let southWest = { lng: leftLng, lat: bottomLat };
// 右上角 经纬度 rightLng topLat
let northEast = { lng: rightLng, lat: topLat };
let lnglats = { southWest, northEast };
return lnglats;
},
// 根据地址获取经纬度
getAddressLngLat(address) {
return new Promise((resolve) => {
AMap.plugin("AMap.Geocoder", function () {
var geocoder = new AMap.Geocoder();
geocoder.getLocation(address, function (status, result) {
resolve({ status, result });
});
});
});
},
// 查询
async searchAddess() {
console.log(this.form);
let o = this.form;
let location = {};
let address = o.name + o.address;
let { status, result } = await this.getAddressLngLat(address);
if (status === "complete" && result.info === "OK") {
// 以解析出来经纬度为中心点来画矩形
let arr = result.geocodes ? result.geocodes : [];
location = arr[0] ? arr[0].location : {};
} else {
// 如果解析不出来经纬度,则以地图中心点来画矩形
location = this.map.getCenter();
}
let lnglats = this.getLngLat(location.lng, location.lat);
this.drawRectangle(lnglats);
},
// 计算矩形宽度、高度
calculateWidthHeight(lnglats) {
if (!lnglats) {
return {};
}
// 左下角点坐标
let southWest = lnglats.southWest || {};
// 右上角点坐标
let northEast = lnglats.northEast || {};
// 计算高度
let _height = AMap.GeometryUtil.distance(
[southWest.lng, southWest.lat],
[southWest.lng, northEast.lat]
);
// 计算宽度
let _width = AMap.GeometryUtil.distance(
[southWest.lng, southWest.lat],
[northEast.lng, southWest.lat]
);
this.rectangleHeight = _height.toFixed(0);
this.rectangleWidth = _width.toFixed(0);
},
// 清空地图覆盖物
clearMap() {
let rectangle = this.rectangle;
let rectangleEditor = this.rectangleEditor;
if (rectangle || rectangleEditor) {
rectangleEditor.close();
}
if (this.map) {
this.map.clearMap();
}
this.rectangleHeight = 500;
this.rectangleWidth = 500;
this.rectangle = null;
this.rectangleEditor = null;
this.map.setZooms([2, 30]);
},
// 展开
unfold() {
let _this = this;
let h = this.bHeight;
let m = Number(this.$refs.map.offsetHeight);
let max = (m * 0.8).toFixed(0);
if (_this.hInterval) {
clearInterval(_this.hInterval);
}
_this.hInterval = setInterval(function () {
if (h >= max) {
clearInterval(_this.hInterval);
return false;
}
h += 30;
_this.bHeight = h;
}, 10);
},
// 收起
packUp() {
let _this = this;
let min = 313;
if (_this.hInterval) {
clearInterval(_this.hInterval);
}
_this.hInterval = setInterval(function () {
let h = _this.bHeight;
if (h <= min) {
clearInterval(_this.hInterval);
return false;
}
h -= 30;
_this.bHeight = h;
}, 10);
},
// 隐藏
onHide() {
this.hideFooter = !this.hideFooter;
},
// 展开
onShow() {
this.hideRowBox = !this.hideRowBox;
},
// 搜索
async onSearch() {
let type = this.menuId;
// 1:区域查车,2:设备号查车
if (type == 1) {
this.getAreaLocation();
} else {
this.getLocation();
}
},
// 获取地图数据
getMapInfo(row) {
let oParams = {};
oParams.sn = row.sn || "";
oParams.name = row.ownerName || "";
oParams.standNo = row.vin || "";
oParams.source = row.source || "";
// gps 信息
oParams.lng = row.lng;
oParams.lat = row.lat;
oParams.address = row.finalGpsAddress || "";
oParams.time = row.dateTime || "";
// 定位类型
oParams.type = 2;
return oParams;
},
// 打开车辆弹框
openMapInfoWindow(sn, vin) {
EventBus.$emit("uiMap.monitor.openInfoWindow", `${sn}-${vin}`);
},
// 添加位置点
addLocation(row, showInfoWindow) {
let drawData = row;
EventBus.$emit("uiMap.monitor.drawMaker", drawData, showInfoWindow);
},
// 获取参数
getParams() {
if (!this.rectangle) {
return {};
}
let params = {};
let o = this.rectangle.getOptions();
let bounds = o.bounds || {};
params.leftLngLat = `${bounds.southWest.lng},${bounds.southWest.lat}`;
params.rightLngLat = `${bounds.northEast.lng},${bounds.northEast.lat}`;
return params;
},
// 导出excel
async downloadExcel() {
let params = this.getParams();
this.dloading = true;
let res = await GER_REGIONAL_EXPORT(params);
this.dloading = false;
if (res.code != 200) {
showToast({
message: res.message,
});
return false;
}
if (res.data) {
window.location.href = res.data;
}
},
// 监听地区选择
onChange(e) {
let o = e.name;
let str = o[0] + o[1] + o[2];
this.$set(this.form, "name", str);
},
// 切换类型
menuEvent(row) {
this.menuId = row.id;
},
// 设备号查车
async getLocation() {
let params = {};
params.sns = this.form.sn;
params.deviceCode = "gps";
let res = await GET_DEVICEINFO_BYSNS(params);
let list = res.data || [];
list.forEach((item) => {
// let relItem = this.monitorList[item.sn];
// if (relItem) {
// relItem.online = item.status === 2 ? false : true;
// relItem.isHasPosition = true;
// item.name = relItem.name;
// item.standNo = relItem.standNo;
// }
//item.eLocateType = relItem.eLocateType;
item = this.filterGpsBase(item);
item.name = item.name || "--";
item.standNo = item.standNo || item.vin;
item.isSource = item.source;
});
this.autoOpenLastInfoWindow = true;
EventBus.$emit("uiMap.monitor.draw", list, this.autoOpenLastInfoWindow);
if (this.autoOpenLastInfoWindow) {
this.autoOpenLastInfoWindow = false;
}
console.log(res);
},
// 区域查车
async getAreaLocation() {
let _this = this;
let params = this.getParams();
if (!_this.rectangle) {
showToast({
message: "请先划定区域",
});
return false;
}
_this.loading = true;
let res = await GER_REGIONAL_SEARCH(params);
_this.loading = false;
if (res.code != 200) {
showToast({
message: res.message,
});
return false;
}
let list = res.data || [];
list.map((k) => {
let o = _this.getMapInfo(k);
if (o.lng || o.bsLng) {
o.elat = o.lat;
o.elng = o.lng;
_this.addLocation(o, false);
}
});
if (list[0]) {
_this.openMapInfoWindow(list[0].sn, list[0].vin);
}
_this.deviceList = list;
_this.hideFooter = false;
},
// 处理数据
filterGpsBase(item) {
console.log(item);
let typeList = { gpsLocation: "bsLocation", bsLocation: "gpsLocation" };
let _type = item.eLocateType || "gpsLocation";
let m = item[_type];
let n = item[typeList[_type]];
console.log(m);
console.log(m.dateTime);
let max =
moment(m.dateTime).format("x") >= moment(n.dateTime).format("x");
/* 如果基站,gps其中一个没数据,自动切换到另一个,如果都没有eLocateType为null */
if (!m || !m.elng || !m.elat) {
if (n && n.elng && n.elat) {
item.eLocateType = typeList[_type];
} else {
item.eLocateType = null;
item.eLocateSingle = true;
}
}
// 如果gps时间大于等于基站时间,则先显示gps点
if (!item.eLocateSingle) {
if (max) {
item.eLocateType = "gpsLocation";
} else {
item.eLocateType = "bsLocation";
}
}
return item;
},
},
};
</script>
<style lang="scss" scoped>
@import "../../assets/scss/zoneCar.scss";
</style>
\ No newline at end of file \ No newline at end of file
...@@ -61,6 +61,8 @@ const stockDeviceList = () => import(/* webpackChunkName: "stockDeviceList" */ ' ...@@ -61,6 +61,8 @@ const stockDeviceList = () => import(/* webpackChunkName: "stockDeviceList" */ '
const anjiAccount = () => import(/* webpackChunkName: "anjiAccount" */ 'pages/business/anjiAccount.vue'); const anjiAccount = () => import(/* webpackChunkName: "anjiAccount" */ 'pages/business/anjiAccount.vue');
const tool = () => import(/* webpackChunkName: "tool" */ 'pages/tool/index.vue'); const tool = () => import(/* webpackChunkName: "tool" */ 'pages/tool/index.vue');
const zoneCar = () => import(/* webpackChunkName: "zoneCar" */ 'pages/monitor/zoneCar.vue')
const routes = [ const routes = [
/* { /* {
path: '*', path: '*',
...@@ -203,6 +205,12 @@ const routes = [ ...@@ -203,6 +205,12 @@ const routes = [
component: monitor component: monitor
}, },
{ {
path: 'zoneCar',
name: 'zoneCar',
meta: { title: '区域查车' },
component: zoneCar
},
{
path: 'historyLocation', path: 'historyLocation',
name: 'historyLocation', name: 'historyLocation',
meta: { title: '历史停留' }, meta: { title: '历史停留' },
......
...@@ -2,6 +2,8 @@ const MAPGEO = { ...@@ -2,6 +2,8 @@ const MAPGEO = {
geocoder: null, geocoder: null,
getGeocoder: function () { getGeocoder: function () {
return new Promise((resolve) => { return new Promise((resolve) => {
// 高德地图兼容方式,兼容低版本
if(AMap.service){
AMap.service('AMap.Geocoder', function () {//回调函数 AMap.service('AMap.Geocoder', function () {//回调函数
var geocoder = new AMap.Geocoder({ var geocoder = new AMap.Geocoder({
batch: true batch: true
...@@ -9,6 +11,16 @@ const MAPGEO = { ...@@ -9,6 +11,16 @@ const MAPGEO = {
MAPGEO.geocoder = geocoder; MAPGEO.geocoder = geocoder;
resolve(geocoder); resolve(geocoder);
}); });
}else{
AMap.plugin('AMap.Geocoder', function () {//回调函数
var geocoder = new AMap.Geocoder({
batch: true
});
MAPGEO.geocoder = geocoder;
resolve(geocoder);
});
}
}) })
}, },
transferAddressByGroup(obj, cb) { transferAddressByGroup(obj, cb) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!