Commit 2b355927 by 张杰

Merge branch 'v1.23.0' into 'develop'

V1.23.0版本需求已上线,合并代码到master

See merge request !37
2 parents 6a5c737f 74e9eed3
...@@ -1591,6 +1591,16 @@ ...@@ -1591,6 +1591,16 @@
"integrity": "sha1-MgmlHKSkrVQaO409am1bg6JIWTU=", "integrity": "sha1-MgmlHKSkrVQaO409am1bg6JIWTU=",
"dev": true "dev": true
}, },
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmmirror.com/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"dev": true,
"optional": true,
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"bluebird": { "bluebird": {
"version": "3.5.1", "version": "3.5.1",
"resolved": "http://registry.npm.taobao.org/bluebird/download/bluebird-3.5.1.tgz", "resolved": "http://registry.npm.taobao.org/bluebird/download/bluebird-3.5.1.tgz",
...@@ -4217,6 +4227,13 @@ ...@@ -4217,6 +4227,13 @@
"schema-utils": "^0.4.5" "schema-utils": "^0.4.5"
} }
}, },
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"dev": true,
"optional": true
},
"filename-regex": { "filename-regex": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "http://registry.npm.taobao.org/filename-regex/download/filename-regex-2.0.1.tgz", "resolved": "http://registry.npm.taobao.org/filename-regex/download/filename-regex-2.0.1.tgz",
...@@ -4445,8 +4462,9 @@ ...@@ -4445,8 +4462,9 @@
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"nan": "^2.3.0", "bindings": "^1.5.0",
"node-pre-gyp": "^0.6.39" "nan": "^2.12.1",
"node-pre-gyp": "*"
}, },
"dependencies": { "dependencies": {
"abbrev": { "abbrev": {
...@@ -4997,6 +5015,13 @@ ...@@ -4997,6 +5015,13 @@
"dev": true, "dev": true,
"optional": true "optional": true
}, },
"nan": {
"version": "2.17.0",
"resolved": "https://registry.npmmirror.com/nan/-/nan-2.17.0.tgz",
"integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==",
"dev": true,
"optional": true
},
"node-pre-gyp": { "node-pre-gyp": {
"version": "0.6.39", "version": "0.6.39",
"bundled": true, "bundled": true,
...@@ -8376,13 +8401,6 @@ ...@@ -8376,13 +8401,6 @@
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=",
"dev": true "dev": true
}, },
"nan": {
"version": "2.10.0",
"resolved": "http://registry.npm.taobao.org/nan/download/nan-2.10.0.tgz",
"integrity": "sha1-ltDNYQ69WNS03pzAxoKM2pnHVI8=",
"dev": true,
"optional": true
},
"nanomatch": { "nanomatch": {
"version": "1.2.9", "version": "1.2.9",
"resolved": "http://registry.npm.taobao.org/nanomatch/download/nanomatch-1.2.9.tgz", "resolved": "http://registry.npm.taobao.org/nanomatch/download/nanomatch-1.2.9.tgz",
......
import request from './request'
// 新增poi点
export const ADD_POI_INFO = params => {
return request(params, '/trialdrive/poifence/add', 'post')
}
// 修改poi点信息
export const UPDATE_POI_INFO = params => {
return request(params, '/trialdrive/poifence/update', 'post')
}
// 修改poi点状态
export const MODIFY_POI_INFO = params => {
return request(params, '/trialdrive/poifence/modify', 'get')
}
// 删除poi点
export const DELETE_POI_INFO = params => {
return request(params, '/trialdrive/poifence/delete', 'get')
}
// 获取历史poi点
export const GET_POI_TRACK = params => {
return request(params, '/trialdrive/poifence/queryPoiTrack', 'get')
}
// 获取历史poi详情
export const GET_POI_INFO = params => {
return request(params, '/trialdrive/poifence/findone', 'get')
}
// 校验poi名称
export const CHECK_POI_NAME = params => {
return request(params, '/trialdrive/poifence/checkPoiName', 'get')
}
.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;
transform: scaleY(0.5);
opacity: 0.5;
}
.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;
}
}
.addPoiForm {
display: flex;
padding: 20px;
.form_list {
flex: 1;
}
.lnglat_box {
display: flex;
.el-form-item {
flex: 1;
}
}
}
.btn_box {
display: flex;
justify-content: flex-end;
border-top: 1px solid #f2f2f2;
padding: 10px 20px;
}
.map-seacrh-wrap {
position: absolute;
top: 40px;
left: 10px;
z-index: 1000;
}
\ No newline at end of file \ No newline at end of file
...@@ -571,28 +571,31 @@ ...@@ -571,28 +571,31 @@
.map-infowindow-title { .map-infowindow-title {
position: relative; position: relative;
padding-right:30px; padding-right: 30px;
.question_icon { .question_icon {
display:inline-block; display: inline-block;
background: url('https://img01.glsx.com.cn/weapp/resource/e-shield/circle-question.png') no-repeat; background: url('https://img01.glsx.com.cn/weapp/resource/e-shield/circle-question.png') no-repeat;
background-size: 20px auto; background-size: 20px auto;
width: 20px; width: 20px;
height: 20px; height: 20px;
vertical-align: middle; vertical-align: middle;
} }
.popover_box { .popover_box {
position: absolute; position: absolute;
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
top: 20px; top: 20px;
right: 0px; right: 0px;
padding:10px; padding: 10px;
z-index:2; z-index: 2;
border-radius:4px; border-radius: 4px;
color:#fff; color: #fff;
font-size:12px; font-size: 12px;
pointer-events: none; pointer-events: none;
p{
margin:0; p {
margin: 0;
} }
} }
} }
...@@ -600,5 +603,47 @@ ...@@ -600,5 +603,47 @@
.map_info_window { .map_info_window {
position: relative; position: relative;
}
// 新增poi 弹框样式
.map_poi_infowindow_popup {
width: 360px;
}
.map_poi_infowindow_title {
position: relative;
padding: 0 10px 10px 10px;
max-width: 400px;
}
.map_poi_infowindow_title:after {
display: block;
content: "";
height: 1px;
background: #f2f2f2;
position: absolute;
left: -10px;
right: -10px;
bottom: 0;
}
.map_poi_infowindow_content {
padding: 10px;
display: flex;
justify-content: space-between;
.clear_link {
flex-shrink: 0;
background: #409EFF;
border-radius: 4px;
border: 0;
color: #fff;
padding: 4px 10px;
cursor: pointer;
}
.clear_link:hover {
opacity: 0.8;
}
} }
\ No newline at end of file \ No newline at end of file
// 图片请求域名前缀
export const IMAGE_PREFIX = 'https://img01.glsx.com.cn/weapp/resource';
export const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899' export const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899'
export const MAP_SERVICE_KEY = 'd22348363c34c266f772ae9b635eef2a' export const MAP_SERVICE_KEY = 'd22348363c34c266f772ae9b635eef2a'
...@@ -22,5 +25,10 @@ export const CONSTANT = { ...@@ -22,5 +25,10 @@ export const CONSTANT = {
MAP_KEY, MAP_KEY,
MAP_SERVICE_KEY, MAP_SERVICE_KEY,
MAP_PLUGINS, MAP_PLUGINS,
AMAP_URL: `https://webapi.amap.com/maps?v=1.4.2&key=${MAP_KEY}&plugin=${MAP_PLUGINS.toString()}` }
// 静态图标地址
export const STATICIMAGE = {
POI_MARKER:`${IMAGE_PREFIX}/e-shield/poi_icon.gif`,
POI_MASS_ICON:`${IMAGE_PREFIX}/e-shield/poi-marker-default.png`
} }
\ No newline at end of file \ No newline at end of file
...@@ -20,6 +20,10 @@ import store from '@/vuex/store.js' ...@@ -20,6 +20,10 @@ import store from '@/vuex/store.js'
import App from '@/App.vue' import App from '@/App.vue'
import Vue from 'vue' import Vue from 'vue'
// 全局引入地图
import {mapInit} from '@/utils/mapInit';
Vue.prototype.$mapInit = mapInit
Vue.component('vLayout', vLayout) Vue.component('vLayout', vLayout)
Vue.component('vFullLayout', vFullLayout) Vue.component('vFullLayout', vFullLayout)
......
<template> <template>
<!-- 查看详情弹框 --> <!-- 查看详情弹框 -->
<el-dialog id="userCarModal" :close-on-click-modal="flag" @click="clickUser" :visible="detailFormVisible" @opened="openDialog" @close="closeDialog" append-to-body width="900px"> <el-dialog
<div class="dialog-header" slot="title"> id="userCarModal"
<h2 class="header-title">车辆管理</h2> :close-on-click-modal="flag"
<nav class="header-nav"> @click="clickUser"
<a :class="scrollToRef=='detailForm'?'active':''" @click="scrollTo('detailForm')">设备信息</a> :visible="detailFormVisible"
<a :class="scrollToRef=='userInfo'?'active':''" @click="scrollTo('userInfo')">用户信息</a> @opened="openDialog"
<a :class="scrollToRef=='carInfo'?'active':''" @click="scrollTo('carInfo')">车辆信息</a> @close="closeDialog"
<a :class="scrollToRef=='clientInfo'?'active':''" @click="scrollTo('clientInfo')">关联商户</a> append-to-body
<a :class="scrollToRef=='log'?'active':''" @click="scrollTo('log')">操作日志</a> width="900px"
<!-- <a :class="scrollToRef=='poi'?'active':''" @click="scrollTo('poi')">POI信息</a> --> >
</nav> <div class="dialog-header" slot="title">
</div> <h2 class="header-title">车辆管理</h2>
<div v-show="showTab==='form'"> <nav class="header-nav">
<el-form ref="detailForm" :model="detailForm" :rules="rules" :inline="false" size="mini" label-width="110px" > <a
<h3>设备信息</h3> :class="scrollToRef == 'detailForm' ? 'active' : ''"
@click="scrollTo('detailForm')"
<el-row> >设备信息</a
<el-col :span="16"> >
<a
<el-row v-for="(item, index) in deviceArr" :key="index"> :class="scrollToRef == 'userInfo' ? 'active' : ''"
<el-col :span="12"> @click="scrollTo('userInfo')"
<el-form-item label="设备SN号" prop="device"> >用户信息</a
<el-input v-model="item.sn"></el-input> >
</el-form-item> <a
</el-col> :class="scrollToRef == 'carInfo' ? 'active' : ''"
<el-col :span="12"> @click="scrollTo('carInfo')"
<el-form-item label="设备型号"> >车辆信息</a
<el-input disabled v-model="item.deviceType"></el-input> >
</el-form-item> <a
</el-col> :class="scrollToRef == 'clientInfo' ? 'active' : ''"
<!-- <el-col :span="8"> @click="scrollTo('clientInfo')"
>关联商户</a
>
<a
:class="scrollToRef == 'log' ? 'active' : ''"
@click="scrollTo('log')"
>操作日志</a
>
<!-- <a :class="scrollToRef=='poi'?'active':''" @click="scrollTo('poi')">POI信息</a> -->
</nav>
</div>
<div v-show="showTab === 'form'">
<el-form
ref="detailForm"
:model="detailForm"
:rules="rules"
:inline="false"
size="mini"
label-width="110px"
>
<h3>设备信息</h3>
<el-row>
<el-col :span="16">
<el-row v-for="(item, index) in deviceArr" :key="index">
<el-col :span="12">
<el-form-item label="设备SN号" prop="device">
<el-input v-model="item.sn"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="设备型号">
<el-input disabled v-model="item.deviceType"></el-input>
</el-form-item>
</el-col>
<!-- <el-col :span="8">
<el-form-item label="*设备SN号"> <el-form-item label="*设备SN号">
<el-input disabled v-model="detailForm.trackInfo.sn"></el-input> <el-input disabled v-model="detailForm.trackInfo.sn"></el-input>
</el-form-item> </el-form-item>
...@@ -47,742 +82,846 @@ ...@@ -47,742 +82,846 @@
<p class="tip el-alert--error">验证不通过<br>{{detailForm.trackInfo.activeDate}}</p> <p class="tip el-alert--error">验证不通过<br>{{detailForm.trackInfo.activeDate}}</p>
</el-form-item> </el-form-item>
</el-col> --> </el-col> -->
</el-row> </el-row>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<i @click="addDevice" class="el-icon-circle-plus-outline" style="font-size: 20px; margin-left:20px; line-height:30px;"></i> <i
</el-col> @click="addDevice"
</el-row> class="el-icon-circle-plus-outline"
<p style="text-align:center; margin: 0"></p> style="font-size: 20px; margin-left: 20px; line-height: 30px"
<h3 ref="userInfo">用户信息</h3> ></i>
<el-row> </el-col>
<el-col :span="12"> </el-row>
<el-form-item label="姓名" prop="name"> <p style="text-align: center; margin: 0"></p>
<el-input :disabled="!isEdit&&detailForm.insuraceStatus!==1" v-model="detailForm.name"></el-input> <h3 ref="userInfo">用户信息</h3>
</el-form-item> <el-row>
</el-col> <el-col :span="12">
<el-col :span="12"> <el-form-item label="姓名" prop="name">
<el-form-item label="性别"> <el-input
<el-select v-model.trim="detailForm.userSex" placeholder="请选择" size="small" style="width:100px;" :disabled="!isEdit"> :disabled="!isEdit && detailForm.insuraceStatus !== 1"
<el-option label="男" :value="1"></el-option> v-model="detailForm.name"
<el-option label="女" :value="2"></el-option> ></el-input>
</el-select> </el-form-item>
</el-form-item> </el-col>
</el-col> <el-col :span="12">
<el-col :span="12"> <el-form-item label="性别">
<el-form-item label="联系方式" prop="userTel"> <el-select
<el-input :disabled="!isEdit" v-model="detailForm.userTel"></el-input> v-model.trim="detailForm.userSex"
</el-form-item> placeholder="请选择"
</el-col> size="small"
</el-row> style="width: 100px"
:disabled="!isEdit"
<h3 ref="carInfo">车辆信息</h3> >
<el-row> <el-option label="男" :value="1"></el-option>
<el-col :span="20"> <el-option label="女" :value="2"></el-option>
</el-select>
<!-- <el-form-item label="车牌号"> </el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系方式" prop="userTel">
<el-input
:disabled="!isEdit"
v-model="detailForm.userTel"
></el-input>
</el-form-item>
</el-col>
</el-row>
<h3 ref="carInfo">车辆信息</h3>
<el-row>
<el-col :span="20">
<!-- <el-form-item label="车牌号">
<el-input :disabled="!isEdit" v-model="detailForm.plateNumber"></el-input> <el-input :disabled="!isEdit" v-model="detailForm.plateNumber"></el-input>
</el-form-item> --> </el-form-item> -->
<plate-number-input <plate-number-input
label="车牌号" label="车牌号"
prop="plateNumber" prop="plateNumber"
:disabled="!isEdit" :disabled="!isEdit"
:plateNumber="detailForm.plateNumber" :plateNumber="detailForm.plateNumber"
:init="plateNumberInit" :init="plateNumberInit"
@onPlateNumberInitChange="plateNumberInit=false" @onPlateNumberInitChange="plateNumberInit = false"
@onPlateNumberChange="plateNumberChange"> @onPlateNumberChange="plateNumberChange"
</plate-number-input> >
<el-form-item label="*车架号"> </plate-number-input>
<el-input disabled v-model="detailForm.standNo"></el-input> <el-form-item label="*车架号">
</el-form-item> <el-input disabled v-model="detailForm.standNo"></el-input>
</el-form-item>
<el-form-item label="发动机号">
<el-input disabled v-model="detailForm.engine"></el-input> <el-form-item label="发动机号">
</el-form-item> <el-input disabled v-model="detailForm.engine"></el-input>
</el-form-item>
<el-form-item label="车辆分组">
<el-input disabled v-model="detailForm.groupName"></el-input> <el-form-item label="车辆分组">
</el-form-item> <el-input disabled v-model="detailForm.groupName"></el-input>
</el-form-item>
<!-- <el-input :disabled="!isEdit&&detailForm.insuraceStatus!==1" disabled v-model="detailForm.vehicleTypeName"></el-input> --> <!-- <el-input :disabled="!isEdit&&detailForm.insuraceStatus!==1" disabled v-model="detailForm.vehicleTypeName"></el-input> -->
<v-vechicle-brand label="品牌/车型" <v-vechicle-brand
:brandId="detailForm.vehicleBrandId" label="品牌/车型"
:typeId="detailForm.vehicleTypeId" :brandId="detailForm.vehicleBrandId"
:init="brandInit" :typeId="detailForm.vehicleTypeId"
@onBrandInitChange="brandInit=false" :init="brandInit"
@onBrandChange="brandChange" @onBrandInitChange="brandInit = false"
prop="vechicleBrand" @onBrandChange="brandChange"
:disabled="!isEdit&&detailForm.insuraceStatus!==1"> prop="vechicleBrand"
</v-vechicle-brand> :disabled="!isEdit && detailForm.insuraceStatus !== 1"
>
</v-vechicle-brand>
<el-form-item label="排量" prop="displacement" >
<el-input :disabled="!isEdit" v-model="detailForm.displacement"><template slot="append">L</template></el-input> <el-form-item label="排量" prop="displacement">
</el-form-item> <el-input :disabled="!isEdit" v-model="detailForm.displacement"
</el-col> ><template slot="append">L</template></el-input
</el-row> >
<el-row> </el-form-item>
<el-col :span="6"> </el-col>
<el-form-item label="车辆标签" v-if="carRemark" prop="carRemarkType"> </el-row>
<el-select :disabled="!isEdit" v-model="detailForm.carRemarkType" style="width:120px;" placeholder="请选择" size="small"> <el-row>
<el-option label="试驶车" :value="1"></el-option> <el-col :span="6">
<el-option label="服务车" :value="2"></el-option> <el-form-item
<el-option label="代步车" :value="3"></el-option> label="车辆标签"
<el-option label="救援车" :value="4"></el-option> v-if="carRemark"
<el-option label="办公车" :value="5"></el-option> prop="carRemarkType"
<el-option label="其他" :value="6"></el-option> >
</el-select> <el-select
</el-form-item> :disabled="!isEdit"
</el-col> v-model="detailForm.carRemarkType"
<el-col :span="14"> style="width: 120px"
<el-form-item label="车辆用途" v-if="carUsed" prop="carUsed"> placeholder="请选择"
<el-input :disabled="!isEdit" v-model.trim="detailForm.carUsed" maxlength="20"></el-input> size="small"
</el-form-item> >
</el-col> <el-option label="试驶车" :value="1"></el-option>
</el-row> <el-option label="服务车" :value="2"></el-option>
<el-row> <el-option label="代步车" :value="3"></el-option>
<el-col :span="20"> <el-option label="救援车" :value="4"></el-option>
<el-form-item label="备注"> <el-option label="办公车" :value="5"></el-option>
<el-input :disabled="!isEdit" v-model="detailForm.remark" type="textarea" :rows="3"></el-input> <el-option label="其他" :value="6"></el-option>
</el-form-item> </el-select>
</el-col> </el-form-item>
</el-row> </el-col>
<el-col :span="14">
<h3 ref="clientInfo">关联商户</h3> <el-form-item label="车辆用途" v-if="carUsed" prop="carUsed">
<el-row > <el-input
<el-col :span="20"> :disabled="!isEdit"
<el-form-item label="店面名称"> v-model.trim="detailForm.carUsed"
<el-input disabled v-model="detailForm.shopName"></el-input> maxlength="20"
</el-form-item> ></el-input>
</el-form-item>
<el-form-item label="店面联系人"> </el-col>
<el-input disabled v-model="detailForm.shopContacts"></el-input> </el-row>
</el-form-item> <el-row>
<el-col :span="20">
<el-form-item label="店面联系方式"> <el-form-item label="备注">
<el-input disabled v-model="detailForm.contactsPhone"></el-input> <el-input
</el-form-item> :disabled="!isEdit"
v-model="detailForm.remark"
<el-form-item label="*创建时间"> type="textarea"
<el-input disabled v-model="detailForm.createTime"></el-input> :rows="3"
</el-form-item> ></el-input>
</el-form-item>
<el-form-item label="*创建人"> </el-col>
<el-input disabled v-model="detailForm.createUser"></el-input> </el-row>
</el-form-item>
</el-col> <h3 ref="clientInfo">关联商户</h3>
</el-row> <el-row>
<h3 ref="log">操作日志</h3> <el-col :span="20">
<el-row> <el-form-item label="店面名称">
<el-col :span="24"> <el-input disabled v-model="detailForm.shopName"></el-input>
<el-form-item label="" v-show="freqTableData.length"> </el-form-item>
<table class="freq_table">
<tr> <el-form-item label="店面联系人">
<th width="90">调频时间</th> <el-input disabled v-model="detailForm.shopContacts"></el-input>
<th width="60">调频模式</th> </el-form-item>
<th width="100">上点频次</th>
<th>调频上点个数</th> <el-form-item label="店面联系方式">
<th>设备上点总个数</th> <el-input disabled v-model="detailForm.contactsPhone"></el-input>
<th>剩余电量</th> </el-form-item>
<th>调频操作人</th>
</tr> <el-form-item label="*创建时间">
<tr v-for="(item, index) in freqTableData" :key="index"> <el-input disabled v-model="detailForm.createTime"></el-input>
<td>{{item.createTime}}</td> </el-form-item>
<td>{{item.freqTypeStr}}</td>
<td>{{item.frequency}}</td> <el-form-item label="*创建人">
<td>{{item.freTotal}}</td> <el-input disabled v-model="detailForm.createUser"></el-input>
<td>{{item.devicePointTotal}}</td> </el-form-item>
<td>{{item.batteryLevel}}%</td> </el-col>
<td>{{item.operation}}</td> </el-row>
</tr> <h3 ref="log">操作日志</h3>
</table> <el-row>
</el-form-item> <el-col :span="24">
<el-form-item label=""> <el-form-item label="" v-show="freqTableData.length">
<el-input disabled v-html="log" type="textarea" :rows="3"></el-input> <table class="freq_table">
</el-form-item> <tr>
</el-col> <th width="90">调频时间</th>
</el-row> <th width="60">调频模式</th>
<h3 ref="clientInfo">设备安装照片</h3> <th width="100">上点频次</th>
<th>调频上点个数</th>
<el-row> <th>设备上点总个数</th>
<el-col :span="6" v-for="(value,index) in detailForm.imageUrls " :key="index"> <th>剩余电量</th>
<el-form-item class="imgList"> <th>调频操作人</th>
<img :src="value" :key="value" @click='bigImg(index,value)'> <!-- @click="bigImg(index)" --> </tr>
<tr v-for="(item, index) in freqTableData" :key="index">
</el-form-item> <td>{{ item.createTime }}</td>
<td>{{ item.freqTypeStr }}</td>
</el-col> <td>{{ item.frequency }}</td>
</el-row> <td>{{ item.freTotal }}</td>
</el-form> <td>{{ item.devicePointTotal }}</td>
</div> <td>{{ item.batteryLevel }}%</td>
<div class="poi-map" v-show="showTab==='poi'"> <td>{{ item.operation }}</td>
<div id="mapContainer" class="map-container"></div> </tr>
<fence-map-controll @onRefreshMap="refreshMap" :isModalMap="true"></fence-map-controll> </table>
<div class="map-seacrh-wrap"> </el-form-item>
<!-- <input type="text" id="mapSearch"> --> <el-form-item label="">
<el-input placeholder="请输入位置" id="mapSearch" size="small" v-model="mapSearch"> <el-input
<template slot="prepend">搜索</template> disabled
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> --> v-html="log"
</el-input> type="textarea"
</div> :rows="3"
</div> ></el-input>
<div slot="footer" class="dialog-footer"> </el-form-item>
<el-button type="primary" @click="gotoMonitor()" size="small">监控</el-button> </el-col>
<el-button type="primary" @click="save" size="small" v-if="isEdit">保存</el-button> </el-row>
<el-button @click="$emit('onUserCarModalChange', false)" size="small">关闭</el-button> <h3 ref="clientInfo">设备安装照片</h3>
</div>
<user-photo-modal :userPhotoVisible="userPhotoVisible" :photoForm="photoForm" @onUserPhotoModalChange="UserPhotoModalChange"></user-photo-modal> <el-row>
</el-dialog> <el-col
:span="6"
<!-- 查看详情弹框 /--> v-for="(value, index) in detailForm.imageUrls"
:key="index"
>
<el-form-item class="imgList">
<img :src="value" :key="value" @click="bigImg(index, value)" />
<!-- @click="bigImg(index)" -->
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<div class="poi-map" v-show="showTab === 'poi'">
<div id="mapContainer" class="map-container"></div>
<fence-map-controll
@onRefreshMap="refreshMap"
:isModalMap="true"
></fence-map-controll>
<div class="map-seacrh-wrap">
<!-- <input type="text" id="mapSearch"> -->
<el-input
placeholder="请输入位置"
id="mapSearch"
size="small"
v-model="mapSearch"
>
<template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="gotoMonitor()" size="small"
>监控</el-button
>
<el-button type="primary" @click="save" size="small" v-if="isEdit"
>保存</el-button
>
<el-button @click="$emit('onUserCarModalChange', false)" size="small"
>关闭</el-button
>
</div>
<user-photo-modal
:userPhotoVisible="userPhotoVisible"
:photoForm="photoForm"
@onUserPhotoModalChange="UserPhotoModalChange"
></user-photo-modal>
</el-dialog>
<!-- 查看详情弹框 /-->
</template> </template>
<script> <script>
import {services} from '../../api' import { services } from "../../api";
import userPhotoModal from './userPhotoModal' import userPhotoModal from "./userPhotoModal";
import remoteLoad from 'utils/remoteLoad.js' import mapService from "utils/mapService.js";
import mapService from 'utils/mapService.js' import EventBus from "../../event-bus";
import EventBus from '../../event-bus' import MAPGEO from "utils/mapgeo";
import MAPGEO from 'utils/mapgeo' const BUSINESS_SERVICE = services.business;
const BUSINESS_SERVICE = services.business; import FenceMapControll from "../monitor/FenceMapControll.vue";
import {CONSTANT} from '../../constant' import vVechicleBrand from "components/VechicleBrand.vue";
import FenceMapControll from '../monitor/FenceMapControll.vue' import plateNumberInput from "components/PlateNumberInput.vue";
import vVechicleBrand from 'components/VechicleBrand.vue' require("images/poi-marker-default.png");
import plateNumberInput from 'components/PlateNumberInput.vue' export default {
props: ["detailFormVisible", "detailForm", "isEdit", "carRemark", "carUsed"],
require('images/poi-marker-default.png') data() {
export default{ let checkPlateNumber = (rule, vaule, cb) => {
props: ['detailFormVisible', 'detailForm', 'isEdit', 'carRemark', 'carUsed'], if (vaule) {
data(){ let num = vaule.split("").length;
let checkPlateNumber = (rule, vaule, cb) => { if (vaule && (num < 7 || num > 10)) {
if (vaule) { cb("请输入正确的车牌号码");
let num = vaule.split('').length }
if (vaule && (num < 7 || num > 10)) { }
cb('请输入正确的车牌号码') cb();
} };
} let checkVechicleBrand = (rule, vaule, cb) => {
cb() if (!this.detailForm.vehicleBrandId && !this.detailForm.vehicleTypeId) {
} cb(new Error("请选择品牌车型"));
let checkVechicleBrand = (rule, vaule, cb)=>{ }
if(!this.detailForm.vehicleBrandId && !this.detailForm.vehicleTypeId){ cb();
cb(new Error('请选择品牌车型')) };
} return {
cb() scrollToRef: "",
} showBigImg: false,
return { userPhotoVisible: false,
scrollToRef: '', num: 0,
showBigImg:false, photoForm: {},
userPhotoVisible:false, flag: true,
num:0, isEdit: true,
photoForm:{}, showTab: "form",
flag:true, checkMapLoaded: false,
isEdit: true, poiNum: 0,
showTab: 'form', markers: {},
checkMapLoaded: false, infoWindows: {},
poiNum: 0, log: "",
markers: {}, brandInit: false,
infoWindows: {}, brandId: undefined,
log: '', typeId: undefined,
brandInit: false, rules: {
brandId: undefined, name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
typeId: undefined, plateNumber: [{ validator: checkPlateNumber, trigger: "blur" }],
rules: { userTel: [
name: [ // { required: true, message: '请输入联系电话', trigger: 'blur' },
{required: true, message: '请输入姓名', trigger: 'blur'}, {
], pattern: /^1\d{10}$/,
plateNumber: [ message: "请输入正确的手机号",
{ validator: checkPlateNumber, trigger: 'blur' } trigger: "blur",
], },
userTel: [ ],
// { required: true, message: '请输入联系电话', trigger: 'blur' }, displacement: [
{ pattern: /^1\d{10}$/, message: '请输入正确的手机号', trigger: 'blur' } {
], pattern: /^(((([1-9][0-9])|[1-9])(\.\d)?)|(0\.[1-9]))$/,
displacement: [ message: "请输入正确的格式(0.1-99.9)L",
{ pattern: /^(((([1-9][0-9])|[1-9])(\.\d)?)|(0\.[1-9]))$/, message: '请输入正确的格式(0.1-99.9)L', trigger: 'blur' } trigger: "blur",
], },
device: [ ],
{required: true, message: '请输入姓名', trigger: 'blur'}, device: [{ required: true, message: "请输入姓名", trigger: "blur" }],
], },
}, trash: [],
trash: [], mapSearch: "",
mapSearch: '', freqTableData: [],
freqTableData: [], deviceArr: [
deviceArr: [{ {
sn: '', sn: "",
deviceType: '' deviceType: "",
}] },
} ],
}, };
async created () { },
if(window.AMap){ async created() {
//this.initMap() // if(window.AMap){
}else{ // //this.initMap()
await remoteLoad(`${CONSTANT.AMAP_URL}`); // }else{
// await remoteLoad(`${CONSTANT.AMAP_URL}`);
} // }
}, },
mounted(){ mounted() {
EventBus.$on('userCarModal.poi.save', (data, deleteBtn, saveBtn, marker, infoWindow)=>{ EventBus.$on(
this.poiSave(data, deleteBtn, saveBtn, marker, infoWindow) "userCarModal.poi.save",
}); (data, deleteBtn, saveBtn, marker, infoWindow) => {
this.poiSave(data, deleteBtn, saveBtn, marker, infoWindow);
EventBus.$on('userCarModal.poi.delete', (id)=>{ }
this.poiRemove(id) );
});
EventBus.$on("userCarModal.poi.delete", (id) => {
console.log(this.detailForm) this.poiRemove(id);
}, });
computed: {
console.log(this.detailForm);
}, },
methods: { computed: {},
openDialog(){ methods: {
this.$emit('onUserCarModalChange', true) openDialog() {
this.log = this.createLogHtml(this.detailForm.vehicleLogs) this.$emit("onUserCarModalChange", true);
this.log = this.createLogHtml(this.detailForm.vehicleLogs);
this.scrollToRef = ''
this.showTab = 'form' this.scrollToRef = "";
if(!this.mapObj){ this.showTab = "form";
this.initMap() if (!this.mapObj) {
}else{ this.initMap();
this.getPOIData() } else {
} this.getPOIData();
if(this.detailForm.remark){ }
this.detailForm.remark = this.detailForm.remark.replace(/\<\/br\>/g, '\n') if (this.detailForm.remark) {
} this.detailForm.remark = this.detailForm.remark.replace(
/\<\/br\>/g,
this.brandInit = true "\n"
this.plateNumberInit = true; );
}
if(this.carRemark){
this.rules.carRemarkType = [{required: true, message: '请选择车辆标签', trigger: 'blur'}] this.brandInit = true;
} this.plateNumberInit = true;
if(this.carUsed){
this.rules.carUsed = [{required: true, message: '请输入车辆用途', trigger: 'blur'}] if (this.carRemark) {
if(!this.detailForm.carUsed){ this.rules.carRemarkType = [
this.detailForm.carUsed = '专属用途' { required: true, message: "请选择车辆标签", trigger: "blur" },
} ];
} }
if (this.carUsed) {
BUSINESS_SERVICE.getAdjFreqInfo({ this.rules.carUsed = [
sn: this.detailForm.trackInfo.sn { required: true, message: "请输入车辆用途", trigger: "blur" },
}).then((res) => { ];
this.freqTableData = res.data if (!this.detailForm.carUsed) {
}) this.detailForm.carUsed = "专属用途";
}, }
closeDialog(){ }
this.$emit('onUserCarModalChange', false)
this.$refs.detailForm.resetFields() BUSINESS_SERVICE.getAdjFreqInfo({
this.clearPOI() sn: this.detailForm.trackInfo.sn,
}, }).then((res) => {
UserPhotoModalChange(isOpen,index,data){ this.freqTableData = res.data;
this.userPhotoVisible = isOpen });
}, },
scrollTo(refName){ closeDialog() {
this.scrollToRef = refName; this.$emit("onUserCarModalChange", false);
this.$refs.detailForm.resetFields();
if(refName === 'poi'){ this.clearPOI();
this.showTab = 'poi' },
//mapService.setFitView(this.markers) UserPhotoModalChange(isOpen, index, data) {
let mapSearchInput = document.getElementById('mapSearch'); this.userPhotoVisible = isOpen;
if(mapSearchInput){ },
mapSearchInput.value = ''; scrollTo(refName) {
} this.scrollToRef = refName;
}else{
this.showTab = 'form' if (refName === "poi") {
this.showTab = "poi";
var element = this.$refs[refName]; //mapService.setFitView(this.markers)
const top = element.offsetTop; let mapSearchInput = document.getElementById("mapSearch");
if (mapSearchInput) {
window.document.getElementById('userCarModal').querySelector('form').scrollTo(0, top-80); mapSearchInput.value = "";
} }
}, } else {
gotoMonitor(row){ this.showTab = "form";
let snO = {
name: this.detailForm.name, var element = this.$refs[refName];
standNo: this.detailForm.standNo, const top = element.offsetTop;
sn: this.detailForm.trackInfo.sn,
sourceType: this.detailForm.trackInfo.source === 0?'无线':'有线', window.document
source: this.detailForm.trackInfo.source .getElementById("userCarModal")
} .querySelector("form")
//this.$router.push({ name: 'monitor', params: { snArr: [snO], mode: 'monitor' }}) .scrollTo(0, top - 80);
let routeData = this.$router.resolve({ path: '/monitor/monitor', query: { snArr: JSON.stringify([snO]), mode: 'monitor' }}); }
window.open(routeData.href, '_blank'); },
}, gotoMonitor(row) {
bigImg(index,value){ let snO = {
this.showBigImg = true; name: this.detailForm.name,
var imageArray = [],current = 0; standNo: this.detailForm.standNo,
var i = 0; sn: this.detailForm.trackInfo.sn,
for(var key in this.detailForm.imageUrls){ sourceType: this.detailForm.trackInfo.source === 0 ? "无线" : "有线",
imageArray.push (this.detailForm.imageUrls[key]); source: this.detailForm.trackInfo.source,
if(key == index){ };
current = i; //this.$router.push({ name: 'monitor', params: { snArr: [snO], mode: 'monitor' }})
} let routeData = this.$router.resolve({
path: "/monitor/monitor",
i ++; query: { snArr: JSON.stringify([snO]), mode: "monitor" },
} });
this.photoForm.data = imageArray; window.open(routeData.href, "_blank");
this.photoForm.index = current; },
this.photoForm.length = imageArray.length; bigImg(index, value) {
this.userPhotoVisible = true; this.showBigImg = true;
}, var imageArray = [],
initMap(){ current = 0;
let check = ()=>{ var i = 0;
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); for (var key in this.detailForm.imageUrls) {
imageArray.push(this.detailForm.imageUrls[key]);
return setTimeout(()=>{ if (key == index) {
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){ current = i;
}
window.AMap = AMap;
this.mapObj = mapService.init('mapContainer'); i++;
this.bindSearch(); }
this.bindContextMenu() this.photoForm.data = imageArray;
this.getPOIData() this.photoForm.index = current;
}else{ this.photoForm.length = imageArray.length;
this.checkMapLoaded = check() this.userPhotoVisible = true;
} },
}, 100) initMap() {
} let _this = this;
this.checkMapLoaded = check(); _this.$mapInit({ version: "1.4.2" }).then((AMap) => {
}, window.AMap = AMap;
bindSearch(){ _this.mapObj = mapService.init("mapContainer");
const self = this; _this.bindSearch();
this.mapDot=false _this.bindContextMenu();
this.auto = new AMap.Autocomplete({ _this.getPOIData();
input: 'mapSearch' });
}); // let check = () => {
// this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
this.autoCenterMarker = new AMap.Marker({
icon: require('images/auto-center-marker.gif'), // return setTimeout(() => {
map: this.mapObj, // if (
offset: new AMap.Pixel(-12,-12), // "AMap" in window &&
visible: false // typeof AMap.Map == "function" &&
}); // !this.mapObj
// ) {
this.autoCenterMarker.on('rightclick', (e)=> { // window.AMap = AMap;
window.mapMenu.contextMenu.open(self.mapObj, e.lnglat); // this.mapObj = mapService.init("mapContainer");
self.contextMenuPositon = e.lnglat; //右键菜单位置 // this.bindSearch();
}); // this.bindContextMenu();
// this.getPOIData();
AMap.event.addListener(this.auto, 'select', (e)=>{ // } else {
if(e.poi && e.poi.location){ // this.checkMapLoaded = check();
// }
this.mapObj.setCenter(e.poi.location); // }, 100);
// };
this.autoCenterMarker.setPosition(e.poi.location); // this.checkMapLoaded = check();
this.autoCenterMarker.show(); },
this.mapObj.add(this.autoCenterMarker); bindSearch() {
const self = this;
//this.mapSearch = ''; this.mapDot = false;
/* this.form.lng = e.poi.location.lng; this.auto = new AMap.Autocomplete({
input: "mapSearch",
});
this.autoCenterMarker = new AMap.Marker({
icon: require("images/auto-center-marker.gif"),
map: this.mapObj,
offset: new AMap.Pixel(-12, -12),
visible: false,
});
this.autoCenterMarker.on("rightclick", (e) => {
window.mapMenu.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
});
AMap.event.addListener(this.auto, "select", (e) => {
if (e.poi && e.poi.location) {
this.mapObj.setCenter(e.poi.location);
this.autoCenterMarker.setPosition(e.poi.location);
this.autoCenterMarker.show();
this.mapObj.add(this.autoCenterMarker);
//this.mapSearch = '';
/* this.form.lng = e.poi.location.lng;
this.form.lat = e.poi.location.lat; */ this.form.lat = e.poi.location.lat; */
/* this.$emit('onUpdateMapData',{ /* this.$emit('onUpdateMapData',{
lng: this.form.lng, lng: this.form.lng,
lat: this.form.lat, lat: this.form.lat,
address: this.form.transferAddr, address: this.form.transferAddr,
//radius: 1 //radius: 1
}); */ }); */
} }
this.mapObj.setZoom(14); this.mapObj.setZoom(14);
});
}); },
bindContextMenu() {
const self = this;
}, window.mapMenu = new ContextMenu(this.mapObj); //暴露mapMenu onclick要用
bindContextMenu(){ function ContextMenu(map) {
var me = this;
const self = this; this.contextMenuPositon = null;
window.mapMenu = new ContextMenu(this.mapObj);//暴露mapMenu onclick要用 this.contextMenu = new AMap.ContextMenu({
function ContextMenu(map) { isCustom: true,
var me = this; content: `<div class="context_menu" >
this.contextMenuPositon = null;
this.contextMenu = new AMap.ContextMenu({
isCustom: true,
content: `<div class="context_menu" >
<p onclick="mapMenu.addPOI()"><i class="el-icon-circle-plus"></i><span>新增POI信息</span></p> <p onclick="mapMenu.addPOI()"><i class="el-icon-circle-plus"></i><span>新增POI信息</span></p>
</div>` </div>`,
}); });
map.on('rightclick', (e)=> {console.log(me.contextMenu) map.on("rightclick", (e) => {
if(!self.isEdit) return; console.log(me.contextMenu);
me.contextMenu.open(self.mapObj, e.lnglat); if (!self.isEdit) return;
self.contextMenuPositon = e.lnglat; //右键菜单位置 me.contextMenu.open(self.mapObj, e.lnglat);
}); self.contextMenuPositon = e.lnglat; //右键菜单位置
} });
ContextMenu.prototype.addPOI = function addPOI() { }
self.addPOI() ContextMenu.prototype.addPOI = function addPOI() {
this.contextMenu.close(); self.addPOI();
}; this.contextMenu.close();
}, };
addPOI(){ },
if(this.poiNum === 5){ addPOI() {
this.$message({ if (this.poiNum === 5) {
type: 'info', this.$message({
message: '您所新增的POI信息已超过5个,请删除旧信息后重试!' type: "info",
}); message: "您所新增的POI信息已超过5个,请删除旧信息后重试!",
return; });
} return;
let transferObj = { }
data: [{ let transferObj = {
elng: this.contextMenuPositon.lng, data: [
elat: this.contextMenuPositon.lat {
}] elng: this.contextMenuPositon.lng,
} elat: this.contextMenuPositon.lat,
MAPGEO.transferAddressByGroup(transferObj, ()=>{ },
transferObj.data.forEach((item)=>{ ],
let marker = this.createPOIMarker(this.contextMenuPositon) };
let infoWindow = this.bindInfoWindow(marker, { MAPGEO.transferAddressByGroup(transferObj, () => {
lng: item.elng, transferObj.data.forEach((item) => {
lat: item.elat, let marker = this.createPOIMarker(this.contextMenuPositon);
address: item.transferAddress, let infoWindow = this.bindInfoWindow(marker, {
poiName: '' lng: item.elng,
}) lat: item.elat,
this.trash.push(marker) address: item.transferAddress,
this.trash.push(infoWindow) poiName: "",
}); });
this.mapObj.setZoomAndCenter(this.mapObj.getZoom(), this.contextMenuPositon); this.trash.push(marker);
this.trash.push(infoWindow);
}) });
return; this.mapObj.setZoomAndCenter(
this.mapObj.getZoom(),
}, this.contextMenuPositon
createPOIMarker(lnglatXY){ );
var marker = new AMap.Marker({ });
position: lnglatXY, return;
content:`<span class="poi_marker"></span>`, },
map: this.mapObj, createPOIMarker(lnglatXY) {
autoRotation: true, var marker = new AMap.Marker({
offset: new AMap.Pixel(-20, -50), position: lnglatXY,
zIndex: 1020, content: `<span class="poi_marker"></span>`,
animation: 'AMAP_ANIMATION_DROP' map: this.mapObj,
}); autoRotation: true,
this.poiNo++; offset: new AMap.Pixel(-20, -50),
return marker; zIndex: 1020,
}, animation: "AMAP_ANIMATION_DROP",
bindInfoWindow(marker, info){ });
var infoDiv = document.createElement('div'); this.poiNo++;
const mapObj = this.mapObj; return marker;
infoDiv.innerHTML = this.createInfo(info); },
let deleteBtn = infoDiv.querySelector('[data-delete]') bindInfoWindow(marker, info) {
let saveBtn = infoDiv.querySelector('[data-save]') var infoDiv = document.createElement("div");
const mapObj = this.mapObj;
var infoWindow = new AMap.InfoWindow({ infoDiv.innerHTML = this.createInfo(info);
offset: new AMap.Pixel(0, -48), let deleteBtn = infoDiv.querySelector("[data-delete]");
content: infoDiv, let saveBtn = infoDiv.querySelector("[data-save]");
autoMove: true
}); var infoWindow = new AMap.InfoWindow({
marker.infoWindow = infoWindow; offset: new AMap.Pixel(0, -48),
marker.on('click', markerClick); content: infoDiv,
function markerClick(e){ autoMove: true,
//infoWindow.setContent(e.target.content); });
infoWindow.open(mapObj, e.target.getPosition()); marker.infoWindow = infoWindow;
} marker.on("click", markerClick);
function markerClick(e) {
//infoWindow.setContent(e.target.content);
if(!('id' in info)){ infoWindow.open(mapObj, e.target.getPosition());
infoWindow.open(mapObj, marker.getPosition()) }
}else{
deleteBtn.setAttribute('data-id', info.id) if (!("id" in info)) {
saveBtn.setAttribute('data-id', info.id) infoWindow.open(mapObj, marker.getPosition());
deleteBtn.style.display = 'inline' } else {
} deleteBtn.setAttribute("data-id", info.id);
saveBtn.setAttribute("data-id", info.id);
infoDiv.querySelector('[data-save]').onclick = function(e){ deleteBtn.style.display = "inline";
const obj = Object.assign({}, info) }
obj.poiName = infoDiv.querySelector('[data-title]').value.replace(/(^\s+)|(\s+$)/g, '');
EventBus.$emit('userCarModal.poi.save', obj, deleteBtn, saveBtn, marker, infoWindow); infoDiv.querySelector("[data-save]").onclick = function (e) {
const obj = Object.assign({}, info);
} obj.poiName = infoDiv
.querySelector("[data-title]")
infoDiv.querySelector('[data-delete]').onclick = function(e){ .value.replace(/(^\s+)|(\s+$)/g, "");
EventBus.$emit('userCarModal.poi.delete', deleteBtn.getAttribute('data-id')); EventBus.$emit(
} "userCarModal.poi.save",
obj,
return infoWindow; deleteBtn,
}, saveBtn,
createInfo(info){ marker,
return `<div class="poi_infowin"> infoWindow
<h3 class="map-infowindow-title">${('id' in info)?'POI信息':'新增POI'}</h3> );
};
infoDiv.querySelector("[data-delete]").onclick = function (e) {
EventBus.$emit(
"userCarModal.poi.delete",
deleteBtn.getAttribute("data-id")
);
};
return infoWindow;
},
createInfo(info) {
return `<div class="poi_infowin">
<h3 class="map-infowindow-title">${"id" in info ? "POI信息" : "新增POI"}</h3>
<div class="map-infowindow-ct"> <div class="map-infowindow-ct">
<p class="poi_item"><label>经度:</label><span>${info.lng}</span></p> <p class="poi_item"><label>经度:</label><span>${info.lng}</span></p>
<p class="poi_item"><label>纬度:</label><span>${info.lat}</span></p> <p class="poi_item"><label>纬度:</label><span>${info.lat}</span></p>
<p class="poi_item"><label>自定义名称:</label><input data-title class="el-input__inner" value="${info.poiName}" maxlength="20"/></p> <p class="poi_item"><label>自定义名称:</label><input data-title class="el-input__inner" value="${
info.poiName
}" maxlength="20"/></p>
<p class="poi_item"><label>解析地址:</label><span>${info.address}</span> <p class="poi_item"><label>解析地址:</label><span>${info.address}</span>
<p class="poi_ctrl" style="${!this.isEdit?'display:none;':''}"><a data-delete style="display:none;">删除</a><a data-save>保存</a></p> <p class="poi_ctrl" style="${
</div></div>` !this.isEdit ? "display:none;" : ""
}, }"><a data-delete style="display:none;">删除</a><a data-save>保存</a></p>
getPOIData(){ </div></div>`;
BUSINESS_SERVICE.getPOI({ },
vehicleId: this.detailForm.vehicleId getPOIData() {
}).then((res)=>{ BUSINESS_SERVICE.getPOI({
if(res.returnCode === '0'){ vehicleId: this.detailForm.vehicleId,
if(res.data && res.data.length){ }).then((res) => {
this.poiNum = res.data.length if (res.returnCode === "0") {
res.data.forEach((item)=>{ if (res.data && res.data.length) {
let marker = this.createPOIMarker(mapService.getLngLat(item.lng, item.lat)) this.poiNum = res.data.length;
let infoWindow = this.bindInfoWindow(marker, item) res.data.forEach((item) => {
this.markers[item.id] = marker let marker = this.createPOIMarker(
this.infoWindows[item.id] = infoWindow mapService.getLngLat(item.lng, item.lat)
}) );
setTimeout(()=>{ let infoWindow = this.bindInfoWindow(marker, item);
mapService.setFitView() this.markers[item.id] = marker;
},1000) this.infoWindows[item.id] = infoWindow;
} });
} setTimeout(() => {
}) mapService.setFitView();
}, }, 1000);
poiSave(data, deleteBtn, saveBtn, marker, infoWindow){ }
const {lng,lat,address} = data }
const id = saveBtn.getAttribute('data-id'); });
},
if(typeof id === 'string'){ poiSave(data, deleteBtn, saveBtn, marker, infoWindow) {
BUSINESS_SERVICE.updatePOI({ const { lng, lat, address } = data;
...data const id = saveBtn.getAttribute("data-id");
}).then((res)=>{
if(res.returnCode === '0'){ if (typeof id === "string") {
deleteBtn.style.display = 'inline' BUSINESS_SERVICE.updatePOI({
infoWindow.close() ...data,
this.$message({ }).then((res) => {
type: 'success', if (res.returnCode === "0") {
message: '保存成功' deleteBtn.style.display = "inline";
}) infoWindow.close();
} this.$message({
}) type: "success",
}else{ message: "保存成功",
BUSINESS_SERVICE.addPOI({ });
vehicleId: this.detailForm.vehicleId, }
...data });
}).then((res)=>{ } else {
if(res.returnCode === '0'){ BUSINESS_SERVICE.addPOI({
this.poiNum++; vehicleId: this.detailForm.vehicleId,
const id = res.data.id ...data,
this.markers[id] = marker }).then((res) => {
this.infoWindows[id] = infoWindow if (res.returnCode === "0") {
deleteBtn.setAttribute('data-id', id) this.poiNum++;
saveBtn.setAttribute('data-id', id); const id = res.data.id;
deleteBtn.style.display = 'inline' this.markers[id] = marker;
infoWindow.close() this.infoWindows[id] = infoWindow;
this.$message({ deleteBtn.setAttribute("data-id", id);
type: 'success', saveBtn.setAttribute("data-id", id);
message: '新增成功' deleteBtn.style.display = "inline";
}) infoWindow.close();
} this.$message({
}) type: "success",
} message: "新增成功",
});
}
}, });
poiRemove(id){ }
this.$confirm('确定删除吗?', '提示', { },
confirmButtonText: '确定', poiRemove(id) {
cancelButtonText: '取消', this.$confirm("确定删除吗?", "提示", {
type: 'warning' confirmButtonText: "确定",
}).then(() => { cancelButtonText: "取消",
BUSINESS_SERVICE.deletePOI({id}).then((res)=>{ type: "warning",
if(res.returnCode === '0'){ })
this.poiNum--; .then(() => {
this.markers[id].setMap(null) BUSINESS_SERVICE.deletePOI({ id }).then((res) => {
this.infoWindows[id].setMap(null) if (res.returnCode === "0") {
delete this.markers[id] this.poiNum--;
delete this.infoWindows[id] this.markers[id].setMap(null);
this.infoWindows[id].setMap(null);
} delete this.markers[id];
}) delete this.infoWindows[id];
}).catch(()=>{}) }
}, });
createLogHtml(arr){ })
if(arr.length){ .catch(() => {});
let _html = '<table style="width:100%">'; },
arr.forEach((item)=>{ createLogHtml(arr) {
_html += `<tr><td>操作人</td><td>${item.operator}</td><td></td></tr>` if (arr.length) {
_html += `<tr><td>操作内容</td><td>${item.content}</td><td>${item.createTime}</td></tr>` let _html = '<table style="width:100%">';
}) arr.forEach((item) => {
_html+='</table>' _html += `<tr><td>操作人</td><td>${item.operator}</td><td></td></tr>`;
return _html _html += `<tr><td>操作内容</td><td>${item.content}</td><td>${item.createTime}</td></tr>`;
}else{ });
return '' _html += "</table>";
} return _html;
} else {
}, return "";
clearPOI(){ }
//this.mapObj.clearMap(); },
for(let id in this.markers){ clearPOI() {
this.markers[id].setMap(null) //this.mapObj.clearMap();
} for (let id in this.markers) {
for(let id in this.infoWindows){ this.markers[id].setMap(null);
this.infoWindows[id].setMap(null) }
} for (let id in this.infoWindows) {
this.trash.forEach((item)=>{ this.infoWindows[id].setMap(null);
item.setMap(null) }
}) this.trash.forEach((item) => {
this.markers = {}; item.setMap(null);
this.infoWindows = {}; });
this.trash = [] this.markers = {};
this.autoCenterMarker.hide() this.infoWindows = {};
window.mapMenu.contextMenu.close() this.trash = [];
}, this.autoCenterMarker.hide();
brandChange(brandId, typeId){ window.mapMenu.contextMenu.close();
this.detailForm.vehicleBrandId = brandId; },
this.detailForm.vehicleTypeId = typeId; brandChange(brandId, typeId) {
//this.$refs.form.validateField('vechicleBrand'); this.detailForm.vehicleBrandId = brandId;
}, this.detailForm.vehicleTypeId = typeId;
plateNumberChange(str){ //this.$refs.form.validateField('vechicleBrand');
this.detailForm.plateNumber = str; },
//this.$refs.form.validateField('plateNumber'); plateNumberChange(str) {
}, this.detailForm.plateNumber = str;
save(){ //this.$refs.form.validateField('plateNumber');
this.$refs.detailForm.validate(valid => { },
if (valid) { save() {
console.log(this.detailForm) this.$refs.detailForm.validate((valid) => {
const params = {}; if (valid) {
const form = this.detailForm; console.log(this.detailForm);
params.vehicleId = form.vehicleId; const params = {};
params.workOrderId = form.workOrderId; const form = this.detailForm;
params.vehicleId = form.vehicleId;
params.name = form.name; params.workOrderId = form.workOrderId;
params.vehicleBrandId = form.vehicleBrandId;
params.vehicleTypeId = form.vehicleTypeId; params.name = form.name;
params.vehicleBrandId = form.vehicleBrandId;
if(form.userSex){ params.vehicleTypeId = form.vehicleTypeId;
params.userSex = form.userSex
} if (form.userSex) {
if(form.userTel){ params.userSex = form.userSex;
params.userTel = form.userTel }
} if (form.userTel) {
params.displacement = form.displacement params.userTel = form.userTel;
params.remark = form.remark }
params.plateNumber = form.plateNumber; params.displacement = form.displacement;
params.remark = form.remark;
if(this.carRemark && form.carRemarkType){ params.plateNumber = form.plateNumber;
params.carRemarkType = form.carRemarkType
} if (this.carRemark && form.carRemarkType) {
if(this.carUsed && form.carUsed){ params.carRemarkType = form.carRemarkType;
params.carUsed = form.carUsed }
} if (this.carUsed && form.carUsed) {
params.carUsed = form.carUsed;
BUSINESS_SERVICE.saveVehicleForm(params).then((res)=>{ }
if(res.returnCode === '0'){
this.$message({ BUSINESS_SERVICE.saveVehicleForm(params).then((res) => {
type: 'success', if (res.returnCode === "0") {
message: '保存成功' this.$message({
}) type: "success",
message: "保存成功",
this.closeDialog() });
this.$emit('updateList')
} this.closeDialog();
}) this.$emit("updateList");
} }
}) });
}, }
addDevice(){ });
this.deviceArr.push({ },
sn: '', addDevice() {
deviceType: '' this.deviceArr.push({
}) sn: "",
this.rules['device'+this.deviceArr.length-1] = [{required: true, message: '请输入姓名', trigger: 'blur'}] deviceType: "",
} });
/*prev(){ this.rules["device" + this.deviceArr.length - 1] = [
{ required: true, message: "请输入姓名", trigger: "blur" },
];
},
/*prev(){
if(this.num==0){ if(this.num==0){
this.num =3 this.num =3
} }
...@@ -795,123 +934,121 @@ export default{ ...@@ -795,123 +934,121 @@ export default{
} }
this.num++; this.num++;
}*/ }*/
}, },
components:{ components: {
userPhotoModal, userPhotoModal,
FenceMapControll, FenceMapControll,
vVechicleBrand, vVechicleBrand,
plateNumberInput plateNumberInput,
} },
} };
</script> </script>
<style scoped> <style scoped>
form {
height: 500px;
overflow: auto;
margin: -30px -20px;
padding: 20px;
}
.tip {
font-size: 12px;
}
form { .imgList img {
height: 500px; width: 160px;
overflow: auto; height: 100px;
margin: -30px -20px; border: none;
padding: 20px; /* opacity: .9; */
} transition: all 0.5s;
.tip{ box-shadow: 10px 10px 16px #ccc;
font-size: 12px; }
} .imgMask {
position: absolute;
.imgList img{ height: 100%;
width: 160px; width: 100%;
height: 100px; top: 0;
border: none; left: 0;
/* opacity: .9; */ z-index: 100;
transition: all 0.5s; background: rgba(0, 0, 0, 0.6);
box-shadow: 10px 10px 16px #ccc; }
} .showImg {
.imgMask{ height: 550px;
position: absolute; width: 800px;
height: 100%; position: absolute;
width:100%; left: 50%;
top:0; top: 50%;
left:0; transform: translate(-50%, -50%);
z-index: 100; }
background:rgba(0,0,0,.6); .bigImg {
} width: 100%;
.showImg{ height: 100%;
height:550px; }
width:800px; .prev {
position: absolute; position: absolute;
left:50%; top: 50%;
top:50%; width: 27px;
transform:translate(-50%,-50%); height: 44px;
margin-top: -22px;
} outline: 0;
.bigImg{ left: 10px;
width:100%; background-position: -5px -50px;
height:100%; background: red;
} z-index: 999;
.prev{ }
position: absolute; .next {
top: 50%; position: absolute;
width: 27px; top: 50%;
height: 44px; width: 27px;
margin-top: -22px; height: 44px;
outline: 0; margin-top: -22px;
left: 10px; outline: 0;
background-position: -5px -50px; right: 10px;
background: red; background-position: -5px -50px;
z-index: 999; background: red;
} }
.next { .poi-map {
position: absolute; position: relative;
top: 50%; }
width: 27px; .poi-map .map-container {
height: 44px; width: 100%;
margin-top: -22px; height: 500px;
outline: 0; }
right: 10px; .poi-map .map-seacrh-wrap {
background-position: -5px -50px; position: absolute;
background: red; top: 10px;
} left: 10px;
.poi-map{ z-index: 1000;
position: relative; }
}
.poi-map .map-container{
width: 100%;
height: 500px;
}
.poi-map .map-seacrh-wrap{
position: absolute;
top: 10px;
left: 10px;
z-index: 1000;
}
</style> </style>
<style lang="scss"> <style lang="scss">
.context_menu{ .context_menu {
min-width: 10em; min-width: 10em;
background-color: #fff; background-color: #fff;
padding: 10px; padding: 10px;
border: 1px solid #efefef; border: 1px solid #efefef;
border-radius: 2px; border-radius: 2px;
cursor: pointer; cursor: pointer;
&>p{ & > p {
margin: 0; margin: 0;
i{ i {
font-size: 18px; font-size: 18px;
color: #094; color: #094;
margin-right: 5px; margin-right: 5px;
} }
i,span{ i,
vertical-align: middle; span {
} vertical-align: middle;
} }
} }
.freq_table{ }
border-collapse: collapse; .freq_table {
th,td{ border-collapse: collapse;
border: 1px solid #ccc; th,
padding: 2px 5px; td {
text-align: center; border: 1px solid #ccc;
} padding: 2px 5px;
} text-align: center;
}
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -79,13 +79,14 @@ ...@@ -79,13 +79,14 @@
<style scoped> <style scoped>
ul.map-control{ ul.map-control{
position: absolute; position: absolute;
bottom: 260px; top: 50%;
right: 10px; right: 10px;
list-style: none; list-style: none;
padding: 5px; padding: 5px;
margin: 0px; margin: 0px;
background-color: rgba(0,0,0,0.1); background-color: rgba(0,0,0,0.1);
z-index: 102; z-index: 102;
transform: translateY(-50%);
} }
.map-control>li{ .map-control>li{
width: 30px; width: 30px;
......
<template> <template>
<div class="map-wrap" > <div class="map-wrap">
<map-menu class="map-menu" <map-menu
:mode="mode" class="map-menu"
:sn="sn" :mode="mode"
@onModeChange="modeChange" :sn="sn"
@onResultConfirm="searchConfirm" @onModeChange="modeChange"
:isMonitorWorking="isMonitorWorking" @onResultConfirm="searchConfirm"
:isMonitorPaused="isMonitorPaused" :isMonitorWorking="isMonitorWorking"
:isMonitorStopped="isMonitorStopped" :isMonitorPaused="isMonitorPaused"
@onMonitorStart="monitorStart" :isMonitorStopped="isMonitorStopped"
@onMonitorPause="monitorPause" @onMonitorStart="monitorStart"
@onMonitorStop="monitorStop" @onMonitorPause="monitorPause"
@onResidentShow="residentShow" @onMonitorStop="monitorStop"
@onReplayShow="replayShow" @onResidentShow="residentShow"
@onReplayPlay="replayPlay" @onReplayShow="replayShow"
@onReplayPause="replayPause" @onReplayPlay="replayPlay"
:playerProgress="playerProgress" @onReplayPause="replayPause"
:replayShowPlayer="replayShowPlayer" :playerProgress="playerProgress"
@onReplaySpeedChange="replaySpeedChange" :replayShowPlayer="replayShowPlayer"
:isInitReplayInfo="isInitReplayInfo" @onReplaySpeedChange="replaySpeedChange"
:isInitReplayInfo="isInitReplayInfo"
></map-menu> ></map-menu>
<div id="map" class="map-container" v-loading="mapLoading"></div> <div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll @onRefreshMap="refreshMap" @onToggleVisible="toggleTable"></map-controll> <map-controll
<map-table @onRefreshMap="refreshMap"
:mode="mode" @onToggleVisible="toggleTable"
:positionType="positionType" ></map-controll>
:replayType="replayType" <map-table
:list="table" :mode="mode"
:showTransfer="showTransfer" :positionType="positionType"
:transferProgress="transferProgress" :replayType="replayType"
@onFenceToggleSelect="fenceToggleSelect" :list="table"
@onPositionTypeChange="positionTypeChange" :showTransfer="showTransfer"
@onReplayTypeChange="replayTypeChange" :transferProgress="transferProgress"
:tableVisible="tableVisible" @onFenceToggleSelect="fenceToggleSelect"
@onToggleVisible="toggleTable"> @onPositionTypeChange="positionTypeChange"
</map-table> @onReplayTypeChange="replayTypeChange"
</div> :tableVisible="tableVisible"
@onToggleVisible="toggleTable"
>
</map-table>
</div>
</template> </template>
<script> <script>
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 MapMenu from './MapMenu.vue' import MapMenu from "./MapMenu.vue";
import MapTable from './MapTable.vue' import MapTable from "./MapTable.vue";
import MapControll from './MapControll.vue' import MapControll from "./MapControll.vue";
import EventBus from '../../event-bus' import EventBus from "../../event-bus";
import {services} from '../../api' import { services } from "../../api";
import mock from '../../mock' import mock from "../../mock";
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
import {CONSTANT} from '../../constant' import { CONSTANT } from "@/constant";
export default{ export default {
data(){ data() {
return { return {
AMap: null, AMap: null,
lng: 114.095388, lng: 114.095388,
lat: 22.574405, lat: 22.574405,
mapObj: null, mapObj: null,
mapLoading: false, mapLoading: false,
mode: 'position', mode: "position",
positionType: 'RtTrack',// MobileBase positionType: "RtTrack", // MobileBase
replayType: 'RtTrack',// MobileBase replayType: "RtTrack", // MobileBase
sn: '', sn: "",
intervalCheckMapLoaded: undefined, intervalCheckMapLoaded: undefined,
tableVisible: true, tableVisible: true,
table: { table: {
position:{ position: {
loading: false, loading: false,
data: [] data: [],
}, },
monitor:{ monitor: {
loading: false, loading: false,
data: [] data: [],
}, },
resident:{ resident: {
loading: false, loading: false,
data: [] data: [],
}, },
replay:{ replay: {
loading: false, loading: false,
data: [], data: [],
display: false display: false,
}, },
fence:{ fence: {
loading: false, loading: false,
data: [] data: [],
} },
}, },
monitorInterval: null, monitorInterval: null,
isMonitorWorking: false, isMonitorWorking: false,
isMonitorPaused: false, isMonitorPaused: false,
isMonitorStopped: false, isMonitorStopped: false,
playerProgress: 0, playerProgress: 0,
replaySpeed: 1, replaySpeed: 1,
replayShowPlayer: false, replayShowPlayer: false,
isInitReplayInfo: false, isInitReplayInfo: false,
showTransfer: false, showTransfer: false,
transferProgress: 0, transferProgress: 0,
fenceSelectArr: [], fenceSelectArr: [],
isInitMap: false isInitMap: false,
} };
}, },
methods: { methods: {
initMap(){ initMap() {
let check = ()=>{ let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(()=>{ return setTimeout(() => {
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){ if (
window.AMap = AMap; "AMap" in window &&
this.mapObj = mapService.init('map'); typeof AMap.Map == "function" &&
!this.mapObj
this.bindEvent(); ) {
this.isInitMap = true; window.AMap = AMap;
}else{ this.mapObj = mapService.init("map");
this.checkMapLoaded = check()
} this.bindEvent();
}, 100) this.isInitMap = true;
} } else {
this.checkMapLoaded = check(); this.checkMapLoaded = check();
}, }
modeChange(mode){ }, 100);
this.mode = mode; };
this.draw() this.checkMapLoaded = check();
}, },
searchConfirm(sns, ifDraw){ modeChange(mode) {
if(sns){ this.mode = mode;
this.sn = sns; this.draw();
if(ifDraw) this.draw(true); },
}else{ searchConfirm(sns, ifDraw) {
this.sn = ''; if (sns) {
this.destroy() this.sn = sns;
} if (ifDraw) this.draw(true);
}, } else {
destroy(){ this.sn = "";
this.table.position.data = []; this.destroy();
EventBus.$emit('uiMap.position.destroy'); }
},
this.table.monitor.data = []; destroy() {
EventBus.$emit('uiMap.monitor.destroy'); this.table.position.data = [];
this.monitorInterval && window.clearTimeout(this.monitorInterval); EventBus.$emit("uiMap.position.destroy");
this.isMonitorWorking = false;
this.table.monitor.data = [];
this.table.resident.data = []; EventBus.$emit("uiMap.monitor.destroy");
EventBus.$emit('uiMap.resident.destroy'); this.monitorInterval && window.clearTimeout(this.monitorInterval);
this.isMonitorWorking = false;
this.table.replay.data = [];
EventBus.$emit('uiMap.replay.destroy'); this.table.resident.data = [];
this.replayShowPlayer = false; EventBus.$emit("uiMap.resident.destroy");
this.playerProgress = 0;
this.table.replay.data = [];
this.table.fence.data = []; EventBus.$emit("uiMap.replay.destroy");
EventBus.$emit('uiMap.fence.destroy'); this.replayShowPlayer = false;
this.playerProgress = 0;
},
draw(isClearCache){ this.table.fence.data = [];
if(!this.isInitMap){ EventBus.$emit("uiMap.fence.destroy");
setTimeout(()=>{ },
this.draw(isClearCache) draw(isClearCache) {
},500) if (!this.isInitMap) {
return; setTimeout(() => {
} this.draw(isClearCache);
if(isClearCache){ }, 500);
this.destroy() return;
}else{ }
EventBus.$emit('uiMap.modeChange', this.mode); if (isClearCache) {
if(this.mode != 'monitor'){ this.destroy();
this.monitorPause() } else {
} EventBus.$emit("uiMap.modeChange", this.mode);
} if (this.mode != "monitor") {
this.monitorPause();
switch(this.mode){ }
case 'position': //实时位置 }
this.getPosition();
break; switch (this.mode) {
case 'fence': case "position": //实时位置
this.getFence(); this.getPosition();
break; break;
case 'replay': case "fence":
this.sn && (this.isInitReplayInfo = true); this.getFence();
break; break;
} case "replay":
}, this.sn && (this.isInitReplayInfo = true);
getPosition(){ break;
if(!this.sn) return; }
},
const resource = this.positionType == 'RtTrack'?MONITOR_SERVICE.getRtTrack:MONITOR_SERVICE.getBaseStationTrack; getPosition() {
const label = this.positionType == 'RtTrack'?'GPS':'基站'; if (!this.sn) return;
this.mapLoading = true;
const resource =
resource({ this.positionType == "RtTrack"
sn: this.sn ? MONITOR_SERVICE.getRtTrack
}).then((result)=>{ : MONITOR_SERVICE.getBaseStationTrack;
//result = mock.getRtTrack const label = this.positionType == "RtTrack" ? "GPS" : "基站";
this.mapLoading = true;
if(result.returnCode == '0'){
let data = result.data; resource({
data.map((item)=>item.transferAddress=null) sn: this.sn,
this.table.position.data = data; }).then((result) => {
//result = mock.getRtTrack
if(data.length){
EventBus.$emit('uiMap.position.draw', data); if (result.returnCode == "0") {
}else{ let data = result.data;
this.$confirm(`<p>暂无${label}定位数据! 原因可能是:<br>1、选择的时间内,GPS终端未连接服务器。<br>2、GPS终端电源已耗尽。</p>`, '提示', { data.map((item) => (item.transferAddress = null));
confirmButtonText: '确定', this.table.position.data = data;
showCancelButton: false,
dangerouslyUseHTMLString: true if (data.length) {
}); EventBus.$emit("uiMap.position.draw", data);
} } else {
} this.$confirm(
this.mapLoading = false; `<p>暂无${label}定位数据! 原因可能是:<br>1、选择的时间内,GPS终端未连接服务器。<br>2、GPS终端电源已耗尽。</p>`,
}); "提示",
{
}, confirmButtonText: "确定",
getMonitor(){ showCancelButton: false,
if(!this.sn) return; dangerouslyUseHTMLString: true,
}
this.mapLoading = true; );
MONITOR_SERVICE.getRtTrack({ }
sn: this.sn }
}).then((result)=>{ this.mapLoading = false;
//result = mock.getRtTrack });
if(this.isMonitorStopped){ },
this.table.monitor.data = [] getMonitor() {
} if (!this.sn) return;
if(result.returnCode == '0'){
let data = result.data; this.mapLoading = true;
let monitorData = this.table.monitor.data; MONITOR_SERVICE.getRtTrack({
sn: this.sn,
if(data.length){ }).then((result) => {
data.map((item)=>item.transferAddress=null) //result = mock.getRtTrack
if(monitorData.length==0 || this.isMonitorStopped){ if (this.isMonitorStopped) {
EventBus.$emit('uiMap.monitor.init', data); this.table.monitor.data = [];
}else{ }
EventBus.$emit('uiMap.monitor.draw', data); if (result.returnCode == "0") {
} let data = result.data;
this.isMonitorWorking = true; let monitorData = this.table.monitor.data;
this.isMonitorPaused = false;
this.isMonitorStopped = false; if (data.length) {
data.map((item) => (item.transferAddress = null));
this.table.monitor.data = monitorData.concat(data); if (monitorData.length == 0 || this.isMonitorStopped) {
this.monitorInterval = this.monitorIntervalFn(); EventBus.$emit("uiMap.monitor.init", data);
} else {
}else{ EventBus.$emit("uiMap.monitor.draw", data);
this.$confirm('<p>暂无实时监控数据! 原因可能是:<br>1、选择的时间内,GPS终端未连接服务器。<br>2、GPS终端电源已耗尽。</p>', '提示', { }
confirmButtonText: '确定', this.isMonitorWorking = true;
showCancelButton: false, this.isMonitorPaused = false;
dangerouslyUseHTMLString: true this.isMonitorStopped = false;
});
} this.table.monitor.data = monitorData.concat(data);
} this.monitorInterval = this.monitorIntervalFn();
this.mapLoading = false; } else {
}); this.$confirm(
}, "<p>暂无实时监控数据! 原因可能是:<br>1、选择的时间内,GPS终端未连接服务器。<br>2、GPS终端电源已耗尽。</p>",
monitorIntervalFn(){ "提示",
return window.setTimeout(()=>{ {
this.getMonitor() confirmButtonText: "确定",
}, 1000*3) showCancelButton: false,
}, dangerouslyUseHTMLString: true,
monitorStart(){ }
this.monitorInterval && window.clearTimeout(this.monitorInterval); );
}
this.getMonitor() }
}, this.mapLoading = false;
monitorPause(){ });
this.monitorInterval && window.clearTimeout(this.monitorInterval); },
this.isMonitorWorking = false; monitorIntervalFn() {
this.isMonitorPaused = true; return window.setTimeout(() => {
}, this.getMonitor();
monitorStop(){ }, 1000 * 3);
this.monitorInterval && window.clearTimeout(this.monitorInterval); },
this.isMonitorStopped = true; monitorStart() {
EventBus.$emit('uiMap.monitor.end'); this.monitorInterval && window.clearTimeout(this.monitorInterval);
this.isMonitorWorking = false; this.getMonitor();
}, },
getResident(params){ monitorPause() {
if(!this.sn) return; this.monitorInterval && window.clearTimeout(this.monitorInterval);
params.sn = this.sn; this.isMonitorWorking = false;
this.isMonitorPaused = true;
this.mapLoading = true; },
MONITOR_SERVICE.getResidentByRealTime(params).then((result)=>{ monitorStop() {
//result = mock.getResidentByRealTime this.monitorInterval && window.clearTimeout(this.monitorInterval);
this.isMonitorStopped = true;
if(result.returnCode == '0'){ EventBus.$emit("uiMap.monitor.end");
let data = result.data;
data.map((item)=>item.transferAddress=null) this.isMonitorWorking = false;
this.table.resident.data = data; },
if(data.length){ getResident(params) {
EventBus.$emit('uiMap.resident.draw', data); if (!this.sn) return;
params.sn = this.sn;
}else{
this.$confirm('<p>没有足够的基站位置数据,无法统计常驻地。</p>', '提示', { this.mapLoading = true;
confirmButtonText: '确定', MONITOR_SERVICE.getResidentByRealTime(params).then((result) => {
showCancelButton: false, //result = mock.getResidentByRealTime
dangerouslyUseHTMLString: true
}); if (result.returnCode == "0") {
} let data = result.data;
} data.map((item) => (item.transferAddress = null));
this.mapLoading = false; this.table.resident.data = data;
}); if (data.length) {
}, EventBus.$emit("uiMap.resident.draw", data);
residentShow(obj){ } else {
let params = obj; this.$confirm(
"<p>没有足够的基站位置数据,无法统计常驻地。</p>",
if(obj.date){ "提示",
params.sTime = obj.date[0]&&(moment(obj.date[0]).format("YYYY-MM-DD HH:mm:ss")); {
params.eTime = obj.date[1]&&(moment(obj.date[1]).endOf('day').format("YYYY-MM-DD HH:mm:ss")); confirmButtonText: "确定",
params.timeRange = 5; showCancelButton: false,
} dangerouslyUseHTMLString: true,
delete params.date; }
);
this.getResident(params) }
}
}, this.mapLoading = false;
getReplay(params){ });
if(!this.sn) return; },
params.sn = params.sn?params.sn:this.sn; residentShow(obj) {
let params = obj;
this.mapLoading = true;
const resource = this.replayType == 'RtTrack'?MONITOR_SERVICE.getTrackHistory:MONITOR_SERVICE.getBaseStationHistory; if (obj.date) {
params.sTime =
resource(params).then((result)=>{ obj.date[0] && moment(obj.date[0]).format("YYYY-MM-DD HH:mm:ss");
//result = mock.getTrackHistory params.eTime =
obj.date[1] &&
if(result.returnCode == '0'){ moment(obj.date[1]).endOf("day").format("YYYY-MM-DD HH:mm:ss");
let data = result.data; params.timeRange = 5;
}
data.map((item)=>item.transferAddress=null) delete params.date;
this.table.replay.sustain = data;
if(data.length){ this.getResident(params);
EventBus.$emit('uiMap.replay.init', data); },
this.replayShowPlayer = true; getReplay(params) {
}else{ if (!this.sn) return;
this.replayShowPlayer = false; params.sn = params.sn ? params.sn : this.sn;
this.$confirm('<p>暂无轨迹数据!</p>', '提示', {
confirmButtonText: '确定', this.mapLoading = true;
showCancelButton: false, const resource =
dangerouslyUseHTMLString: true this.replayType == "RtTrack"
}); ? MONITOR_SERVICE.getTrackHistory
} : MONITOR_SERVICE.getBaseStationHistory;
}
resource(params).then((result) => {
this.mapLoading = false; //result = mock.getTrackHistory
});
}, if (result.returnCode == "0") {
replayShow(obj){ let data = result.data;
this.table.replay.data = [];
this.replayShowPlayer = false; data.map((item) => (item.transferAddress = null));
this.playerProgress = 0; this.table.replay.sustain = data;
EventBus.$emit('uiMap.replay.destroy') if (data.length) {
this.getReplay(obj) EventBus.$emit("uiMap.replay.init", data);
}, this.replayShowPlayer = true;
replayPlay(data){ } else {
this.table.replay.data = this.table.replay.sustain; this.replayShowPlayer = false;
EventBus.$emit('uiMap.replay.play') this.$confirm("<p>暂无轨迹数据!</p>", "提示", {
}, confirmButtonText: "确定",
replayPause(){ showCancelButton: false,
EventBus.$emit('uiMap.replay.pause') dangerouslyUseHTMLString: true,
}, });
replaySpeedChange(type){ }
if(type=='up' && this.replaySpeed<3){ }
this.replaySpeed++;
}else if(type=='down' && this.replaySpeed>1){ this.mapLoading = false;
this.replaySpeed--; });
} },
EventBus.$emit('uiMap.replay.speedChange', this.replaySpeed); replayShow(obj) {
}, this.table.replay.data = [];
getFence(){ this.replayShowPlayer = false;
if(!this.sn) return; this.playerProgress = 0;
EventBus.$emit("uiMap.replay.destroy");
this.getReplay(obj);
MONITOR_SERVICE.getEcFenceList({ },
sn: this.sn replayPlay(data) {
}).then((result)=>{ this.table.replay.data = this.table.replay.sustain;
//result = mock.getEcFenceList EventBus.$emit("uiMap.replay.play");
},
if(result.returnCode == '0'){ replayPause() {
let data = result.data; EventBus.$emit("uiMap.replay.pause");
},
if(data.length){ replaySpeedChange(type) {
if (type == "up" && this.replaySpeed < 3) {
EventBus.$emit('uiMap.fence.init'); this.replaySpeed++;
data.forEach((o, i)=>o.index=i) } else if (type == "down" && this.replaySpeed > 1) {
this.table.fence.data = data; this.replaySpeed--;
}
}else{ EventBus.$emit("uiMap.replay.speedChange", this.replaySpeed);
this.$confirm('<p>暂无电子围栏数据!</p>', '提示', { },
confirmButtonText: '确定', getFence() {
showCancelButton: false, if (!this.sn) return;
dangerouslyUseHTMLString: true
}); MONITOR_SERVICE.getEcFenceList({
} sn: this.sn,
} }).then((result) => {
//result = mock.getEcFenceList
}); if (result.returnCode == "0") {
}, let data = result.data;
fenceToggleSelect(index, id){
const isSelected = !this.fenceSelectArr[index]; if (data.length) {
if(isSelected){ EventBus.$emit("uiMap.fence.init");
this.mapLoading = true; data.forEach((o, i) => (o.index = i));
MONITOR_SERVICE.getEcFenceById({id, id}).then((result)=>{ this.table.fence.data = data;
//result = mock.getEcFenceById } else {
if(result.returnCode == '0'){ this.$confirm("<p>暂无电子围栏数据!</p>", "提示", {
let data = result.data; confirmButtonText: "确定",
showCancelButton: false,
if(data){ dangerouslyUseHTMLString: true,
});
EventBus.$emit('uiMap.fence.show', data, index); }
}
}else{ });
},
} fenceToggleSelect(index, id) {
} const isSelected = !this.fenceSelectArr[index];
this.mapLoading = false; if (isSelected) {
}); this.mapLoading = true;
}else{ MONITOR_SERVICE.getEcFenceById({ id, id }).then((result) => {
EventBus.$emit('uiMap.fence.hide', index); //result = mock.getEcFenceById
} if (result.returnCode == "0") {
this.fenceSelectArr[index] = isSelected; let data = result.data;
},
positionTypeChange(type){ if (data) {
this.positionType = type; EventBus.$emit("uiMap.fence.show", data, index);
this.getPosition(); } else {
}, }
replayTypeChange(type){ }
this.replayType = type; this.mapLoading = false;
//this.replayPlay(); });
}, } else {
refreshMap(){ EventBus.$emit("uiMap.fence.hide", index);
if(this.sn){ }
switch (this.mode) { this.fenceSelectArr[index] = isSelected;
case 'position': //实时位置 },
this.getPosition(); positionTypeChange(type) {
break; this.positionType = type;
case 'monitor': this.getPosition();
this.isMonitorStopped = true; },
this.monitorStart(); replayTypeChange(type) {
break; this.replayType = type;
case 'resident': //this.replayPlay();
},
break; refreshMap() {
case 'replay': if (this.sn) {
switch (this.mode) {
break; case "position": //实时位置
case 'fence': this.getPosition();
this.getFence(); break;
break; case "monitor":
} this.isMonitorStopped = true;
} this.monitorStart();
}, break;
toggleTable(ifShow){ case "resident":
if(ifShow){ break;
this.tableVisible = true; case "replay":
}else{ break;
this.tableVisible = false; case "fence":
} this.getFence();
}, break;
bindEvent(){ }
EventBus.$on('uiMap.replay.progressUpdate', (num)=>{ }
this.playerProgress = num; },
}); toggleTable(ifShow) {
EventBus.$on('uiMap.transfer.hide', ()=>{ if (ifShow) {
this.showTransfer = false; this.tableVisible = true;
}); } else {
EventBus.$on('uiMap.transfer.show', ()=>{ this.tableVisible = false;
this.showTransfer = true; }
}); },
EventBus.$on('uiMap.transfer.num', (num)=>{ bindEvent() {
this.transferProgress = parseFloat(num); EventBus.$on("uiMap.replay.progressUpdate", (num) => {
}); this.playerProgress = num;
}, });
offEvent(){ EventBus.$on("uiMap.transfer.hide", () => {
EventBus.$off('uiMap.replay.progressUpdate') this.showTransfer = false;
EventBus.$off('uiMap.transfer.hide') });
EventBus.$off('uiMap.transfer.show') EventBus.$on("uiMap.transfer.show", () => {
EventBus.$off('uiMap.transfer.num') this.showTransfer = true;
} });
}, EventBus.$on("uiMap.transfer.num", (num) => {
async created () { this.transferProgress = parseFloat(num);
if(window.AMap){ });
this.initMap(); },
}else{ offEvent() {
await remoteLoad(`https://webapi.amap.com/maps?v=1.3&key=${CONSTANT.MAP_KEY}&plugin=AMap.PolyEditor,AMap.CircleEditor,AMap.DistrictSearch,AMap.Autocomplete`).then(()=>{ EventBus.$off("uiMap.replay.progressUpdate");
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{ EventBus.$off("uiMap.transfer.hide");
this.initMap(); EventBus.$off("uiMap.transfer.show");
}) EventBus.$off("uiMap.transfer.num");
}) },
},
} async created() {
let _this = this;
}, let plugins = CONSTANT.MAP_PLUGINS.concat([
beforeDestroy(){ "AMap.CircleEditor",
this.offEvent(); "AMap.DistrictSearch",
this.monitorInterval && window.clearTimeout(this.monitorInterval); "AMap.Autocomplete",
EventBus.$emit('uiMap.position.destroy'); "AMap.PolyEditor",
EventBus.$emit('uiMap.monitor.destroy'); ]);
EventBus.$emit('uiMap.resident.destroy'); _this.$mapInit({ version: "1.3", plugins: plugins }).then((AMap) => {
EventBus.$emit('uiMap.replay.destroy'); _this.initMap();
EventBus.$emit('uiMap.fence.destroy'); });
},
}, beforeDestroy() {
components: { this.offEvent();
MapMenu, this.monitorInterval && window.clearTimeout(this.monitorInterval);
MapTable, EventBus.$emit("uiMap.position.destroy");
MapControll EventBus.$emit("uiMap.monitor.destroy");
} EventBus.$emit("uiMap.resident.destroy");
} EventBus.$emit("uiMap.replay.destroy");
EventBus.$emit("uiMap.fence.destroy");
},
components: {
MapMenu,
MapTable,
MapControll,
},
};
</script> </script>
<style scoped> <style scoped>
.map-wrap{ .map-wrap {
position: absolute; position: absolute;
top: 100px; top: 100px;
left: 0; left: 0;
width: 100%; width: 100%;
height: calc(100% - 100px); height: calc(100% - 100px);
overflow: hidden; overflow: hidden;
} }
.map-container{ .map-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 100 z-index: 100;
} }
.el-loading-mask{ .el-loading-mask {
z-index: 101; z-index: 101;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<div class="map-wrap" > <div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div> <div id="map" class="map-container" v-loading="mapLoading"></div>
<div class="menu-search"> <div class="menu-search">
<el-input placeholder="请输入对应条件值" v-model="search.text" size="small" class="input-with-select"> <el-input
<el-select v-model="search.type" slot="prepend" placeholder="请选择" size="small" > placeholder="请输入对应条件值"
<el-option label="设备号" value="1"></el-option> v-model="search.text"
<el-option label="车架号" value="2"></el-option> size="small"
<el-option label="姓名" value="3"></el-option> class="input-with-select"
<el-option label="工单号" value="4"></el-option> >
</el-select> <el-select
v-model="search.type"
</el-input> slot="prepend"
<el-button icon="el-icon-search" size="mini" type="primary" :loading="search.isSearching" @click="searchSubmit">搜索</el-button> placeholder="请选择"
<el-button :icon="search.showResult?'fa fa-caret-up':'fa fa-caret-down'" size="mini" type="primary" @click="toggleResult"></el-button> size="small"
</div> >
</div> <el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option>
<el-option label="工单号" value="4"></el-option>
</el-select>
</el-input>
<el-button
icon="el-icon-search"
size="mini"
type="primary"
:loading="search.isSearching"
@click="searchSubmit"
>搜索</el-button
>
<el-button
:icon="search.showResult ? 'fa fa-caret-up' : 'fa fa-caret-down'"
size="mini"
type="primary"
@click="toggleResult"
></el-button>
</div>
</div>
</template> </template>
<script> <script>
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 MapMenu from './MapMenu.vue' import MapMenu from "./MapMenu.vue";
import MapTable from './MapTable.vue' import MapTable from "./MapTable.vue";
import MapControll from './MapControll.vue' import MapControll from "./MapControll.vue";
import EventBus from '../../event-bus' import EventBus from "../../event-bus";
import {services} from '../../api' import { services } from "../../api";
import mock from '../../mock' import mock from "../../mock";
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
import {CONSTANT} from '../../constant' import { CONSTANT } from "../../constant";
export default{ export default {
data(){ data() {
return { return {
AMap: null, AMap: null,
mapObj: null, mapObj: null,
mapLoading: false, mapLoading: false,
isInitMap: false isInitMap: false,
} };
}, },
methods: { methods: {
initMap(){ initMap() {
let check = ()=>{ let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(()=>{ return setTimeout(() => {
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){ if (
window.AMap = AMap; "AMap" in window &&
this.mapObj = mapService.init('map'); typeof AMap.Map == "function" &&
!this.mapObj
//this.bindEvent(); ) {
this.isInitMap = true; window.AMap = AMap;
}else{ this.mapObj = mapService.init("map");
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
},
},
async created () {
if(window.AMap){
this.initMap();
}else{
await remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{
this.initMap();
})
})
}
},
beforeDestroy(){
this.offEvent();
this.monitorInterval && window.clearTimeout(this.monitorInterval);
}, //this.bindEvent();
components: { this.isInitMap = true;
} else {
} this.checkMapLoaded = check();
} }
}, 100);
};
this.checkMapLoaded = check();
},
},
async created() {
let _this = this;
_this.$mapInit({ version: "1.0.11" }).then((AMap) => {
_this.initMap();
});
},
beforeDestroy() {
this.offEvent();
this.monitorInterval && window.clearTimeout(this.monitorInterval);
},
components: {},
};
</script> </script>
<style scoped> <style scoped>
.map-wrap{ .map-wrap {
position: absolute; position: absolute;
top: 100px; top: 100px;
left: 0; left: 0;
width: 100%; width: 100%;
height: calc(100% - 100px); height: calc(100% - 100px);
overflow: hidden; overflow: hidden;
} }
.map-container{ .map-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 100 z-index: 100;
} }
.el-loading-mask{ .el-loading-mask {
z-index: 101; z-index: 101;
} }
.menu-search{ .menu-search {
position: absolute; position: absolute;
top: 20px; top: 20px;
left: 20px; left: 20px;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -4,21 +4,26 @@ ...@@ -4,21 +4,26 @@
<el-breadcrumb-item>激活位置</el-breadcrumb-item> <el-breadcrumb-item>激活位置</el-breadcrumb-item>
</template> </template>
<template slot="main"> <template slot="main">
<div class="device_list" v-if="deviceList && deviceList.length>1"> <div class="device_list" v-if="deviceList && deviceList.length > 1">
<div class="title"> <div class="title">
<span>设备列表({{deviceList.length}})</span> <span>设备列表({{ deviceList.length }})</span>
<!-- <i class="el-icon-close i_close"></i> --> <!-- <i class="el-icon-close i_close"></i> -->
</div> </div>
<div class="list_box"> <div class="list_box">
<div class="cell" v-for="(item,index) in deviceList" :key="index" @click="openMapInfoWindow(item.sn, item.vin)"> <div
class="cell"
v-for="(item, index) in deviceList"
:key="index"
@click="openMapInfoWindow(item.sn, item.vin)"
>
<div class="top"> <div class="top">
<i class="i_circle" :class="item.status == 2?'i_red':''"></i> <i class="i_circle" :class="item.status == 2 ? 'i_red' : ''"></i>
<span>{{item.ownerName||''}}</span> <span>{{ item.ownerName || "" }}</span>
<span>{{item.sn||''}}({{statusList[item.source]}})</span> <span>{{ item.sn || "" }}({{ statusList[item.source] }})</span>
</div> </div>
<div class="bottom"> <div class="bottom">
<span>车架号:</span> <span>车架号:</span>
<span>{{item.vin||''}}</span> <span>{{ item.vin || "" }}</span>
</div> </div>
</div> </div>
</div> </div>
...@@ -55,17 +60,10 @@ export default { ...@@ -55,17 +60,10 @@ export default {
}, },
created() { created() {
console.log(history.state); console.log(history.state);
if (window.AMap) { let _this = this;
this.initMap(); _this.$mapInit({ version: "1.0.11" }).then((AMap) => {
} else { _this.initMap();
remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => { });
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
() => {
this.initMap();
}
);
});
}
}, },
methods: { methods: {
// 初始化地图 // 初始化地图
...@@ -93,10 +91,10 @@ export default { ...@@ -93,10 +91,10 @@ export default {
} }
// 兼容其他页面的跳转 // 兼容其他页面的跳转
if(query && query.sn){ if (query && query.sn) {
query.elat = query.lat query.elat = query.lat;
query.elng = query.lng query.elng = query.lng;
this.addLocation(query,true); this.addLocation(query, true);
return false; return false;
} }
...@@ -104,7 +102,7 @@ export default { ...@@ -104,7 +102,7 @@ export default {
if (o.lng || o.bsLng) { if (o.lng || o.bsLng) {
o.elat = o.lat; o.elat = o.lat;
o.elng = o.lng; o.elng = o.lng;
this.addLocation(o,true); this.addLocation(o, true);
} }
} else { } else {
this.checkLoadedTimeoutId = check(); this.checkLoadedTimeoutId = check();
...@@ -295,5 +293,4 @@ export default { ...@@ -295,5 +293,4 @@ export default {
.i_red { .i_red {
background: #f00; background: #f00;
} }
</style> </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>
<!-- 地图工具 开始 -->
<fence-map-controll
@onRefreshMap="refreshMap"
:isModalMap="true"
></fence-map-controll>
<!-- 地图工具 end -->
<!-- 地图搜索工具 开始 -->
<div class="map-seacrh-wrap">
<el-input
placeholder="请输入搜索地址"
id="poiMapSearch"
size="small"
maxlength="40"
v-model="poiMapSearch"
:disabled="readonlyStatus"
>
<template slot="prepend">搜索</template>
</el-input>
</div>
<!-- 地图搜索工具 end -->
<!-- 底部 开始 -->
<div class="bottom_list_hide" v-show="hideFooter" @click="onHide">
<i class="el-icon-arrow-up"></i>
<span>显示</span>
</div>
<div class="bottom_list" v-show="!hideFooter">
<div class="head">
<div class="left">
<span>POI基础信息</span>
</div>
<div class="right">
<a href="javascript:void(0)" class="link" @click="onHide">收起</a>
</div>
</div>
<div class="bottom_content">
<el-form
ref="poiForm"
:model="form"
:rules="formRules"
label-width="100px"
class="addPoiForm"
>
<div class="form_list">
<el-form-item label="POI名称:" prop="poiName">
<el-input v-model="form.poiName" maxlength="20"></el-input>
</el-form-item>
<el-form-item label="POI类型:" prop="poiType">
<el-select v-model="form.poiType" class="small_select">
<el-option label="黑区圆心" :value="1"></el-option>
<el-option label="二押点" :value="2"></el-option>
<el-option label="异常聚集点" :value="3"></el-option>
</el-select>
</el-form-item>
<div class="lnglat_box">
<el-form-item label="经度:" prop="lng">
<el-input v-model="form.lng" disabled />
</el-form-item>
<el-form-item label="维度:" prop="lat">
<el-input v-model="form.lat" disabled />
</el-form-item>
</div>
</div>
<div class="form_list">
<el-form-item label="描述:">
<el-input
type="textarea"
v-model="form.remark"
rows="5"
resize="none"
maxlength="200"
show-word-limit
></el-input>
</el-form-item>
</div>
</el-form>
<div class="btn_box">
<el-button type="primary" :loading="aloading" @click="saveInfo"
>保存</el-button
>
<el-button type="default" @click="goListPage">取消</el-button>
</div>
</div>
</div>
<!-- 底部 end -->
</template>
</v-full-layout>
</template>
<script>
import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js";
import { STATICIMAGE } from "@/constant";
import FenceMapControll from "./FenceMapControll";
import EventBus from "@/event-bus";
import { showToast, deepClone, showModal } from "@/utils/utils.js";
import {
ADD_POI_INFO,
GET_POI_TRACK,
DELETE_POI_INFO,
UPDATE_POI_INFO,
CHECK_POI_NAME,
GET_POI_INFO,
} from "@/api/services/poi";
export default {
components: {
FenceMapControll,
},
data() {
return {
map: null,
mapLoading: true,
form: {},
formRules: {
poiName: [
{ required: true, message: "请输入POI名称", trigger: "blur" },
{ validator: this.checkName, trigger: "blur" },
],
poiType: [
{ required: true, message: "请选择POI类型!", trigger: "change" },
],
lng: [
{
required: true,
message: "经纬度不能为空,请在地图中标注!",
trigger: "blur",
},
],
lat: [
{
required: true,
message: "经纬度不能为空,请在地图中标注!",
trigger: "blur",
},
],
},
hideFooter: false,
poi: {},
poiMapSearch: "",
poiMarker: null, // 通过搜索、右键创建的点标记
aloading: false,
trackList: [], // 历史poi点
poiInfoWindow: null, // 当前的弹框
markerList: {}, // poi点标记列表
showMapText: false, //是否地图展示道路、标题
};
},
mounted() {
console.log(STATICIMAGE);
this.initMap();
EventBus.$on("uiMap.poi.marker.delete", this.removePoi);
},
methods: {
// 地图初始化
initMap() {
let _this = this;
let plugins = ["AMap.LngLat", "AMap.MassMarks", "AMap.Geocoder"];
_this.$mapInit({ plugins: plugins }).then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map", {
zoom: 15,
showIndoorMap: false,
showLabel: false,
});
_this.bindSearch();
_this.initMapEvent();
_this.getPoiTrack();
});
},
// 创建地图右键菜单
initMapEvent() {
let _this = this;
let _map = this.map;
let _position = "";
let _contextMenu = new AMap.ContextMenu();
//右键添加Marker标记
_contextMenu.addItem("设置POI点", function () {
_contextMenu.close();
_this.addPoiMarker(_position);
});
//地图绑定鼠标右击事件——弹出右键菜单
_map.on("rightclick", function (e) {
_contextMenu.open(_map, e.lnglat);
_position = e.lnglat;
});
},
// 批量添加海量点
addMassMarkers(arr) {
let _this = this;
let _query = _this.$route.query;
let markers = [];
let _icon = {
url: STATICIMAGE.POI_MASS_ICON,
size: new AMap.Size(16, 21),
anchor: new AMap.Pixel(3, 3),
};
for (let i = 0, len = arr.length; i < len; i++) {
let k = arr[i];
if (k.id != _query.id) {
if (k.lnglat) {
let m = k.lnglat.split(",");
k.lng = m[0];
k.lat = m[1];
k.lnglat = m;
markers.push(k);
}
}
}
let mass = new AMap.MassMarks(markers, {
opacity: 0.8,
zIndex: 10,
cursor: "pointer",
style: _icon,
});
mass.on("click", function (e) {
console.log(e);
_this.markerEvent(e.data);
});
mass.setMap(_this.map);
},
// 地图右键添加poi点
addPoiMarker(options, type, isOpen) {
let _this = this;
let _map = _this.map;
let _InfoWindow = _this.poiInfoWindow;
if (_this.poiMarker) {
_map.remove(_this.poiMarker);
_InfoWindow && _InfoWindow.close();
_this.poiMarker = null;
}
let _icon = new AMap.Icon({
image: STATICIMAGE.POI_MARKER,
});
if (options.id) {
_icon = new AMap.Icon({
image: STATICIMAGE.POI_MASS_ICON,
imageSize: new AMap.Size(16, 21),
});
}
let _marker = new AMap.Marker({
icon: _icon,
position: [options.lng, options.lat],
extData: options,
});
let _markerInfo = _marker.getExtData();
//_marker.infoWindow = mapService.createPoiMarkerInfowindow(options);
_marker.on("click", function (e) {
_this.markerEvent(_markerInfo);
});
_marker.setMap(_this.map);
// 历史marker存储起来,以id为键值,方便后续删除用
if (options.id) {
_this.$set(_this.markerList, options.id, _marker);
}
if (!options.id) {
_this.poiMarker = _marker;
_this.$set(_this.form, "lng", options.lng);
_this.$set(_this.form, "lat", options.lat);
_this.markerEvent(_markerInfo);
}
if (type && type == "search") {
_this.setCenter(options.lng, options.lat);
}
// 默认打开信息弹框
if (isOpen) {
_this.markerEvent(options);
_this.setCenter(options.lng, options.lat);
}
},
// marker点击事件
markerEvent(e) {
let _this = this;
console.log(e);
let _params = e;
const geocoder = new AMap.Geocoder({
extensions: "all",
});
_this.setPoiInfo(e);
geocoder.getAddress(
new AMap.LngLat(e.lng, e.lat),
function (status, result) {
console.log(status);
console.log(result);
let _regeocode = result.regeocode || {};
let _pois = _regeocode.pois || [];
_params.address = _regeocode.formattedAddress || "";
_params.near = _pois[0] ? _pois[0].name : "";
let infoWindow = mapService.createPoiMarkerInfowindow(_params);
_this.poiInfoWindow = infoWindow;
infoWindow.open(_this.map);
}
);
},
// 设置poi信息
setPoiInfo(row) {
let _this = this;
_this.$set(_this.form, "lng", row.lng);
_this.$set(_this.form, "lat", row.lat);
_this.$set(_this.form, "remark", row.remark || "");
_this.$set(_this.form, "poiName", row.poiName || "");
_this.$set(_this.form, "poiType", row.poiType || "");
_this.$set(_this.form, "id", row.id || "");
_this.$set(_this.form, "enableStatus", row.enableStatus || "");
setTimeout(function () {
_this.$refs.poiForm.clearValidate();
}, 100);
},
// 隐藏
onHide() {
this.hideFooter = !this.hideFooter;
},
// 绑定搜索
bindSearch() {
const _this = this;
AMap.plugin("AMap.AutoComplete", function () {
let autoComplete = new AMap.AutoComplete({
input: "poiMapSearch",
});
autoComplete.on("select", function (e) {
console.log(e);
let _poi = e.poi || {};
let _params = {};
_params.lng = _poi.location.lng;
_params.lat = _poi.location.lat;
_this.addPoiMarker(_params, "search");
});
});
},
// 返回列表页面
goListPage() {
let path = `/trialRun#/poi/index`;
history.pushState({}, path, path);
},
// 获取参数
getParams() {
let params = {};
let m = deepClone(this.form);
params.poiName = m.poiName;
params.poiType = m.poiType;
params.lnglat = `${m.lng},${m.lat}`;
params.remark = m.remark;
if (m.id) {
params.id = m.id;
params.enableStatus = m.enableStatus;
}
return params;
},
// 保存信息
saveInfo() {
let _this = this;
_this.$refs.poiForm.validate((valid) => {
if (!valid) {
return false;
}
let _params = _this.getParams();
let _callBack = ADD_POI_INFO;
if (_params.id) {
_callBack = UPDATE_POI_INFO;
}
_this.aloading = true;
_callBack(_params).then((res) => {
console.log(res);
_this.aloading = false;
if (res.code == 200) {
showToast({
message: "保存成功",
type: "success",
});
_this.goListPage();
}
});
});
},
// 删除poi点
removePoi(row) {
console.log(row);
let _this = this;
let _message = "确认删除该POI信息吗?";
let _typeList = {
1: "黑区圆心",
2: "二押点",
3: "异常聚集点",
};
if (row.poiName) {
_message = `确认删除【${row.poiName}】的【${
_typeList[row.poiType]
}】POI信息吗?`;
}
showModal({
message: _message,
type: "warning",
showCancelButton: true,
success: function () {
_this.removeRequest(row);
},
});
},
// 删除请求
removeRequest(row) {
let _this = this;
let _map = this.map;
let _params = {};
let _InfoWindow = this.poiInfoWindow;
// id不存在,临时的poi点,删除marker就行了
if (!row.id) {
_map.remove(_this.poiMarker);
_InfoWindow && _InfoWindow.close();
_this.form = {};
setTimeout(function () {
_this.$refs.poiForm.clearValidate();
}, 100);
return false;
}
_params.id = row.id;
DELETE_POI_INFO(_params).then((res) => {
if (res.code == 200) {
let _marker = _this.markerList[row.id];
_map.remove(_marker);
_InfoWindow && _InfoWindow.close();
showToast({
message: "删除成功",
type: "success",
});
_this.form = {};
setTimeout(function () {
_this.$refs.poiForm.clearValidate();
}, 100);
}
});
},
// 获取历史poi点
getPoiTrack() {
let _this = this;
let _query = _this.$route.query;
GET_POI_TRACK().then((res) => {
if (res.code == 200) {
let _list = res.data || [];
_this.addMassMarkers(_list);
// 编辑页面
if (_query.id) {
_this.getInfo();
}
_this.trackList = res.data || [];
_this.showRoadTitle();
}
});
},
// 获取poi详情接口
getInfo() {
let _this = this;
let _query = _this.$route.query;
let _params = {};
_params.id = _query.id;
GET_POI_INFO(_params).then((res) => {
console.log(res);
let _obj = res.data || {};
if (_obj.lnglat) {
let arr = _obj.lnglat.split(",");
_obj.lng = arr[0];
_obj.lat = arr[1];
}
console.log(_obj);
_this.addPoiMarker(_obj, "", true);
});
},
// 校验名称
checkName(rule, value, callback) {
let _params = {};
_params.poiName = value;
if (this.form.id) {
_params.id = this.form.id;
}
CHECK_POI_NAME(_params).then((res) => {
if (res.code == 200) {
callback();
} else {
callback(new Error(res.message));
}
});
},
// 设置地图中心点
setCenter(lng, lat) {
let _this = this;
let _map = _this.map;
if (_map) {
console.log(lng, lat);
setTimeout(function () {
_map.setCenter([lng, lat]);
}, 1000);
}
},
// 展示隐藏地图标题
showRoadTitle() {
let _road = new AMap.TileLayer.RoadNet();
let _title = new AMap.TileLayer();
this.map.add([_title]);
},
},
};
</script>
<style lang="scss" scoped>
@import "../../assets/scss/addPoi.scss";
</style>
\ No newline at end of file \ No newline at end of file
...@@ -217,17 +217,10 @@ export default { ...@@ -217,17 +217,10 @@ export default {
}, },
}, },
created() { created() {
if (window.AMap) { let _this = this;
this.initMap(); _this.$mapInit({ version: "1.0.11" }).then((AMap) => {
} else { _this.initMap();
remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => { });
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
() => {
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);
......
<template> <template>
<v-full-layout> <v-full-layout>
<template slot="breadcrumb"> <template slot="breadcrumb">
<el-breadcrumb-item>电子围栏</el-breadcrumb-item> <el-breadcrumb-item>电子围栏</el-breadcrumb-item>
</template> </template>
<template slot="main"> <template slot="main">
<div class="map-wrap" > <div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div> <div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll> <map-controll></map-controll>
<div class="controll-wrap"> <div class="controll-wrap">
<div class="search-box active side_auto_h"> <div class="search-box active side_auto_h">
<h3>电子围栏</h3> <h3>电子围栏</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p> <p class="info">{{ name }}/{{ standno }}/{{ sn }}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form"> <el-form
<el-form-item label="定位方式"> ref="form"
<el-select v-model="form.locationType" placeholder="请选择" size="small" style="width: 280px"> :model="form"
<el-option label="GPS" :value="1"></el-option> :rules="rules"
<el-option label="基站" :value="2"></el-option> :inline="false"
</el-select> size="mini"
</el-form-item> class="form"
<el-form-item label="围栏名称" prop="electricFenceName"> >
<el-input v-model.trim="form.electricFenceName" maxlength="200"></el-input> <el-form-item label="定位方式">
</el-form-item> <el-select
<el-form-item label="触发类型"> v-model="form.locationType"
<el-select v-model="form.triggerType" placeholder="请选择" size="small" style="width: 280px"> placeholder="请选择"
<el-option label="驶出" :value="2"></el-option> size="small"
<el-option label="驶入" :value="1"></el-option> style="width: 280px"
<el-option label="驶入驶出" :value="3"></el-option> >
</el-select> <el-option label="GPS" :value="1"></el-option>
</el-form-item> <el-option label="基站" :value="2"></el-option>
<el-form-item label="指定区间" prop="daterange"> </el-select>
<el-date-picker </el-form-item>
style="width: 100%;" <el-form-item label="围栏名称" prop="electricFenceName">
v-model="form.dateRange" <el-input
type="daterange" v-model.trim="form.electricFenceName"
size="small" maxlength="200"
:clearable="false" ></el-input>
:editable="false" </el-form-item>
:unlink-panels="true" <el-form-item label="触发类型">
range-separator="至" <el-select
start-placeholder="开始日期" v-model="form.triggerType"
end-placeholder="结束日期"> placeholder="请选择"
</el-date-picker> size="small"
</el-form-item> style="width: 280px"
<el-form-item label="监控区域" class="row-form-item"> >
<el-row> <el-option label="驶出" :value="2"></el-option>
<el-col :span="8"> <el-option label="驶入" :value="1"></el-option>
<el-radio v-model="form.shapeType" :label="2">圆形</el-radio> <el-option label="驶入驶出" :value="3"></el-option>
</el-col> </el-select>
<el-col :span="16"> </el-form-item>
<el-form-item label="" prop="fenceRadius"> <el-form-item label="指定区间" prop="daterange">
<el-input v-model.trim="form.fenceRadius" style="width: 80px;" maxlength="200"></el-input>米 <el-date-picker
</el-form-item> style="width: 100%"
</el-col> v-model="form.dateRange"
</el-row> type="daterange"
<el-row> size="small"
<el-col :span="8"> :clearable="false"
<el-radio v-model="form.shapeType" :label="5">多边形</el-radio> :editable="false"
</el-col> :unlink-panels="true"
<el-col :span="16" class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</el-col> range-separator="至"
</el-row> start-placeholder="开始日期"
<el-row> end-placeholder="结束日期"
<el-col :span="8"> >
<el-radio v-model="form.shapeType" :label="3">行政区域</el-radio> </el-date-picker>
</el-col> </el-form-item>
<el-col :span="16"> <el-form-item label="监控区域" class="row-form-item">
<el-form-item label=""> <el-row>
<!-- 监控省市区组件 --> <el-col :span="8">
<!-- <area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="form.areaCode"></area-select> --> <el-radio v-model="form.shapeType" :label="2"
<!-- 监控省市区组件 /--> >圆形</el-radio
>
</el-form-item> </el-col>
</el-col> <el-col :span="16">
</el-row> <el-form-item label="" prop="fenceRadius">
</el-form-item> <el-input
<el-form-item label="短信通知" prop="msgtel"> v-model.trim="form.fenceRadius"
<el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input> style="width: 80px"
</el-form-item> maxlength="200"
<el-form-item label="围栏状态"> ></el-input
<el-radio v-model="form.status" :label="1">启用</el-radio> >米
<el-radio v-model="form.status" :label="0">停用</el-radio> </el-form-item>
</el-form-item> </el-col>
<el-form-item> </el-row>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button> <el-row>
</el-form-item> <el-col :span="8">
</el-form> <el-radio v-model="form.shapeType" :label="5"
</div> >多边形</el-radio
>
</div> </el-col>
</div> <el-col :span="16" class="shape_tip"
</template> >*注:地图任意位置,单击新增双击结束绘制。</el-col
</v-full-layout> >
</el-row>
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="3"
>行政区域</el-radio
>
</el-col>
<el-col :span="16">
<el-form-item label="">
<!-- 监控省市区组件 -->
<!-- <area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="form.areaCode"></area-select> -->
<!-- 监控省市区组件 /-->
</el-form-item>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="短信通知" prop="msgtel">
<el-input
v-model.trim="form.msgtel"
maxlength="100"
placeholder="输入格式:手机号码,手机号码(支持双号)"
></el-input>
</el-form-item>
<el-form-item label="围栏状态">
<el-radio v-model="form.status" :label="1">启用</el-radio>
<el-radio v-model="form.status" :label="0">停用</el-radio>
</el-form-item>
<el-form-item>
<el-button
type="primary"
@click="submit"
size="small"
:loading="isSubmitting"
>保存</el-button
>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
</v-full-layout>
</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 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;
import { CONSTANT } from "@/constant";
import AreaSelect from "./AreaSelect.vue";
import MAPGEO from "@/utils/mapgeo";
import MapControll from "./MapControll.vue";
import {CONSTANT} from '@/constant' export default {
data() {
let checkFenceName = (rule, vaule, cb) => {
if (
typeof this.restainFenceName != "undefined" &&
this.form.electricFenceName === this.restainFenceName
) {
cb();
}
MONITOR_SERVICE.checkFenceName({
name: this.form.electricFenceName,
}).then((res) => {
if (res.returnCode == 0) {
if (res.data.isExist == 1) {
cb(new Error("该围栏名已存在,请重新输入!"));
} else {
cb();
}
}
});
};
let checkDaterange = (rule, vaule, cb) => {
const dateRange = this.form.dateRange;
if (!dateRange || !dateRange.length) {
cb(new Error("请选择日期"));
} else {
let min = dateRange[0];
let max = dateRange[1];
import AreaSelect from './AreaSelect.vue' if (!moment.isMoment(min)) {
import MAPGEO from '@/utils/mapgeo' min = moment(min);
import MapControll from './MapControll.vue' }
if (!moment.isMoment(max)) {
max = moment(max);
}
export default{ if (min.isBefore(moment(max).subtract(30 * 6, "days"), "minute")) {
data(){ cb(new Error("日期范围不能超过180天"));
let checkFenceName = (rule, vaule, cb)=>{ }
if(typeof this.restainFenceName != 'undefined' && this.form.electricFenceName === this.restainFenceName){ }
cb(); cb();
} };
MONITOR_SERVICE.checkFenceName({name: this.form.electricFenceName}).then((res)=>{
if(res.returnCode == 0){
if(res.data.isExist == 1){
cb(new Error('该围栏名已存在,请重新输入!'))
}else{
cb();
}
}
})
}
let checkDaterange = (rule, vaule, cb)=>{
const dateRange = this.form.dateRange; let checkRadius = (rule, vaule, cb) => {
if(!dateRange || !dateRange.length){ const fenceRadius = this.form.fenceRadius;
cb(new Error('请选择日期')) if (
}else{ this.form.shapeType == 2 &&
let min = dateRange[0]; (!/^\d+$/.test(fenceRadius) || fenceRadius < 1000)
let max = dateRange[1]; ) {
cb(new Error("请输入整数且不小于1000"));
if(!moment.isMoment(min)){ } else {
min = moment(min) cb();
} }
if(!moment.isMoment(max)){ };
max = moment(max)
}
if(min.isBefore( moment(max).subtract(30*6, 'days'), 'minute')){
cb(new Error('日期范围不能超过180天'))
}
}
cb()
}
let checkRadius = (rule, vaule, cb)=>{ let checkMsgtel = (rule, vaule, cb) => {
const fenceRadius = this.form.fenceRadius; if (this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)) {
if(this.form.shapeType == 2 && (!/^\d+$/.test(fenceRadius) || fenceRadius<1000)){ cb(new Error("请输入正确的格式"));
cb(new Error('请输入整数且不小于1000')) } else {
}else{ cb();
cb(); }
} };
} return {
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: "",
searchType: "sn",
isSearching: false,
areaId: "",
areaStr: "",
isSubmitting: false,
form: {
fenceNo: "",
electricFenceName: "",
locationType: 1,
triggerType: 3,
dateRange: [],
shapeType: 2,
fenceRadius: "1000",
status: 1,
areaCode: "",
lng: "",
lat: "",
analysisAddress: "",
msgtel: "",
},
rules: {
electricFenceName: [
{ required: true, message: "请输入围栏名称", trigger: "blur" },
{ pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
{ validator: checkFenceName, trigger: "blur" },
],
daterange: [{ validator: checkDaterange }],
fenceRadius: [{ validator: checkRadius, trigger: "blur" }],
msgtel: [{ validator: checkMsgtel, trigger: "blur" }],
},
fenceId: undefined,
restainFenceName: "",
polygonPath: [],
};
},
mounted() {
store.dispatch("setFullsize", true);
},
watch: {
"form.fenceRadius"(newVal) {
if (this.form.shapeType === 2) {
if (this._updateFenceRadiusTimeoutId) {
clearTimeout(this._updateFenceRadiusTimeoutId);
}
this._updateFenceRadiusTimeoutId = setTimeout(() => {
this.$refs.form.validateField("fenceRadius", (error) => {
if (error) {
return false;
} else {
this.updateFenceRadius(newVal);
}
});
let checkMsgtel = (rule, vaule, cb)=>{ /*this.$refs.form.validate((valid, field)=>{
if(this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)){
cb(new Error('请输入正确的格式'))
}else{
cb();
}
}
return {
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: '',
searchType: 'sn',
isSearching: false,
areaId: '',
areaStr: '',
isSubmitting: false,
form: {
fenceNo: '',
electricFenceName: '',
locationType: 1,
triggerType: 3,
dateRange: [],
shapeType: 2,
fenceRadius: '1000',
status: 1,
areaCode: '',
lng: '',
lat: '',
analysisAddress: '',
msgtel: ''
},
rules: {
electricFenceName: [
{required: true, message: '请输入围栏名称', trigger: 'blur'},
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' },
{validator: checkFenceName, trigger: 'blur'}
],
daterange: [{validator: checkDaterange}],
fenceRadius: [
{validator: checkRadius, trigger: 'blur'}
],
msgtel: [{validator: checkMsgtel, trigger: 'blur'}],
},
fenceId: undefined,
restainFenceName: '',
polygonPath: []
}
},
mounted(){
store.dispatch('setFullsize', true)
},
watch: {
'form.fenceRadius'(newVal){
if(this.form.shapeType === 2){
if(this._updateFenceRadiusTimeoutId){
clearTimeout(this._updateFenceRadiusTimeoutId)
}
this._updateFenceRadiusTimeoutId = setTimeout(()=>{
this.$refs.form.validateField('fenceRadius', (error)=>{
if(error){
return false;
}else{
this.updateFenceRadius(newVal)
}
});
/*this.$refs.form.validate((valid, field)=>{
if(valid){ if(valid){
this.updateFenceRadius(newVal) this.updateFenceRadius(newVal)
...@@ -234,305 +281,301 @@ ...@@ -234,305 +281,301 @@
return false; return false;
} }
});*/ });*/
}, 500); }, 500);
}
} },
}, "form.shapeType"(newVal) {
'form.shapeType'(newVal){ this._shapeTypeTimeoutId && clearTimeout(this._shapeTypeTimeoutId);
this._shapeTypeTimeoutId && clearTimeout(this._shapeTypeTimeoutId); this._shapeTypeTimeoutId = setTimeout(() => {
this._shapeTypeTimeoutId = setTimeout(()=>{ console.log(newVal);
console.log(newVal) if (newVal === 2) {
if(newVal === 2){ this.$refs.form.validateField("fenceRadius", (error) => {
this.$refs.form.validateField('fenceRadius', (error)=>{ if (error) {
if(error){ EventBus.$emit("uiMap.fence.destroy");
EventBus.$emit('uiMap.fence.destroy'); return false;
return false; } else {
}else{ this.drawFenceCircle();
this.drawFenceCircle() }
} });
}); } else if (newVal === 3) {
}else if(newVal === 3){ if (this.areaId) {
if(this.areaId){ this.drawDistrict(this.areaId);
this.drawDistrict(this.areaId) } else {
}else{ EventBus.$emit("uiMap.fence.destroy");
EventBus.$emit('uiMap.fence.destroy'); }
} } else if (newVal === 5) {
this.drawPolygon();
}else if(newVal === 5){ }
this.drawPolygon() }, 500);
} },
}, 500) },
methods: {
} initMap() {
}, let check = () => {
methods: { this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
initMap(){
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(()=>{ return setTimeout(() => {
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){ if (
window.AMap = AMap; "AMap" in window &&
this.mapObj = mapService.init('map'); typeof AMap.Map == "function" &&
!this.mapObj
//this.bindEvent(); ) {
this.isInitMap = true; window.AMap = AMap;
this.initFence(); this.mapObj = mapService.init("map");
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
},
initFence(){
MONITOR_SERVICE.getSingleFence({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
if(data){
this.fenceId = data.fenceId;
const form = this.form;
form.locationType = data.locationType;
form.electricFenceName = data.electricFenceName;
this.restainFenceName = form.electricFenceName;
form.triggerType = data.electricFenceType; //this.bindEvent();
form.dateRange = [moment(data.startTime),moment(data.endTime)]; this.isInitMap = true;
form.shapeType = data.shapeType; this.initFence();
form.status = data.status; } else {
form.areaCode = data.areaCode; this.checkMapLoaded = check();
form.msgtel = data.telNumbers; }
}, 100);
if(form.shapeType === 2){ };
form.fenceRadius = data.radius; this.checkMapLoaded = check();
form.lng = data.lng; },
form.lat = data.lat; initFence() {
EventBus.$emit('uiMap.fence.createFenceCircle', { MONITOR_SERVICE.getSingleFence({
lng: data.lng, sn: this.sn,
lat: data.lat, }).then((res) => {
radius: data.radius if (res.returnCode == 0) {
}); const data = res.data;
}else if(form.shapeType === 3){ if (data) {
this.drawDistrict(data.areaCode) this.fenceId = data.fenceId;
}else if(form.shapeType === 5){ const form = this.form;
if(data.lnglat){ form.locationType = data.locationType;
this.polygonPath = data.lnglat.split('|').map((item)=>{ form.electricFenceName = data.electricFenceName;
return [item.split(',')[0], item.split(',')[1]] this.restainFenceName = form.electricFenceName;
})
}
this.drawPolygon()
}
}else{
this.restainFenceName = undefined;
}
this.initDetail();
}
});
},
initDetail(){
MONITOR_SERVICE.getTrackBySn({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
const form = this.form;
if(!this.restainFenceName){
form.electricFenceName = '单设备围栏-'+this.name;
}
if(!form.lng && !form.lat){
form.lng = data.lngGPS;
form.lat = data.latGPS;
this.drawFenceCircle();
}
EventBus.$emit('uiMap.fence.createFenceMarker', data);
}
});
},
pickDate(beforeDays){
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')]
},
submit(){
if(this.form.shapeType == 5){
if(this.polygonPath.length === 0){
this.$message({
message: '请绘制围栏',
type: 'error'
});
return;
}
}
this.$refs.form.validate((valid, field)=>{
if(valid){
this.isSubmitting = true;
this.getParams().then((data)=>{
let params = data;
if(typeof this.fenceId != 'undefined'){ form.triggerType = data.electricFenceType;
form.dateRange = [moment(data.startTime), moment(data.endTime)];
params.id = this.fenceId; form.shapeType = data.shapeType;
form.status = data.status;
MONITOR_SERVICE.updateFence(JSON.stringify(params)).then((res)=>{ form.areaCode = data.areaCode;
if(res.returnCode == 0){ form.msgtel = data.telNumbers;
//this.closeDialog();
this.$message({ if (form.shapeType === 2) {
message: res.message, form.fenceRadius = data.radius;
type: 'success' form.lng = data.lng;
}); form.lat = data.lat;
} EventBus.$emit("uiMap.fence.createFenceCircle", {
this.isSubmitting = false; lng: data.lng,
}); lat: data.lat,
}else{ radius: data.radius,
MONITOR_SERVICE.getNewFenceId().then((res)=>{ });
if(res.returnCode == 0){ } else if (form.shapeType === 3) {
params.fenceNo = res.data.fenceNo; this.drawDistrict(data.areaCode);
MONITOR_SERVICE.saveFence(JSON.stringify(params)).then((res)=>{ } else if (form.shapeType === 5) {
if(res.returnCode == 0){ if (data.lnglat) {
//this.closeDialog(); this.polygonPath = data.lnglat.split("|").map((item) => {
this.$message({ return [item.split(",")[0], item.split(",")[1]];
message: res.message, });
type: 'success' }
}); this.drawPolygon();
this.fenceId = res.data; }
this.restainFenceName = this.form.electricFenceName; } else {
} this.restainFenceName = undefined;
this.isSubmitting = false; }
});
} this.initDetail();
}); }
} });
}); },
initDetail() {
}else{ MONITOR_SERVICE.getTrackBySn({
return false; sn: this.sn,
} }).then((res) => {
}); if (res.returnCode == 0) {
}, const data = res.data;
getParams(){ const form = this.form;
return new Promise((resolve, reject)=>{ if (!this.restainFenceName) {
const form = this.form; form.electricFenceName = "单设备围栏-" + this.name;
const params = {}; }
const transferItem = {
data: [{ if (!form.lng && !form.lat) {
elng: form.lng, form.lng = data.lngGPS;
elat: form.lat form.lat = data.latGPS;
}] this.drawFenceCircle();
} }
MAPGEO.transferAddressByGroup(transferItem, ()=>{ EventBus.$emit("uiMap.fence.createFenceMarker", data);
params.electricFenceName = form.electricFenceName; }
params.electricFenceType = form.triggerType; });
params.shapeType = form.shapeType; },
params.locationType = form.locationType; pickDate(beforeDays) {
this.form.dateRange = [
moment().subtract(beforeDays, "days"),
moment().subtract(1, "days"),
];
},
submit() {
if (this.form.shapeType == 5) {
if (this.polygonPath.length === 0) {
this.$message({
message: "请绘制围栏",
type: "error",
});
return;
}
}
this.$refs.form.validate((valid, field) => {
if (valid) {
this.isSubmitting = true;
this.getParams().then((data) => {
let params = data;
if (typeof this.fenceId != "undefined") {
params.id = this.fenceId;
MONITOR_SERVICE.updateFence(JSON.stringify(params)).then(
(res) => {
if (res.returnCode == 0) {
//this.closeDialog();
this.$message({
message: res.message,
type: "success",
});
}
this.isSubmitting = false;
}
);
} else {
MONITOR_SERVICE.getNewFenceId().then((res) => {
if (res.returnCode == 0) {
params.fenceNo = res.data.fenceNo;
MONITOR_SERVICE.saveFence(JSON.stringify(params)).then(
(res) => {
if (res.returnCode == 0) {
//this.closeDialog();
this.$message({
message: res.message,
type: "success",
});
this.fenceId = res.data;
this.restainFenceName = this.form.electricFenceName;
}
this.isSubmitting = false;
}
);
}
});
}
});
} else {
return false;
}
});
},
getParams() {
return new Promise((resolve, reject) => {
const form = this.form;
const params = {};
const transferItem = {
data: [
{
elng: form.lng,
elat: form.lat,
},
],
};
MAPGEO.transferAddressByGroup(transferItem, () => {
params.electricFenceName = form.electricFenceName;
params.electricFenceType = form.triggerType;
params.shapeType = form.shapeType;
params.locationType = form.locationType;
if (params.shapeType == 3) {
params.areaCode = this.areaId;
params.areaString = this.areaStr;
} else if (params.shapeType == 2) {
params.lng = form.lng;
params.lat = form.lat;
params.radius = form.fenceRadius;
params.analysisAddress = transferItem.data[0].transferAddress;
} else if (params.shapeType == 5) {
params.lnglat = this.polygonPath.join("|");
}
params.status = form.status;
params.snList = [{ sn: this.sn }];
if(params.shapeType == 3){ params.startTime = moment(this.form.dateRange[0]).format(
params.areaCode = this.areaId; "YYYY-MM-DD"
params.areaString = this.areaStr; );
}else if(params.shapeType == 2){ params.endTime = moment(this.form.dateRange[1]).format("YYYY-MM-DD");
params.lng = form.lng; if (form.msgtel) {
params.lat = form.lat; params.telNumbers = form.msgtel;
params.radius = form.fenceRadius; }
params.analysisAddress = transferItem.data[0].transferAddress; params.timeType = 2;
}else if(params.shapeType == 5){
params.lnglat = this.polygonPath.join('|')
}
params.status = form.status;
params.snList = [{sn: this.sn}]
params.startTime = moment(this.form.dateRange[0]).format('YYYY-MM-DD');
params.endTime = moment(this.form.dateRange[1]).format('YYYY-MM-DD');
if(form.msgtel){
params.telNumbers = form.msgtel
}
params.timeType = 2
resolve(params) resolve(params);
}); });
}); });
},
}, areaChoose(areaId, areaStr) {
areaChoose(areaId, areaStr){ this.areaId = areaId;
this.areaId = areaId; this.areaStr = areaStr;
this.areaStr = areaStr; if (this.form.shapeType === 3) {
if(this.form.shapeType === 3){ this.drawDistrict(areaId);
this.drawDistrict(areaId) }
} },
}, updateFenceRadius(radius) {
updateFenceRadius(radius){ EventBus.$emit("uiMap.fence.updateFenceRadius", radius);
EventBus.$emit('uiMap.fence.updateFenceRadius', radius) },
}, drawFenceCircle() {
drawFenceCircle(){ EventBus.$emit("uiMap.fence.createFenceCircle", {
EventBus.$emit('uiMap.fence.createFenceCircle', { lng: this.form.lng,
lng: this.form.lng, lat: this.form.lat,
lat: this.form.lat, radius: this.form.fenceRadius,
radius: this.form.fenceRadius });
}); },
}, drawDistrict(areaCode) {
drawDistrict(areaCode){ this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
this._drawDistrictTimeoutId = setTimeout(()=>{ this._drawDistrictTimeoutId = setTimeout(() => {
EventBus.$emit('uiMap.fence.drawDistrict', areaCode); EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
}, 500); }, 500);
}, },
drawPolygon(){ drawPolygon() {
EventBus.$emit('uiMap.fence.drawPolygon', this.polygonPath) EventBus.$emit("uiMap.fence.drawPolygon", this.polygonPath);
} },
}, },
created () { created() {
if(window.AMap){ let _this = this;
this.initMap(); _this.$mapInit({ version: "1.0.11" }).then((AMap) => {
}else{ _this.initMap();
remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{ });
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{ EventBus.$on("uiMap.fence.loading", (isLoading) => {
this.initMap(); this.mapLoading = isLoading;
}) });
}) EventBus.$on("uiMap.fence.onFenceRadiusChange", (radius) => {
this.form.fenceRadius = radius;
} //this.$refs.form.validateField('fenceRadius');
EventBus.$on('uiMap.fence.loading', (isLoading)=>{ });
this.mapLoading = isLoading; EventBus.$on("uiMap.fence.onFenceLngLatChange", (data) => {
}); this.form.lng = data.lng;
EventBus.$on('uiMap.fence.onFenceRadiusChange', (radius)=>{ this.form.lat = data.lat;
this.form.fenceRadius = radius; });
//this.$refs.form.validateField('fenceRadius');
});
EventBus.$on('uiMap.fence.onFenceLngLatChange', (data)=>{
this.form.lng = data.lng;
this.form.lat = data.lat;
});
EventBus.$on('uiMap.fence.polygonChange', (data)=>{
this.polygonPath = data.polygonPath
});
},
beforeDestroy(){
}, EventBus.$on("uiMap.fence.polygonChange", (data) => {
components: { this.polygonPath = data.polygonPath;
AreaSelect, });
MapControll },
} beforeDestroy() {},
} components: {
AreaSelect,
MapControll,
},
};
</script> </script>
<style scoped> <style scoped>
/*样式写在 scss/monitor.scss*/ /*样式写在 scss/monitor.scss*/
.side_auto_h{ .side_auto_h {
max-height: calc(100vh - 100px); max-height: calc(100vh - 100px);
overflow: auto; overflow: auto;
} }
.shape_tip{ .shape_tip {
color:#999; color: #999;
line-height:1.5; line-height: 1.5;
margin-bottom: 10px; margin-bottom: 10px;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -11,65 +11,137 @@ ...@@ -11,65 +11,137 @@
<el-scrollbar class="el_scrollbar"> <el-scrollbar class="el_scrollbar">
<div class="search-box"> <div class="search-box">
<h3>电子围栏</h3> <h3>电子围栏</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p> <p class="info">{{ name }}/{{ standno }}/{{ sn }}</p>
<el-form ref="form" :model="form" :rules="rules" size="mini" class="form" label-position="top"> <el-form
ref="form"
:model="form"
:rules="rules"
size="mini"
class="form"
label-position="top"
>
<el-form-item label="定位方式"> <el-form-item label="定位方式">
<el-select v-model="form.locationType" class="a_select" placeholder="请选择" size="small" :disabled="true"> <el-select
v-model="form.locationType"
class="a_select"
placeholder="请选择"
size="small"
:disabled="true"
>
<el-option label="GPS" :value="1"></el-option> <el-option label="GPS" :value="1"></el-option>
<el-option label="基站" :value="2"></el-option> <el-option label="基站" :value="2"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="围栏名称" prop="fenceName"> <el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" maxlength="200"></el-input> <el-input
v-model.trim="form.fenceName"
maxlength="200"
></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" class="a_select" placeholder="请选择" size="small"> <el-select
v-model="form.triggerType"
class="a_select"
placeholder="请选择"
size="small"
>
<el-option label="驶出" :value="2"></el-option> <el-option label="驶出" :value="2"></el-option>
<el-option label="驶入" :value="1"></el-option> <el-option label="驶入" :value="1"></el-option>
<el-option label="驶入驶出" :value="3"></el-option> <el-option label="驶入驶出" :value="3"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="指定区间" prop="dateRange"> <el-form-item label="指定区间" prop="dateRange">
<el-date-picker style="width: 100%;" v-model="form.dateRange" type="daterange" size="small" :clearable="false" :editable="false" :unlink-panels="true" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd"> <el-date-picker
style="width: 100%"
v-model="form.dateRange"
type="daterange"
size="small"
:clearable="false"
:editable="false"
:unlink-panels="true"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
>
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="监控区域" class="row-form-item is-required"> <el-form-item
label="监控区域"
class="row-form-item is-required"
>
<div class="el_radio_group"> <div class="el_radio_group">
<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:120px" maxlength="200"> <el-input
v-model.trim="form.radius"
style="width: 120px"
maxlength="200"
>
<template slot="append">米</template> <template slot="append">米</template>
</el-input> </el-input>
<el-button type="primary" class="btn" :disabled="!form.radius" @click="changeRadius">更新</el-button> <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">
<el-radio :label="3" v-model="form.shapeType">多边形</el-radio> <el-radio :label="3" v-model="form.shapeType"
<div class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</div> >多边形</el-radio
>
<div class="shape_tip">
*注:地图任意位置,单击新增双击结束绘制。
</div>
</div> </div>
<div class="radio_cell"> <div class="radio_cell">
<el-radio :label="4" v-model="form.shapeType">行政区域</el-radio> <el-radio :label="4" v-model="form.shapeType"
>行政区域</el-radio
>
<el-form-item label="" prop="areaName"> <el-form-item label="" prop="areaName">
<city-select v-model="form.areaName" :checkStrictly="true" :disabled="form.shapeType != 4" @change="changeArea"></city-select> <city-select
v-model="form.areaName"
:checkStrictly="true"
:disabled="form.shapeType != 4"
@change="changeArea"
></city-select>
</el-form-item> </el-form-item>
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="短信通知" prop="telNumbers"> <el-form-item label="短信通知" prop="telNumbers">
<el-input v-model.trim="form.telNumbers" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input> <el-input
v-model.trim="form.telNumbers"
maxlength="100"
placeholder="输入格式:手机号码,手机号码(支持双号)"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="围栏状态" class="is-required"> <el-form-item label="围栏状态" class="is-required">
<el-radio v-model="form.enableStatus" :label="1">开启</el-radio> <el-radio v-model="form.enableStatus" :label="1"
<el-radio v-model="form.enableStatus" :label="0">关闭</el-radio> >开启</el-radio
>
<el-radio v-model="form.enableStatus" :label="0"
>关闭</el-radio
>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button> <el-button
type="primary"
@click="submit"
size="small"
:loading="isSubmitting"
>保存</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</el-scrollbar> </el-scrollbar>
</div> </div>
<!-- <el-alert v-show="showSuccessTips" :title="`保存成功,页面将在${timer}秒后自动关闭`" type="success" :closable="false" show-icon class="show_success_tips"></el-alert> --> <!-- <el-alert v-show="showSuccessTips" :title="`保存成功,页面将在${timer}秒后自动关闭`" type="success" :closable="false" show-icon class="show_success_tips"></el-alert> -->
<!-- <el-dialog title="提示" custom-class="monitor_dialog" :visible.sync="showSuccessTips" width="340px" append-to-body :show-close="false" :close-on-click-modal="false" :close-on-press-escape="false"> <!-- <el-dialog title="提示" custom-class="monitor_dialog" :visible.sync="showSuccessTips" width="340px" append-to-body :show-close="false" :close-on-click-modal="false" :close-on-press-escape="false">
...@@ -86,13 +158,20 @@ ...@@ -86,13 +158,20 @@
<div class="monitor_dialog" v-show="showSuccessTips"> <div class="monitor_dialog" v-show="showSuccessTips">
<div class="monitor_dialog_content"> <div class="monitor_dialog_content">
<i class="el-icon-circle-check i_icon"></i> <i class="el-icon-circle-check i_icon"></i>
<span class="tips">{{`保存成功,页面将在${timer}秒后自动关闭`}}</span> <span class="tips">{{
<el-button type="primary" class="btn" size="small" @click="closePage">立即关闭</el-button> `保存成功,页面将在${timer}秒后自动关闭`
}}</span>
<el-button
type="primary"
class="btn"
size="small"
@click="closePage"
>立即关闭</el-button
>
</div> </div>
<div class="blk"></div> <div class="blk"></div>
</div> </div>
<!-- 提示弹框 end --> <!-- 提示弹框 end -->
</div> </div>
</template> </template>
</v-full-layout> </v-full-layout>
...@@ -109,7 +188,6 @@ import { CONSTANT } from "@/constant"; ...@@ -109,7 +188,6 @@ import { CONSTANT } from "@/constant";
import { deepClone, showToast } from "@/utils/utils"; import { deepClone, showToast } from "@/utils/utils";
import AreaSelect from "./AreaSelect.vue"; import AreaSelect from "./AreaSelect.vue";
import MapControll from "./MapControll.vue"; import MapControll from "./MapControll.vue";
import AMapLoader from "@amap/amap-jsapi-loader";
import { GET_DEVICE_LOCATION } from "@/api/services/monitor"; import { GET_DEVICE_LOCATION } from "@/api/services/monitor";
import CitySelect from "@/components/area"; import CitySelect from "@/components/area";
import { SAVE_ELECFENCE_INFO } from "@/api/services/fence"; import { SAVE_ELECFENCE_INFO } from "@/api/services/fence";
...@@ -256,11 +334,8 @@ export default { ...@@ -256,11 +334,8 @@ export default {
// 初始化地图 // 初始化地图
initMap() { initMap() {
let _this = this; let _this = this;
AMapLoader.load({ _this.$mapInit().then((AMap) => {
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填 window.AMap = AMap;
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: CONSTANT.MAP_PLUGINS, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((AMap) => {
window.AMap = AMap; window.AMap = AMap;
_this.map = mapService.init("map"); _this.map = mapService.init("map");
_this.getDevinceInfo(); _this.getDevinceInfo();
...@@ -614,8 +689,8 @@ export default { ...@@ -614,8 +689,8 @@ export default {
} }
.tips { .tips {
margin: 15px 0; margin: 15px 0;
font-size:14px; font-size: 14px;
color:#999; color: #999;
} }
} }
} }
......
...@@ -26,16 +26,25 @@ ...@@ -26,16 +26,25 @@
<div id="mapContainer" class="map-container"></div> <div id="mapContainer" class="map-container"></div>
<fence-map-controll @onRefreshMap="refreshMap" :isModalMap="true"></fence-map-controll> <fence-map-controll
@onRefreshMap="refreshMap"
:isModalMap="true"
></fence-map-controll>
<div class="map-seacrh-wrap"> <div class="map-seacrh-wrap">
<!-- <input type="text" id="fenceMapSearch"> --> <!-- <input type="text" id="fenceMapSearch"> -->
<el-input placeholder="请输入搜索地址" id="fenceMapSearch" size="small" maxlength="200" v-model="fenceMapSearch" :disabled="readonlyStatus"> <el-input
placeholder="请输入搜索地址"
id="fenceMapSearch"
size="small"
maxlength="200"
v-model="fenceMapSearch"
:disabled="readonlyStatus"
>
<template slot="prepend">搜索</template> <template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> --> <!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input> </el-input>
</div> </div>
</div> </div>
<!-- <div slot="footer" class="dialog-footer"> <!-- <div slot="footer" class="dialog-footer">
...@@ -51,7 +60,6 @@ import remoteLoad from "utils/remoteLoad.js"; ...@@ -51,7 +60,6 @@ import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js"; import mapService from "utils/mapService.js";
import FenceMapControll from "./FenceMapControll.vue"; import FenceMapControll from "./FenceMapControll.vue";
import { CONSTANT } from "../../constant"; import { CONSTANT } from "../../constant";
import AMapLoader from "@amap/amap-jsapi-loader";
export default { export default {
props: ["fenceMapModalVisible", "init", "readonlyStatus"], props: ["fenceMapModalVisible", "init", "readonlyStatus"],
data() { data() {
...@@ -93,11 +101,8 @@ export default { ...@@ -93,11 +101,8 @@ export default {
}, },
mounted() { mounted() {
let _this = this; let _this = this;
AMapLoader.load({ let plugins = ["AMap.LngLat", "AMap.AutoComplete"];
key: CONSTANT.MAP_KEY, _this.$mapInit({ version: "1.4.2", plugins: plugins }).then((AMap) => {
version: "1.4.2",
plugins: CONSTANT.MAP_PLUGINS,
}).then((AMap) => {
window.AMap = AMap; window.AMap = AMap;
_this.mapObj = mapService.init("mapContainer"); _this.mapObj = mapService.init("mapContainer");
_this.bindContextMenu(); _this.bindContextMenu();
...@@ -168,22 +173,36 @@ export default { ...@@ -168,22 +173,36 @@ export default {
} }
}); });
AMap.event.addListener(self.auto, "select", (e) => { self.auto.on("select", (e) => {
console.log(e.poi) console.log(e.poi);
if (e.poi && e.poi.location) { if (e.poi && e.poi.location) {
self.mapObj.setCenter(e.poi.location); self.mapObj.setCenter(e.poi.location);
self.autoCenterMarker.setPosition(e.poi.location); self.autoCenterMarker.setPosition(e.poi.location);
/*for(var i = 0, l = this.polygons.length; i < l; i++) { self.lng = e.poi.location.lng;
this.polygons[i].setMap(null); self.lat = e.poi.location.lat;
}*/
self.lng = e.poi.location.lng
self.lat = e.poi.location.lat
self.autoCenterMarker.show(); self.autoCenterMarker.show();
self.mapObj.add(self.autoCenterMarker); self.mapObj.add(self.autoCenterMarker);
} }
self.mapObj.setZoom(14); self.mapObj.setZoom(14);
}); });
// AMap.event.addListener(self.auto, "select", (e) => {
// console.log(e.poi);
// if (e.poi && e.poi.location) {
// self.mapObj.setCenter(e.poi.location);
// self.autoCenterMarker.setPosition(e.poi.location);
// /*for(var i = 0, l = this.polygons.length; i < l; i++) {
// this.polygons[i].setMap(null);
// }*/
// self.lng = e.poi.location.lng;
// self.lat = e.poi.location.lat;
// self.autoCenterMarker.show();
// self.mapObj.add(self.autoCenterMarker);
// }
// self.mapObj.setZoom(14);
// });
}); });
}, },
bindContextMenu() { bindContextMenu() {
...@@ -201,7 +220,7 @@ export default { ...@@ -201,7 +220,7 @@ export default {
contextMenu.open(self.mapObj, e.lnglat); contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; self.contextMenuPositon = e.lnglat;
}); });
self.contextMenu = contextMenu self.contextMenu = contextMenu;
//contextMenu.open(self.mapObj, lnglat); //contextMenu.open(self.mapObj, lnglat);
}, },
drawFence() { drawFence() {
...@@ -229,10 +248,10 @@ export default { ...@@ -229,10 +248,10 @@ export default {
} else { } else {
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat)); this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat));
this.$emit("onUpdateMapData", { this.$emit("onUpdateMapData", {
lng: this.lng, lng: this.lng,
lat: this.lat, lat: this.lat,
radius: this.radius, radius: this.radius,
}); });
} }
}, },
drawFenceCircle(fenceCenter) { drawFenceCircle(fenceCenter) {
...@@ -254,6 +273,9 @@ export default { ...@@ -254,6 +273,9 @@ export default {
mapObj.plugin(["AMap.CircleEditor"], () => { mapObj.plugin(["AMap.CircleEditor"], () => {
this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle); this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle);
// this.circleEditor.on("adjust", function (e) {
// console.log(e);
// });
AMap.event.addListener(this.circleEditor, "adjust", (e) => { AMap.event.addListener(this.circleEditor, "adjust", (e) => {
this.radius = e.radius / 1; this.radius = e.radius / 1;
this.$emit("onUpdateMapData", { this.$emit("onUpdateMapData", {
...@@ -416,19 +438,33 @@ export default { ...@@ -416,19 +438,33 @@ export default {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
mapObj.plugin("AMap.Geolocation", function () { mapObj.plugin("AMap.Geolocation", function () {
self.geolocation = new AMap.Geolocation(); self.geolocation = new AMap.Geolocation();
self.geolocation.getCurrentPosition(); self.geolocation.getCurrentPosition(function (status, result) {
if (status == "complete") {
var lnglatXY = mapService.getLngLat(
result.position.lng,
result.position.lat
);
resolve(lnglatXY);
}
AMap.event.addListener(self.geolocation, "complete", function (e) { if (status == "error") {
console.log("complete", e); console.log("error", result);
//返回定位信息 //返回定位出错信息
var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat); resolve(mapObj.getCenter());
resolve(lnglatXY); }
});
AMap.event.addListener(self.geolocation, "error", function (e) {
console.log("error", e);
//返回定位出错信息
resolve(mapObj.getCenter());
}); });
// AMap.event.addListener(self.geolocation, "complete", function (e) {
// console.log("complete", e);
// //返回定位信息
// var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat);
// resolve(lnglatXY);
// });
// AMap.event.addListener(self.geolocation, "error", function (e) {
// console.log("error", e);
// //返回定位出错信息
// resolve(mapObj.getCenter());
// });
}); });
}); });
}, },
......
<template> <template>
<!-- 围栏调用地图弹框 --> <!-- 围栏调用地图弹框 -->
<el-dialog id="fenceMapModal" :visible="fenceMapModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="1200px" top="10vh"> <el-dialog
<div class="dialog-header" slot="title"> id="fenceMapModal"
<h2 class="header-title">地图引用</h2> :visible="fenceMapModalVisible"
</div> @open="openDialog"
<div class="fence-map"> @close="closeDialog"
append-to-body
width="1200px"
top="10vh"
>
<div class="dialog-header" slot="title">
<h2 class="header-title">地图引用</h2>
</div>
<div class="fence-map">
<el-form
:model="form"
ref="fenceMapForm"
:rules="rules"
:inline="true"
size="mini"
>
<el-form-item label="经度" prop="lng">
<el-input
v-model="form.lng"
style="width: 100px"
@change="transfer"
></el-input>
</el-form-item>
<el-form-item label="纬度" prop="lat">
<el-input
v-model="form.lat"
style="width: 100px"
@change="transfer"
></el-input>
</el-form-item>
<el-form-item label="经纬度解析" prop="transferAddr">
<el-input
v-model="form.transferAddr"
disabled
placeholder="自动生成"
style="width: 410px"
></el-input>
</el-form-item>
<el-form-item label="监控范围" prop="radius">
<el-input v-model="form.radius" style="width: 160px" maxlength="10">
<template slot="append">KM</template>
</el-input>
</el-form-item>
<el-form-item
><el-button type="primary" @click="updateFence"
>更新围栏</el-button
></el-form-item
>
</el-form>
<el-form :model="form" ref="fenceMapForm" :rules="rules" :inline="true" size="mini" > <div id="mapContainer" class="map-container"></div>
<el-form-item label="经度" prop="lng">
<el-input v-model="form.lng" style="width:100px" @change="transfer"></el-input>
</el-form-item>
<el-form-item label="纬度" prop="lat">
<el-input v-model="form.lat" style="width:100px" @change="transfer"></el-input>
</el-form-item>
<el-form-item label="经纬度解析" prop="transferAddr">
<el-input v-model="form.transferAddr" disabled placeholder="自动生成" style="width: 410px;"></el-input>
</el-form-item>
<el-form-item label="监控范围" prop="radius">
<el-input v-model="form.radius" style="width:160px" maxlength="10">
<template slot="append">KM</template>
</el-input>
</el-form-item>
<el-form-item><el-button type="primary" @click="updateFence">更新围栏</el-button></el-form-item>
</el-form>
<div id="mapContainer" class="map-container"></div> <map-controll
@onRefreshMap="refreshMap"
:isModalMap="true"
></map-controll>
<map-controll @onRefreshMap="refreshMap" :isModalMap="true"></map-controll> <div class="map-seacrh-wrap">
<!-- <input type="text" id="fenceMapSearch"> -->
<div class="map-seacrh-wrap"> <el-input
<!-- <input type="text" id="fenceMapSearch"> --> placeholder="请输入位置"
<el-input placeholder="请输入位置" id="fenceMapSearch" size="small" v-model="fenceMapSearch"> id="fenceMapSearch"
<template slot="prepend">搜索</template> size="small"
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> --> v-model="fenceMapSearch"
</el-input> >
</div> <template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</div> </el-input>
<div slot="footer" class="dialog-footer"> </div>
</div>
<el-button type="primary" @click="sure" size="small">确认</el-button> <div slot="footer" class="dialog-footer">
<el-button @click="$emit('onFenceMapModalChange', false)" size="small">关闭</el-button> <el-button type="primary" @click="sure" size="small">确认</el-button>
</div> <el-button @click="$emit('onFenceMapModalChange', false)" size="small"
</el-dialog> >关闭</el-button
<!-- 围栏调用地图弹框 /--> >
</div>
</el-dialog>
<!-- 围栏调用地图弹框 /-->
</template> </template>
<script> <script>
import {services} from '../../api' import { services } from "../../api";
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 MapControll from './MapControll.vue' import MapControll from "./MapControll.vue";
const BUSINESS_SERVICE = services.business; const BUSINESS_SERVICE = services.business;
import {CONSTANT} from '../../constant' import { CONSTANT } from "../../constant";
export default{
props: ['fenceMapModalVisible', 'mapData', 'init'],
data(){
let checkLng = (rule, vaule, cb)=>{
if(!/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(this.form.lng)){
cb(new Error('请输入正确的格式'))
}else{
cb();
}
}
let checkLat = (rule, vaule, cb)=>{ export default {
if(!/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(this.form.lat)){ props: ["fenceMapModalVisible", "mapData", "init"],
cb(new Error('请输入正确的格式')) data() {
}else{ let checkLng = (rule, vaule, cb) => {
cb(); if (
} !/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(
} this.form.lng
)
) {
cb(new Error("请输入正确的格式"));
} else {
cb();
}
};
let checkTransferAddr = (rule, vaule, cb)=>{ let checkLat = (rule, vaule, cb) => {
if (
if(this.transferError){ !/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(
cb(new Error('所填经纬度不能正确解析地址,请重新输入')) this.form.lat
}else if(!this.form.transferAddr){ )
cb(new Error('经纬度解析地址不能为空')) ) {
}else{ cb(new Error("请输入正确的格式"));
cb() } else {
} cb();
}
} };
let checkRadius = (rule, vaule, cb)=>{
if(!/^(\d+|\d+\.\d{0,3})$/.test(this.form.radius)){
cb(new Error('数字,精确到小数点后三位'))
}else{
cb();
}
}
return { let checkTransferAddr = (rule, vaule, cb) => {
fenceMapSearch: '', if (this.transferError) {
geolocation: null, cb(new Error("所填经纬度不能正确解析地址,请重新输入"));
circleEditor: null, } else if (!this.form.transferAddr) {
circle: null, cb(new Error("经纬度解析地址不能为空"));
form: { } else {
lng: '', cb();
lat: '', }
transferAddr: '', };
radius: 1 let checkRadius = (rule, vaule, cb) => {
}, if (!/^(\d+|\d+\.\d{0,3})$/.test(this.form.radius)) {
transferTimeoutId: undefined, cb(new Error("数字,精确到小数点后三位"));
geocoder: null, } else {
transferFlag: null, cb();
}
};
rules: { return {
lng: [ fenceMapSearch: "",
{validator: checkLng, trigger: 'blur'} geolocation: null,
], circleEditor: null,
lat: [ circle: null,
{validator: checkLat, trigger: 'blur'} form: {
], lng: "",
transferAddr: [ lat: "",
{validator: checkTransferAddr, trigger: 'blur'} transferAddr: "",
], radius: 1,
radius: [ },
{validator: checkRadius, trigger: 'blur'} transferTimeoutId: undefined,
] geocoder: null,
}, transferFlag: null,
transferError: false rules: {
} lng: [{ validator: checkLng, trigger: "blur" }],
}, lat: [{ validator: checkLat, trigger: "blur" }],
mounted(){ transferAddr: [{ validator: checkTransferAddr, trigger: "blur" }],
radius: [{ validator: checkRadius, trigger: "blur" }],
}, },
watch: {
lng(newVal){
//this.transfer()
},
lat(newVal){
//this.transfer()
}
},
async created () {
if(window.AMap){
}else{
await remoteLoad(`${CONSTANT.AMAP_URL}`);
//this.initMap()
}
},
methods: {
sure(){
this.$refs.fenceMapForm.validate((valid)=>{
if(valid){
this.$emit('onFenceMapModalChange', false);
this.$emit('onUpdateMapData',{
lng: this.form.lng,
lat: this.form.lat,
address: this.form.transferAddr,
radius: this.form.radius
});
}else{ transferError: false,
return false; };
} },
}) mounted() {},
}, watch: {
initMap(){ lng(newVal) {
let check = ()=>{ //this.transfer()
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); },
lat(newVal) {
return setTimeout(()=>{ //this.transfer()
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){ },
window.AMap = AMap; },
this.mapObj = mapService.init('mapContainer'); async created() {
this.bindSearch(); // if (window.AMap) {
this.drawFence() // } else {
}else{ // await remoteLoad(`${CONSTANT.AMAP_URL}`);
this.checkMapLoaded = check() // //this.initMap()
} // }
}, 100) },
} methods: {
this.checkMapLoaded = check(); sure() {
}, this.$refs.fenceMapForm.validate((valid) => {
openDialog(){ if (valid) {
this.$emit("onFenceMapModalChange", false);
this.form.lng = this.mapData.lng
this.form.lat = this.mapData.lat
this.form.transferAddr = this.mapData.address
this.form.radius = this.mapData.radius?this.mapData.radius:1
//this.$emit('onFenceMapModalChange', true)
if(this.mapObj){
this.updateFence();
}else{
this.initMap()
}
},
closeDialog(){
this.$emit('onFenceMapModalChange', false)
},
bindSearch(){
this.auto = new AMap.Autocomplete({
input: 'fenceMapSearch'
});
this.autoCenterMarker = new AMap.Marker({ this.$emit("onUpdateMapData", {
icon: require('images/auto-center-marker.gif'), lng: this.form.lng,
map: this.mapObj, lat: this.form.lat,
offset: new AMap.Pixel(-12,-12), address: this.form.transferAddr,
visible: false radius: this.form.radius,
}); });
} else {
return false;
}
});
},
initMap() {
let _this = this;
_this.$mapInit({ version: "1.0.11" }).then((AMap) => {
window.AMap = AMap;
_this.mapObj = mapService.init("mapContainer");
_this.bindSearch();
_this.drawFence();
});
// let check = ()=>{
// this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
AMap.event.addListener(this.auto, 'select', (e)=>{ // return setTimeout(()=>{
if(e.poi && e.poi.location){ // if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
//this.mapObj.setZoom(15); // window.AMap = AMap;
//this.mapObj.setCenter(e.poi.location) // this.mapObj = mapService.init('mapContainer');
//this.circle.setCenter(e.poi.location); // this.bindSearch();
//this.mapObj.setCenter(e.poi.location); // this.drawFence()
// }else{
// this.checkMapLoaded = check()
// }
// }, 100)
// }
// this.checkMapLoaded = check();
},
openDialog() {
this.form.lng = this.mapData.lng;
this.form.lat = this.mapData.lat;
this.form.transferAddr = this.mapData.address;
this.form.radius = this.mapData.radius ? this.mapData.radius : 1;
this.autoCenterMarker.setPosition(e.poi.location); //this.$emit('onFenceMapModalChange', true)
this.autoCenterMarker.show(); if (this.mapObj) {
mapService.setFitView() this.updateFence();
this.fenceMapSearch = ''; } else {
this.form.lng = e.poi.location.lng; this.initMap();
this.form.lat = e.poi.location.lat; }
} },
}); closeDialog() {
}, this.$emit("onFenceMapModalChange", false);
drawFence(){ },
this.circleEditor && this.circleEditor.destroy(); bindSearch() {
const mapObj = this.mapObj; this.auto = new AMap.Autocomplete({
let circleCenter = null; input: "fenceMapSearch",
});
if(this.form.transferAddr){ this.autoCenterMarker = new AMap.Marker({
circleCenter = mapService.getLngLat(this.form.lng, this.form.lat) icon: require("images/auto-center-marker.gif"),
}else{ map: this.mapObj,
offset: new AMap.Pixel(-12, -12),
visible: false,
});
circleCenter = mapObj.getCenter(); AMap.event.addListener(this.auto, "select", (e) => {
this.form.lng = circleCenter.lng; if (e.poi && e.poi.location) {
this.form.lat = circleCenter.lat; //this.mapObj.setZoom(15);
this.transfer() //this.mapObj.setCenter(e.poi.location)
} //this.circle.setCenter(e.poi.location);
//this.mapObj.setCenter(e.poi.location);
this.circle = new AMap.Circle({
map: mapObj,
center: circleCenter,
radius: this.form.radius*1000,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35
});
mapObj.plugin(["AMap.CircleEditor"],()=>{ this.autoCenterMarker.setPosition(e.poi.location);
this.circleEditor = new AMap.CircleEditor(mapObj, this.circle); this.autoCenterMarker.show();
mapService.setFitView();
this.fenceMapSearch = "";
this.form.lng = e.poi.location.lng;
this.form.lat = e.poi.location.lat;
}
});
},
drawFence() {
this.circleEditor && this.circleEditor.destroy();
const mapObj = this.mapObj;
let circleCenter = null;
AMap.event.addListener(this.circleEditor, 'adjust', (e)=>{ if (this.form.transferAddr) {
this.form.radius = e.radius/1000; circleCenter = mapService.getLngLat(this.form.lng, this.form.lat);
this.$refs.fenceMapForm.validateField('radius'); } else {
}); circleCenter = mapObj.getCenter();
this.form.lng = circleCenter.lng;
this.form.lat = circleCenter.lat;
this.transfer();
}
AMap.event.addListener(this.circleEditor, 'move', (e)=>{ this.circle = new AMap.Circle({
this.form.lng = e.lnglat.lng; map: mapObj,
this.form.lat = e.lnglat.lat; center: circleCenter,
this.transfer() radius: this.form.radius * 1000,
}); strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
});
this.circleEditor.open(); mapObj.plugin(["AMap.CircleEditor"], () => {
}); this.circleEditor = new AMap.CircleEditor(mapObj, this.circle);
mapService.setFitView()
mapObj.setZoom(14);
},
updateFence(){
this.$refs.fenceMapForm.validateField('radius', (error)=>{
if(!error){
this.circle.setRadius(this.form.radius*1000);
if(!this.transferError){
if(this.form.transferAddr){ AMap.event.addListener(this.circleEditor, "adjust", (e) => {
let center = mapService.getLngLat(this.form.lng, this.form.lat); this.form.radius = e.radius / 1000;
console.log(center) this.$refs.fenceMapForm.validateField("radius");
this.circle.setCenter(center); });
}else{
const circleCenter = this.mapObj.getCenter();
this.circle.setCenter(circleCenter);
this.form.lng = circleCenter.lng;
this.form.lat = circleCenter.lat;
this.transfer()
}
AMap.event.addListener(this.circleEditor, "move", (e) => {
this.form.lng = e.lnglat.lng;
this.form.lat = e.lnglat.lat;
this.transfer();
});
mapService.setFitView() this.circleEditor.open();
this.mapObj.setZoom(14); });
}
}
});
},
search(){
this.auto&&AMap.event.trigger(this.auto, 'select') mapService.setFitView();
}, mapObj.setZoom(14);
validateLngLat(){ },
let pass = true; updateFence() {
this.$refs.fenceMapForm.validateField('lng', (error)=>{ this.$refs.fenceMapForm.validateField("radius", (error) => {
if(error){ if (!error) {
pass = false; this.circle.setRadius(this.form.radius * 1000);
} if (!this.transferError) {
}); if (this.form.transferAddr) {
this.$refs.fenceMapForm.validateField('lat', (error)=>{ let center = mapService.getLngLat(this.form.lng, this.form.lat);
if(error){ console.log(center);
pass = false; this.circle.setCenter(center);
} } else {
}); const circleCenter = this.mapObj.getCenter();
return pass; this.circle.setCenter(circleCenter);
}, this.form.lng = circleCenter.lng;
transfer(){ this.form.lat = circleCenter.lat;
if(this.form.lng && this.form.lat && this.validateLngLat()){ this.transfer();
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId); }
this.transferTimeoutId = window.setTimeout(()=>{
const flag = new Date();
this.transferFlag = flag;
if(!this.geocoder){
mapService.getGeocoder().then((gc)=>{
this.geocoder = gc;
this.getAddress(flag);
});
}else{
this.getAddress(flag);
}
}, 500)
}
},
getAddress(flag){
const lnglatXY = [this.form.lng, this.form.lat]; mapService.setFitView();
this.transferAddr = ''; this.mapObj.setZoom(14);
}
this.geocoder.getAddress(lnglatXY, (status, result)=>{ }
if(flag == this.transferFlag){ });
if (status === 'complete' && result.info === 'OK') {//获取地址成功 },
this.form.transferAddr = result.regeocode.formattedAddress; search() {
this.transferError = false; this.auto && AMap.event.trigger(this.auto, "select");
this.$refs.fenceMapForm.validateField('transferAddr'); },
}else{ validateLngLat() {
this.form.transferAddr = ''; let pass = true;
this.transferError = true; this.$refs.fenceMapForm.validateField("lng", (error) => {
this.$refs.fenceMapForm.validateField('transferAddr'); if (error) {
} pass = false;
} }
});
this.$refs.fenceMapForm.validateField("lat", (error) => {
if (error) {
pass = false;
}
});
return pass;
},
transfer() {
if (this.form.lng && this.form.lat && this.validateLngLat()) {
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(() => {
const flag = new Date();
this.transferFlag = flag;
if (!this.geocoder) {
mapService.getGeocoder().then((gc) => {
this.geocoder = gc;
this.getAddress(flag);
}); });
}, } else {
refreshMap(){ this.getAddress(flag);
}
}, 500);
}
},
getAddress(flag) {
const lnglatXY = [this.form.lng, this.form.lat];
this.transferAddr = "";
} this.geocoder.getAddress(lnglatXY, (status, result) => {
if (flag == this.transferFlag) {
if (status === "complete" && result.info === "OK") {
//获取地址成功
this.form.transferAddr = result.regeocode.formattedAddress;
this.transferError = false;
this.$refs.fenceMapForm.validateField("transferAddr");
} else {
this.form.transferAddr = "";
this.transferError = true;
this.$refs.fenceMapForm.validateField("transferAddr");
}
}
});
}, },
components:{ refreshMap() {},
MapControll },
} components: {
} MapControll,
},
};
</script> </script>
<style scoped> <style scoped>
.fence-map{ .fence-map {
position: relative; position: relative;
} }
.fence-map .map-container{ .fence-map .map-container {
width: 100%; width: 100%;
height: 600px; height: 600px;
} }
.fence-map .map-seacrh-wrap{ .fence-map .map-seacrh-wrap {
position: absolute; position: absolute;
top: 40px; top: 40px;
left: 10px; left: 10px;
z-index: 1000; z-index: 1000;
} }
.el-form-item{ .el-form-item {
margin: -20px 0 20px 10px; margin: -20px 0 20px 10px;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<v-full-layout> <v-full-layout>
<template slot="breadcrumb"> <template slot="breadcrumb">
<el-breadcrumb-item>历史停留</el-breadcrumb-item> <el-breadcrumb-item>历史停留</el-breadcrumb-item>
</template> </template>
<template slot="main"> <template slot="main">
<div class="map-wrap" > <div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div> <div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll> <map-controll></map-controll>
<div class="controll-wrap"> <div class="controll-wrap">
<div class="search-box" :class="resultBoxHidden?'active':''"> <div class="search-box" :class="resultBoxHidden ? 'active' : ''">
<h3>历史停留</h3> <h3>历史停留</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p> <p class="info">{{ name }}/{{ standno }}/{{ sn }}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form"> <el-form
<el-form-item label="查询范围" prop="dateRange"> ref="form"
<el-date-picker :model="form"
style="width: 100%;" :rules="rules"
:inline="false"
size="mini"
class="form"
>
<el-form-item label="查询范围" prop="dateRange">
<el-date-picker
style="width: 100%"
v-model="form.dateRange" v-model="form.dateRange"
type="daterange" type="daterange"
size="small" size="small"
...@@ -24,401 +31,468 @@ ...@@ -24,401 +31,468 @@
:picker-options="pickerOptions" :picker-options="pickerOptions"
range-separator="至" range-separator="至"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期"> end-placeholder="结束日期"
>
</el-date-picker> </el-date-picker>
<!-- <div class="date-filter"> <!-- <div class="date-filter">
<el-button size="mini" type="text" @click="pickDate(7)">前7天</el-button> <el-button size="mini" type="text" @click="pickDate(7)">前7天</el-button>
<el-button size="mini" type="text" @click="pickDate(15)">前15天</el-button> <el-button size="mini" type="text" @click="pickDate(15)">前15天</el-button>
<el-button size="mini" type="text" @click="pickDate(30)">前30天</el-button> <el-button size="mini" type="text" @click="pickDate(30)">前30天</el-button>
</div> --> </div> -->
</el-form-item> </el-form-item>
<el-form-item label="查询时段" prop="timerange"> <el-form-item label="查询时段" prop="timerange">
<el-select v-model="form.timerange" placeholder="请选择" size="small" style="width: 280px"> <el-select
<el-option label="上午(06:00~12:00)" value="1"></el-option> v-model="form.timerange"
<el-option label="下午(12:00~21:00)" value="2"></el-option> placeholder="请选择"
<el-option label="夜晚(21:00~06:00)" value="3"></el-option> size="small"
<el-option label="全天(00:00~24:00)" value="0"></el-option> style="width: 280px"
</el-select> >
</el-form-item> <el-option label="上午(06:00~12:00)" value="1"></el-option>
<el-form-item label="停留时长" prop="stay"> <el-option label="下午(12:00~21:00)" value="2"></el-option>
<el-row class="stay-ctrl pull-left"> <el-option label="夜晚(21:00~06:00)" value="3"></el-option>
<el-col :span="8"> <el-option label="全天(00:00~24:00)" value="0"></el-option>
<el-form-item prop="stayMin"> </el-select>
<el-input v-model.trim="form.stayMin" placeholder="最小值"></el-input> </el-form-item>
</el-form-item> <el-form-item label="停留时长" prop="stay">
</el-col> <el-row class="stay-ctrl pull-left">
<el-col :span="2" class="text-center">~</el-col> <el-col :span="8">
<el-col :span="8"> <el-form-item prop="stayMin">
<el-form-item prop="stayMax"> <el-input
<el-input v-model.trim="form.stayMax" placeholder="最大值"></el-input> v-model.trim="form.stayMin"
</el-form-item> placeholder="最小值"
</el-col> ></el-input>
<span class="unit">分钟</span> </el-form-item>
</el-row> </el-col>
</el-form-item> <el-col :span="2" class="text-center">~</el-col>
<el-form-item class="submit-el-form-item"> <el-col :span="8">
<el-button type="primary" @click="searchSubmit" size="small" :loading="isSearching">查询</el-button> <el-form-item prop="stayMax">
</el-form-item> <el-input
</el-form> v-model.trim="form.stayMax"
</div> placeholder="最大值"
<div class="result-box" :class="resultBoxHidden?'':'active'"> ></el-input>
<div class="result-box-head"> </el-form-item>
<el-button class="pull-left" size="mini" type="text" @click="resultBoxHidden=true;">返回“查询”</el-button> </el-col>
<el-button class="pull-right" size="mini" type="text" @click="exportExcel">导出Excel</el-button> <span class="unit">分钟</span>
<span>停留点({{resultList.length}})</span> </el-row>
</div> </el-form-item>
<div class="result-box-filter text-center"> <el-form-item class="submit-el-form-item">
<el-button class="" size="mini" type="text" @click="sortByTime">停留时间<i class="fa fa-sort"></i></el-button> <el-button
<el-button class="" size="mini" type="text" @click="sortByStay">停留时长<i class="fa fa-sort"></i></el-button> type="primary"
</div> @click="searchSubmit"
<ul class="stay-list"> size="small"
<li class="stay-list-item" v-for="(item, index) in resultList" :key="index" @click="openMapInfoWindow(item.idx)"> :loading="isSearching"
<p class="addr">{{item.transferAddress}}</p> >查询</el-button
<p class="datetime"><span>{{item.begintime}}</span><span class="pull-right">{{item.duration}}</span></p> >
</li> </el-form-item>
<li v-show="!resultList.length"> </el-form>
<p class="text-center">无数据</p> </div>
</li> <div class="result-box" :class="resultBoxHidden ? '' : 'active'">
<!-- <infinite-loading v-if="needInfinite" @infinite="infiniteHandler" ref="infiniteLoading"> <div class="result-box-head">
<el-button
class="pull-left"
size="mini"
type="text"
@click="resultBoxHidden = true"
>返回“查询”</el-button
>
<el-button
class="pull-right"
size="mini"
type="text"
@click="exportExcel"
>导出Excel</el-button
>
<span>停留点({{ resultList.length }})</span>
</div>
<div class="result-box-filter text-center">
<el-button class="" size="mini" type="text" @click="sortByTime"
>停留时间<i class="fa fa-sort"></i
></el-button>
<el-button class="" size="mini" type="text" @click="sortByStay"
>停留时长<i class="fa fa-sort"></i
></el-button>
</div>
<ul class="stay-list">
<li
class="stay-list-item"
v-for="(item, index) in resultList"
:key="index"
@click="openMapInfoWindow(item.idx)"
>
<p class="addr">{{ item.transferAddress }}</p>
<p class="datetime">
<span>{{ item.begintime }}</span
><span class="pull-right">{{ item.duration }}</span>
</p>
</li>
<li v-show="!resultList.length">
<p class="text-center">无数据</p>
</li>
<!-- <infinite-loading v-if="needInfinite" @infinite="infiniteHandler" ref="infiniteLoading">
<span slot="no-more">没有更多数据了</span> <span slot="no-more">没有更多数据了</span>
<span slot="no-results">无结果</span> <span slot="no-results">无结果</span>
</infinite-loading> --> </infinite-loading> -->
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
</v-full-layout> </v-full-layout>
</template> </template>
<script> <script>
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 EventBus from '../../event-bus' import EventBus from "../../event-bus";
import {services} from '../../api' import { services } from "../../api";
import mock from '../../mock' import mock from "../../mock";
import {CONSTANT} from '../../constant' import { CONSTANT } from "../../constant";
import InfiniteLoading from 'vue-infinite-loading'; import InfiniteLoading from "vue-infinite-loading";
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
import {exportExcel} from 'utils'; import { exportExcel } from "utils";
import MapControll from './MapControll.vue' import MapControll from "./MapControll.vue";
import AMapLoader from '@amap/amap-jsapi-loader' import { historyShortcuts } from "@/common/index";
import {historyShortcuts} from '@/common/index' import { GET_HISTORY_LOCATION } from "@/api/services/monitor";
import {GET_HISTORY_LOCATION} from "@/api/services/monitor" const BUSINESS_SERVICE = services.business;
const BUSINESS_SERVICE = services.business;
export default{ export default {
data(){ data() {
let checkDaterange = (rule, vaule, cb)=>{ let checkDaterange = (rule, vaule, cb) => {
const dateRange = this.form.dateRange const dateRange = this.form.dateRange;
if(!dateRange.length){ if (!dateRange.length) {
cb(new Error('请选择日期')) cb(new Error("请选择日期"));
}else{ } else {
let min = dateRange[0]; let min = dateRange[0];
let max = dateRange[1]; let max = dateRange[1];
if(!moment.isMoment(min)){
min = moment(min)
}
if(!moment.isMoment(max)){
max = moment(max)
}
if(min.isBefore(moment(Object.assign({},max)).subtract(29, 'days'), 'day')){
cb(new Error('日期范围不能超过30天'))
}
}
cb()
}
let checkStay = (rule, vaule, cb)=>{
const stayMin = this.form.stayMin;
const stayMax = this.form.stayMax;
if((stayMin && !/^(\d{1,4}|10000)$/.test(stayMin)) || (stayMax && !/^(\d{1,4}|10000)$/.test(stayMax))){ if (!moment.isMoment(min)) {
cb(new Error('只能输入0~10000的正整数')) min = moment(min);
}else if(stayMin!='' && stayMax!='' && parseInt(stayMin)>parseInt(stayMax)){ }
cb(new Error('最小值不可大于最大值')) if (!moment.isMoment(max)) {
} max = moment(max);
cb()
}
return {
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: '',
searchType: 'sn',
isSearching: false,
resultBoxHidden: true,
form: {
dateRange: [moment().subtract(7, 'days'),moment().subtract(1, 'days')],
timerange: '1',
stayMin: '',
stayMax: ''
},
rules: {
dateRange: [{validator: checkDaterange}],
stay: [{validator: checkStay}]
},
needInfinite: true,
params: {},
currentPage: 1,
pageSize: 10,
total: 100,
maxPage: 10,
resultList: [],
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
sortByTimeIsPositive: true,
sortByStayIsPositive: true,
sortType: '',
pickerOptions: {
disabledDate(time){
return time.getTime() > ((new Date()).getTime()-24*60*60*1000)
},
shortcuts: historyShortcuts
} }
}
},
mounted(){
// store.dispatch('setFullsize', true)
let _this = this
AMapLoader.load({
key: CONSTANT.MAP_KEY,
version: '1.4.2',
plugins: CONSTANT.MAP_PLUGINS
}).then((AMap) => {
window.AMap = AMap
_this.initMap()
})
},
methods: {
initMap(){
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(()=>{ if (
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){ min.isBefore(
window.AMap = AMap; moment(Object.assign({}, max)).subtract(29, "days"),
this.mapObj = mapService.init('map'); "day"
)
//this.bindEvent(); ) {
this.isInitMap = true; cb(new Error("日期范围不能超过30天"));
// this.drawPoi() }
}else{ }
this.checkMapLoaded = check() cb();
} };
}, 100) let checkStay = (rule, vaule, cb) => {
} const stayMin = this.form.stayMin;
this.checkMapLoaded = check(); const stayMax = this.form.stayMax;
},
pickDate(beforeDays){
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')]
},
searchSubmit(){
this.$refs.form.validate((valid, field)=>{
if(valid){
this.isSearching = true;
let params = {
sn: this.sn,
startTime: moment(this.form.dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss'),
endTime: moment(this.form.dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss'),
times: this.form.timerange,
}
if(this.form.stayMax !== ''){
params.maxTime = this.form.stayMax;
}
if(this.form.stayMin !== ''){
params.minTime = this.form.stayMin;
}
this.params = params
this.getSortParams()
EventBus.$emit('uiMap.historyLocation.destroy');
GET_HISTORY_LOCATION({...this.params}).then((res)=>{
if(res.code == 200){
const data = res.data;
if(data.length){
data.forEach((item, idx)=>{
item.idx = idx;
item.name = item.ownerName || '--'
item.sn = item.sn || '--'
item.vin = item.vin || '--'
item.begintime = item.beginTime
item.endtime = item.endTime
item.transferAddress = item.address || '--' // 取后端返回address
});
this.resultList = data;
EventBus.$emit('uiMap.historyLocation.draw', data);
this.resultBoxHidden = false;
}else{
this.$message({
type: 'info',
message: '暂无数据'
});
}
this.isSearching = false;
}
});
}else{
return false;
}
});
},
infiniteHandler($state){
if(this.currentPage> this.maxPage){
$state.complete();
return;
}
this.params.currentPage = this.currentPage;
this.params.pageSize = this.pageSize;
this.params.status = 1;
if (
(stayMin && !/^(\d{1,4}|10000)$/.test(stayMin)) ||
(stayMax && !/^(\d{1,4}|10000)$/.test(stayMax))
) {
cb(new Error("只能输入0~10000的正整数"));
} else if (
stayMin != "" &&
stayMax != "" &&
parseInt(stayMin) > parseInt(stayMax)
) {
cb(new Error("最小值不可大于最大值"));
}
cb();
};
return {
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: "",
searchType: "sn",
isSearching: false,
resultBoxHidden: true,
form: {
dateRange: [moment().subtract(7, "days"), moment().subtract(1, "days")],
timerange: "1",
stayMin: "",
stayMax: "",
},
rules: {
dateRange: [{ validator: checkDaterange }],
stay: [{ validator: checkStay }],
},
needInfinite: true,
params: {},
currentPage: 1,
pageSize: 10,
total: 100,
maxPage: 10,
resultList: [],
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
sortByTimeIsPositive: true,
sortByStayIsPositive: true,
sortType: "",
pickerOptions: {
disabledDate(time) {
return time.getTime() > new Date().getTime() - 24 * 60 * 60 * 1000;
},
shortcuts: historyShortcuts,
},
};
},
mounted() {
// store.dispatch('setFullsize', true)
let _this = this;
_this.$mapInit({version:'1.4.2'}).then(AMap => {
window.AMap = AMap;
_this.initMap();
})
},
methods: {
initMap() {
let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
this.currentPage++; return setTimeout(() => {
$state.loaded(); if (
setTimeout(()=>{ "AMap" in window &&
this.resultList = this.resultList.concat([{ typeof AMap.Map == "function" &&
addr: '甘肃省酒泉市肃州区海马福仕达中瑞汽车', !this.mapObj
date: '2018-11-20 15:19:21', ) {
restTime: '25小时26分钟25秒' window.AMap = AMap;
}]) this.mapObj = mapService.init("map");
},10000)
return;
DEVICE_SERVICE.getDeviceList(this.params).then((res)=>{
const data = res.data;
if(data && data.length){
const arr = []
data.forEach((item) => {
arr.push({
label: item.name,
value: item.id
})
})
if(this.options[0] && 'label' in this.options[0]){
this.options = this.options.concat(arr);
}else{
this.options = arr
}
this.total = res.recordsTotal;
this.maxPage = Math.ceil(this.total/this.pageSize);
this.currentPage++;
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded');
}else{
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
this.options = []
}
})
},
sortByTime(){
// let sortArr = this.resultList.sort((a,b)=>{
// return moment(a.begintime).isBefore(moment(b.begintime))?(this.sortByTimeIsPositive?-1:1):(this.sortByTimeIsPositive?1:-1);
// });
this.sortByTimeIsPositive = !this.sortByTimeIsPositive;
// this.resultList = [].concat(sortArr);
this.sortType = 'beginTime'
this.getSortParams()
this.searchSubmit()
},
getSortParams() {
this.params.sort = this.sortType ? {
filed: this.sortType,
order: this.sortType === 'beginTime' ? (this.sortByTimeIsPositive ? 'ASC' : 'DESC') : (this.sortByStayIsPositive ? 'ASC' : 'DESC')
} : undefined
return this.params
},
sortByStay(){
// let sortArr = this.resultList.sort((a,b)=>{
// let aTime = (new Date(a.endtime)).getTime() - (new Date(a.begintime)).getTime();
// let bTime = (new Date(b.endtime)).getTime() - (new Date(b.begintime)).getTime();
// return aTime>bTime?(this.sortByStayIsPositive?-1:1):(this.sortByStayIsPositive?1:-1);
// });
this.sortByStayIsPositive = !this.sortByStayIsPositive;
// this.resultList = [].concat(sortArr);
this.sortType = 'duration'
this.getSortParams()
this.searchSubmit()
},
exportExcel(){
// let arr = [];
// this.resultList.forEach((item)=>{
// item.address = item.transferAddress;
// arr.push(item);
// });
// exportExcel('track/exportVMData', {
// vmExportType: 6,
// jsonStr: encodeURI(JSON.stringify(arr))
// }, 'post');
// let params = this.params
// params.sort = this.sortType ? {
// filed: this.sortType,
// order: this.sortType === 'beginTime' ? (this.sortByTimeIsPositive ? 'ASC' : 'DESC') : (this.sortByStayIsPositive ? 'ASC' : 'DESC')
// } : undefined
this.getSortParams()
if (this.resultList.length) {
exportExcel('/trialdrive/monitor/exportStayPoint', {...this.params}, 'post', '', true);
} else {
this.$message({
type: 'error',
message: '导出数据为空'
});
}
},
openMapInfoWindow(idx){
EventBus.$emit('uiMap.historyLocation.openInfoWindow', idx)
},
drawPoi(){
BUSINESS_SERVICE.getPOI({
sn: this.sn
}).then((res)=>{
if(res.returnCode === '0'){
if(res.data && res.data.length){
res.data.forEach((item)=>{
let marker = mapService.createPOIMarker(mapService.getLngLat(item.lng, item.lat), this.mapObj)
let infoWindow = mapService.bindPOIInfoWindow(marker, this.mapObj, item)
})
}
}
})
}
},
async created () {
// if(window.AMap){
// this.initMap();
// }else{
// await remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{
// remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{
// this.initMap();
// })
// })
// }
EventBus.$on('uiMap.historyLocation.transferSuccess', (data)=>{
this.resultList = [].concat(data);
});
},
beforeDestroy(){
}, //this.bindEvent();
components: { this.isInitMap = true;
MapControll // this.drawPoi()
} } else {
} this.checkMapLoaded = check();
}
}, 100);
};
this.checkMapLoaded = check();
},
pickDate(beforeDays) {
this.form.dateRange = [
moment().subtract(beforeDays, "days"),
moment().subtract(1, "days"),
];
},
searchSubmit() {
this.$refs.form.validate((valid, field) => {
if (valid) {
this.isSearching = true;
let params = {
sn: this.sn,
startTime: moment(this.form.dateRange[0])
.startOf("day")
.format("YYYY-MM-DD HH:mm:ss"),
endTime: moment(this.form.dateRange[1])
.endOf("day")
.format("YYYY-MM-DD HH:mm:ss"),
times: this.form.timerange,
};
if (this.form.stayMax !== "") {
params.maxTime = this.form.stayMax;
}
if (this.form.stayMin !== "") {
params.minTime = this.form.stayMin;
}
this.params = params;
this.getSortParams();
EventBus.$emit("uiMap.historyLocation.destroy");
GET_HISTORY_LOCATION({ ...this.params }).then((res) => {
if (res.code == 200) {
const data = res.data;
if (data.length) {
data.forEach((item, idx) => {
item.idx = idx;
item.name = item.ownerName || "--";
item.sn = item.sn || "--";
item.vin = item.vin || "--";
item.begintime = item.beginTime;
item.endtime = item.endTime;
item.transferAddress = item.address || "--"; // 取后端返回address
});
this.resultList = data;
EventBus.$emit("uiMap.historyLocation.draw", data);
this.resultBoxHidden = false;
} else {
this.$message({
type: "info",
message: "暂无数据",
});
}
this.isSearching = false;
}
});
} else {
return false;
}
});
},
infiniteHandler($state) {
if (this.currentPage > this.maxPage) {
$state.complete();
return;
}
this.params.currentPage = this.currentPage;
this.params.pageSize = this.pageSize;
this.params.status = 1;
this.currentPage++;
$state.loaded();
setTimeout(() => {
this.resultList = this.resultList.concat([
{
addr: "甘肃省酒泉市肃州区海马福仕达中瑞汽车",
date: "2018-11-20 15:19:21",
restTime: "25小时26分钟25秒",
},
]);
}, 10000);
return;
DEVICE_SERVICE.getDeviceList(this.params).then((res) => {
const data = res.data;
if (data && data.length) {
const arr = [];
data.forEach((item) => {
arr.push({
label: item.name,
value: item.id,
});
});
if (this.options[0] && "label" in this.options[0]) {
this.options = this.options.concat(arr);
} else {
this.options = arr;
}
this.total = res.recordsTotal;
this.maxPage = Math.ceil(this.total / this.pageSize);
this.currentPage++;
this.$refs.infiniteLoading.$emit("$InfiniteLoading:loaded");
} else {
this.$refs.infiniteLoading.$emit("$InfiniteLoading:complete");
this.options = [];
}
});
},
sortByTime() {
// let sortArr = this.resultList.sort((a,b)=>{
// return moment(a.begintime).isBefore(moment(b.begintime))?(this.sortByTimeIsPositive?-1:1):(this.sortByTimeIsPositive?1:-1);
// });
this.sortByTimeIsPositive = !this.sortByTimeIsPositive;
// this.resultList = [].concat(sortArr);
this.sortType = "beginTime";
this.getSortParams();
this.searchSubmit();
},
getSortParams() {
this.params.sort = this.sortType
? {
filed: this.sortType,
order:
this.sortType === "beginTime"
? this.sortByTimeIsPositive
? "ASC"
: "DESC"
: this.sortByStayIsPositive
? "ASC"
: "DESC",
}
: undefined;
return this.params;
},
sortByStay() {
// let sortArr = this.resultList.sort((a,b)=>{
// let aTime = (new Date(a.endtime)).getTime() - (new Date(a.begintime)).getTime();
// let bTime = (new Date(b.endtime)).getTime() - (new Date(b.begintime)).getTime();
// return aTime>bTime?(this.sortByStayIsPositive?-1:1):(this.sortByStayIsPositive?1:-1);
// });
this.sortByStayIsPositive = !this.sortByStayIsPositive;
// this.resultList = [].concat(sortArr);
this.sortType = "duration";
this.getSortParams();
this.searchSubmit();
},
exportExcel() {
// let arr = [];
// this.resultList.forEach((item)=>{
// item.address = item.transferAddress;
// arr.push(item);
// });
// exportExcel('track/exportVMData', {
// vmExportType: 6,
// jsonStr: encodeURI(JSON.stringify(arr))
// }, 'post');
// let params = this.params
// params.sort = this.sortType ? {
// filed: this.sortType,
// order: this.sortType === 'beginTime' ? (this.sortByTimeIsPositive ? 'ASC' : 'DESC') : (this.sortByStayIsPositive ? 'ASC' : 'DESC')
// } : undefined
this.getSortParams();
if (this.resultList.length) {
exportExcel(
"/trialdrive/monitor/exportStayPoint",
{ ...this.params },
"post",
"",
true
);
} else {
this.$message({
type: "error",
message: "导出数据为空",
});
}
},
openMapInfoWindow(idx) {
EventBus.$emit("uiMap.historyLocation.openInfoWindow", idx);
},
drawPoi() {
BUSINESS_SERVICE.getPOI({
sn: this.sn,
}).then((res) => {
if (res.returnCode === "0") {
if (res.data && res.data.length) {
res.data.forEach((item) => {
let marker = mapService.createPOIMarker(
mapService.getLngLat(item.lng, item.lat),
this.mapObj
);
let infoWindow = mapService.bindPOIInfoWindow(
marker,
this.mapObj,
item
);
});
}
}
});
},
},
async created() {
EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
this.resultList = [].concat(data);
});
},
beforeDestroy() {},
components: {
MapControll,
},
};
</script> </script>
<style scoped> <style scoped>
/*样式写在 scss/monitor.scss*/ /*样式写在 scss/monitor.scss*/
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -383,7 +383,6 @@ import { CONSTANT } from "@/constant"; ...@@ -383,7 +383,6 @@ 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) => {
...@@ -1319,10 +1318,9 @@ export default { ...@@ -1319,10 +1318,9 @@ export default {
} }
} */ } */
this._drawTimeoutId = setTimeout(() => { this._drawTimeoutId = setTimeout(() => {
this.getPositionData(); this.getPositionData();
}, 10 * 1000); }, 60 * 1000);
}, },
terminate() { terminate() {
this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId); this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId);
...@@ -1419,17 +1417,6 @@ export default { ...@@ -1419,17 +1417,6 @@ export default {
}, },
}, },
created() { created() {
// if (window.AMap) {
// this.initMap();
// } else {
// remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => {
// remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
// () => {
// this.initMap();
// }
// );
// });
// }
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);
...@@ -1439,19 +1426,9 @@ export default { ...@@ -1439,19 +1426,9 @@ export default {
}, },
mounted() { mounted() {
let _this = this; let _this = this;
if (window.AMap) { _this.$mapInit({ version: "2.0" }).then((AMap) => {
window.AMap = null;
}
AMapLoader.reset();
AMapLoader.load({
key: CONSTANT.MAP_KEY,
version: "1.4.2",
plugins: CONSTANT.MAP_PLUGINS,
}).then((AMap) => {
window.AMap = AMap; window.AMap = AMap;
_this.initMap(); _this.initMap();
}).catch(error => {
window.location.reload()
}); });
}, },
beforeDestroy() { beforeDestroy() {
......
...@@ -8,69 +8,173 @@ ...@@ -8,69 +8,173 @@
<div id="map" class="map-container" v-loading="mapLoading"></div> <div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll> <map-controll></map-controll>
<div class="controll-wrap"> <div class="controll-wrap">
<div class="search-box" :class="resultBoxHidden?'active':''"> <div class="search-box" :class="resultBoxHidden ? 'active' : ''">
<h3>轨迹回放</h3> <h3>轨迹回放</h3>
<p class="info">{{name||'--'}}/{{standno||'--'}}/{{sn||'--'}}</p> <p class="info">
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form"> {{ name || "--" }}/{{ standno || "--" }}/{{ sn || "--" }}
</p>
<el-form
ref="form"
:model="form"
:rules="rules"
:inline="false"
size="mini"
class="form"
>
<el-form-item label="查询范围" prop="daterange"> <el-form-item label="查询范围" prop="daterange">
<el-date-picker class="pull-left" style="width: 100%;" v-model="form.dateRange" type="datetimerange" range-separator="至" start-placeholder="开始日期" format="yyyy-MM-dd HH:mm" :clearable="false" :editable="false" :picker-options="pickerOptions" end-placeholder="结束日期"> <el-date-picker
class="pull-left"
style="width: 100%"
v-model="form.dateRange"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
format="yyyy-MM-dd HH:mm"
:clearable="false"
:editable="false"
:picker-options="pickerOptions"
end-placeholder="结束日期"
>
</el-date-picker> </el-date-picker>
<div class="pull-left"> <div class="pull-left">
<el-button size="mini" type="text" @click="pickDate(-6)">近6小时</el-button> <el-button size="mini" type="text" @click="pickDate(-6)"
<el-button size="mini" type="text" @click="pickDate(3)">近3天</el-button> >近6小时</el-button
<el-button size="mini" type="text" @click="pickDate(7)">近7天</el-button> >
<el-button size="mini" type="text" @click="pickDate(15)">近15天</el-button> <el-button size="mini" type="text" @click="pickDate(3)"
>近3天</el-button
>
<el-button size="mini" type="text" @click="pickDate(7)"
>近7天</el-button
>
<el-button size="mini" type="text" @click="pickDate(15)"
>近15天</el-button
>
<!-- <el-button size="mini" type="text" @click="pickDate(90)">近90天</el-button> --> <!-- <el-button size="mini" type="text" @click="pickDate(90)">近90天</el-button> -->
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="播放速度"> <el-form-item label="播放速度">
<el-select v-model="form.replaySpeed" placeholder="请选择" style="width: 80px"> <el-select
<el-option v-for="item in form.speedOpts" :key="item.value" :label="item.label" :value="item.value"> v-model="form.replaySpeed"
placeholder="请选择"
style="width: 80px"
>
<el-option
v-for="item in form.speedOpts"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="定位类型"> <el-form-item label="定位类型">
<el-select v-model="form.replayType" placeholder="请选择" style="width: 80px"> <el-select
<el-option v-for="item in form.replayTypeOpts" :key="item.value" :label="item.label" :value="item.value"> v-model="form.replayType"
placeholder="请选择"
style="width: 80px"
>
<el-option
v-for="item in form.replayTypeOpts"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
<p> <p>
<el-button size="mini" type="primary" v-show="!replayIng" @click="replayStart" :loading="replayIniting">播放 <i class="fa fa-play"></i> <el-button
size="mini"
type="primary"
v-show="!replayIng"
@click="replayStart"
:loading="replayIniting"
>播放 <i class="fa fa-play"></i>
</el-button> </el-button>
<el-button size="mini" type="primary" @click="replayPause" v-show="replayIng" class="clearMargin">暂停 <i class="fa fa-pause"></i> <el-button
size="mini"
type="primary"
@click="replayPause"
v-show="replayIng"
class="clearMargin"
>暂停 <i class="fa fa-pause"></i>
</el-button> </el-button>
<el-button size="mini" @click="replayReresh" type="primary"><i class="fa fa-refresh"></i> <el-button size="mini" @click="replayReresh" type="primary"
><i class="fa fa-refresh"></i>
</el-button> </el-button>
</p> </p>
<p> <p>
<el-button size="mini" type="primary" plain @click="exportReplay" :loading="exporting">导出轨迹(.csv) <i class="fa fa-download"></i></el-button> <el-button
<el-button size="mini" type="primary" plain @click="resultBoxHidden=false">停留点</el-button> size="mini"
type="primary"
plain
@click="exportReplay"
:loading="exporting"
>导出轨迹(.csv) <i class="fa fa-download"></i
></el-button>
<el-button
size="mini"
type="primary"
plain
@click="resultBoxHidden = false"
>停留点</el-button
>
</p> </p>
<p class="replay-addr" v-show="replayAddr">暂停地址:<span>{{replayAddr}}</span></p> <p class="replay-addr" v-show="replayAddr">
暂停地址:<span>{{ replayAddr }}</span>
</p>
</div> </div>
<div class="result-box" :class="resultBoxHidden?'':'active'"> <div class="result-box" :class="resultBoxHidden ? '' : 'active'">
<div class="result-box-head"> <div class="result-box-head">
<el-button class="pull-left" size="mini" type="text" @click="resultBoxHidden=true;">返回“查询”</el-button> <el-button
<el-button class="pull-right" size="mini" type="text" @click="exportExcel" :loading="exportLocationIng">导出Excel</el-button> class="pull-left"
size="mini"
type="text"
@click="resultBoxHidden = true"
>返回“查询”</el-button
>
<el-button
class="pull-right"
size="mini"
type="text"
@click="exportExcel"
:loading="exportLocationIng"
>导出Excel</el-button
>
<span>停留点</span> <span>停留点</span>
</div> </div>
<div class="result-box-filter text-center"> <div class="result-box-filter text-center">
<el-button class="" size="mini" type="text" @click="sortByTime">停留时间<i class="fa fa-sort"></i></el-button> <el-button class="" size="mini" type="text" @click="sortByTime"
<el-button class="" size="mini" type="text" @click="sortByStay">停留时长<i class="fa fa-sort"></i></el-button> >停留时间<i class="fa fa-sort"></i
></el-button>
<el-button class="" size="mini" type="text" @click="sortByStay"
>停留时长<i class="fa fa-sort"></i
></el-button>
</div> </div>
<ul class="stay-list"> <ul class="stay-list">
<li class="stay-list-item" v-for="item in resultList" @click="openMapInfoWindow(item.idx)" :key="item.idx"> <li
<p class="addr">{{item.transferAddress}}</p> class="stay-list-item"
<p class="datetime"><span>{{item.begintime}}</span><span class="pull-right">{{item.duration}}</span></p> v-for="item in resultList"
@click="openMapInfoWindow(item.idx)"
:key="item.idx"
>
<p class="addr">{{ item.transferAddress }}</p>
<p class="datetime">
<span>{{ item.begintime }}</span
><span class="pull-right">{{ item.duration }}</span>
</p>
</li> </li>
<li v-show="!resultList.length"> <li v-show="!resultList.length">
<p class="text-center">无数据</p> <p class="text-center">无数据</p>
</li> </li>
<infinite-loading v-if="needInfinite" @infinite="infiniteHandler" ref="infiniteLoading"> <infinite-loading
v-if="needInfinite"
@infinite="infiniteHandler"
ref="infiniteLoading"
>
<span slot="no-more">没有更多数据了</span> <span slot="no-more">没有更多数据了</span>
<span slot="no-results">无结果</span> <span slot="no-results">无结果</span>
</infinite-loading> </infinite-loading>
...@@ -96,9 +200,8 @@ import { exportExcel } from "utils"; ...@@ -96,9 +200,8 @@ import { exportExcel } from "utils";
import { CONSTANT } from "../../constant"; import { CONSTANT } from "../../constant";
import InfiniteLoading from "vue-infinite-loading"; import InfiniteLoading from "vue-infinite-loading";
import MapControll from "./MapControll.vue"; import MapControll from "./MapControll.vue";
import {replayShortcuts} from '@/common/index' import { replayShortcuts } from "@/common/index";
import { GET_ELECFENCE_INFO } from "@/api/services/fence"; import { GET_ELECFENCE_INFO } from "@/api/services/fence";
export default { export default {
data() { data() {
let checkDaterange = (rule, vaule, cb) => { let checkDaterange = (rule, vaule, cb) => {
...@@ -194,11 +297,11 @@ export default { ...@@ -194,11 +297,11 @@ export default {
isInitFence: this.$route.query.isInitFence === "1" ? true : false, isInitFence: this.$route.query.isInitFence === "1" ? true : false,
fenceId: this.$route.query.fenceId, fenceId: this.$route.query.fenceId,
pickerOptions: { pickerOptions: {
disabledDate(time){ disabledDate(time) {
return time.getTime() > (new Date()).getTime() return time.getTime() > new Date().getTime();
}, },
shortcuts: replayShortcuts shortcuts: replayShortcuts,
} },
}; };
}, },
mounted() { mounted() {
...@@ -670,17 +773,24 @@ export default { ...@@ -670,17 +773,24 @@ export default {
}, },
}, },
created() { created() {
if (window.AMap) { let _this = this;
this.initMap(); let _config = { version: "1.4.2" };
} else { _config.AMapUI = {
remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => { version: "1.1",
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then( plugins: ["/misc/PathSimplifier"],
() => { };
this.initMap();
} _this.$mapInit(_config).then((AMap) => {
); console.log(window.AMap);
}); _this.initMap();
} // if (AMap) {
// remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
// () => {
// _this.initMap();
// }
// );
// }
});
//轨迹播放当前位置地址显示 //轨迹播放当前位置地址显示
EventBus.$on("uiMap.replay.currAddress", (adr) => { EventBus.$on("uiMap.replay.currAddress", (adr) => {
......
<template> <template>
<v-full-layout> <v-full-layout>
<template slot="breadcrumb"> <template slot="breadcrumb">
<el-breadcrumb-item>常驻地</el-breadcrumb-item> <el-breadcrumb-item>常驻地</el-breadcrumb-item>
</template> </template>
<template slot="main"> <template slot="main">
<div class="map-wrap" > <div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div> <div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll> <map-controll></map-controll>
<div class="controll-wrap"> <div class="controll-wrap">
<div class="search-box" :class="resultBoxHidden?'active':''"> <div class="search-box" :class="resultBoxHidden ? 'active' : ''">
<h3>常驻地</h3> <h3>常驻地</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p> <p class="info">{{ name }}/{{ standno }}/{{ sn }}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form"> <el-form
<el-form-item label="查询范围" prop="timerange"> ref="form"
<el-select v-model="form.daterange" placeholder="请选择" size="small" style="width: 280px"> :model="form"
<el-option label="前一个月" value="1"></el-option> :rules="rules"
<el-option label="前三个月" value="2"></el-option> :inline="false"
<el-option label="前六个月" value="3"></el-option> size="mini"
<el-option label="截止目前" value="4"></el-option> class="form"
</el-select> >
</el-form-item> <el-form-item label="查询范围" prop="timerange">
<!-- <el-form-item label="查询时段" prop="timerange"> <el-select
v-model="form.daterange"
placeholder="请选择"
size="small"
style="width: 280px"
>
<el-option label="前一个月" value="1"></el-option>
<el-option label="前三个月" value="2"></el-option>
<el-option label="前六个月" value="3"></el-option>
<el-option label="截止目前" value="4"></el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="查询时段" prop="timerange">
<el-select v-model="form.timerange" placeholder="请选择" size="small" style="width: 280px"> <el-select v-model="form.timerange" placeholder="请选择" size="small" style="width: 280px">
<el-option label="上午(06:00~12:00)" value="1"></el-option> <el-option label="上午(06:00~12:00)" value="1"></el-option>
<el-option label="下午(12:00~21:00)" value="2"></el-option> <el-option label="下午(12:00~21:00)" value="2"></el-option>
...@@ -28,294 +40,326 @@ ...@@ -28,294 +40,326 @@
<el-option label="全天(00:00~24:00)" value="4"></el-option> <el-option label="全天(00:00~24:00)" value="4"></el-option>
</el-select> </el-select>
</el-form-item> --> </el-form-item> -->
<el-form-item class="submit-el-form-item"> <el-form-item class="submit-el-form-item">
<el-button type="primary" @click="searchSubmit" size="small" :loading="isSearching">查询</el-button> <el-button
</el-form-item> type="primary"
</el-form> @click="searchSubmit"
</div> size="small"
<div class="result-box" :class="resultBoxHidden?'':'active'"> :loading="isSearching"
<div class="result-box-head"> >查询</el-button
<el-button class="pull-left" size="mini" type="text" @click="resultBoxHidden=true;">返回“查询”</el-button> >
<el-button class="pull-right" size="mini" type="text" @click="exportExcel">导出Excel</el-button> </el-form-item>
<span>常驻地({{resultList.length}})</span> </el-form>
</div> </div>
<div class="result-box" :class="resultBoxHidden ? '' : 'active'">
<ul class="stay-list"> <div class="result-box-head">
<li class="stay-list-item" v-for="(item, index) in resultList" :key="index" @click="openMapInfoWindow(item.idx)"> <el-button
<p class="addr">{{item.transferAddress}}</p> class="pull-left"
<p class="datetime">驻留次数:<span>{{item.totalTimes}}次</span> | 驻留时长:<span>{{item.totalDurationString}}</span></p> size="mini"
</li> type="text"
<li v-show="!resultList.length"> @click="resultBoxHidden = true"
<p class="text-center">无数据</p> >返回“查询”</el-button
</li> >
<!-- <infinite-loading v-if="needInfinite" @infinite="infiniteHandler" ref="infiniteLoading"> <el-button
class="pull-right"
size="mini"
type="text"
@click="exportExcel"
>导出Excel</el-button
>
<span>常驻地({{ resultList.length }})</span>
</div>
<ul class="stay-list">
<li
class="stay-list-item"
v-for="(item, index) in resultList"
:key="index"
@click="openMapInfoWindow(item.idx)"
>
<p class="addr">{{ item.transferAddress }}</p>
<p class="datetime">
驻留次数:<span>{{ item.totalTimes }}次</span> |
驻留时长:<span>{{ item.totalDurationString }}</span>
</p>
</li>
<li v-show="!resultList.length">
<p class="text-center">无数据</p>
</li>
<!-- <infinite-loading v-if="needInfinite" @infinite="infiniteHandler" ref="infiniteLoading">
<span slot="no-more">没有更多数据了</span> <span slot="no-more">没有更多数据了</span>
<span slot="no-results">无结果</span> <span slot="no-results">无结果</span>
</infinite-loading> --> </infinite-loading> -->
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
</v-full-layout> </v-full-layout>
</template> </template>
<script> <script>
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 EventBus from '../../event-bus' import EventBus from "../../event-bus";
import {services} from '../../api' import { services } from "../../api";
import mock from '../../mock' import mock from "../../mock";
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
const BUSINESS_SERVICE = services.business; const BUSINESS_SERVICE = services.business;
import {CONSTANT} from '../../constant' import { CONSTANT } from "../../constant";
import InfiniteLoading from 'vue-infinite-loading'; import InfiniteLoading from "vue-infinite-loading";
import {exportExcel} from 'utils'; import { exportExcel } from "utils";
import MapControll from './MapControll.vue' import MapControll from "./MapControll.vue";
import AMapLoader from '@amap/amap-jsapi-loader' import { GET_RESIDENT_LOCATION } from "@/api/services/monitor";
import {GET_RESIDENT_LOCATION} from "@/api/services/monitor" export default {
export default{ data() {
data(){ return {
return { sn: this.$route.query.sn,
sn: this.$route.query.sn, name: this.$route.query.name,
name: this.$route.query.name, standno: this.$route.query.standno,
standno: this.$route.query.standno, locationType: this.$route.query.locationType,
locationType: this.$route.query.locationType, AMap: null,
AMap: null, mapObj: null,
mapObj: null, mapLoading: false,
mapLoading: false, isInitMap: false,
isInitMap: false, searchText: "",
searchText: '', searchType: "sn",
searchType: 'sn', isSearching: false,
isSearching: false, resultBoxHidden: true,
resultBoxHidden: true, form: {
form: { daterange: "1",
daterange: '1', timerange: "4",
timerange: '4', },
}, needInfinite: true,
needInfinite: true, params: {},
params: {}, currentPage: 1,
currentPage: 1, pageSize: 10,
pageSize: 10, total: 100,
total: 100, maxPage: 10,
maxPage: 10, resultList: [],
resultList: [], };
} },
}, mounted() {
mounted(){ // store.dispatch('setFullsize', true)
// store.dispatch('setFullsize', true) let _this = this;
let _this = this _this.$mapInit({ version: "1.4.2" }).then((AMap) => {
AMapLoader.load({ window.AMap = AMap;
key: CONSTANT.MAP_KEY, _this.initMap();
version: '1.4.2', });
plugins: CONSTANT.MAP_PLUGINS },
}).then((AMap) => { methods: {
window.AMap = AMap initMap() {
_this.initMap() let check = () => {
}) this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
},
methods: { return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("map");
//this.bindEvent();
this.isInitMap = true;
// this.drawPoi()
} else {
this.checkMapLoaded = check();
}
}, 100);
};
this.checkMapLoaded = check();
},
pickDate(beforeDays) {
this.form.dateRange = [
moment().subtract(beforeDays, "days"),
moment().subtract(1, "days"),
];
},
searchSubmit() {
this.$refs.form.validate((valid, field) => {
if (valid) {
this.isSearching = true;
let params = {
sn: this.sn,
timeRange: this.form.daterange,
locationType:
this.locationType === "bsLocation"
? 2
: this.locationType === "gpsLocation"
? 1
: "",
// times: this.form.timerange,
times: 4, // 无时间段选项 默认传全天(4)
};
this.params = params;
GET_RESIDENT_LOCATION(params).then((res) => {
if (res.code == 200) {
const data = res.data;
if (data.length) {
data.forEach((item, idx) => {
item.idx = idx;
item.name = item.ownerName || "--";
item.sn = item.sn || "--";
item.vin = item.vin || "--";
item.transferAddress = item.address || "--"; // 取后端返回address
});
this.resultList = data;
EventBus.$emit("uiMap.resident.draw", data);
initMap(){ this.resultBoxHidden = false;
let check = ()=>{ } else {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); this.$message({
type: "info",
message: "暂无数据",
});
EventBus.$emit("uiMap.resident.destroy", data);
}
this.isSearching = false;
}
});
} else {
return false;
}
});
},
infiniteHandler($state) {
if (this.currentPage > this.maxPage) {
$state.complete();
return;
}
return setTimeout(()=>{ this.params.currentPage = this.currentPage;
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){ this.params.pageSize = this.pageSize;
window.AMap = AMap; this.params.status = 1;
this.mapObj = mapService.init('map');
//this.bindEvent();
this.isInitMap = true;
// this.drawPoi()
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
},
pickDate(beforeDays){
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')]
},
searchSubmit(){
this.$refs.form.validate((valid, field)=>{
if(valid){
this.isSearching = true;
let params = {
sn: this.sn,
timeRange: this.form.daterange,
locationType: this.locationType === 'bsLocation' ? 2 : this.locationType === 'gpsLocation' ? 1 : '',
// times: this.form.timerange,
times: 4 // 无时间段选项 默认传全天(4)
}
this.params = params
GET_RESIDENT_LOCATION(params).then((res)=>{
if(res.code == 200){
const data = res.data;
if(data.length){
data.forEach((item, idx)=>{
item.idx = idx;
item.name = item.ownerName || '--'
item.sn = item.sn || '--'
item.vin = item.vin || '--'
item.transferAddress = item.address || '--' // 取后端返回address
});
this.resultList = data;
EventBus.$emit('uiMap.resident.draw', data);
this.resultBoxHidden = false;
}else{
this.$message({
type: 'info',
message: '暂无数据'
});
EventBus.$emit('uiMap.resident.destroy', data);
}
this.isSearching = false;
}
});
}else{
return false;
}
});
},
infiniteHandler($state){
if(this.currentPage> this.maxPage){
$state.complete();
return;
}
this.params.currentPage = this.currentPage;
this.params.pageSize = this.pageSize;
this.params.status = 1;
this.currentPage++;
$state.loaded();
setTimeout(() => {
this.resultList = this.resultList.concat([
{
addr: "甘肃省酒泉市肃州区海马福仕达中瑞汽车",
date: "2018-11-20 15:19:21",
restTime: "25小时26分钟25秒",
},
]);
}, 10000);
this.currentPage++; return;
$state.loaded(); DEVICE_SERVICE.getDeviceList(this.params).then((res) => {
setTimeout(()=>{ const data = res.data;
this.resultList = this.resultList.concat([{ if (data && data.length) {
addr: '甘肃省酒泉市肃州区海马福仕达中瑞汽车', const arr = [];
date: '2018-11-20 15:19:21', data.forEach((item) => {
restTime: '25小时26分钟25秒' arr.push({
}]) label: item.name,
},10000) value: item.id,
});
return; });
DEVICE_SERVICE.getDeviceList(this.params).then((res)=>{ if (this.options[0] && "label" in this.options[0]) {
const data = res.data; this.options = this.options.concat(arr);
if(data && data.length){ } else {
const arr = [] this.options = arr;
data.forEach((item) => { }
arr.push({
label: item.name,
value: item.id
})
})
if(this.options[0] && 'label' in this.options[0]){
this.options = this.options.concat(arr);
}else{
this.options = arr
}
this.total = res.recordsTotal;
this.maxPage = Math.ceil(this.total/this.pageSize);
this.currentPage++;
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded');
}else{
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
this.options = []
}
})
},
exportExcel(){
if(this.exporting) return;
if(this.resultList.length){
// let paramArr = [];
// this.resultList.forEach((dataItem)=>{
// let paramItem = {};
// for(let key in dataItem){
// switch(key){
// case 'name':
// case 'shopName':
// case 'sn':
// case 'sqbh':
// case 'standNo':
// case 'totalDurationString':
// case 'transferAddress':
// paramItem[key] = dataItem[key]?dataItem[key]:'';
// break;
// case 'totalTimes':
// paramItem[key] = dataItem[key]?(dataItem[key]+'次'):'';
// break;
// /*case 'transferAddress':
// paramItem.address = dataItem.transferAddress?dataItem.transferAddress:'';
// break;*/
// }
// }
// paramArr.push(paramItem);
// });
// exportExcel('track/exportVMData', { this.total = res.recordsTotal;
// jsonStr: encodeURI(JSON.stringify(paramArr)), this.maxPage = Math.ceil(this.total / this.pageSize);
// vmExportType: 4 this.currentPage++;
// }, 'post'); this.$refs.infiniteLoading.$emit("$InfiniteLoading:loaded");
exportExcel('/trialdrive/monitor/exportResident', {...this.params}, 'get', '', true); } else {
this.exporting = false; this.$refs.infiniteLoading.$emit("$InfiniteLoading:complete");
}else{ this.options = [];
this.$message({ }
type: 'error', });
message: '导出数据为空' },
}); exportExcel() {
} if (this.exporting) return;
}, if (this.resultList.length) {
openMapInfoWindow(idx){ // let paramArr = [];
EventBus.$emit('uiMap.resident.openInfoWindow', idx) // this.resultList.forEach((dataItem)=>{
}, // let paramItem = {};
drawPoi(){ // for(let key in dataItem){
BUSINESS_SERVICE.getPOI({ // switch(key){
sn: this.sn // case 'name':
}).then((res)=>{ // case 'shopName':
if(res.returnCode === '0'){ // case 'sn':
if(res.data && res.data.length){ // case 'sqbh':
res.data.forEach((item)=>{ // case 'standNo':
let marker = mapService.createPOIMarker(mapService.getLngLat(item.lng, item.lat), this.mapObj) // case 'totalDurationString':
let infoWindow = mapService.bindPOIInfoWindow(marker, this.mapObj, item) // case 'transferAddress':
}) // paramItem[key] = dataItem[key]?dataItem[key]:'';
} // break;
} // case 'totalTimes':
}) // paramItem[key] = dataItem[key]?(dataItem[key]+'次'):'';
} // break;
}, // /*case 'transferAddress':
async created () { // paramItem.address = dataItem.transferAddress?dataItem.transferAddress:'';
// if(window.AMap){ // break;*/
// this.initMap(); // }
// }else{ // }
// await remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{ // paramArr.push(paramItem);
// remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{ // });
// this.initMap();
// })
// })
// }
// exportExcel('track/exportVMData', {
EventBus.$on('uiMap.historyLocation.transferSuccess', (data)=>{ // jsonStr: encodeURI(JSON.stringify(paramArr)),
this.resultList = [].concat(data); // vmExportType: 4
}); // }, 'post');
}, exportExcel(
beforeDestroy(){ "/trialdrive/monitor/exportResident",
{ ...this.params },
"get",
"",
true
);
this.exporting = false;
} else {
this.$message({
type: "error",
message: "导出数据为空",
});
}
},
openMapInfoWindow(idx) {
EventBus.$emit("uiMap.resident.openInfoWindow", idx);
},
drawPoi() {
BUSINESS_SERVICE.getPOI({
sn: this.sn,
}).then((res) => {
if (res.returnCode === "0") {
if (res.data && res.data.length) {
res.data.forEach((item) => {
let marker = mapService.createPOIMarker(
mapService.getLngLat(item.lng, item.lat),
this.mapObj
);
let infoWindow = mapService.bindPOIInfoWindow(
marker,
this.mapObj,
item
);
});
}
}
});
},
},
async created() {
}, EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
components: { this.resultList = [].concat(data);
MapControll });
} },
} beforeDestroy() {},
components: {
MapControll,
},
};
</script> </script>
<style scoped> <style scoped>
/*样式写在 scss/monitor.scss*/ /*样式写在 scss/monitor.scss*/
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -186,7 +186,6 @@ ...@@ -186,7 +186,6 @@
<script> <script>
import mapService from "@/utils/mapService.js"; import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js"; import "@/utils/mapEvent.js";
import AMapLoader from "@amap/amap-jsapi-loader";
import { CONSTANT } from "@/constant"; import { CONSTANT } from "@/constant";
import CitySelect from "@/components/area"; import CitySelect from "@/components/area";
import { import {
...@@ -254,24 +253,12 @@ export default { ...@@ -254,24 +253,12 @@ export default {
"AMap.LabelsLayer", "AMap.LabelsLayer",
"AMap.LabelMarker", "AMap.LabelMarker",
]); ]);
if (window.AMap) {
window.AMap = null; _this.$mapInit({ plugins: plugins }).then((AMap) => {
} _this.mapLoading = false;
AMapLoader.reset(); window.AMap = AMap;
AMapLoader.load({ _this.map = mapService.init("map");
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();
});
}, },
// 画矩形 // 画矩形
...@@ -377,7 +364,8 @@ export default { ...@@ -377,7 +364,8 @@ export default {
let num = w ? w / 2 : 500 / 2; let num = w ? w / 2 : 500 / 2;
// 中心点-左边点的经纬度 // 中心点-左边点的经纬度
let leftLng = lng + (num * Math.sin(180)) / ((arc * Math.cos(lat) * 2 * pi) / 360); let leftLng =
lng + (num * Math.sin(180)) / ((arc * Math.cos(lat) * 2 * pi) / 360);
// let leftLat = lat; // let leftLat = lat;
// 中心点-下边点的经纬度 // 中心点-下边点的经纬度
...@@ -437,8 +425,8 @@ export default { ...@@ -437,8 +425,8 @@ export default {
console.log(location); console.log(location);
let lnglats = this.getLngLat(location.lng, location.lat); let lnglats = this.getLngLat(location.lng, location.lat);
console.log(lnglats) console.log(lnglats);
console.log(this.getLngLat2(location.lng, location.lat)) console.log(this.getLngLat2(location.lng, location.lat));
this.drawRectangle(lnglats); this.drawRectangle(lnglats);
}, },
......
...@@ -162,7 +162,6 @@ ...@@ -162,7 +162,6 @@
<script> <script>
import mapService from "@/utils/mapService.js"; import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js"; import "@/utils/mapEvent.js";
import AMapLoader from "@amap/amap-jsapi-loader";
import { CONSTANT } from "@/constant"; import { CONSTANT } from "@/constant";
import { import {
GER_REGIONAL_SEARCH, GER_REGIONAL_SEARCH,
...@@ -238,42 +237,33 @@ export default { ...@@ -238,42 +237,33 @@ export default {
"AMap.MassMarks", "AMap.MassMarks",
"AMap.MarkerCluster", "AMap.MarkerCluster",
"AMap.Bounds", "AMap.Bounds",
"AMap.MouseTool"
]); ]);
if (window.AMap) { _this.$mapInit({ plugins: plugins }).then((AMap) => {
window.AMap = null; _this.mapLoading = false;
} window.AMap = AMap;
AMapLoader.reset(); _this.map = mapService.init("map", { zoom: 11, showLabel: false });
AMapLoader.load({ _this.mouseTool = new AMap.MouseTool(_this.map);
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填 var autoComplete = new AMap.AutoComplete({
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15 input: "tipInput",
plugins: plugins, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map", { zoom: 11 });
_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.$set(_this.form, "address", poi.name);
_this.$refs.addressInput.focus();
});
// 判断是否为全屏,是否带参数,如果带了矩形参数,则默认画一个矩形
let _query = _this.$route.query;
if (_query.type == "full" && _query.leftLngLat) {
this.initPage(_query);
}
})
.catch((error) => {
console.log(error);
window.location.reload();
}); });
autoComplete.on("select", function (e) {
console.log(e);
let poi = e.poi || {};
_this.poi = poi;
_this.$set(_this.form, "address", poi.name);
_this.$refs.addressInput.focus();
});
// 判断是否为全屏,是否带参数,如果带了矩形参数,则默认画一个矩形
let _query = _this.$route.query;
if (_query.type == "full" && _query.leftLngLat) {
this.initPage(_query);
}
// 给地图添加文字图层
_this.map.add([new AMap.TileLayer()]);
});
}, },
// 获取地址 // 获取地址
......
...@@ -273,7 +273,15 @@ const routes = [ ...@@ -273,7 +273,15 @@ const routes = [
meta: { title: '设备激活位置' }, meta: { title: '设备激活位置' },
component: () => import('pages/monitor/activeLocation.vue'), component: () => import('pages/monitor/activeLocation.vue'),
notMenu: true, notMenu: true,
}] },
{
path: 'addPoi',
name: 'addPoi',
meta: { title: '新增POI' },
component: () => import('pages/monitor/addPoi.vue'),
notMenu: true,
}
]
}, },
{ {
path: '/business', path: '/business',
......
import AMapLoader from "@amap/amap-jsapi-loader";
import { CONSTANT } from "@/constant";
export const mapInit = params => {
return new Promise((resolve,reject) => {
let options = params || {};
// let plugins = options.plugins|| CONSTANT.MAP_PLUGINS;
// let version = options.version || '2.0';
console.log(window.window)
console.log(window.AMap);
let _list = window.localStorage || {};
// if(window.AMap){
// let _amap = window.AMap|| {};
// console.log(_amap.version)
// if(options.version == _amap.version){
// resolve(window.AMap);
// }else{
// delete window.AMap;
// delete window.AMapUI;
// delete window.Loca;
// // 删除高德地图缓存,防止出现禁止多种API加载方式混用的bug
// for(let k in _list){
// if(k.indexOf('_AMap') == 0){
// localStorage.removeItem(k);
// }
// }
// }
// }
let mapConfig ={...options};
mapConfig.key = CONSTANT.MAP_KEY; // 申请好的Web端开发者Key,首次调用 load 时必填
mapConfig.version = options.version || '2.0'; // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
mapConfig.plugins = options.plugins|| CONSTANT.MAP_PLUGINS;// 需要使用的的插件列表,如比例尺'AMap.Scale'等
if(options.AMapUI){
mapConfig.AMapUI = options.AMapUI;
}
AMapLoader.reset();
AMapLoader.load(mapConfig).then((AMap) => {
window.AMap = AMap;
resolve(AMap);
})
.catch((error) => {
window.location.reload();
reject(error);
});
})
}
\ No newline at end of file \ No newline at end of file
...@@ -29,7 +29,8 @@ MapService.prototype = { ...@@ -29,7 +29,8 @@ MapService.prototype = {
} }
var map = new AMap.Map(id, { var map = new AMap.Map(id, {
resizeEnable: true, resizeEnable: true,
zoom: params.zoom||11 zoom: params.zoom||11,
...params
}); });
// 添加比例尺 // 添加比例尺
...@@ -53,9 +54,18 @@ MapService.prototype = { ...@@ -53,9 +54,18 @@ MapService.prototype = {
}, },
toggleMapType: function () { toggleMapType: function () {
var self = this; var self = this;
let _map = self.map;
self.type = self.type ? 0 : 1; //0:使用2D地图,1:混合图 self.type = self.type ? 0 : 1; //0:使用2D地图,1:混合图
_map.plugin(["AMap.MapType"],function(){
//地图类型切换
let _mapType= new AMap.MapType({
defaultType: self.type,
});
_map.addControl(_mapType);
_mapType.hide();
});
return false;
if (self.type === 1) { if (self.type === 1) {
// 构造官方卫星、路网图层 // 构造官方卫星、路网图层
...@@ -70,6 +80,7 @@ MapService.prototype = { ...@@ -70,6 +80,7 @@ MapService.prototype = {
} else { } else {
// 地图上设置图层 // 地图上设置图层
self.map.remove(self.mixLayers); self.map.remove(self.mixLayers);
/*self.map.plugin(["AMap.MapType"],function(){ /*self.map.plugin(["AMap.MapType"],function(){
//地图类型切换 //地图类型切换
var type = new window.AMap.MapType({ var type = new window.AMap.MapType({
...@@ -87,17 +98,28 @@ MapService.prototype = { ...@@ -87,17 +98,28 @@ MapService.prototype = {
}, },
getCurrentLocation: function () { getCurrentLocation: function () {
var self = this; var self = this;
self.geolocation.getCurrentPosition(); self.geolocation.getCurrentPosition(function(status,result){
self.currentMarker && self.map.remove(self.currentMarker); console.log(status);
AMap.event.addListener(self.geolocation, 'complete', function (e) {//返回定位信息 console.log(result);
var lnglatXY = self.getLngLat(e.position.lng, e.position.lat); if(status == 'complete'){
self.currentMarker = self.createMarker(lnglatXY); self.currentMarker && self.map.remove(self.currentMarker);
//self.map.setCenter(lnglatXY); var lnglatXY = self.getLngLat(result.position.lng, result.position.lat);
self.setFitView() self.currentMarker = self.createMarker(lnglatXY);
}); self.setFitView()
AMap.event.addListener(self.geolocation, 'error', function (e) {//返回定位出错信息 }
}); });
// console.log(self.geolocation)
// self.currentMarker && self.map.remove(self.currentMarker);
// AMap.event.addListener(self.geolocation, 'complete', function (e) {//返回定位信息
// console.log(e);
// var lnglatXY = self.getLngLat(e.position.lng, e.position.lat);
// self.currentMarker = self.createMarker(lnglatXY);
// //self.map.setCenter(lnglatXY);
// self.setFitView()
// });
// AMap.event.addListener(self.geolocation, 'error', function (e) {//返回定位出错信息
// });
}, },
createMarker: function (lnglatXY) { createMarker: function (lnglatXY) {
var marker = new AMap.Marker({ var marker = new AMap.Marker({
...@@ -935,6 +957,28 @@ MapService.prototype = { ...@@ -935,6 +957,28 @@ MapService.prototype = {
return infoWindow return infoWindow
}, },
// 创建poi信息弹框
createPoiMarkerInfowindow(info){
let infoDiv = document.createElement('div');
let _div = `<div class="map_poi_infowindow_popup"><h3 class="map_poi_infowindow_title">${info.address || '暂无地址'}</h3>
<div class="map_poi_infowindow_content">
<span class="near_address">${info.near||'无'}${info.near?'附近':''}</span>
<button href="javascript:void(0)" class="clear_link" data-poi-delete>删除</button>
</div></div>`;
infoDiv.innerHTML = _div;
infoDiv.querySelector('[data-poi-delete]').onclick = function (e) {
console.log(e);
EventBus.$emit('uiMap.poi.marker.delete',info);
}
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(12, -5),
content: infoDiv,
autoMove: true,
position:[info.lng,info.lat],
})
return infoWindow
}
} }
const mapService = new MapService(); const mapService = new MapService();
......
...@@ -62,6 +62,21 @@ const MAPGEO = { ...@@ -62,6 +62,21 @@ const MAPGEO = {
})(initIdx) })(initIdx)
} }
function fixed6(num) {
return Number(num).toFixed(6);
}
// 循环设置地址,修复数组中相同经纬度只设置第一个的bug jack 20230720
function setAddress(row, item) {
let _list = data.filter(
(k) =>
fixed6(k.elng) == fixed6(row.lng) && fixed6(k.elat) == fixed6(row.lat)
);
_list.map((k) => {
k.transferAddress = item.formattedAddress;
});
}
function geocoderGetAdr(arr, initIdx) { function geocoderGetAdr(arr, initIdx) {
if (!arr || arr.length <= 0) { if (!arr || arr.length <= 0) {
return false; return false;
...@@ -72,9 +87,10 @@ const MAPGEO = { ...@@ -72,9 +87,10 @@ const MAPGEO = {
if (status === 'complete' && result.info === 'OK') {//获取地址成功 if (status === 'complete' && result.info === 'OK') {//获取地址成功
result.regeocodes.forEach((item, idx) => { result.regeocodes.forEach((item, idx) => {
let o = arr[idx] let o = arr[idx]
let _idx = data.findIndex(k => k.elng == o.lng && k.elat == o.lat); // let _idx = data.findIndex(k => k.elng == o.lng && k.elat == o.lat);
//data[initIdx + idx].transferAddress = item.formattedAddress; // //data[initIdx + idx].transferAddress = item.formattedAddress;
data[_idx].transferAddress = item.formattedAddress; // data[_idx].transferAddress = item.formattedAddress;
setAddress(o, item);
obj.totalNum++; obj.totalNum++;
}); });
if (obj.totalNum === obj.realNum) { if (obj.totalNum === obj.realNum) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!