Commit ac2d2a40 by 前端

Merge branch 'develop' into 'master'

v1.17.0版本已上线,合并代码到master

See merge request !32
2 parents e71bf45c 8108a00a
This diff could not be displayed because it is too large.
...@@ -3,12 +3,15 @@ import HTTP from '../config' ...@@ -3,12 +3,15 @@ import HTTP from '../config'
const axiosHttp = new HTTP() const axiosHttp = new HTTP()
function request (data = {} , url, method = 'GET') { function request (data = {} , url, method = 'GET') {
console.log('开始请求:',new Date().getTime())
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var reqMethod = method.toLocaleLowerCase() === 'get' ? 'axiosGet' : 'axiosPost' var reqMethod = method.toLocaleLowerCase() === 'get' ? 'axiosGet' : 'axiosPost'
axiosHttp[reqMethod]({ axiosHttp[reqMethod]({
url: url, url: url,
data: data, data: data,
success(data) { success(data) {
console.log(data)
console.log('结束请求:',new Date().getTime())
resolve(data) resolve(data)
}, },
error(error) { error(error) {
......
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')
}
// 区域查车-查询设备定位信息
export const GER_REGIONAL_LOCATION = function(params = {}){
return request(params, '/trialdrive/regional/location', 'get')
}
\ No newline at end of file \ No newline at end of file

19.4 KB | W: | H:

515 Bytes | W: | H:

src/assets/images/icon_car.png
src/assets/images/icon_car.png
src/assets/images/icon_car.png
src/assets/images/icon_car.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -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%;
}
.img_hover{
display:none;
}
}
.row_box_hide:hover{
.img_normal{
display:none;
}
.img_hover{
display:block;
}
}
.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%;
}
}
.device_item{
display:flex;
align-items: center;
/deep/ .el-input__inner{
border-radius:4px 0 0 4px;
}
.btn{
border-radius:0 4px 4px 0;
}
}
.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;
cursor: pointer;
}
.tips_info {
color: #666666ff;
font-size: 16px;
font-weight: 400;
margin: 15px 0;
i {
color: #ee3040ff;
font-style: normal;
}
span{
margin-right:40px;
}
span:last-child{
margin-right:0;
}
}
.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;
}
}
.device_label{
display:flex;
align-items: center;
.img{
width:16px;
height: 16px;
margin-left:4px;
}
}
.draw_area{
margin-top:10px;
}
\ No newline at end of file \ No newline at end of file
export const Validator = {
/*手机号码格式校验正则*/
PHONEREG: /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/,
/*同时包含字母和数字*/
ISNUMANDLETTERS: /^[a-zA-Z0-9]+$/,
/*特殊字符正则*/
SPECIALLETTER:new RegExp("[`~!@#$^&*=|{}':;',\\[\\]<>?~!@#¥……&*——|{}【】‘;:”“'。,、? ]"),
/*邮箱地址格式正则*/
//EMAILREG:/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/,
EMAILREG:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
/*判断是否为中文*/
ISCHINESE:/^[\u0391-\uFFE5]+$/,
/*判断是否为英文字母*/
ISENGLISH:/^[a-zA-Z]+$/,
/*是否包含空格*/
ISHAVENULL:/^[^\s]*$/,
/*保留两位小数*/
TWODECIMAL: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/,
/*判断是否为正整数*/
ISDECIMAL:/^[0-9]*$/,
// 只能输入负数
ISNEGATIVENUMBER:/^-[0-9]+.?[0-9]*/,
/**
* 账号管理-手机号码校验
*/
checkPhoneNumber:function(str){
return Validator.PHONEREG.test(str);
}
};
// 校验手机号码格式
export const PHONE_VALIDATOR = (rule, value, callback) => {
let reg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
if (!reg.test(value)) {
return callback(new Error('手机号格式不正确'));
}
callback()
}
// 校验是否为数字
export const CHECK_NUMBER = function(rule, value, callback){
let reg = /^[0-9]*$/
console.log(reg.test(value))
if (!reg.test(value)) {
return callback(new Error('请输入纯数字'));
}
callback()
}
// 校验值的大小
export const CHECK_MAX_MIN = function(rule, value, callback){
if (value>5 || value<1) {
return callback(new Error('总体评分最小1,最大5'));
}
callback()
}
...@@ -37,8 +37,9 @@ export default { ...@@ -37,8 +37,9 @@ export default {
watch: { watch: {
// value: { // value: {
// handler: function (n, o) { // handler: function (n, o) {
// console.log(n)
// if (n) { // if (n) {
// this.init(); // //this.init();
// } // }
// }, // },
// immediate: true, // immediate: true,
...@@ -47,10 +48,10 @@ export default { ...@@ -47,10 +48,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;
...@@ -61,17 +62,17 @@ export default { ...@@ -61,17 +62,17 @@ export default {
console.log(e); console.log(e);
let list = this.cityList; let list = this.cityList;
let nameList = []; let nameList = [];
let id = 'fullname';
let m = list.find((k) => k.code == e[0]); let m = list.find((k) => k.code == e[0]);
console.log(m); nameList.push(m[id]);
nameList.push(m.name);
let n = m.children.find((k) => k.code == e[1]); let n = m.children.find((k) => k.code == e[1]);
let b = ((n && n.children) || []).find((k) => k.code == e[2]); let b = ((n && n.children) || []).find((k) => k.code == e[2]);
if (n) { if (n) {
this.$emit("input", n.name); this.$emit("input", n[id]);
nameList.push(n.name); nameList.push(n[id]);
} }
if (b) { if (b) {
nameList.push(b.name); nameList.push(b[id]);
} }
this.$emit("change", { code: e, name: nameList }); this.$emit("change", { code: e, name: nameList });
}, },
...@@ -143,25 +144,30 @@ export default { ...@@ -143,25 +144,30 @@ export default {
return afterArray; return afterArray;
}, },
// 重置
reset(){
this.city = []
}
// 查询高德地图的省市区 // 查询高德地图的省市区
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>
<el-image
:src="imgPath"
:fit="fit"
class="img"
>
<div slot="error" class="image_slot">
<i class="el-icon-user"></i>
</div>
</el-image>
</template>
<script>
export default {
name: "GlsxImage",
props: {
src: {
type: String,
default: "",
},
fit: {
type: String,
default: "",
},
},
watch: {
src: {
handler: function (n) {
if (n) {
console.log(n);
this.imgPath = this.IMAGEURL + n;
}
},
immediate: true,
},
},
data() {
return {
imgPath: "",
IMAGEURL: 'https://img01.glsx.com.cn/weapp/resource/e-shield/',
};
},
created() {
console.log(this.src);
},
mounted() {},
methods: {
},
};
</script>
<style lang="scss" scoped>
.img {
cursor: pointer;
width: 100%;
height: 100%;
}
</style>
<style lang="scss">
.image_slot{
width: 100%;
height: 100%;
display:flex;
flex-direction: column;
align-items: center;
justify-content: center;
background:#f5f7fa;
i{
font-size:24px;
color:#909399;
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -32,6 +32,14 @@ import 'vxe-table/lib/style.css' ...@@ -32,6 +32,14 @@ import 'vxe-table/lib/style.css'
Vue.use(VXETable) Vue.use(VXETable)
// // worker多线程
// import VueWorker from 'vue-worker'
// Vue.use(VueWorker)
// 引入 公共图片组件
import GlsxImage from '@/components/glsx-image/index.vue';
Vue.component('GlsxImage', GlsxImage)
// new Vue({ // new Vue({
// el: '#app', // el: '#app',
// router, // router,
......
...@@ -20,14 +20,32 @@ ...@@ -20,14 +20,32 @@
:trigger-on-focus="false" :trigger-on-focus="false"
:placeholder="'请输入'+['6位以上设备号','6位以上车架号','2位以上姓名'][searchType-1]" :placeholder="'请输入'+['6位以上设备号','6位以上车架号','2位以上姓名'][searchType-1]"
@select="handleSelect"> --> @select="handleSelect"> -->
<el-input :placeholder="placeholderText" v-model.trim="searchText" size="small" class="input-with-select" @keyup.enter.native='searchSubmit'> <el-input
<el-select v-model="searchType" @change="selectChange" slot="prepend" placeholder="请选择" size="small"> :placeholder="placeholderText"
v-model.trim="searchText"
size="small"
class="input-with-select"
@keyup.enter.native="searchSubmit"
>
<el-select
v-model="searchType"
@change="selectChange"
slot="prepend"
placeholder="请选择"
size="small"
>
<el-option label="设备号" value="1"></el-option> <el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option> <el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option> <el-option label="姓名" value="3"></el-option>
<!-- <el-option label="工单号" value="4"></el-option> --> <!-- <el-option label="工单号" value="4"></el-option> -->
</el-select> </el-select>
<el-button icon="el-icon-search" size="mini" slot="append" :loading="isSearching" @click="searchSubmit"> <el-button
icon="el-icon-search"
size="mini"
slot="append"
:loading="isSearching"
@click="searchSubmit"
>
</el-button> </el-button>
<!-- <template slot-scope="{ item }"> <!-- <template slot-scope="{ item }">
<div style="margin: 0 -20px; font-size: 12px; " class="auto_item"> <div style="margin: 0 -20px; font-size: 12px; " class="auto_item">
...@@ -46,93 +64,242 @@ ...@@ -46,93 +64,242 @@
</div> </div>
<el-row type="flex" class="filter-entrance" justify="space-between"> <el-row type="flex" class="filter-entrance" justify="space-between">
<!-- <el-button type="text" @click="importDialogHidden=false;listDialogHidden=true;resultDialogHidden=true;">导入查询</el-button> --> <!-- <el-button type="text" @click="importDialogHidden=false;listDialogHidden=true;resultDialogHidden=true;">导入查询</el-button> -->
<el-button type="text" @click="treeHidden=false;listDialogHidden=true;importDialogHidden=true;resultDialogHidden=true;">组织</el-button> <el-button
<el-button type="text" @click="listDialogHidden=false;treeHidden=true;importDialogHidden=true;resultDialogHidden=true;">监控列表({{getMonitorListVisibleCount}})</el-button> type="text"
@click="
treeHidden = false;
listDialogHidden = true;
importDialogHidden = true;
resultDialogHidden = true;
"
>组织</el-button
>
<el-button
type="text"
@click="
listDialogHidden = false;
treeHidden = true;
importDialogHidden = true;
resultDialogHidden = true;
"
>监控列表({{ getMonitorListVisibleCount }})</el-button
>
</el-row> </el-row>
<div class="filter-dialog-set"> <div class="filter-dialog-set">
<div class="filter-dialog animated " :class="importDialogHidden?'fadeOut':'active fadeIn'"> <div
class="filter-dialog animated"
:class="importDialogHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header"> <div class="filter-dialog-header">
导入查询 导入查询
<i class="el-icon-close pull-right" @click.stop="importDialogHidden=true"></i> <i
class="el-icon-close pull-right"
@click.stop="importDialogHidden = true"
></i>
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini"> <el-form
ref="form"
:model="form"
:rules="rules"
:inline="false"
size="mini"
>
<el-form-item label="" prop="filename"> <el-form-item label="" prop="filename">
<el-upload ref="upload" class="upload-wrap" action="vehicle/importSerchDevice" :on-change="changeFile" :before-upload="beforeUpload" :multiple="false" :show-file-list="false" :on-success="successUpload" :on-error="errorUpload" :data="uploadData" accept=".xlsx" :auto-upload="false"> <el-upload
<el-input v-model="form.filename" placeholder="未选取任何文件" class="input-with-select" size="small"> ref="upload"
<el-select v-model="form.uploadType" slot="prepend" placeholder="请选择" size="small"> class="upload-wrap"
action="vehicle/importSerchDevice"
:on-change="changeFile"
:before-upload="beforeUpload"
:multiple="false"
:show-file-list="false"
:on-success="successUpload"
:on-error="errorUpload"
:data="uploadData"
accept=".xlsx"
:auto-upload="false"
>
<el-input
v-model="form.filename"
placeholder="未选取任何文件"
class="input-with-select"
size="small"
>
<el-select
v-model="form.uploadType"
slot="prepend"
placeholder="请选择"
size="small"
>
<el-option label="设备号" value="1"></el-option> <el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option> <el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option> <el-option label="姓名" value="3"></el-option>
<el-option label="工单号" value="4"></el-option> <el-option label="工单号" value="4"></el-option>
</el-select> </el-select>
</el-input> </el-input>
<div slot="tip" class="el-upload__tip">仅支持同时监控100台设备,还可导入{{100-monitorList.itemArr.length}}台设备</div> <div slot="tip" class="el-upload__tip">
仅支持同时监控100台设备,还可导入{{
100 - monitorList.itemArr.length
}}台设备
</div>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-button type="primary" class="upload-sure-btn" size="small" @click="submitUpload" :loading="importing" :disabled="uploadDisabled">确认</el-button> <el-button
<el-button size="mini" type="text" @click="downloadTpl" style="margin-left: 0px;">下载模板</el-button> type="primary"
class="upload-sure-btn"
size="small"
@click="submitUpload"
:loading="importing"
:disabled="uploadDisabled"
>确认</el-button
>
<el-button
size="mini"
type="text"
@click="downloadTpl"
style="margin-left: 0px"
>下载模板</el-button
>
</el-form> </el-form>
</div> </div>
</div> </div>
<div class="filter-dialog animated " :class="listDialogHidden?'fadeOut':'active fadeIn'"> <div
class="filter-dialog animated"
:class="listDialogHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header monitor_dialog_header"> <div class="filter-dialog-header monitor_dialog_header">
<span>监控列表({{ monitorList.itemArr.length }})</span>
<span>监控列表({{monitorList.itemArr.length}})</span> <i
<i class="el-icon-close pull-right" @click.stop="listDialogHidden=true"></i> class="el-icon-close pull-right"
@click.stop="listDialogHidden = true"
></i>
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
<el-row type="flex" class="sub-filter" justify="space-between"> <el-row type="flex" class="sub-filter" justify="space-between">
<el-select v-model="monitorFilterType" placeholder="请选择" size="small" style="width: 100px;"> <el-select
v-model="monitorFilterType"
placeholder="请选择"
size="small"
style="width: 100px"
>
<el-option label="全部" value=""></el-option> <el-option label="全部" value=""></el-option>
<el-option label="有线" value="1"></el-option> <el-option label="有线" value="1"></el-option>
<el-option label="无线" value="0"></el-option> <el-option label="无线" value="0"></el-option>
</el-select> </el-select>
<el-button type="primary" plain size="small" @click="removeMonitorByGroup(monitorList.itemArr)">批量删除</el-button> <el-button
type="primary"
plain
size="small"
@click="removeMonitorByGroup(monitorList.itemArr)"
>批量删除</el-button
>
</el-row> </el-row>
<ul class="monitor-list" style="max-height:calc(100vh - 380px);"> <ul
class="monitor-list"
style="max-height: calc(100vh - 380px)"
>
<template v-for="(sn, key) in monitorList.itemArr"> <template v-for="(sn, key) in monitorList.itemArr">
<li class="monitor-list-item" :key="sn" @click="openMapInfoWindow(sn, monitorList[sn].source)" v-if="key!=='count' && monitorList[sn]&&(monitorList[sn].source==monitorFilterType||monitorFilterType=='')"> <li
<span class="device-icon" :class="monitorList[sn].online?'':'offline'" v-show="monitorList[sn].online !== undefined"></span> class="monitor-list-item"
:key="sn"
@click="openMapInfoWindow(sn, monitorList[sn].source)"
v-if="
key !== 'count' &&
monitorList[sn] &&
(monitorList[sn].source == monitorFilterType ||
monitorFilterType == '')
"
>
<span
class="device-icon"
:class="monitorList[sn].online ? '' : 'offline'"
v-show="monitorList[sn].online !== undefined"
></span>
<div class="user-info"> <div class="user-info">
<p> <p>
<span class="name">{{monitorList[sn].name||'--'}}</span> <span class="name">{{
<span>{{sn}}({{monitorList[sn].sourceType}})</span> monitorList[sn].name || "--"
}}</span>
<span
>{{ sn }}({{ monitorList[sn].sourceType }})</span
>
</p> </p>
<p>车架号:{{monitorList[sn].standNo}}</p> <p>车架号:{{ monitorList[sn].standNo }}</p>
</div> </div>
<span class="none_tip" v-show="!monitorList[sn].isHasPosition">无定位信息</span> <span
<el-button type="text" @click.stop="removeMonitor(monitorList[sn], true)"><i class="fa fa-trash"></i></el-button> class="none_tip"
v-show="!monitorList[sn].isHasPosition"
>无定位信息</span
>
<el-button
type="text"
@click.stop="removeMonitor(monitorList[sn], true)"
><i class="fa fa-trash"></i
></el-button>
</li> </li>
</template> </template>
</ul> </ul>
</div> </div>
<div class="filter-dialog-footer"> <div class="filter-dialog-footer">
<div class="device-icon-label"><span class="device-icon"></span> <span>在线</span></div> <div class="device-icon-label">
<div class="device-icon-label"><span class="device-icon offline"></span> <span>离线</span></div> <span class="device-icon"></span> <span>在线</span>
</div> </div>
<div class="device-icon-label">
<span class="device-icon offline"></span> <span>离线</span>
</div> </div>
<div class="filter-dialog animated " :class="resultDialogHidden?'fadeOut':'active fadeIn'"> </div>
</div>
<div
class="filter-dialog animated"
:class="resultDialogHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header"> <div class="filter-dialog-header">
查询结果 查询结果
<i class="el-icon-close pull-right" @click.stop="resultDialogHidden=true"></i> <i
class="el-icon-close pull-right"
@click.stop="resultDialogHidden = true"
></i>
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
<el-row type="flex" class="sub-filter" justify="space-between"> <el-row type="flex" class="sub-filter" justify="space-between">
<el-select v-model="resultFilterType" placeholder="请选择" size="small" style="width: 100px;"> <el-select
v-model="resultFilterType"
placeholder="请选择"
size="small"
style="width: 100px"
>
<el-option label="全部" value=""></el-option> <el-option label="全部" value=""></el-option>
<el-option label="有线" value="1"></el-option> <el-option label="有线" value="1"></el-option>
<el-option label="无线" value="0"></el-option> <el-option label="无线" value="0"></el-option>
</el-select> </el-select>
<el-button type="primary" plain size="small" @click="addMonitorByGroup">批量监控</el-button> <el-button
type="primary"
plain
size="small"
@click="addMonitorByGroup"
>批量监控</el-button
>
</el-row> </el-row>
<ul class="monitor-list"> <ul class="monitor-list">
<li class="monitor-list-item" v-for="item in resultList" :key="item.id" v-show="item.source==resultFilterType||resultFilterType==''"> <li
class="monitor-list-item"
v-for="item in resultList"
:key="item.id"
v-show="
item.source == resultFilterType || resultFilterType == ''
"
>
<div class="user-info"> <div class="user-info">
<p><span class="name">{{item.name}}</span><span>{{item.sn}}({{item.sourceType}})</span></p> <p>
<p>车架号:{{item.standNo}}</p> <span class="name">{{ item.name }}</span
><span>{{ item.sn }}({{ item.sourceType }})</span>
</p>
<p>车架号:{{ item.standNo }}</p>
</div> </div>
<el-button type="text" @click.prevent="addMonitor(item)">监控</el-button> <el-button type="text" @click.prevent="addMonitor(item)"
>监控</el-button
>
</li> </li>
<li v-show="!resultList.length"> <li v-show="!resultList.length">
<p class="text-center">无数据</p> <p class="text-center">无数据</p>
...@@ -140,31 +307,59 @@ ...@@ -140,31 +307,59 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="filter-dialog" :class="treeHidden?'fadeOut':'active fadeIn'"> <div
class="filter-dialog"
:class="treeHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header monitor_dialog_header"> <div class="filter-dialog-header monitor_dialog_header">
<i class="el-icon-refresh i_refresh" title="重置组织" @click.stop="restInitTree"></i> <i
class="el-icon-refresh i_refresh"
title="重置组织"
@click.stop="restInitTree"
></i>
<span>组织</span> <span>组织</span>
<i class="el-icon-close pull-right" @click.stop="treeHidden=true"></i> <i
class="el-icon-close pull-right"
@click.stop="treeHidden = true"
></i>
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
<div class="monitor-list"> <div class="monitor-list">
<el-tree ref="tree" :key="treeKey" :data="treeData" :props="treeProps" lazy :load="loadNode" show-checkbox node-key="id" :default-expanded-keys="expandedKeys" :default-checked-keys="checkedKeys" @check="handleCheck" v-loading="treeLoading" @check-change="handleCheckChange"> <el-tree
<span class="custom-tree-node" slot-scope="{ node,data }"> ref="tree"
:key="treeKey"
:data="treeData"
:props="treeProps"
lazy
:load="loadNode"
show-checkbox
node-key="id"
:default-expanded-keys="expandedKeys"
:default-checked-keys="checkedKeys"
@check="handleCheck"
v-loading="treeLoading"
@check-change="handleCheckChange"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<div v-if="node.data.leaf"> <div v-if="node.data.leaf">
<div>姓名:{{node.data.label1 || "--"}}</div> <div>姓名:{{ node.data.label1 || "--" }}</div>
<div>设备号:{{node.data.label||'--'}}</div> <div>设备号:{{ node.data.label || "--" }}</div>
<div>车架号:{{node.data.label2}}</div> <div>车架号:{{ node.data.label2 }}</div>
<div class="load_more_link" v-if="data.showMore" v-loading="loadingMore" @click="loadNext(node, data)"> <div
class="load_more_link"
v-if="data.showMore"
v-loading="loadingMore"
@click="loadNext(node, data)"
>
查看更多 查看更多
</div> </div>
</div> </div>
<span v-else> <span v-else>
{{node.data.label}} {{ node.data.label }}
</span> </span>
</span> </span>
</el-tree> </el-tree>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
...@@ -175,10 +370,11 @@ ...@@ -175,10 +370,11 @@
</template> </template>
<script> <script>
import "@/assets/spritesmith-generated/sprite.css"; import "@/assets/spritesmith-generated/sprite.css";
import store from "@/vuex/store.js"; //import store from "@/vuex/store.js";
import remoteLoad from "@/utils/remoteLoad.js"; //import remoteLoad from "@/utils/remoteLoad.js";
import mapService from "@/utils/mapService.js"; import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js"; import "@/utils/mapEvent.js";
//import monitor from '@/utils/monitor'
import EventBus from "@/event-bus"; import EventBus from "@/event-bus";
import { services } from "@/api"; import { services } from "@/api";
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
...@@ -250,7 +446,7 @@ export default { ...@@ -250,7 +446,7 @@ export default {
pageSizeList: {}, pageSizeList: {},
pageSize: 10, pageSize: 10,
loadingMore: false, loadingMore: false,
placeholderText: '请输入6位以上车架号' placeholderText: "请输入6位以上车架号",
}; };
}, },
computed: { computed: {
...@@ -330,19 +526,19 @@ export default { ...@@ -330,19 +526,19 @@ export default {
}, },
// 切换查询类型 // 切换查询类型
selectChange(data) { selectChange(data) {
let tex = '' let tex = "";
switch(data) { switch (data) {
case '1': case "1":
tex = '请输入4位以上设备号' tex = "请输入4位以上设备号";
break break;
case '2': case "2":
tex = '请输入6位以上车架号' tex = "请输入6位以上车架号";
break break;
case '3': case "3":
tex = '请输入1位以上汉字' tex = "请输入1位以上汉字";
break break;
} }
this.placeholderText = tex this.placeholderText = tex;
}, },
// 勾选树 // 勾选树
handleCheck(data, node) { handleCheck(data, node) {
...@@ -537,7 +733,6 @@ export default { ...@@ -537,7 +733,6 @@ export default {
} }
}, },
loadNode(node, resolve) { loadNode(node, resolve) {
console.log(node);
let _this = this; let _this = this;
let id = node.data.id; let id = node.data.id;
const nodeData = node.data; const nodeData = node.data;
...@@ -1243,6 +1438,10 @@ export default { ...@@ -1243,6 +1438,10 @@ export default {
}, },
mounted() { mounted() {
let _this = this; let _this = this;
if (window.AMap) {
window.AMap = null;
}
AMapLoader.reset();
AMapLoader.load({ AMapLoader.load({
key: CONSTANT.MAP_KEY, key: CONSTANT.MAP_KEY,
version: "1.4.2", version: "1.4.2",
...@@ -1250,6 +1449,8 @@ export default { ...@@ -1250,6 +1449,8 @@ export default {
}).then((AMap) => { }).then((AMap) => {
window.AMap = AMap; window.AMap = AMap;
_this.initMap(); _this.initMap();
}).catch(error => {
window.location.reload()
}); });
}, },
beforeDestroy() { beforeDestroy() {
......
<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">
<glsx-image src="car.png" class="img img_normal" />
<glsx-image src="car_hover.png" class="img img_hover" />
<!-- <img src="@/assets/images/car.png" class="img img_normal" alt="" />
<img src="@/assets/images/car_hover.png" class="img img_hover" alt="" /> -->
</div>
<div class="row_box" v-else>
<div class="hide_icon" @click="onShow">
<!-- <img src="@/assets/images/hide.png" class="img" alt="" /> -->
<glsx-image src="hide.png" class="img" />
</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"
>
<div v-show="menuId == 1">
<el-form-item label="行政区域">
<CitySelect
ref="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>
</div>
<div v-show="menuId == 2">
<el-form-item label="设备号">
<div class="device_label" slot="label">
<span>设备号</span>
<el-tooltip
content="请先设备号精准搜索设备定位后,再进行“选择区域”操作"
placement="top"
>
<i class="el-icon-warning-outline"></i>
</el-tooltip>
</div>
<div class="device_item">
<el-input
v-model="form.sn"
placeholder="请输入您要查询的设备号"
/>
<el-button
type="primary"
class="btn"
:disabled="!form.sn"
@click="getLocation"
>搜索</el-button
>
</div>
</el-form-item>
</div>
<el-form-item label="">
<div>
<el-button class="area_btn" @click="chooseArea"
>选择区域</el-button
>
<span class="clear_link" @click="onClear">清除</span>
</div>
</el-form-item>
<div class="tips_info">
<span
>长度:<i>{{ rectangleWidth || "--" }}</i
>m</span
>
<span
>宽度:<i>{{ rectangleHeight || "--" }}</i
>m</span
>
</div>
<div class="btn_group">
<el-button
type="primary"
class="search_btn"
:loading="loading"
:disabled="!rectangle"
@click="getAreaLocation"
>查询</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">
<!-- <vxe-grid
:columns="columns"
ref="xGrid"
max-height="100%"
:data="deviceList"
size="small"
show-overflow
v-if="drawDone"
>
</vxe-grid> -->
<!-- <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, deepClone } 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: 0, // 矩形宽度
rectangleHeight: 0, // 矩形高度
bHeight: 313,
hInterval: null,
hideRowBox: false,
hideFooter: true,
//rectangleInfo:{}, // 矩形坐标点信息
deviceList: [],
loading: false,
dloading: false,
autoOpenLastInfoWindow: false,
columns: [
{ type: "seq", title: "序号", width: "55px" },
{ field: "workOrderNo", title: "业务工单号" },
{ field: "shopName", title: "店面名称" },
{ field: "ownerName", title: "姓名" },
{ field: "vin", title: "车架号" },
{ field: "sn", title: "设备号" },
{ field: "activeDate", title: "激活时间" },
{ field: "deviceTypeStr", title: "设备类型" },
{ field: "finalGpsTime", title: "最后GPS定位时间" },
{ field: "finalGpsAddress", title: "最后GPS定位地址", width: "300px" },
],
drawDone: false,
location: {}, // 设备维度查询的位置点
};
},
mounted() {
this.initMap();
},
methods: {
// 地图初始化
initMap() {
let _this = this;
let plugins = CONSTANT.MAP_PLUGINS.concat([
"AMap.LngLat",
"AMap.Rectangle",
"AMap.RectangleEditor",
"AMap.LabelsLayer",
"AMap.LabelMarker",
]);
if (window.AMap) {
window.AMap = null;
}
AMapLoader.reset();
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: plugins, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map");
})
.catch((error) => {
console.log(error);
window.location.reload();
});
},
// 画矩形
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();
// }
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,
});
rectangleEditor = new AMap.RectangleEditor(this.map, rectangle);
rectangleEditor.open();
rectangleEditor.on("adjust", function (event) {
_this.calculateWidthHeight(event.bounds);
});
this.map.add(rectangle);
this.map.setFitView(rectangle);
// rectangle.on("dragend", function (event) {
// console.log("拖动:", event);
// });
this.rectangleEditor = rectangleEditor;
this.rectangle = rectangle;
this.rectangleHeight = 500;
this.rectangleWidth = 500;
this.map.setZooms([12, 30]);
},
/**
* 计算对应点的位置
* lng:中心点经度 lat:中心点维度 距离默认500m
* 垂直距离lath(所求点在已知点上方(北方)为正,否则为负)
* 水平距离longw(所求点在已知点右方(东方)为正,否则为负)
* lat = latitude + lath / (ARC * math.pi / 180);
* lng = 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;
},
// 第二种算法
/**
* 距离dis的单位是米(默认500M),deg是方位角,需要化为弧度。lon1,lat1是起始点经纬度信息
* 左侧开始,角度0,逆时针方向360度
* long1 + dis*math.sin(deg)/(arc*math.cos(lati1)*2*math.pi/360)
* lati1 + dis*math.cos(deg)/(arc*2*math.pi/360)
*/
getLngLat2(lng, lat, w) {
let arc = 6371.393 * 1000;
let pi = Math.PI;
let num = w ? w / 2 : 500 / 2;
// 中心点-左边点的经纬度
let leftLng = lng + (num * Math.sin(180)) / ((arc * Math.cos(lat) * 2 * pi) / 360);
// let leftLat = lat;
// 中心点-下边点的经纬度
// let bottomLng = lng;
let bottomLat = lat + (num * Math.cos(270)) / ((arc * 2 * pi) / 360);
// 中心点-右边点经纬度
let rightLng =
lng + (num * Math.sin(0)) / ((arc * Math.cos(lat) * 2 * pi) / 360);
// let rightLat = lat;
// 中心点-上边点经纬度
// let topLng = lng;
let topLat = lat + (num * Math.cos(90)) / ((arc * 2 * pi) / 360);
// 左下角 经纬度 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 chooseArea() {
let _type = this.menuId;
let o = this.form;
let location = {};
if (_type == 1) {
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.location;
}
// 如果location 不存在,则以地图中心点来画矩形
if (!location.lng || !location.lat) {
location = this.map.getCenter();
}
console.log(location);
let lnglats = this.getLngLat(location.lng, location.lat);
console.log(lnglats)
console.log(this.getLngLat2(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 = 0;
this.rectangleWidth = 0;
this.rectangle = null;
this.rectangleEditor = null;
this.map.setZooms([2, 30]);
},
// 清空筛选条件
onClear() {
this.clearMap();
this.rectangleHeight = 0;
this.rectangleWidth = 0;
this.form = {};
this.deviceList = [];
this.$refs.citySelect.reset();
},
// 展开
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;
},
// 添加位置点
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) {
console.log(e);
let code = e.code;
let o = e.name;
let str = o[0] + o[1] + o[2];
this.$set(this.form, "name", str);
this.drawDistrict(code);
},
// 切换类型
menuEvent(row) {
this.menuId = row.id;
},
// 设备号查车
async getLocation() {
let params = {};
this.clearMap();
params.sns = this.form.sn;
params.deviceCode = "gps";
let res = await GET_DEVICEINFO_BYSNS(params);
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.autoOpenLastInfoWindow = true;
// if (this.autoOpenLastInfoWindow) {
// this.autoOpenLastInfoWindow = false;
// }
//this.addLocation(o, this.autoOpenLastInfoWindow);
this.location = o;
});
this.addMarkers(arr);
},
// 区域查车
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 || [];
_this.deviceList = list;
_this.hideFooter = false;
_this.addMarkers(list);
},
// 在地图上画行政区域
drawDistrict(areaCode) {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
},
// 添加海量点
addMarkers(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: [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);
}
layer.add(markers);
console.log("画点结束", new Date().getTime());
this.drawDone = true;
this.map.setFitView();
},
},
};
</script>
<style lang="scss" scoped>
@import "../../assets/scss/zoneCar.scss";
</style>
\ No newline at end of file \ No newline at end of file
<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-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-show="!hideRowBox">
<div class="hide_icon" @click="onShow">
<glsx-image src="hide.png" class="img" />
</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"
:rules="formRules"
class="el_form"
label-position="top"
hide-required-asterisk
>
<div v-show="menuId == 1">
<el-form-item label="详细地址">
<div class="device_item">
<el-input
ref="addressInput"
v-model.trim="form.address"
id="tipInput"
maxlength="50"
placeholder="请输入详细地址"
@keyup.enter.native="getAddress"
/>
<el-button
type="primary"
class="btn"
:disabled="!form.address"
@click="getAddress"
>搜索</el-button
>
</div>
</el-form-item>
</div>
<div v-show="menuId == 2">
<el-form-item label="设备号" prop="sn">
<div class="device_label" slot="label">
<span>设备号</span>
<el-popover
trigger="hover"
placement="top"
content="请先设备号精准搜索设备定位后,再进行“划定区域”操作"
>
<glsx-image
slot="reference"
src="circle-question.png"
class="img"
/>
</el-popover>
</div>
<div class="device_item">
<el-input
v-model.trim="form.sn"
maxlength="50"
placeholder="请输入您要查询的设备号"
@keyup.enter.native="getLocation"
/>
<el-button
type="primary"
class="btn"
:disabled="!form.sn"
@click="getLocation"
>搜索</el-button
>
</div>
</el-form-item>
</div>
<el-form-item label="">
<div class="draw_area">
<el-button class="area_btn" @click="chooseArea"
>划定区域</el-button
>
<span class="clear_link" @click="onClear">清除</span>
</div>
</el-form-item>
<div class="tips_info">
<span
>长度:<i>{{ rectangleWidth || "--" }}</i
>m</span
>
<span
>宽度:<i>{{ rectangleHeight || "--" }}</i
>m</span
>
</div>
<div class="btn_group">
<el-button
type="primary"
class="search_btn"
:loading="loading"
:disabled="!rectangle"
@click="getAreaLocation"
>查询</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" @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">
<vxe-grid
:columns="columns"
ref="xGrid"
max-height="100%"
:data="deviceList"
size="small"
show-overflow
v-if="drawDone"
>
</vxe-grid>
</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 {
GER_REGIONAL_SEARCH,
GER_REGIONAL_EXPORT,
GER_REGIONAL_LOCATION,
} from "@/api/services/zooneCar";
import EventBus from "@/event-bus";
import { showToast, deepClone } from "@/utils/utils.js";
import { Validator, CHECK_NUMBER } from "@/common/validator";
export default {
data() {
return {
menus: [
{ name: "区域查车", id: 1 },
{ name: "设备号查车", id: 2 },
],
menuId: 1,
map: null,
mapLoading: true,
form: {},
formRules: {
sn: [
{ required: true, message: "请输入设备号", trigger: "blur" },
{ validator: CHECK_NUMBER, trigger: "blur" },
],
},
rectangle: null,
rectangleEditor: null,
rectangleWidth: 0, // 矩形宽度
rectangleHeight: 0, // 矩形高度
bHeight: 313,
hInterval: null,
hideRowBox: false,
hideFooter: true,
//rectangleInfo:{}, // 矩形坐标点信息
deviceList: [],
loading: false,
dloading: false,
columns: [
{ type: "seq", title: "序号", width: "55px" },
{ field: "workOrderNo", title: "业务工单号" },
{ field: "shopName", title: "店面名称" },
{ field: "ownerName", title: "姓名" },
{ field: "vin", title: "车架号" },
{ field: "sn", title: "设备号" },
{ field: "sourceStr", title: "设备类型" },
{ field: "activeDate", title: "激活时间" },
{ field: "finalGpsTime", title: "最后GPS定位时间" },
{ field: "finalGpsAddress", title: "最后GPS定位地址", width: "300px" },
],
drawDone: false,
location: {}, // 设备维度查询的位置点
autoCenterMarker: null,
mouseTool: null,
mapMass: null,
poi: {},
};
},
mounted() {
this.initMap();
},
methods: {
// 地图初始化
initMap() {
let _this = this;
let plugins = CONSTANT.MAP_PLUGINS.concat([
"AMap.LngLat",
"AMap.Rectangle",
"AMap.LabelsLayer",
"AMap.LabelMarker",
"AMap.AutoComplete",
"AMap.MassMarks",
"AMap.MarkerCluster",
]);
if (window.AMap) {
window.AMap = null;
}
AMapLoader.reset();
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: plugins, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map", { zoom: 12 });
_this.mouseTool = new AMap.MouseTool(_this.map);
var autoComplete = new AMap.AutoComplete({
input: "tipInput",
});
autoComplete.on("select", function (e) {
console.log(e);
let poi = e.poi || {};
_this.poi = poi;
_this.$refs.addressInput.focus();
});
})
.catch((error) => {
console.log(error);
window.location.reload();
});
},
// 获取地址
getAddress() {
let _this = this;
let poi = this.poi;
_this.clearMap();
if (poi && poi.location) {
_this.autoCenterMarker = mapService.createMarker(poi.location);
_this.map.setFitView();
_this.map.add(_this.autoCenterMarker);
}
},
// 选择区域
async chooseArea() {
let _this = this;
let _map = this.map;
let _zoom = _map.getZoom();
if (_this.rectangle) {
showToast({
message: "地图上已有矩形,请先清除再画",
});
return false;
}
// if (_this.mouseTool) {
// _this.mouseTool.close();
// return false;
// }
if (_zoom < 14) {
_this.map.setZoom(14);
}
_this.map.setZooms([14, 30]);
if (_this.mouseTool) {
_this.mouseTool.rectangle({
fillColor: "#2C68FF",
strokeColor: "#2C68FF",
fillOpacity: 0.3,
strokeWeight: 4,
strokeOpacity: 1,
draggable: true,
});
_this.mouseTool.on("draw", function (e) {
let rectangle = e.obj;
_this.mouseTool.close();
_this.rectangle = rectangle;
_this.calculateWidthHeight(rectangle.getOptions().bounds);
});
}
},
// 计算矩形宽度、高度
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() {
if (this.map) {
this.map.clearMap();
}
this.rectangleHeight = 0;
this.rectangleWidth = 0;
this.rectangle = null;
//this.mouseTool = null;
this.deviceList = [];
this.map.setZooms([2, 30]);
},
// 清空筛选条件
onClear() {
this.clearMap();
this.rectangleHeight = 0;
this.rectangleWidth = 0;
this.form = {};
this.deviceList = [];
if (this.mouseTool) {
this.mouseTool.close(true);
//this.mouseTool = null;
}
},
// 展开
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;
},
// 添加位置点
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();
if (!params.leftLngLat) {
showToast({
message: "请先划定区域",
});
return false;
}
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) {
console.log(e);
let code = e.code;
let o = e.name;
let str = o[0] + o[1] + o[2];
this.$set(this.form, "name", str);
this.drawDistrict(code);
},
// 切换类型
menuEvent(row) {
this.menuId = row.id;
this.$refs.form.clearValidate("sn");
},
// 设备号查车
getLocation() {
let _this = this;
let params = {};
this.clearMap();
params.sns = this.form.sn;
params.deviceCode = "gps";
this.$refs.form.validate((valid) => {
if (!valid) {
return false;
}
GER_REGIONAL_LOCATION(params).then((res) => {
let list = res.data || [];
if (res.code != 200) {
showToast({
message: res.message,
});
return false;
}
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);
});
});
// if (!this.form.sn) {
// showToast({
// message: "请输入设备号",
// });
// return false;
// }
// if (!Validator.ISDECIMAL.test(this.form.sn)) {
// showToast({
// message: "设备号必须为纯数字",
// });
// return false;
// }
},
// 区域查车
async getAreaLocation() {
let _this = this;
let params = this.getParams();
if (!_this.rectangle) {
showToast({
message: "请先划定区域",
});
return false;
}
_this.deviceList = [];
if (_this.mapMass) {
_this.mapMass.clear();
_this.mapMass = null;
}
_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 || [];
_this.deviceList = list;
_this.hideFooter = false;
_this.addMarkers(list);
},
// 在地图上画行政区域
drawDistrict(areaCode) {
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) {
let _this = this;
let markers = [];
let icon = {
type: "image",
url: require("images/icon_car.png"),
size: [24, 15],
anchor: new AMap.Pixel(4, 4),
};
for (let i = 0, len = arr.length; i < len; i++) {
let k = arr[i];
k.lnglat = [k.lng, k.lat];
markers.push(k);
}
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;
if(arr && arr.length<10){
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>
<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: '历史停留' },
......
...@@ -20,11 +20,15 @@ function MapService() { ...@@ -20,11 +20,15 @@ function MapService() {
var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据 var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据
MapService.prototype = { MapService.prototype = {
init: function (id) { init: function (id,options) {
var self = this; var self = this;
let params = options||{}
if(self.map){
self.map.destroy()
}
var map = new AMap.Map(id, { var map = new AMap.Map(id, {
resizeEnable: true, resizeEnable: true,
zoom: 11 zoom: params.zoom||11
}); });
// 添加比例尺 // 添加比例尺
...@@ -854,8 +858,31 @@ MapService.prototype = { ...@@ -854,8 +858,31 @@ MapService.prototype = {
openPage(path) { openPage(path) {
vue.prototype.$parentCommon.setBreadCrumbs(path); vue.prototype.$parentCommon.setBreadCrumbs(path);
window.open(path) window.open(path)
} },
// 区域查车弹框
createAraeInfowindow(info){
let _types = {
1:'有线设备',
0:'无线设备'
}
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||'--'} (${_types[info.source]||'--'})</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>
<i class="text" data-battery-text>${info.battery}</i>
</span></p>
</div>`;
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, -20),
content: _div,
autoMove: true,
position:[info.lng,info.lat]
})
return infoWindow
},
} }
......
...@@ -2,13 +2,32 @@ const MAPGEO = { ...@@ -2,13 +2,32 @@ const MAPGEO = {
geocoder: null, geocoder: null,
getGeocoder: function () { getGeocoder: function () {
return new Promise((resolve) => { return new Promise((resolve) => {
AMap.service('AMap.Geocoder', function () {//回调函数 // 高德地图兼容方式,兼容低版本
// if(AMap.service){
// AMap.service('AMap.Geocoder', function () {//回调函数
// var geocoder = new AMap.Geocoder({
// batch: true
// });
// MAPGEO.geocoder = geocoder;
// resolve(geocoder);
// });
// }else{
// AMap.plugin('AMap.Geocoder', function () {//回调函数
// var geocoder = new AMap.Geocoder({
// batch: true
// });
// MAPGEO.geocoder = geocoder;
// resolve(geocoder);
// });
// }
AMap.plugin('AMap.Geocoder', function () {//回调函数
var geocoder = new AMap.Geocoder({ var geocoder = new AMap.Geocoder({
batch: true batch: true
}); });
MAPGEO.geocoder = geocoder; MAPGEO.geocoder = geocoder;
resolve(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!