Commit a668374c by 前端

Merge branch 'v1.23.0' into 'master'

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

See merge request !38
2 parents 80a00715 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;
} }
} }
} }
...@@ -602,3 +605,45 @@ ...@@ -602,3 +605,45 @@
} }
// 新增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
id="userCarModal"
:close-on-click-modal="flag"
@click="clickUser"
:visible="detailFormVisible"
@opened="openDialog"
@close="closeDialog"
append-to-body
width="900px"
>
<div class="dialog-header" slot="title"> <div class="dialog-header" slot="title">
<h2 class="header-title">车辆管理</h2> <h2 class="header-title">车辆管理</h2>
<nav class="header-nav"> <nav class="header-nav">
<a :class="scrollToRef=='detailForm'?'active':''" @click="scrollTo('detailForm')">设备信息</a> <a
<a :class="scrollToRef=='userInfo'?'active':''" @click="scrollTo('userInfo')">用户信息</a> :class="scrollToRef == 'detailForm' ? 'active' : ''"
<a :class="scrollToRef=='carInfo'?'active':''" @click="scrollTo('carInfo')">车辆信息</a> @click="scrollTo('detailForm')"
<a :class="scrollToRef=='clientInfo'?'active':''" @click="scrollTo('clientInfo')">关联商户</a> >设备信息</a
<a :class="scrollToRef=='log'?'active':''" @click="scrollTo('log')">操作日志</a> >
<a
:class="scrollToRef == 'userInfo' ? 'active' : ''"
@click="scrollTo('userInfo')"
>用户信息</a
>
<a
:class="scrollToRef == 'carInfo' ? 'active' : ''"
@click="scrollTo('carInfo')"
>车辆信息</a
>
<a
:class="scrollToRef == 'clientInfo' ? 'active' : ''"
@click="scrollTo('clientInfo')"
>关联商户</a
>
<a
:class="scrollToRef == 'log' ? 'active' : ''"
@click="scrollTo('log')"
>操作日志</a
>
<!-- <a :class="scrollToRef=='poi'?'active':''" @click="scrollTo('poi')">POI信息</a> --> <!-- <a :class="scrollToRef=='poi'?'active':''" @click="scrollTo('poi')">POI信息</a> -->
</nav> </nav>
</div> </div>
<div v-show="showTab==='form'"> <div v-show="showTab === 'form'">
<el-form ref="detailForm" :model="detailForm" :rules="rules" :inline="false" size="mini" label-width="110px" > <el-form
ref="detailForm"
:model="detailForm"
:rules="rules"
:inline="false"
size="mini"
label-width="110px"
>
<h3>设备信息</h3> <h3>设备信息</h3>
<el-row> <el-row>
<el-col :span="16"> <el-col :span="16">
<el-row v-for="(item, index) in deviceArr" :key="index"> <el-row v-for="(item, index) in deviceArr" :key="index">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="设备SN号" prop="device"> <el-form-item label="设备SN号" prop="device">
...@@ -50,20 +85,33 @@ ...@@ -50,20 +85,33 @@
</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
@click="addDevice"
class="el-icon-circle-plus-outline"
style="font-size: 20px; margin-left: 20px; line-height: 30px"
></i>
</el-col> </el-col>
</el-row> </el-row>
<p style="text-align:center; margin: 0"></p> <p style="text-align: center; margin: 0"></p>
<h3 ref="userInfo">用户信息</h3> <h3 ref="userInfo">用户信息</h3>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="姓名" prop="name"> <el-form-item label="姓名" prop="name">
<el-input :disabled="!isEdit&&detailForm.insuraceStatus!==1" v-model="detailForm.name"></el-input> <el-input
:disabled="!isEdit && detailForm.insuraceStatus !== 1"
v-model="detailForm.name"
></el-input>
</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="性别">
<el-select v-model.trim="detailForm.userSex" placeholder="请选择" size="small" style="width:100px;" :disabled="!isEdit"> <el-select
v-model.trim="detailForm.userSex"
placeholder="请选择"
size="small"
style="width: 100px"
:disabled="!isEdit"
>
<el-option label="男" :value="1"></el-option> <el-option label="男" :value="1"></el-option>
<el-option label="女" :value="2"></el-option> <el-option label="女" :value="2"></el-option>
</el-select> </el-select>
...@@ -71,7 +119,10 @@ ...@@ -71,7 +119,10 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="联系方式" prop="userTel"> <el-form-item label="联系方式" prop="userTel">
<el-input :disabled="!isEdit" v-model="detailForm.userTel"></el-input> <el-input
:disabled="!isEdit"
v-model="detailForm.userTel"
></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
...@@ -79,7 +130,6 @@ ...@@ -79,7 +130,6 @@
<h3 ref="carInfo">车辆信息</h3> <h3 ref="carInfo">车辆信息</h3>
<el-row> <el-row>
<el-col :span="20"> <el-col :span="20">
<!-- <el-form-item label="车牌号"> <!-- <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> -->
...@@ -89,8 +139,9 @@ ...@@ -89,8 +139,9 @@
: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> </plate-number-input>
<el-form-item label="*车架号"> <el-form-item label="*车架号">
<el-input disabled v-model="detailForm.standNo"></el-input> <el-input disabled v-model="detailForm.standNo"></el-input>
...@@ -104,28 +155,40 @@ ...@@ -104,28 +155,40 @@
<el-input disabled v-model="detailForm.groupName"></el-input> <el-input disabled v-model="detailForm.groupName"></el-input>
</el-form-item> </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
label="品牌/车型"
:brandId="detailForm.vehicleBrandId" :brandId="detailForm.vehicleBrandId"
:typeId="detailForm.vehicleTypeId" :typeId="detailForm.vehicleTypeId"
:init="brandInit" :init="brandInit"
@onBrandInitChange="brandInit=false" @onBrandInitChange="brandInit = false"
@onBrandChange="brandChange" @onBrandChange="brandChange"
prop="vechicleBrand" prop="vechicleBrand"
:disabled="!isEdit&&detailForm.insuraceStatus!==1"> :disabled="!isEdit && detailForm.insuraceStatus !== 1"
>
</v-vechicle-brand> </v-vechicle-brand>
<el-form-item label="排量" prop="displacement">
<el-form-item label="排量" prop="displacement" > <el-input :disabled="!isEdit" v-model="detailForm.displacement"
<el-input :disabled="!isEdit" v-model="detailForm.displacement"><template slot="append">L</template></el-input> ><template slot="append">L</template></el-input
>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="车辆标签" v-if="carRemark" prop="carRemarkType"> <el-form-item
<el-select :disabled="!isEdit" v-model="detailForm.carRemarkType" style="width:120px;" placeholder="请选择" size="small"> label="车辆标签"
v-if="carRemark"
prop="carRemarkType"
>
<el-select
:disabled="!isEdit"
v-model="detailForm.carRemarkType"
style="width: 120px"
placeholder="请选择"
size="small"
>
<el-option label="试驶车" :value="1"></el-option> <el-option label="试驶车" :value="1"></el-option>
<el-option label="服务车" :value="2"></el-option> <el-option label="服务车" :value="2"></el-option>
<el-option label="代步车" :value="3"></el-option> <el-option label="代步车" :value="3"></el-option>
...@@ -137,20 +200,29 @@ ...@@ -137,20 +200,29 @@
</el-col> </el-col>
<el-col :span="14"> <el-col :span="14">
<el-form-item label="车辆用途" v-if="carUsed" prop="carUsed"> <el-form-item label="车辆用途" v-if="carUsed" prop="carUsed">
<el-input :disabled="!isEdit" v-model.trim="detailForm.carUsed" maxlength="20"></el-input> <el-input
:disabled="!isEdit"
v-model.trim="detailForm.carUsed"
maxlength="20"
></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="20"> <el-col :span="20">
<el-form-item label="备注"> <el-form-item label="备注">
<el-input :disabled="!isEdit" v-model="detailForm.remark" type="textarea" :rows="3"></el-input> <el-input
:disabled="!isEdit"
v-model="detailForm.remark"
type="textarea"
:rows="3"
></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<h3 ref="clientInfo">关联商户</h3> <h3 ref="clientInfo">关联商户</h3>
<el-row > <el-row>
<el-col :span="20"> <el-col :span="20">
<el-form-item label="店面名称"> <el-form-item label="店面名称">
<el-input disabled v-model="detailForm.shopName"></el-input> <el-input disabled v-model="detailForm.shopName"></el-input>
...@@ -188,285 +260,336 @@ ...@@ -188,285 +260,336 @@
<th>调频操作人</th> <th>调频操作人</th>
</tr> </tr>
<tr v-for="(item, index) in freqTableData" :key="index"> <tr v-for="(item, index) in freqTableData" :key="index">
<td>{{item.createTime}}</td> <td>{{ item.createTime }}</td>
<td>{{item.freqTypeStr}}</td> <td>{{ item.freqTypeStr }}</td>
<td>{{item.frequency}}</td> <td>{{ item.frequency }}</td>
<td>{{item.freTotal}}</td> <td>{{ item.freTotal }}</td>
<td>{{item.devicePointTotal}}</td> <td>{{ item.devicePointTotal }}</td>
<td>{{item.batteryLevel}}%</td> <td>{{ item.batteryLevel }}%</td>
<td>{{item.operation}}</td> <td>{{ item.operation }}</td>
</tr> </tr>
</table> </table>
</el-form-item> </el-form-item>
<el-form-item label=""> <el-form-item label="">
<el-input disabled v-html="log" type="textarea" :rows="3"></el-input> <el-input
disabled
v-html="log"
type="textarea"
:rows="3"
></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<h3 ref="clientInfo">设备安装照片</h3> <h3 ref="clientInfo">设备安装照片</h3>
<el-row> <el-row>
<el-col :span="6" v-for="(value,index) in detailForm.imageUrls " :key="index"> <el-col
:span="6"
v-for="(value, index) in detailForm.imageUrls"
:key="index"
>
<el-form-item class="imgList"> <el-form-item class="imgList">
<img :src="value" :key="value" @click='bigImg(index,value)'> <!-- @click="bigImg(index)" --> <img :src="value" :key="value" @click="bigImg(index, value)" />
<!-- @click="bigImg(index)" -->
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
</div> </div>
<div class="poi-map" v-show="showTab==='poi'"> <div class="poi-map" v-show="showTab === 'poi'">
<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="mapSearch"> --> <!-- <input type="text" id="mapSearch"> -->
<el-input placeholder="请输入位置" id="mapSearch" size="small" v-model="mapSearch"> <el-input
placeholder="请输入位置"
id="mapSearch"
size="small"
v-model="mapSearch"
>
<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">
<el-button type="primary" @click="gotoMonitor()" size="small">监控</el-button> <el-button type="primary" @click="gotoMonitor()" size="small"
<el-button type="primary" @click="save" size="small" v-if="isEdit">保存</el-button> >监控</el-button
<el-button @click="$emit('onUserCarModalChange', false)" 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> </div>
<user-photo-modal :userPhotoVisible="userPhotoVisible" :photoForm="photoForm" @onUserPhotoModalChange="UserPhotoModalChange"></user-photo-modal> <user-photo-modal
:userPhotoVisible="userPhotoVisible"
:photoForm="photoForm"
@onUserPhotoModalChange="UserPhotoModalChange"
></user-photo-modal>
</el-dialog> </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 {CONSTANT} from '../../constant' import FenceMapControll from "../monitor/FenceMapControll.vue";
import FenceMapControll from '../monitor/FenceMapControll.vue' import vVechicleBrand from "components/VechicleBrand.vue";
import vVechicleBrand from 'components/VechicleBrand.vue' import plateNumberInput from "components/PlateNumberInput.vue";
import plateNumberInput from 'components/PlateNumberInput.vue' require("images/poi-marker-default.png");
export default {
require('images/poi-marker-default.png') props: ["detailFormVisible", "detailForm", "isEdit", "carRemark", "carUsed"],
export default{ data() {
props: ['detailFormVisible', 'detailForm', 'isEdit', 'carRemark', 'carUsed'],
data(){
let checkPlateNumber = (rule, vaule, cb) => { let checkPlateNumber = (rule, vaule, cb) => {
if (vaule) { if (vaule) {
let num = vaule.split('').length let num = vaule.split("").length;
if (vaule && (num < 7 || num > 10)) { if (vaule && (num < 7 || num > 10)) {
cb('请输入正确的车牌号码') cb("请输入正确的车牌号码");
}
}
cb()
} }
let checkVechicleBrand = (rule, vaule, cb)=>{
if(!this.detailForm.vehicleBrandId && !this.detailForm.vehicleTypeId){
cb(new Error('请选择品牌车型'))
} }
cb() cb();
};
let checkVechicleBrand = (rule, vaule, cb) => {
if (!this.detailForm.vehicleBrandId && !this.detailForm.vehicleTypeId) {
cb(new Error("请选择品牌车型"));
} }
cb();
};
return { return {
scrollToRef: '', scrollToRef: "",
showBigImg:false, showBigImg: false,
userPhotoVisible:false, userPhotoVisible: false,
num:0, num: 0,
photoForm:{}, photoForm: {},
flag:true, flag: true,
isEdit: true, isEdit: true,
showTab: 'form', showTab: "form",
checkMapLoaded: false, checkMapLoaded: false,
poiNum: 0, poiNum: 0,
markers: {}, markers: {},
infoWindows: {}, infoWindows: {},
log: '', log: "",
brandInit: false, brandInit: false,
brandId: undefined, brandId: undefined,
typeId: undefined, typeId: undefined,
rules: { rules: {
name: [ name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
{required: true, message: '请输入姓名', trigger: 'blur'}, plateNumber: [{ validator: checkPlateNumber, trigger: "blur" }],
],
plateNumber: [
{ validator: checkPlateNumber, trigger: 'blur' }
],
userTel: [ userTel: [
// { required: true, message: '请输入联系电话', trigger: 'blur' }, // { required: true, message: '请输入联系电话', trigger: 'blur' },
{ pattern: /^1\d{10}$/, message: '请输入正确的手机号', trigger: 'blur' } {
pattern: /^1\d{10}$/,
message: "请输入正确的手机号",
trigger: "blur",
},
], ],
displacement: [ displacement: [
{ pattern: /^(((([1-9][0-9])|[1-9])(\.\d)?)|(0\.[1-9]))$/, message: '请输入正确的格式(0.1-99.9)L', trigger: 'blur' } {
], pattern: /^(((([1-9][0-9])|[1-9])(\.\d)?)|(0\.[1-9]))$/,
device: [ message: "请输入正确的格式(0.1-99.9)L",
{required: true, message: '请输入姓名', trigger: 'blur'}, trigger: "blur",
},
], ],
device: [{ required: true, message: "请输入姓名", trigger: "blur" }],
}, },
trash: [], trash: [],
mapSearch: '', mapSearch: "",
freqTableData: [], freqTableData: [],
deviceArr: [{ deviceArr: [
sn: '', {
deviceType: '' sn: "",
}] deviceType: "",
}
}, },
async created () { ],
if(window.AMap){ };
//this.initMap()
}else{
await remoteLoad(`${CONSTANT.AMAP_URL}`);
}
}, },
mounted(){ async created() {
EventBus.$on('userCarModal.poi.save', (data, deleteBtn, saveBtn, marker, infoWindow)=>{ // if(window.AMap){
this.poiSave(data, deleteBtn, saveBtn, marker, infoWindow) // //this.initMap()
}); // }else{
// await remoteLoad(`${CONSTANT.AMAP_URL}`);
// }
},
mounted() {
EventBus.$on(
"userCarModal.poi.save",
(data, deleteBtn, saveBtn, marker, infoWindow) => {
this.poiSave(data, deleteBtn, saveBtn, marker, infoWindow);
}
);
EventBus.$on('userCarModal.poi.delete', (id)=>{ EventBus.$on("userCarModal.poi.delete", (id) => {
this.poiRemove(id) this.poiRemove(id);
}); });
console.log(this.detailForm) console.log(this.detailForm);
},
computed: {
}, },
computed: {},
methods: { methods: {
openDialog(){ openDialog() {
this.$emit('onUserCarModalChange', true) this.$emit("onUserCarModalChange", true);
this.log = this.createLogHtml(this.detailForm.vehicleLogs) this.log = this.createLogHtml(this.detailForm.vehicleLogs);
this.scrollToRef = '' this.scrollToRef = "";
this.showTab = 'form' this.showTab = "form";
if(!this.mapObj){ if (!this.mapObj) {
this.initMap() this.initMap();
}else{ } else {
this.getPOIData() this.getPOIData();
} }
if(this.detailForm.remark){ if (this.detailForm.remark) {
this.detailForm.remark = this.detailForm.remark.replace(/\<\/br\>/g, '\n') this.detailForm.remark = this.detailForm.remark.replace(
/\<\/br\>/g,
"\n"
);
} }
this.brandInit = true this.brandInit = true;
this.plateNumberInit = true; this.plateNumberInit = true;
if(this.carRemark){ if (this.carRemark) {
this.rules.carRemarkType = [{required: true, message: '请选择车辆标签', trigger: 'blur'}] this.rules.carRemarkType = [
{ required: true, message: "请选择车辆标签", trigger: "blur" },
];
} }
if(this.carUsed){ if (this.carUsed) {
this.rules.carUsed = [{required: true, message: '请输入车辆用途', trigger: 'blur'}] this.rules.carUsed = [
if(!this.detailForm.carUsed){ { required: true, message: "请输入车辆用途", trigger: "blur" },
this.detailForm.carUsed = '专属用途' ];
if (!this.detailForm.carUsed) {
this.detailForm.carUsed = "专属用途";
} }
} }
BUSINESS_SERVICE.getAdjFreqInfo({ BUSINESS_SERVICE.getAdjFreqInfo({
sn: this.detailForm.trackInfo.sn sn: this.detailForm.trackInfo.sn,
}).then((res) => { }).then((res) => {
this.freqTableData = res.data this.freqTableData = res.data;
}) });
}, },
closeDialog(){ closeDialog() {
this.$emit('onUserCarModalChange', false) this.$emit("onUserCarModalChange", false);
this.$refs.detailForm.resetFields() this.$refs.detailForm.resetFields();
this.clearPOI() this.clearPOI();
}, },
UserPhotoModalChange(isOpen,index,data){ UserPhotoModalChange(isOpen, index, data) {
this.userPhotoVisible = isOpen this.userPhotoVisible = isOpen;
}, },
scrollTo(refName){ scrollTo(refName) {
this.scrollToRef = refName; this.scrollToRef = refName;
if(refName === 'poi'){ if (refName === "poi") {
this.showTab = 'poi' this.showTab = "poi";
//mapService.setFitView(this.markers) //mapService.setFitView(this.markers)
let mapSearchInput = document.getElementById('mapSearch'); let mapSearchInput = document.getElementById("mapSearch");
if(mapSearchInput){ if (mapSearchInput) {
mapSearchInput.value = ''; mapSearchInput.value = "";
} }
}else{ } else {
this.showTab = 'form' this.showTab = "form";
var element = this.$refs[refName]; var element = this.$refs[refName];
const top = element.offsetTop; const top = element.offsetTop;
window.document.getElementById('userCarModal').querySelector('form').scrollTo(0, top-80); window.document
.getElementById("userCarModal")
.querySelector("form")
.scrollTo(0, top - 80);
} }
}, },
gotoMonitor(row){ gotoMonitor(row) {
let snO = { let snO = {
name: this.detailForm.name, name: this.detailForm.name,
standNo: this.detailForm.standNo, standNo: this.detailForm.standNo,
sn: this.detailForm.trackInfo.sn, sn: this.detailForm.trackInfo.sn,
sourceType: this.detailForm.trackInfo.source === 0?'无线':'有线', sourceType: this.detailForm.trackInfo.source === 0 ? "无线" : "有线",
source: this.detailForm.trackInfo.source source: this.detailForm.trackInfo.source,
} };
//this.$router.push({ name: 'monitor', params: { snArr: [snO], mode: 'monitor' }}) //this.$router.push({ name: 'monitor', params: { snArr: [snO], mode: 'monitor' }})
let routeData = this.$router.resolve({ path: '/monitor/monitor', query: { snArr: JSON.stringify([snO]), mode: 'monitor' }}); let routeData = this.$router.resolve({
window.open(routeData.href, '_blank'); path: "/monitor/monitor",
query: { snArr: JSON.stringify([snO]), mode: "monitor" },
});
window.open(routeData.href, "_blank");
}, },
bigImg(index,value){ bigImg(index, value) {
this.showBigImg = true; this.showBigImg = true;
var imageArray = [],current = 0; var imageArray = [],
current = 0;
var i = 0; var i = 0;
for(var key in this.detailForm.imageUrls){ for (var key in this.detailForm.imageUrls) {
imageArray.push (this.detailForm.imageUrls[key]); imageArray.push(this.detailForm.imageUrls[key]);
if(key == index){ if (key == index) {
current = i; current = i;
} }
i ++; i++;
} }
this.photoForm.data = imageArray; this.photoForm.data = imageArray;
this.photoForm.index = current; this.photoForm.index = current;
this.photoForm.length = imageArray.length; this.photoForm.length = imageArray.length;
this.userPhotoVisible = true; this.userPhotoVisible = true;
}, },
initMap(){ initMap() {
let check = ()=>{ let _this = this;
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); _this.$mapInit({ version: "1.4.2" }).then((AMap) => {
return setTimeout(()=>{
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
window.AMap = AMap; window.AMap = AMap;
this.mapObj = mapService.init('mapContainer'); _this.mapObj = mapService.init("mapContainer");
this.bindSearch(); _this.bindSearch();
this.bindContextMenu() _this.bindContextMenu();
this.getPOIData() _this.getPOIData();
}else{ });
this.checkMapLoaded = check() // let check = () => {
} // this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
}, 100)
} // return setTimeout(() => {
this.checkMapLoaded = check(); // if (
// "AMap" in window &&
// typeof AMap.Map == "function" &&
// !this.mapObj
// ) {
// window.AMap = AMap;
// this.mapObj = mapService.init("mapContainer");
// this.bindSearch();
// this.bindContextMenu();
// this.getPOIData();
// } else {
// this.checkMapLoaded = check();
// }
// }, 100);
// };
// this.checkMapLoaded = check();
}, },
bindSearch(){ bindSearch() {
const self = this; const self = this;
this.mapDot=false this.mapDot = false;
this.auto = new AMap.Autocomplete({ this.auto = new AMap.Autocomplete({
input: 'mapSearch' input: "mapSearch",
}); });
this.autoCenterMarker = new AMap.Marker({ this.autoCenterMarker = new AMap.Marker({
icon: require('images/auto-center-marker.gif'), icon: require("images/auto-center-marker.gif"),
map: this.mapObj, map: this.mapObj,
offset: new AMap.Pixel(-12,-12), offset: new AMap.Pixel(-12, -12),
visible: false visible: false,
}); });
this.autoCenterMarker.on('rightclick', (e)=> { this.autoCenterMarker.on("rightclick", (e) => {
window.mapMenu.contextMenu.open(self.mapObj, e.lnglat); window.mapMenu.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置 self.contextMenuPositon = e.lnglat; //右键菜单位置
}); });
AMap.event.addListener(this.auto, 'select', (e)=>{ AMap.event.addListener(this.auto, "select", (e) => {
if(e.poi && e.poi.location){ if (e.poi && e.poi.location) {
this.mapObj.setCenter(e.poi.location); this.mapObj.setCenter(e.poi.location);
this.autoCenterMarker.setPosition(e.poi.location); this.autoCenterMarker.setPosition(e.poi.location);
...@@ -486,15 +609,11 @@ export default{ ...@@ -486,15 +609,11 @@ export default{
} }
this.mapObj.setZoom(14); this.mapObj.setZoom(14);
}); });
}, },
bindContextMenu(){ bindContextMenu() {
const self = this; const self = this;
window.mapMenu = new ContextMenu(this.mapObj);//暴露mapMenu onclick要用 window.mapMenu = new ContextMenu(this.mapObj); //暴露mapMenu onclick要用
function ContextMenu(map) { function ContextMenu(map) {
var me = this; var me = this;
this.contextMenuPositon = null; this.contextMenuPositon = null;
...@@ -502,239 +621,257 @@ export default{ ...@@ -502,239 +621,257 @@ export default{
isCustom: true, isCustom: true,
content: `<div class="context_menu" > 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);
if (!self.isEdit) return;
me.contextMenu.open(self.mapObj, e.lnglat); me.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置 self.contextMenuPositon = e.lnglat; //右键菜单位置
}); });
} }
ContextMenu.prototype.addPOI = function addPOI() { ContextMenu.prototype.addPOI = function addPOI() {
self.addPOI() self.addPOI();
this.contextMenu.close(); this.contextMenu.close();
}; };
}, },
addPOI(){ addPOI() {
if(this.poiNum === 5){ if (this.poiNum === 5) {
this.$message({ this.$message({
type: 'info', type: "info",
message: '您所新增的POI信息已超过5个,请删除旧信息后重试!' message: "您所新增的POI信息已超过5个,请删除旧信息后重试!",
}); });
return; return;
} }
let transferObj = { let transferObj = {
data: [{ data: [
{
elng: this.contextMenuPositon.lng, elng: this.contextMenuPositon.lng,
elat: this.contextMenuPositon.lat elat: this.contextMenuPositon.lat,
}] },
} ],
MAPGEO.transferAddressByGroup(transferObj, ()=>{ };
transferObj.data.forEach((item)=>{ MAPGEO.transferAddressByGroup(transferObj, () => {
let marker = this.createPOIMarker(this.contextMenuPositon) transferObj.data.forEach((item) => {
let marker = this.createPOIMarker(this.contextMenuPositon);
let infoWindow = this.bindInfoWindow(marker, { let infoWindow = this.bindInfoWindow(marker, {
lng: item.elng, lng: item.elng,
lat: item.elat, lat: item.elat,
address: item.transferAddress, address: item.transferAddress,
poiName: '' poiName: "",
}) });
this.trash.push(marker) this.trash.push(marker);
this.trash.push(infoWindow) this.trash.push(infoWindow);
});
this.mapObj.setZoomAndCenter(
this.mapObj.getZoom(),
this.contextMenuPositon
);
}); });
this.mapObj.setZoomAndCenter(this.mapObj.getZoom(), this.contextMenuPositon);
})
return; return;
}, },
createPOIMarker(lnglatXY){ createPOIMarker(lnglatXY) {
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: lnglatXY, position: lnglatXY,
content:`<span class="poi_marker"></span>`, content: `<span class="poi_marker"></span>`,
map: this.mapObj, map: this.mapObj,
autoRotation: true, autoRotation: true,
offset: new AMap.Pixel(-20, -50), offset: new AMap.Pixel(-20, -50),
zIndex: 1020, zIndex: 1020,
animation: 'AMAP_ANIMATION_DROP' animation: "AMAP_ANIMATION_DROP",
}); });
this.poiNo++; this.poiNo++;
return marker; return marker;
}, },
bindInfoWindow(marker, info){ bindInfoWindow(marker, info) {
var infoDiv = document.createElement('div'); var infoDiv = document.createElement("div");
const mapObj = this.mapObj; const mapObj = this.mapObj;
infoDiv.innerHTML = this.createInfo(info); infoDiv.innerHTML = this.createInfo(info);
let deleteBtn = infoDiv.querySelector('[data-delete]') let deleteBtn = infoDiv.querySelector("[data-delete]");
let saveBtn = infoDiv.querySelector('[data-save]') let saveBtn = infoDiv.querySelector("[data-save]");
var infoWindow = new AMap.InfoWindow({ var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, -48), offset: new AMap.Pixel(0, -48),
content: infoDiv, content: infoDiv,
autoMove: true autoMove: true,
}); });
marker.infoWindow = infoWindow; marker.infoWindow = infoWindow;
marker.on('click', markerClick); marker.on("click", markerClick);
function markerClick(e){ function markerClick(e) {
//infoWindow.setContent(e.target.content); //infoWindow.setContent(e.target.content);
infoWindow.open(mapObj, e.target.getPosition()); infoWindow.open(mapObj, e.target.getPosition());
} }
if (!("id" in info)) {
if(!('id' in info)){ infoWindow.open(mapObj, marker.getPosition());
infoWindow.open(mapObj, marker.getPosition()) } else {
}else{ deleteBtn.setAttribute("data-id", info.id);
deleteBtn.setAttribute('data-id', info.id) saveBtn.setAttribute("data-id", info.id);
saveBtn.setAttribute('data-id', info.id) deleteBtn.style.display = "inline";
deleteBtn.style.display = 'inline'
} }
infoDiv.querySelector('[data-save]').onclick = function(e){ infoDiv.querySelector("[data-save]").onclick = function (e) {
const obj = Object.assign({}, info) const obj = Object.assign({}, info);
obj.poiName = infoDiv.querySelector('[data-title]').value.replace(/(^\s+)|(\s+$)/g, ''); obj.poiName = infoDiv
EventBus.$emit('userCarModal.poi.save', obj, deleteBtn, saveBtn, marker, infoWindow); .querySelector("[data-title]")
.value.replace(/(^\s+)|(\s+$)/g, "");
} EventBus.$emit(
"userCarModal.poi.save",
obj,
deleteBtn,
saveBtn,
marker,
infoWindow
);
};
infoDiv.querySelector('[data-delete]').onclick = function(e){ infoDiv.querySelector("[data-delete]").onclick = function (e) {
EventBus.$emit('userCarModal.poi.delete', deleteBtn.getAttribute('data-id')); EventBus.$emit(
} "userCarModal.poi.delete",
deleteBtn.getAttribute("data-id")
);
};
return infoWindow; return infoWindow;
}, },
createInfo(info){ createInfo(info) {
return `<div class="poi_infowin"> return `<div class="poi_infowin">
<h3 class="map-infowindow-title">${('id' in info)?'POI信息':'新增POI'}</h3> <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>
</div></div>`;
}, },
getPOIData(){ getPOIData() {
BUSINESS_SERVICE.getPOI({ BUSINESS_SERVICE.getPOI({
vehicleId: this.detailForm.vehicleId vehicleId: this.detailForm.vehicleId,
}).then((res)=>{ }).then((res) => {
if(res.returnCode === '0'){ if (res.returnCode === "0") {
if(res.data && res.data.length){ if (res.data && res.data.length) {
this.poiNum = res.data.length this.poiNum = res.data.length;
res.data.forEach((item)=>{ res.data.forEach((item) => {
let marker = this.createPOIMarker(mapService.getLngLat(item.lng, item.lat)) let marker = this.createPOIMarker(
let infoWindow = this.bindInfoWindow(marker, item) mapService.getLngLat(item.lng, item.lat)
this.markers[item.id] = marker );
this.infoWindows[item.id] = infoWindow let infoWindow = this.bindInfoWindow(marker, item);
}) this.markers[item.id] = marker;
setTimeout(()=>{ this.infoWindows[item.id] = infoWindow;
mapService.setFitView() });
},1000) setTimeout(() => {
mapService.setFitView();
}, 1000);
} }
} }
}) });
}, },
poiSave(data, deleteBtn, saveBtn, marker, infoWindow){ poiSave(data, deleteBtn, saveBtn, marker, infoWindow) {
const {lng,lat,address} = data const { lng, lat, address } = data;
const id = saveBtn.getAttribute('data-id'); const id = saveBtn.getAttribute("data-id");
if(typeof id === 'string'){ if (typeof id === "string") {
BUSINESS_SERVICE.updatePOI({ BUSINESS_SERVICE.updatePOI({
...data ...data,
}).then((res)=>{ }).then((res) => {
if(res.returnCode === '0'){ if (res.returnCode === "0") {
deleteBtn.style.display = 'inline' deleteBtn.style.display = "inline";
infoWindow.close() infoWindow.close();
this.$message({ this.$message({
type: 'success', type: "success",
message: '保存成功' message: "保存成功",
}) });
} }
}) });
}else{ } else {
BUSINESS_SERVICE.addPOI({ BUSINESS_SERVICE.addPOI({
vehicleId: this.detailForm.vehicleId, vehicleId: this.detailForm.vehicleId,
...data ...data,
}).then((res)=>{ }).then((res) => {
if(res.returnCode === '0'){ if (res.returnCode === "0") {
this.poiNum++; this.poiNum++;
const id = res.data.id const id = res.data.id;
this.markers[id] = marker this.markers[id] = marker;
this.infoWindows[id] = infoWindow this.infoWindows[id] = infoWindow;
deleteBtn.setAttribute('data-id', id) deleteBtn.setAttribute("data-id", id);
saveBtn.setAttribute('data-id', id); saveBtn.setAttribute("data-id", id);
deleteBtn.style.display = 'inline' deleteBtn.style.display = "inline";
infoWindow.close() infoWindow.close();
this.$message({ this.$message({
type: 'success', type: "success",
message: '新增成功' message: "新增成功",
}) });
} }
}) });
} }
}, },
poiRemove(id){ poiRemove(id) {
this.$confirm('确定删除吗?', '提示', { this.$confirm("确定删除吗?", "提示", {
confirmButtonText: '确定', confirmButtonText: "确定",
cancelButtonText: '取消', cancelButtonText: "取消",
type: 'warning' type: "warning",
}).then(() => { })
BUSINESS_SERVICE.deletePOI({id}).then((res)=>{ .then(() => {
if(res.returnCode === '0'){ BUSINESS_SERVICE.deletePOI({ id }).then((res) => {
if (res.returnCode === "0") {
this.poiNum--; this.poiNum--;
this.markers[id].setMap(null) this.markers[id].setMap(null);
this.infoWindows[id].setMap(null) this.infoWindows[id].setMap(null);
delete this.markers[id] delete this.markers[id];
delete this.infoWindows[id] delete this.infoWindows[id];
} }
});
}) })
}).catch(()=>{}) .catch(() => {});
}, },
createLogHtml(arr){ createLogHtml(arr) {
if(arr.length){ if (arr.length) {
let _html = '<table style="width:100%">'; let _html = '<table style="width:100%">';
arr.forEach((item)=>{ arr.forEach((item) => {
_html += `<tr><td>操作人</td><td>${item.operator}</td><td></td></tr>` _html += `<tr><td>操作人</td><td>${item.operator}</td><td></td></tr>`;
_html += `<tr><td>操作内容</td><td>${item.content}</td><td>${item.createTime}</td></tr>` _html += `<tr><td>操作内容</td><td>${item.content}</td><td>${item.createTime}</td></tr>`;
}) });
_html+='</table>' _html += "</table>";
return _html return _html;
}else{ } else {
return '' return "";
} }
}, },
clearPOI(){ clearPOI() {
//this.mapObj.clearMap(); //this.mapObj.clearMap();
for(let id in this.markers){ for (let id in this.markers) {
this.markers[id].setMap(null) this.markers[id].setMap(null);
} }
for(let id in this.infoWindows){ for (let id in this.infoWindows) {
this.infoWindows[id].setMap(null) this.infoWindows[id].setMap(null);
} }
this.trash.forEach((item)=>{ this.trash.forEach((item) => {
item.setMap(null) item.setMap(null);
}) });
this.markers = {}; this.markers = {};
this.infoWindows = {}; this.infoWindows = {};
this.trash = [] this.trash = [];
this.autoCenterMarker.hide() this.autoCenterMarker.hide();
window.mapMenu.contextMenu.close() window.mapMenu.contextMenu.close();
}, },
brandChange(brandId, typeId){ brandChange(brandId, typeId) {
this.detailForm.vehicleBrandId = brandId; this.detailForm.vehicleBrandId = brandId;
this.detailForm.vehicleTypeId = typeId; this.detailForm.vehicleTypeId = typeId;
//this.$refs.form.validateField('vechicleBrand'); //this.$refs.form.validateField('vechicleBrand');
}, },
plateNumberChange(str){ plateNumberChange(str) {
this.detailForm.plateNumber = str; this.detailForm.plateNumber = str;
//this.$refs.form.validateField('plateNumber'); //this.$refs.form.validateField('plateNumber');
}, },
save(){ save() {
this.$refs.detailForm.validate(valid => { this.$refs.detailForm.validate((valid) => {
if (valid) { if (valid) {
console.log(this.detailForm) console.log(this.detailForm);
const params = {}; const params = {};
const form = this.detailForm; const form = this.detailForm;
params.vehicleId = form.vehicleId; params.vehicleId = form.vehicleId;
...@@ -744,44 +881,46 @@ export default{ ...@@ -744,44 +881,46 @@ export default{
params.vehicleBrandId = form.vehicleBrandId; params.vehicleBrandId = form.vehicleBrandId;
params.vehicleTypeId = form.vehicleTypeId; params.vehicleTypeId = form.vehicleTypeId;
if(form.userSex){ if (form.userSex) {
params.userSex = form.userSex params.userSex = form.userSex;
} }
if(form.userTel){ if (form.userTel) {
params.userTel = form.userTel params.userTel = form.userTel;
} }
params.displacement = form.displacement params.displacement = form.displacement;
params.remark = form.remark params.remark = form.remark;
params.plateNumber = form.plateNumber; params.plateNumber = form.plateNumber;
if(this.carRemark && form.carRemarkType){ if (this.carRemark && form.carRemarkType) {
params.carRemarkType = form.carRemarkType params.carRemarkType = form.carRemarkType;
} }
if(this.carUsed && form.carUsed){ if (this.carUsed && form.carUsed) {
params.carUsed = form.carUsed params.carUsed = form.carUsed;
} }
BUSINESS_SERVICE.saveVehicleForm(params).then((res)=>{ BUSINESS_SERVICE.saveVehicleForm(params).then((res) => {
if(res.returnCode === '0'){ if (res.returnCode === "0") {
this.$message({ this.$message({
type: 'success', type: "success",
message: '保存成功' message: "保存成功",
}) });
this.closeDialog() this.closeDialog();
this.$emit('updateList') this.$emit("updateList");
} }
}) });
} }
}) });
}, },
addDevice(){ addDevice() {
this.deviceArr.push({ this.deviceArr.push({
sn: '', sn: "",
deviceType: '' deviceType: "",
}) });
this.rules['device'+this.deviceArr.length-1] = [{required: true, message: '请输入姓名', trigger: 'blur'}] this.rules["device" + this.deviceArr.length - 1] = [
} { required: true, message: "请输入姓名", trigger: "blur" },
];
},
/*prev(){ /*prev(){
if(this.num==0){ if(this.num==0){
this.num =3 this.num =3
...@@ -795,60 +934,57 @@ export default{ ...@@ -795,60 +934,57 @@ export default{
} }
this.num++; this.num++;
}*/ }*/
}, },
components:{ components: {
userPhotoModal, userPhotoModal,
FenceMapControll, FenceMapControll,
vVechicleBrand, vVechicleBrand,
plateNumberInput plateNumberInput,
} },
} };
</script> </script>
<style scoped> <style scoped>
form {
form {
height: 500px; height: 500px;
overflow: auto; overflow: auto;
margin: -30px -20px; margin: -30px -20px;
padding: 20px; padding: 20px;
} }
.tip{ .tip {
font-size: 12px; font-size: 12px;
} }
.imgList img{ .imgList img {
width: 160px; width: 160px;
height: 100px; height: 100px;
border: none; border: none;
/* opacity: .9; */ /* opacity: .9; */
transition: all 0.5s; transition: all 0.5s;
box-shadow: 10px 10px 16px #ccc; box-shadow: 10px 10px 16px #ccc;
} }
.imgMask{ .imgMask {
position: absolute; position: absolute;
height: 100%; height: 100%;
width:100%; width: 100%;
top:0; top: 0;
left:0; left: 0;
z-index: 100; z-index: 100;
background:rgba(0,0,0,.6); background: rgba(0, 0, 0, 0.6);
} }
.showImg{ .showImg {
height:550px; height: 550px;
width:800px; width: 800px;
position: absolute; position: absolute;
left:50%; left: 50%;
top:50%; top: 50%;
transform:translate(-50%,-50%); transform: translate(-50%, -50%);
}
} .bigImg {
.bigImg{ width: 100%;
width:100%; height: 100%;
height:100%; }
} .prev {
.prev{
position: absolute; position: absolute;
top: 50%; top: 50%;
width: 27px; width: 27px;
...@@ -859,8 +995,8 @@ export default{ ...@@ -859,8 +995,8 @@ export default{
background-position: -5px -50px; background-position: -5px -50px;
background: red; background: red;
z-index: 999; z-index: 999;
} }
.next { .next {
position: absolute; position: absolute;
top: 50%; top: 50%;
width: 27px; width: 27px;
...@@ -870,48 +1006,49 @@ export default{ ...@@ -870,48 +1006,49 @@ export default{
right: 10px; right: 10px;
background-position: -5px -50px; background-position: -5px -50px;
background: red; background: red;
} }
.poi-map{ .poi-map {
position: relative; position: relative;
} }
.poi-map .map-container{ .poi-map .map-container {
width: 100%; width: 100%;
height: 500px; height: 500px;
} }
.poi-map .map-seacrh-wrap{ .poi-map .map-seacrh-wrap {
position: absolute; position: absolute;
top: 10px; top: 10px;
left: 10px; left: 10px;
z-index: 1000; 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,
span {
vertical-align: middle; vertical-align: middle;
} }
} }
} }
.freq_table{ .freq_table {
border-collapse: collapse; border-collapse: collapse;
th,td{ th,
td {
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 2px 5px; padding: 2px 5px;
text-align: center; 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
class="map-menu"
:mode="mode" :mode="mode"
:sn="sn" :sn="sn"
@onModeChange="modeChange" @onModeChange="modeChange"
...@@ -19,10 +20,12 @@ ...@@ -19,10 +20,12 @@
:replayShowPlayer="replayShowPlayer" :replayShowPlayer="replayShowPlayer"
@onReplaySpeedChange="replaySpeedChange" @onReplaySpeedChange="replaySpeedChange"
:isInitReplayInfo="isInitReplayInfo" :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
@onRefreshMap="refreshMap"
@onToggleVisible="toggleTable"
></map-controll>
<map-table <map-table
:mode="mode" :mode="mode"
:positionType="positionType" :positionType="positionType"
...@@ -34,28 +37,29 @@ ...@@ -34,28 +37,29 @@
@onPositionTypeChange="positionTypeChange" @onPositionTypeChange="positionTypeChange"
@onReplayTypeChange="replayTypeChange" @onReplayTypeChange="replayTypeChange"
:tableVisible="tableVisible" :tableVisible="tableVisible"
@onToggleVisible="toggleTable"> @onToggleVisible="toggleTable"
>
</map-table> </map-table>
</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,
lng: 114.095388, lng: 114.095388,
...@@ -63,35 +67,35 @@ ...@@ -63,35 +67,35 @@
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,
...@@ -105,142 +109,151 @@ ...@@ -105,142 +109,151 @@
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 (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap; window.AMap = AMap;
this.mapObj = mapService.init('map'); this.mapObj = mapService.init("map");
this.bindEvent(); this.bindEvent();
this.isInitMap = true; this.isInitMap = true;
}else{ } else {
this.checkMapLoaded = check() this.checkMapLoaded = check();
}
}, 100)
} }
}, 100);
};
this.checkMapLoaded = check(); this.checkMapLoaded = check();
}, },
modeChange(mode){ modeChange(mode) {
this.mode = mode; this.mode = mode;
this.draw() this.draw();
}, },
searchConfirm(sns, ifDraw){ searchConfirm(sns, ifDraw) {
if(sns){ if (sns) {
this.sn = sns; this.sn = sns;
if(ifDraw) this.draw(true); if (ifDraw) this.draw(true);
}else{ } else {
this.sn = ''; this.sn = "";
this.destroy() this.destroy();
} }
}, },
destroy(){ destroy() {
this.table.position.data = []; this.table.position.data = [];
EventBus.$emit('uiMap.position.destroy'); EventBus.$emit("uiMap.position.destroy");
this.table.monitor.data = []; this.table.monitor.data = [];
EventBus.$emit('uiMap.monitor.destroy'); EventBus.$emit("uiMap.monitor.destroy");
this.monitorInterval && window.clearTimeout(this.monitorInterval); this.monitorInterval && window.clearTimeout(this.monitorInterval);
this.isMonitorWorking = false; this.isMonitorWorking = false;
this.table.resident.data = []; this.table.resident.data = [];
EventBus.$emit('uiMap.resident.destroy'); EventBus.$emit("uiMap.resident.destroy");
this.table.replay.data = []; this.table.replay.data = [];
EventBus.$emit('uiMap.replay.destroy'); EventBus.$emit("uiMap.replay.destroy");
this.replayShowPlayer = false; this.replayShowPlayer = false;
this.playerProgress = 0; this.playerProgress = 0;
this.table.fence.data = []; this.table.fence.data = [];
EventBus.$emit('uiMap.fence.destroy'); EventBus.$emit("uiMap.fence.destroy");
}, },
draw(isClearCache){ draw(isClearCache) {
if(!this.isInitMap){ if (!this.isInitMap) {
setTimeout(()=>{ setTimeout(() => {
this.draw(isClearCache) this.draw(isClearCache);
},500) }, 500);
return; return;
} }
if(isClearCache){ if (isClearCache) {
this.destroy() this.destroy();
}else{ } else {
EventBus.$emit('uiMap.modeChange', this.mode); EventBus.$emit("uiMap.modeChange", this.mode);
if(this.mode != 'monitor'){ if (this.mode != "monitor") {
this.monitorPause() this.monitorPause();
} }
} }
switch(this.mode){ switch (this.mode) {
case 'position': //实时位置 case "position": //实时位置
this.getPosition(); this.getPosition();
break; break;
case 'fence': case "fence":
this.getFence(); this.getFence();
break; break;
case 'replay': case "replay":
this.sn && (this.isInitReplayInfo = true); this.sn && (this.isInitReplayInfo = true);
break; break;
} }
}, },
getPosition(){ getPosition() {
if(!this.sn) return; if (!this.sn) return;
const resource = this.positionType == 'RtTrack'?MONITOR_SERVICE.getRtTrack:MONITOR_SERVICE.getBaseStationTrack; const resource =
const label = this.positionType == 'RtTrack'?'GPS':'基站'; this.positionType == "RtTrack"
? MONITOR_SERVICE.getRtTrack
: MONITOR_SERVICE.getBaseStationTrack;
const label = this.positionType == "RtTrack" ? "GPS" : "基站";
this.mapLoading = true; this.mapLoading = true;
resource({ resource({
sn: this.sn sn: this.sn,
}).then((result)=>{ }).then((result) => {
//result = mock.getRtTrack //result = mock.getRtTrack
if(result.returnCode == '0'){ if (result.returnCode == "0") {
let data = result.data; let data = result.data;
data.map((item)=>item.transferAddress=null) data.map((item) => (item.transferAddress = null));
this.table.position.data = data; this.table.position.data = data;
if(data.length){ if (data.length) {
EventBus.$emit('uiMap.position.draw', data); EventBus.$emit("uiMap.position.draw", data);
}else{ } else {
this.$confirm(`<p>暂无${label}定位数据! 原因可能是:<br>1、选择的时间内,GPS终端未连接服务器。<br>2、GPS终端电源已耗尽。</p>`, '提示', { this.$confirm(
confirmButtonText: '确定', `<p>暂无${label}定位数据! 原因可能是:<br>1、选择的时间内,GPS终端未连接服务器。<br>2、GPS终端电源已耗尽。</p>`,
"提示",
{
confirmButtonText: "确定",
showCancelButton: false, showCancelButton: false,
dangerouslyUseHTMLString: true dangerouslyUseHTMLString: true,
}); }
);
} }
} }
this.mapLoading = false; this.mapLoading = false;
}); });
}, },
getMonitor(){ getMonitor() {
if(!this.sn) return; if (!this.sn) return;
this.mapLoading = true; this.mapLoading = true;
MONITOR_SERVICE.getRtTrack({ MONITOR_SERVICE.getRtTrack({
sn: this.sn sn: this.sn,
}).then((result)=>{ }).then((result) => {
//result = mock.getRtTrack //result = mock.getRtTrack
if(this.isMonitorStopped){ if (this.isMonitorStopped) {
this.table.monitor.data = [] this.table.monitor.data = [];
} }
if(result.returnCode == '0'){ if (result.returnCode == "0") {
let data = result.data; let data = result.data;
let monitorData = this.table.monitor.data; let monitorData = this.table.monitor.data;
if(data.length){ if (data.length) {
data.map((item)=>item.transferAddress=null) data.map((item) => (item.transferAddress = null));
if(monitorData.length==0 || this.isMonitorStopped){ if (monitorData.length == 0 || this.isMonitorStopped) {
EventBus.$emit('uiMap.monitor.init', data); EventBus.$emit("uiMap.monitor.init", data);
}else{ } else {
EventBus.$emit('uiMap.monitor.draw', data); EventBus.$emit("uiMap.monitor.draw", data);
} }
this.isMonitorWorking = true; this.isMonitorWorking = true;
this.isMonitorPaused = false; this.isMonitorPaused = false;
...@@ -248,103 +261,114 @@ ...@@ -248,103 +261,114 @@
this.table.monitor.data = monitorData.concat(data); this.table.monitor.data = monitorData.concat(data);
this.monitorInterval = this.monitorIntervalFn(); this.monitorInterval = this.monitorIntervalFn();
} else {
}else{ this.$confirm(
this.$confirm('<p>暂无实时监控数据! 原因可能是:<br>1、选择的时间内,GPS终端未连接服务器。<br>2、GPS终端电源已耗尽。</p>', '提示', { "<p>暂无实时监控数据! 原因可能是:<br>1、选择的时间内,GPS终端未连接服务器。<br>2、GPS终端电源已耗尽。</p>",
confirmButtonText: '确定', "提示",
{
confirmButtonText: "确定",
showCancelButton: false, showCancelButton: false,
dangerouslyUseHTMLString: true dangerouslyUseHTMLString: true,
}); }
);
} }
} }
this.mapLoading = false; this.mapLoading = false;
}); });
}, },
monitorIntervalFn(){ monitorIntervalFn() {
return window.setTimeout(()=>{ return window.setTimeout(() => {
this.getMonitor() this.getMonitor();
}, 1000*3) }, 1000 * 3);
}, },
monitorStart(){ monitorStart() {
this.monitorInterval && window.clearTimeout(this.monitorInterval); this.monitorInterval && window.clearTimeout(this.monitorInterval);
this.getMonitor() this.getMonitor();
}, },
monitorPause(){ monitorPause() {
this.monitorInterval && window.clearTimeout(this.monitorInterval); this.monitorInterval && window.clearTimeout(this.monitorInterval);
this.isMonitorWorking = false; this.isMonitorWorking = false;
this.isMonitorPaused = true; this.isMonitorPaused = true;
}, },
monitorStop(){ monitorStop() {
this.monitorInterval && window.clearTimeout(this.monitorInterval); this.monitorInterval && window.clearTimeout(this.monitorInterval);
this.isMonitorStopped = true; this.isMonitorStopped = true;
EventBus.$emit('uiMap.monitor.end'); EventBus.$emit("uiMap.monitor.end");
this.isMonitorWorking = false; this.isMonitorWorking = false;
}, },
getResident(params){ getResident(params) {
if(!this.sn) return; if (!this.sn) return;
params.sn = this.sn; params.sn = this.sn;
this.mapLoading = true; this.mapLoading = true;
MONITOR_SERVICE.getResidentByRealTime(params).then((result)=>{ MONITOR_SERVICE.getResidentByRealTime(params).then((result) => {
//result = mock.getResidentByRealTime //result = mock.getResidentByRealTime
if(result.returnCode == '0'){ if (result.returnCode == "0") {
let data = result.data; let data = result.data;
data.map((item)=>item.transferAddress=null) data.map((item) => (item.transferAddress = null));
this.table.resident.data = data; this.table.resident.data = data;
if(data.length){ if (data.length) {
EventBus.$emit('uiMap.resident.draw', data); EventBus.$emit("uiMap.resident.draw", data);
} else {
}else{ this.$confirm(
this.$confirm('<p>没有足够的基站位置数据,无法统计常驻地。</p>', '提示', { "<p>没有足够的基站位置数据,无法统计常驻地。</p>",
confirmButtonText: '确定', "提示",
{
confirmButtonText: "确定",
showCancelButton: false, showCancelButton: false,
dangerouslyUseHTMLString: true dangerouslyUseHTMLString: true,
}); }
);
} }
} }
this.mapLoading = false; this.mapLoading = false;
}); });
}, },
residentShow(obj){ residentShow(obj) {
let params = obj; let params = obj;
if(obj.date){ if (obj.date) {
params.sTime = obj.date[0]&&(moment(obj.date[0]).format("YYYY-MM-DD HH:mm:ss")); params.sTime =
params.eTime = obj.date[1]&&(moment(obj.date[1]).endOf('day').format("YYYY-MM-DD HH:mm:ss")); 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");
params.timeRange = 5; params.timeRange = 5;
} }
delete params.date; delete params.date;
this.getResident(params) this.getResident(params);
}, },
getReplay(params){ getReplay(params) {
if(!this.sn) return; if (!this.sn) return;
params.sn = params.sn?params.sn:this.sn; params.sn = params.sn ? params.sn : this.sn;
this.mapLoading = true; this.mapLoading = true;
const resource = this.replayType == 'RtTrack'?MONITOR_SERVICE.getTrackHistory:MONITOR_SERVICE.getBaseStationHistory; const resource =
this.replayType == "RtTrack"
? MONITOR_SERVICE.getTrackHistory
: MONITOR_SERVICE.getBaseStationHistory;
resource(params).then((result)=>{ resource(params).then((result) => {
//result = mock.getTrackHistory //result = mock.getTrackHistory
if(result.returnCode == '0'){ if (result.returnCode == "0") {
let data = result.data; let data = result.data;
data.map((item)=>item.transferAddress=null) data.map((item) => (item.transferAddress = null));
this.table.replay.sustain = data; this.table.replay.sustain = data;
if(data.length){ if (data.length) {
EventBus.$emit('uiMap.replay.init', data); EventBus.$emit("uiMap.replay.init", data);
this.replayShowPlayer = true; this.replayShowPlayer = true;
}else{ } else {
this.replayShowPlayer = false; this.replayShowPlayer = false;
this.$confirm('<p>暂无轨迹数据!</p>', '提示', { this.$confirm("<p>暂无轨迹数据!</p>", "提示", {
confirmButtonText: '确定', confirmButtonText: "确定",
showCancelButton: false, showCancelButton: false,
dangerouslyUseHTMLString: true dangerouslyUseHTMLString: true,
}); });
} }
} }
...@@ -352,186 +376,173 @@ ...@@ -352,186 +376,173 @@
this.mapLoading = false; this.mapLoading = false;
}); });
}, },
replayShow(obj){ replayShow(obj) {
this.table.replay.data = []; this.table.replay.data = [];
this.replayShowPlayer = false; this.replayShowPlayer = false;
this.playerProgress = 0; this.playerProgress = 0;
EventBus.$emit('uiMap.replay.destroy') EventBus.$emit("uiMap.replay.destroy");
this.getReplay(obj) this.getReplay(obj);
}, },
replayPlay(data){ replayPlay(data) {
this.table.replay.data = this.table.replay.sustain; this.table.replay.data = this.table.replay.sustain;
EventBus.$emit('uiMap.replay.play') EventBus.$emit("uiMap.replay.play");
}, },
replayPause(){ replayPause() {
EventBus.$emit('uiMap.replay.pause') EventBus.$emit("uiMap.replay.pause");
}, },
replaySpeedChange(type){ replaySpeedChange(type) {
if(type=='up' && this.replaySpeed<3){ if (type == "up" && this.replaySpeed < 3) {
this.replaySpeed++; this.replaySpeed++;
}else if(type=='down' && this.replaySpeed>1){ } else if (type == "down" && this.replaySpeed > 1) {
this.replaySpeed--; this.replaySpeed--;
} }
EventBus.$emit('uiMap.replay.speedChange', this.replaySpeed); EventBus.$emit("uiMap.replay.speedChange", this.replaySpeed);
}, },
getFence(){ getFence() {
if(!this.sn) return; if (!this.sn) return;
MONITOR_SERVICE.getEcFenceList({ MONITOR_SERVICE.getEcFenceList({
sn: this.sn sn: this.sn,
}).then((result)=>{ }).then((result) => {
//result = mock.getEcFenceList //result = mock.getEcFenceList
if(result.returnCode == '0'){ if (result.returnCode == "0") {
let data = result.data; let data = result.data;
if(data.length){ if (data.length) {
EventBus.$emit("uiMap.fence.init");
EventBus.$emit('uiMap.fence.init'); data.forEach((o, i) => (o.index = i));
data.forEach((o, i)=>o.index=i)
this.table.fence.data = data; this.table.fence.data = data;
} else {
}else{ this.$confirm("<p>暂无电子围栏数据!</p>", "提示", {
this.$confirm('<p>暂无电子围栏数据!</p>', '提示', { confirmButtonText: "确定",
confirmButtonText: '确定',
showCancelButton: false, showCancelButton: false,
dangerouslyUseHTMLString: true dangerouslyUseHTMLString: true,
}); });
} }
} }
}); });
}, },
fenceToggleSelect(index, id){ fenceToggleSelect(index, id) {
const isSelected = !this.fenceSelectArr[index]; const isSelected = !this.fenceSelectArr[index];
if(isSelected){ if (isSelected) {
this.mapLoading = true; this.mapLoading = true;
MONITOR_SERVICE.getEcFenceById({id, id}).then((result)=>{ MONITOR_SERVICE.getEcFenceById({ id, id }).then((result) => {
//result = mock.getEcFenceById //result = mock.getEcFenceById
if(result.returnCode == '0'){ if (result.returnCode == "0") {
let data = result.data; let data = result.data;
if(data){ if (data) {
EventBus.$emit("uiMap.fence.show", data, index);
EventBus.$emit('uiMap.fence.show', data, index); } else {
}else{
} }
} }
this.mapLoading = false; this.mapLoading = false;
}); });
}else{ } else {
EventBus.$emit('uiMap.fence.hide', index); EventBus.$emit("uiMap.fence.hide", index);
} }
this.fenceSelectArr[index] = isSelected; this.fenceSelectArr[index] = isSelected;
}, },
positionTypeChange(type){ positionTypeChange(type) {
this.positionType = type; this.positionType = type;
this.getPosition(); this.getPosition();
}, },
replayTypeChange(type){ replayTypeChange(type) {
this.replayType = type; this.replayType = type;
//this.replayPlay(); //this.replayPlay();
}, },
refreshMap(){ refreshMap() {
if(this.sn){ if (this.sn) {
switch (this.mode) { switch (this.mode) {
case 'position': //实时位置 case "position": //实时位置
this.getPosition(); this.getPosition();
break; break;
case 'monitor': case "monitor":
this.isMonitorStopped = true; this.isMonitorStopped = true;
this.monitorStart(); this.monitorStart();
break; break;
case 'resident': case "resident":
break; break;
case 'replay': case "replay":
break; break;
case 'fence': case "fence":
this.getFence(); this.getFence();
break; break;
} }
} }
}, },
toggleTable(ifShow){ toggleTable(ifShow) {
if(ifShow){ if (ifShow) {
this.tableVisible = true; this.tableVisible = true;
}else{ } else {
this.tableVisible = false; this.tableVisible = false;
} }
}, },
bindEvent(){ bindEvent() {
EventBus.$on('uiMap.replay.progressUpdate', (num)=>{ EventBus.$on("uiMap.replay.progressUpdate", (num) => {
this.playerProgress = num; this.playerProgress = num;
}); });
EventBus.$on('uiMap.transfer.hide', ()=>{ EventBus.$on("uiMap.transfer.hide", () => {
this.showTransfer = false; this.showTransfer = false;
}); });
EventBus.$on('uiMap.transfer.show', ()=>{ EventBus.$on("uiMap.transfer.show", () => {
this.showTransfer = true; this.showTransfer = true;
}); });
EventBus.$on('uiMap.transfer.num', (num)=>{ EventBus.$on("uiMap.transfer.num", (num) => {
this.transferProgress = parseFloat(num); this.transferProgress = parseFloat(num);
}); });
}, },
offEvent(){ offEvent() {
EventBus.$off('uiMap.replay.progressUpdate') EventBus.$off("uiMap.replay.progressUpdate");
EventBus.$off('uiMap.transfer.hide') EventBus.$off("uiMap.transfer.hide");
EventBus.$off('uiMap.transfer.show') EventBus.$off("uiMap.transfer.show");
EventBus.$off('uiMap.transfer.num') EventBus.$off("uiMap.transfer.num");
} },
}, },
async created () { async created() {
if(window.AMap){ let _this = this;
this.initMap(); let plugins = CONSTANT.MAP_PLUGINS.concat([
}else{ "AMap.CircleEditor",
await remoteLoad(`https://webapi.amap.com/maps?v=1.3&key=${CONSTANT.MAP_KEY}&plugin=AMap.PolyEditor,AMap.CircleEditor,AMap.DistrictSearch,AMap.Autocomplete`).then(()=>{ "AMap.DistrictSearch",
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{ "AMap.Autocomplete",
this.initMap(); "AMap.PolyEditor",
}) ]);
}) _this.$mapInit({ version: "1.3", plugins: plugins }).then((AMap) => {
_this.initMap();
} });
}, },
beforeDestroy(){ beforeDestroy() {
this.offEvent(); this.offEvent();
this.monitorInterval && window.clearTimeout(this.monitorInterval); this.monitorInterval && window.clearTimeout(this.monitorInterval);
EventBus.$emit('uiMap.position.destroy'); EventBus.$emit("uiMap.position.destroy");
EventBus.$emit('uiMap.monitor.destroy'); EventBus.$emit("uiMap.monitor.destroy");
EventBus.$emit('uiMap.resident.destroy'); EventBus.$emit("uiMap.resident.destroy");
EventBus.$emit('uiMap.replay.destroy'); EventBus.$emit("uiMap.replay.destroy");
EventBus.$emit('uiMap.fence.destroy'); EventBus.$emit("uiMap.fence.destroy");
}, },
components: { components: {
MapMenu, MapMenu,
MapTable, MapTable,
MapControll 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="请输入对应条件值"
v-model="search.text"
size="small"
class="input-with-select"
>
<el-select
v-model="search.type"
slot="prepend"
placeholder="请选择"
size="small"
>
<el-option label="设备号" value="1"></el-option> <el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option> <el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option> <el-option label="姓名" value="3"></el-option>
<el-option label="工单号" value="4"></el-option> <el-option label="工单号" value="4"></el-option>
</el-select> </el-select>
</el-input> </el-input>
<el-button icon="el-icon-search" size="mini" type="primary" :loading="search.isSearching" @click="searchSubmit">搜索</el-button> <el-button
<el-button :icon="search.showResult?'fa fa-caret-up':'fa fa-caret-down'" size="mini" type="primary" @click="toggleResult"></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>
</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 (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap; window.AMap = AMap;
this.mapObj = mapService.init('map'); this.mapObj = mapService.init("map");
//this.bindEvent(); //this.bindEvent();
this.isInitMap = true; this.isInitMap = true;
}else{ } else {
this.checkMapLoaded = check() this.checkMapLoaded = check();
}
}, 100)
} }
}, 100);
};
this.checkMapLoaded = check(); this.checkMapLoaded = check();
}, },
}, },
async created () { async created() {
if(window.AMap){ let _this = this;
this.initMap(); _this.$mapInit({ version: "1.0.11" }).then((AMap) => {
}else{ _this.initMap();
await remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{ });
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{
this.initMap();
})
})
}
}, },
beforeDestroy(){ beforeDestroy() {
this.offEvent(); this.offEvent();
this.monitorInterval && window.clearTimeout(this.monitorInterval); this.monitorInterval && window.clearTimeout(this.monitorInterval);
}, },
components: { 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);
......
...@@ -4,25 +4,45 @@ ...@@ -4,25 +4,45 @@
<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
ref="form"
:model="form"
:rules="rules"
:inline="false"
size="mini"
class="form"
>
<el-form-item label="定位方式"> <el-form-item label="定位方式">
<el-select v-model="form.locationType" placeholder="请选择" size="small" style="width: 280px"> <el-select
v-model="form.locationType"
placeholder="请选择"
size="small"
style="width: 280px"
>
<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="electricFenceName"> <el-form-item label="围栏名称" prop="electricFenceName">
<el-input v-model.trim="form.electricFenceName" maxlength="200"></el-input> <el-input
v-model.trim="form.electricFenceName"
maxlength="200"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="触发类型"> <el-form-item label="触发类型">
<el-select v-model="form.triggerType" placeholder="请选择" size="small" style="width: 280px"> <el-select
v-model="form.triggerType"
placeholder="请选择"
size="small"
style="width: 280px"
>
<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>
...@@ -30,7 +50,7 @@ ...@@ -30,7 +50,7 @@
</el-form-item> </el-form-item>
<el-form-item label="指定区间" prop="daterange"> <el-form-item label="指定区间" prop="daterange">
<el-date-picker <el-date-picker
style="width: 100%;" style="width: 100%"
v-model="form.dateRange" v-model="form.dateRange"
type="daterange" type="daterange"
size="small" size="small"
...@@ -39,129 +59,158 @@ ...@@ -39,129 +59,158 @@
:unlink-panels="true" :unlink-panels="true"
range-separator="至" range-separator="至"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期"> end-placeholder="结束日期"
>
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="监控区域" class="row-form-item"> <el-form-item label="监控区域" class="row-form-item">
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-radio v-model="form.shapeType" :label="2">圆形</el-radio> <el-radio v-model="form.shapeType" :label="2"
>圆形</el-radio
>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<el-form-item label="" prop="fenceRadius"> <el-form-item label="" prop="fenceRadius">
<el-input v-model.trim="form.fenceRadius" style="width: 80px;" maxlength="200"></el-input>米 <el-input
v-model.trim="form.fenceRadius"
style="width: 80px"
maxlength="200"
></el-input
>米
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-radio v-model="form.shapeType" :label="5">多边形</el-radio> <el-radio v-model="form.shapeType" :label="5"
>多边形</el-radio
>
</el-col> </el-col>
<el-col :span="16" class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</el-col> <el-col :span="16" class="shape_tip"
>*注:地图任意位置,单击新增双击结束绘制。</el-col
>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-radio v-model="form.shapeType" :label="3">行政区域</el-radio> <el-radio v-model="form.shapeType" :label="3"
>行政区域</el-radio
>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<el-form-item label=""> <el-form-item label="">
<!-- 监控省市区组件 --> <!-- 监控省市区组件 -->
<!-- <area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="form.areaCode"></area-select> --> <!-- <area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="form.areaCode"></area-select> -->
<!-- 监控省市区组件 /--> <!-- 监控省市区组件 /-->
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item label="短信通知" prop="msgtel"> <el-form-item label="短信通知" prop="msgtel">
<el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input> <el-input
v-model.trim="form.msgtel"
maxlength="100"
placeholder="输入格式:手机号码,手机号码(支持双号)"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="围栏状态"> <el-form-item label="围栏状态">
<el-radio v-model="form.status" :label="1">启用</el-radio> <el-radio v-model="form.status" :label="1">启用</el-radio>
<el-radio v-model="form.status" :label="0">停用</el-radio> <el-radio v-model="form.status" :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>
</div> </div>
</div> </div>
</template> </template>
</v-full-layout> </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 { CONSTANT } from "@/constant";
import AreaSelect from './AreaSelect.vue' import AreaSelect from "./AreaSelect.vue";
import MAPGEO from '@/utils/mapgeo' import MAPGEO from "@/utils/mapgeo";
import MapControll from './MapControll.vue' import MapControll from "./MapControll.vue";
export default{ export default {
data(){ data() {
let checkFenceName = (rule, vaule, cb)=>{ let checkFenceName = (rule, vaule, cb) => {
if(typeof this.restainFenceName != 'undefined' && this.form.electricFenceName === this.restainFenceName){ if (
typeof this.restainFenceName != "undefined" &&
this.form.electricFenceName === this.restainFenceName
) {
cb(); cb();
} }
MONITOR_SERVICE.checkFenceName({name: this.form.electricFenceName}).then((res)=>{ MONITOR_SERVICE.checkFenceName({
if(res.returnCode == 0){ name: this.form.electricFenceName,
if(res.data.isExist == 1){ }).then((res) => {
cb(new Error('该围栏名已存在,请重新输入!')) if (res.returnCode == 0) {
}else{ if (res.data.isExist == 1) {
cb(new Error("该围栏名已存在,请重新输入!"));
} else {
cb(); cb();
} }
} }
}) });
} };
let checkDaterange = (rule, vaule, cb)=>{ let checkDaterange = (rule, vaule, cb) => {
const dateRange = this.form.dateRange; const dateRange = this.form.dateRange;
if(!dateRange || !dateRange.length){ if (!dateRange || !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)){ if (!moment.isMoment(min)) {
min = moment(min) min = moment(min);
} }
if(!moment.isMoment(max)){ if (!moment.isMoment(max)) {
max = moment(max) max = moment(max);
} }
if(min.isBefore( moment(max).subtract(30*6, 'days'), 'minute')){ if (min.isBefore(moment(max).subtract(30 * 6, "days"), "minute")) {
cb(new Error('日期范围不能超过180天')) cb(new Error("日期范围不能超过180天"));
} }
} }
cb() cb();
} };
let checkRadius = (rule, vaule, cb)=>{ let checkRadius = (rule, vaule, cb) => {
const fenceRadius = this.form.fenceRadius; const fenceRadius = this.form.fenceRadius;
if(this.form.shapeType == 2 && (!/^\d+$/.test(fenceRadius) || fenceRadius<1000)){ if (
cb(new Error('请输入整数且不小于1000')) this.form.shapeType == 2 &&
}else{ (!/^\d+$/.test(fenceRadius) || fenceRadius < 1000)
) {
cb(new Error("请输入整数且不小于1000"));
} else {
cb(); cb();
} }
} };
let checkMsgtel = (rule, vaule, cb)=>{ let checkMsgtel = (rule, vaule, cb) => {
if(this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)){ if (this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)) {
cb(new Error('请输入正确的格式')) cb(new Error("请输入正确的格式"));
}else{ } else {
cb(); cb();
} }
} };
return { return {
sn: this.$route.query.sn, sn: this.$route.query.sn,
name: this.$route.query.name, name: this.$route.query.name,
...@@ -170,59 +219,57 @@ ...@@ -170,59 +219,57 @@
mapObj: null, mapObj: null,
mapLoading: false, mapLoading: false,
isInitMap: false, isInitMap: false,
searchText: '', searchText: "",
searchType: 'sn', searchType: "sn",
isSearching: false, isSearching: false,
areaId: '', areaId: "",
areaStr: '', areaStr: "",
isSubmitting: false, isSubmitting: false,
form: { form: {
fenceNo: '', fenceNo: "",
electricFenceName: '', electricFenceName: "",
locationType: 1, locationType: 1,
triggerType: 3, triggerType: 3,
dateRange: [], dateRange: [],
shapeType: 2, shapeType: 2,
fenceRadius: '1000', fenceRadius: "1000",
status: 1, status: 1,
areaCode: '', areaCode: "",
lng: '', lng: "",
lat: '', lat: "",
analysisAddress: '', analysisAddress: "",
msgtel: '' msgtel: "",
}, },
rules: { rules: {
electricFenceName: [ electricFenceName: [
{required: true, message: '请输入围栏名称', trigger: 'blur'}, { required: true, message: "请输入围栏名称", trigger: "blur" },
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' }, { pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
{validator: checkFenceName, trigger: 'blur'} { validator: checkFenceName, trigger: "blur" },
],
daterange: [{validator: checkDaterange}],
fenceRadius: [
{validator: checkRadius, trigger: 'blur'}
], ],
msgtel: [{validator: checkMsgtel, trigger: 'blur'}], daterange: [{ validator: checkDaterange }],
fenceRadius: [{ validator: checkRadius, trigger: "blur" }],
msgtel: [{ validator: checkMsgtel, trigger: "blur" }],
}, },
fenceId: undefined, fenceId: undefined,
restainFenceName: '', restainFenceName: "",
polygonPath: [] polygonPath: [],
} };
}, },
mounted(){ mounted() {
store.dispatch('setFullsize', true) store.dispatch("setFullsize", true);
}, },
watch: { watch: {
'form.fenceRadius'(newVal){ "form.fenceRadius"(newVal) {
if(this.form.shapeType === 2){ if (this.form.shapeType === 2) {
if(this._updateFenceRadiusTimeoutId){ if (this._updateFenceRadiusTimeoutId) {
clearTimeout(this._updateFenceRadiusTimeoutId) clearTimeout(this._updateFenceRadiusTimeoutId);
} }
this._updateFenceRadiusTimeoutId = setTimeout(()=>{ this._updateFenceRadiusTimeoutId = setTimeout(() => {
this.$refs.form.validateField('fenceRadius', (error)=>{ this.$refs.form.validateField("fenceRadius", (error) => {
if(error){ if (error) {
return false; return false;
}else{ } else {
this.updateFenceRadius(newVal) this.updateFenceRadius(newVal);
} }
}); });
...@@ -235,65 +282,64 @@ ...@@ -235,65 +282,64 @@
} }
});*/ });*/
}, 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()
} }
}, 500) } else if (newVal === 5) {
this.drawPolygon();
} }
}, 500);
},
}, },
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 (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap; window.AMap = AMap;
this.mapObj = mapService.init('map'); this.mapObj = mapService.init("map");
//this.bindEvent(); //this.bindEvent();
this.isInitMap = true; this.isInitMap = true;
this.initFence(); this.initFence();
} else {
this.checkMapLoaded = check();
}else{
this.checkMapLoaded = check()
}
}, 100)
} }
}, 100);
};
this.checkMapLoaded = check(); this.checkMapLoaded = check();
}, },
initFence(){ initFence() {
MONITOR_SERVICE.getSingleFence({ MONITOR_SERVICE.getSingleFence({
sn: this.sn sn: this.sn,
}).then((res)=>{ }).then((res) => {
if(res.returnCode == 0){ if (res.returnCode == 0) {
const data = res.data; const data = res.data;
if(data){ if (data) {
this.fenceId = data.fenceId; this.fenceId = data.fenceId;
const form = this.form; const form = this.form;
form.locationType = data.locationType; form.locationType = data.locationType;
...@@ -301,33 +347,32 @@ ...@@ -301,33 +347,32 @@
this.restainFenceName = form.electricFenceName; this.restainFenceName = form.electricFenceName;
form.triggerType = data.electricFenceType; form.triggerType = data.electricFenceType;
form.dateRange = [moment(data.startTime),moment(data.endTime)]; form.dateRange = [moment(data.startTime), moment(data.endTime)];
form.shapeType = data.shapeType; form.shapeType = data.shapeType;
form.status = data.status; form.status = data.status;
form.areaCode = data.areaCode; form.areaCode = data.areaCode;
form.msgtel = data.telNumbers; form.msgtel = data.telNumbers;
if(form.shapeType === 2){ if (form.shapeType === 2) {
form.fenceRadius = data.radius; form.fenceRadius = data.radius;
form.lng = data.lng; form.lng = data.lng;
form.lat = data.lat; form.lat = data.lat;
EventBus.$emit('uiMap.fence.createFenceCircle', { EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: data.lng, lng: data.lng,
lat: data.lat, lat: data.lat,
radius: data.radius radius: data.radius,
});
} else if (form.shapeType === 3) {
this.drawDistrict(data.areaCode);
} else if (form.shapeType === 5) {
if (data.lnglat) {
this.polygonPath = data.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
}); });
}else if(form.shapeType === 3){
this.drawDistrict(data.areaCode)
}else if(form.shapeType === 5){
if(data.lnglat){
this.polygonPath = data.lnglat.split('|').map((item)=>{
return [item.split(',')[0], item.split(',')[1]]
})
} }
this.drawPolygon() this.drawPolygon();
} }
} else {
}else{
this.restainFenceName = undefined; this.restainFenceName = undefined;
} }
...@@ -335,204 +380,202 @@ ...@@ -335,204 +380,202 @@
} }
}); });
}, },
initDetail(){ initDetail() {
MONITOR_SERVICE.getTrackBySn({ MONITOR_SERVICE.getTrackBySn({
sn: this.sn sn: this.sn,
}).then((res)=>{ }).then((res) => {
if(res.returnCode == 0){ if (res.returnCode == 0) {
const data = res.data; const data = res.data;
const form = this.form; const form = this.form;
if(!this.restainFenceName){ if (!this.restainFenceName) {
form.electricFenceName = '单设备围栏-'+this.name; form.electricFenceName = "单设备围栏-" + this.name;
} }
if(!form.lng && !form.lat){ if (!form.lng && !form.lat) {
form.lng = data.lngGPS; form.lng = data.lngGPS;
form.lat = data.latGPS; form.lat = data.latGPS;
this.drawFenceCircle(); this.drawFenceCircle();
} }
EventBus.$emit('uiMap.fence.createFenceMarker', data); EventBus.$emit("uiMap.fence.createFenceMarker", data);
} }
}); });
}, },
pickDate(beforeDays){ pickDate(beforeDays) {
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')] this.form.dateRange = [
moment().subtract(beforeDays, "days"),
moment().subtract(1, "days"),
];
}, },
submit(){ submit() {
if(this.form.shapeType == 5){ if (this.form.shapeType == 5) {
if(this.polygonPath.length === 0){ if (this.polygonPath.length === 0) {
this.$message({ this.$message({
message: '请绘制围栏', message: "请绘制围栏",
type: 'error' type: "error",
}); });
return; return;
} }
} }
this.$refs.form.validate((valid, field)=>{ this.$refs.form.validate((valid, field) => {
if(valid){ if (valid) {
this.isSubmitting = true; this.isSubmitting = true;
this.getParams().then((data)=>{ this.getParams().then((data) => {
let params = data; let params = data;
if(typeof this.fenceId != 'undefined'){ if (typeof this.fenceId != "undefined") {
params.id = this.fenceId; params.id = this.fenceId;
MONITOR_SERVICE.updateFence(JSON.stringify(params)).then((res)=>{ MONITOR_SERVICE.updateFence(JSON.stringify(params)).then(
if(res.returnCode == 0){ (res) => {
if (res.returnCode == 0) {
//this.closeDialog(); //this.closeDialog();
this.$message({ this.$message({
message: res.message, message: res.message,
type: 'success' type: "success",
}); });
} }
this.isSubmitting = false; this.isSubmitting = false;
}); }
}else{ );
MONITOR_SERVICE.getNewFenceId().then((res)=>{ } else {
if(res.returnCode == 0){ MONITOR_SERVICE.getNewFenceId().then((res) => {
if (res.returnCode == 0) {
params.fenceNo = res.data.fenceNo; params.fenceNo = res.data.fenceNo;
MONITOR_SERVICE.saveFence(JSON.stringify(params)).then((res)=>{ MONITOR_SERVICE.saveFence(JSON.stringify(params)).then(
if(res.returnCode == 0){ (res) => {
if (res.returnCode == 0) {
//this.closeDialog(); //this.closeDialog();
this.$message({ this.$message({
message: res.message, message: res.message,
type: 'success' type: "success",
}); });
this.fenceId = res.data; this.fenceId = res.data;
this.restainFenceName = this.form.electricFenceName; this.restainFenceName = this.form.electricFenceName;
} }
this.isSubmitting = false; this.isSubmitting = false;
}); }
);
} }
}); });
} }
}); });
} else {
}else{
return false; return false;
} }
}); });
}, },
getParams(){ getParams() {
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject) => {
const form = this.form; const form = this.form;
const params = {}; const params = {};
const transferItem = { const transferItem = {
data: [{ data: [
{
elng: form.lng, elng: form.lng,
elat: form.lat elat: form.lat,
}] },
} ],
MAPGEO.transferAddressByGroup(transferItem, ()=>{ };
MAPGEO.transferAddressByGroup(transferItem, () => {
params.electricFenceName = form.electricFenceName; params.electricFenceName = form.electricFenceName;
params.electricFenceType = form.triggerType; params.electricFenceType = form.triggerType;
params.shapeType = form.shapeType; params.shapeType = form.shapeType;
params.locationType = form.locationType; params.locationType = form.locationType;
if(params.shapeType == 3){ if (params.shapeType == 3) {
params.areaCode = this.areaId; params.areaCode = this.areaId;
params.areaString = this.areaStr; params.areaString = this.areaStr;
}else if(params.shapeType == 2){ } else if (params.shapeType == 2) {
params.lng = form.lng; params.lng = form.lng;
params.lat = form.lat; params.lat = form.lat;
params.radius = form.fenceRadius; params.radius = form.fenceRadius;
params.analysisAddress = transferItem.data[0].transferAddress; params.analysisAddress = transferItem.data[0].transferAddress;
}else if(params.shapeType == 5){ } else if (params.shapeType == 5) {
params.lnglat = this.polygonPath.join('|') params.lnglat = this.polygonPath.join("|");
} }
params.status = form.status; params.status = form.status;
params.snList = [{sn: this.sn}] params.snList = [{ sn: this.sn }];
params.startTime = moment(this.form.dateRange[0]).format('YYYY-MM-DD'); params.startTime = moment(this.form.dateRange[0]).format(
params.endTime = moment(this.form.dateRange[1]).format('YYYY-MM-DD'); "YYYY-MM-DD"
if(form.msgtel){ );
params.telNumbers = form.msgtel params.endTime = moment(this.form.dateRange[1]).format("YYYY-MM-DD");
if (form.msgtel) {
params.telNumbers = form.msgtel;
} }
params.timeType = 2 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 () { },
if(window.AMap){ created() {
this.initMap(); let _this = this;
}else{ _this.$mapInit({ version: "1.0.11" }).then((AMap) => {
remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{ _this.initMap();
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{ });
this.initMap(); EventBus.$on("uiMap.fence.loading", (isLoading) => {
})
})
}
EventBus.$on('uiMap.fence.loading', (isLoading)=>{
this.mapLoading = isLoading; this.mapLoading = isLoading;
}); });
EventBus.$on('uiMap.fence.onFenceRadiusChange', (radius)=>{ EventBus.$on("uiMap.fence.onFenceRadiusChange", (radius) => {
this.form.fenceRadius = radius; this.form.fenceRadius = radius;
//this.$refs.form.validateField('fenceRadius'); //this.$refs.form.validateField('fenceRadius');
}); });
EventBus.$on('uiMap.fence.onFenceLngLatChange', (data)=>{ EventBus.$on("uiMap.fence.onFenceLngLatChange", (data) => {
this.form.lng = data.lng; this.form.lng = data.lng;
this.form.lat = data.lat; this.form.lat = data.lat;
}); });
EventBus.$on('uiMap.fence.polygonChange', (data)=>{ EventBus.$on("uiMap.fence.polygonChange", (data) => {
this.polygonPath = data.polygonPath this.polygonPath = data.polygonPath;
}); });
},
beforeDestroy(){
}, },
beforeDestroy() {},
components: { components: {
AreaSelect, AreaSelect,
MapControll 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() {
...@@ -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") {
AMap.event.addListener(self.geolocation, "complete", function (e) { var lnglatXY = mapService.getLngLat(
console.log("complete", e); result.position.lng,
//返回定位信息 result.position.lat
var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat); );
resolve(lnglatXY); resolve(lnglatXY);
}); }
AMap.event.addListener(self.geolocation, "error", function (e) {
console.log("error", e); if (status == "error") {
console.log("error", result);
//返回定位出错信息 //返回定位出错信息
resolve(mapObj.getCenter()); 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
id="fenceMapModal"
:visible="fenceMapModalVisible"
@open="openDialog"
@close="closeDialog"
append-to-body
width="1200px"
top="10vh"
>
<div class="dialog-header" slot="title"> <div class="dialog-header" slot="title">
<h2 class="header-title">地图引用</h2> <h2 class="header-title">地图引用</h2>
</div> </div>
<div class="fence-map"> <div class="fence-map">
<el-form
<el-form :model="form" ref="fenceMapForm" :rules="rules" :inline="true" size="mini" > :model="form"
ref="fenceMapForm"
:rules="rules"
:inline="true"
size="mini"
>
<el-form-item label="经度" prop="lng"> <el-form-item label="经度" prop="lng">
<el-input v-model="form.lng" style="width:100px" @change="transfer"></el-input> <el-input
v-model="form.lng"
style="width: 100px"
@change="transfer"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="纬度" prop="lat"> <el-form-item label="纬度" prop="lat">
<el-input v-model="form.lat" style="width:100px" @change="transfer"></el-input> <el-input
v-model="form.lat"
style="width: 100px"
@change="transfer"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="经纬度解析" prop="transferAddr"> <el-form-item label="经纬度解析" prop="transferAddr">
<el-input v-model="form.transferAddr" disabled placeholder="自动生成" style="width: 410px;"></el-input> <el-input
v-model="form.transferAddr"
disabled
placeholder="自动生成"
style="width: 410px"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="监控范围" prop="radius"> <el-form-item label="监控范围" prop="radius">
<el-input v-model="form.radius" style="width:160px" maxlength="10"> <el-input v-model="form.radius" style="width: 160px" maxlength="10">
<template slot="append">KM</template> <template slot="append">KM</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item><el-button type="primary" @click="updateFence">更新围栏</el-button></el-form-item> <el-form-item
><el-button type="primary" @click="updateFence"
>更新围栏</el-button
></el-form-item
>
</el-form> </el-form>
<div id="mapContainer" class="map-container"></div> <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"> <div class="map-seacrh-wrap">
<!-- <input type="text" id="fenceMapSearch"> --> <!-- <input type="text" id="fenceMapSearch"> -->
<el-input placeholder="请输入位置" id="fenceMapSearch" size="small" v-model="fenceMapSearch"> <el-input
placeholder="请输入位置"
id="fenceMapSearch"
size="small"
v-model="fenceMapSearch"
>
<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">
<el-button type="primary" @click="sure" size="small">确认</el-button> <el-button type="primary" @click="sure" size="small">确认</el-button>
<el-button @click="$emit('onFenceMapModalChange', false)" size="small">关闭</el-button> <el-button @click="$emit('onFenceMapModalChange', false)" size="small"
>关闭</el-button
>
</div> </div>
</el-dialog> </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{ export default {
props: ['fenceMapModalVisible', 'mapData', 'init'], props: ["fenceMapModalVisible", "mapData", "init"],
data(){ data() {
let checkLng = (rule, vaule, cb)=>{ 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)){ if (
cb(new Error('请输入正确的格式')) !/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(
}else{ this.form.lng
)
) {
cb(new Error("请输入正确的格式"));
} else {
cb(); cb();
} }
} };
let checkLat = (rule, vaule, cb)=>{ let checkLat = (rule, vaule, cb) => {
if(!/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(this.form.lat)){ if (
cb(new Error('请输入正确的格式')) !/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(
}else{ this.form.lat
)
) {
cb(new Error("请输入正确的格式"));
} else {
cb(); cb();
} }
} };
let checkTransferAddr = (rule, vaule, cb)=>{
if(this.transferError){ let checkTransferAddr = (rule, vaule, cb) => {
cb(new Error('所填经纬度不能正确解析地址,请重新输入')) if (this.transferError) {
}else if(!this.form.transferAddr){ cb(new Error("所填经纬度不能正确解析地址,请重新输入"));
cb(new Error('经纬度解析地址不能为空')) } else if (!this.form.transferAddr) {
}else{ cb(new Error("经纬度解析地址不能为空"));
cb() } else {
}
}
let checkRadius = (rule, vaule, cb)=>{
if(!/^(\d+|\d+\.\d{0,3})$/.test(this.form.radius)){
cb(new Error('数字,精确到小数点后三位'))
}else{
cb(); cb();
} }
};
let checkRadius = (rule, vaule, cb) => {
if (!/^(\d+|\d+\.\d{0,3})$/.test(this.form.radius)) {
cb(new Error("数字,精确到小数点后三位"));
} else {
cb();
} }
};
return { return {
fenceMapSearch: '', fenceMapSearch: "",
geolocation: null, geolocation: null,
circleEditor: null, circleEditor: null,
circle: null, circle: null,
form: { form: {
lng: '', lng: "",
lat: '', lat: "",
transferAddr: '', transferAddr: "",
radius: 1 radius: 1,
}, },
transferTimeoutId: undefined, transferTimeoutId: undefined,
geocoder: null, geocoder: null,
transferFlag: null, transferFlag: null,
rules: { rules: {
lng: [ lng: [{ validator: checkLng, trigger: "blur" }],
{validator: checkLng, trigger: 'blur'} lat: [{ validator: checkLat, trigger: "blur" }],
], transferAddr: [{ validator: checkTransferAddr, trigger: "blur" }],
lat: [ radius: [{ validator: checkRadius, trigger: "blur" }],
{validator: checkLat, trigger: 'blur'}
],
transferAddr: [
{validator: checkTransferAddr, trigger: 'blur'}
],
radius: [
{validator: checkRadius, trigger: 'blur'}
]
},
transferError: false
}
}, },
mounted(){
transferError: false,
};
}, },
mounted() {},
watch: { watch: {
lng(newVal){ lng(newVal) {
//this.transfer() //this.transfer()
}, },
lat(newVal){ lat(newVal) {
//this.transfer() //this.transfer()
}
}, },
async created () { },
if(window.AMap){ async created() {
// if (window.AMap) {
}else{ // } else {
await remoteLoad(`${CONSTANT.AMAP_URL}`); // await remoteLoad(`${CONSTANT.AMAP_URL}`);
//this.initMap() // //this.initMap()
} // }
}, },
methods: { methods: {
sure(){ sure() {
this.$refs.fenceMapForm.validate((valid)=>{ this.$refs.fenceMapForm.validate((valid) => {
if(valid){ if (valid) {
this.$emit('onFenceMapModalChange', false); this.$emit("onFenceMapModalChange", false);
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: this.form.radius radius: this.form.radius,
}); });
} else {
}else{
return false; return false;
} }
}) });
}, },
initMap(){ initMap() {
let check = ()=>{ let _this = this;
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); _this.$mapInit({ version: "1.0.11" }).then((AMap) => {
return setTimeout(()=>{
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
window.AMap = AMap; window.AMap = AMap;
this.mapObj = mapService.init('mapContainer'); _this.mapObj = mapService.init("mapContainer");
this.bindSearch(); _this.bindSearch();
this.drawFence() _this.drawFence();
}else{ });
this.checkMapLoaded = check() // let check = ()=>{
} // this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
}, 100)
} // return setTimeout(()=>{
this.checkMapLoaded = check(); // if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
// window.AMap = AMap;
// this.mapObj = mapService.init('mapContainer');
// this.bindSearch();
// this.drawFence()
// }else{
// this.checkMapLoaded = check()
// }
// }, 100)
// }
// this.checkMapLoaded = check();
}, },
openDialog(){ openDialog() {
this.form.lng = this.mapData.lng;
this.form.lng = this.mapData.lng this.form.lat = this.mapData.lat;
this.form.lat = this.mapData.lat this.form.transferAddr = this.mapData.address;
this.form.transferAddr = this.mapData.address this.form.radius = this.mapData.radius ? this.mapData.radius : 1;
this.form.radius = this.mapData.radius?this.mapData.radius:1
//this.$emit('onFenceMapModalChange', true) //this.$emit('onFenceMapModalChange', true)
if(this.mapObj){ if (this.mapObj) {
this.updateFence(); this.updateFence();
}else{ } else {
this.initMap() this.initMap();
} }
}, },
closeDialog(){ closeDialog() {
this.$emit('onFenceMapModalChange', false) this.$emit("onFenceMapModalChange", false);
}, },
bindSearch(){ bindSearch() {
this.auto = new AMap.Autocomplete({ this.auto = new AMap.Autocomplete({
input: 'fenceMapSearch' input: "fenceMapSearch",
}); });
this.autoCenterMarker = new AMap.Marker({ this.autoCenterMarker = new AMap.Marker({
icon: require('images/auto-center-marker.gif'), icon: require("images/auto-center-marker.gif"),
map: this.mapObj, map: this.mapObj,
offset: new AMap.Pixel(-12,-12), offset: new AMap.Pixel(-12, -12),
visible: false visible: false,
}); });
AMap.event.addListener(this.auto, 'select', (e)=>{ AMap.event.addListener(this.auto, "select", (e) => {
if(e.poi && e.poi.location){ if (e.poi && e.poi.location) {
//this.mapObj.setZoom(15); //this.mapObj.setZoom(15);
//this.mapObj.setCenter(e.poi.location) //this.mapObj.setCenter(e.poi.location)
//this.circle.setCenter(e.poi.location); //this.circle.setCenter(e.poi.location);
...@@ -217,170 +254,157 @@ export default{ ...@@ -217,170 +254,157 @@ export default{
this.autoCenterMarker.setPosition(e.poi.location); this.autoCenterMarker.setPosition(e.poi.location);
this.autoCenterMarker.show(); this.autoCenterMarker.show();
mapService.setFitView() mapService.setFitView();
this.fenceMapSearch = ''; this.fenceMapSearch = "";
this.form.lng = e.poi.location.lng; this.form.lng = e.poi.location.lng;
this.form.lat = e.poi.location.lat; this.form.lat = e.poi.location.lat;
} }
}); });
}, },
drawFence(){ drawFence() {
this.circleEditor && this.circleEditor.destroy(); this.circleEditor && this.circleEditor.destroy();
const mapObj = this.mapObj; const mapObj = this.mapObj;
let circleCenter = null; let circleCenter = null;
if(this.form.transferAddr){ if (this.form.transferAddr) {
circleCenter = mapService.getLngLat(this.form.lng, this.form.lat) circleCenter = mapService.getLngLat(this.form.lng, this.form.lat);
}else{ } else {
circleCenter = mapObj.getCenter(); circleCenter = mapObj.getCenter();
this.form.lng = circleCenter.lng; this.form.lng = circleCenter.lng;
this.form.lat = circleCenter.lat; this.form.lat = circleCenter.lat;
this.transfer() this.transfer();
} }
this.circle = new AMap.Circle({ this.circle = new AMap.Circle({
map: mapObj, map: mapObj,
center: circleCenter, center: circleCenter,
radius: this.form.radius*1000, radius: this.form.radius * 1000,
strokeColor: "#F33", strokeColor: "#F33",
strokeOpacity: 1, strokeOpacity: 1,
strokeWeight: 3, strokeWeight: 3,
fillColor: "ee2200", fillColor: "ee2200",
fillOpacity: 0.35 fillOpacity: 0.35,
}); });
mapObj.plugin(["AMap.CircleEditor"],()=>{ mapObj.plugin(["AMap.CircleEditor"], () => {
this.circleEditor = new AMap.CircleEditor(mapObj, this.circle); this.circleEditor = new AMap.CircleEditor(mapObj, this.circle);
AMap.event.addListener(this.circleEditor, 'adjust', (e)=>{ AMap.event.addListener(this.circleEditor, "adjust", (e) => {
this.form.radius = e.radius/1000; this.form.radius = e.radius / 1000;
this.$refs.fenceMapForm.validateField('radius'); this.$refs.fenceMapForm.validateField("radius");
}); });
AMap.event.addListener(this.circleEditor, 'move', (e)=>{ AMap.event.addListener(this.circleEditor, "move", (e) => {
this.form.lng = e.lnglat.lng; this.form.lng = e.lnglat.lng;
this.form.lat = e.lnglat.lat; this.form.lat = e.lnglat.lat;
this.transfer() this.transfer();
}); });
this.circleEditor.open(); this.circleEditor.open();
}); });
mapService.setFitView() mapService.setFitView();
mapObj.setZoom(14); mapObj.setZoom(14);
}, },
updateFence(){ updateFence() {
this.$refs.fenceMapForm.validateField('radius', (error)=>{ this.$refs.fenceMapForm.validateField("radius", (error) => {
if(!error){ if (!error) {
this.circle.setRadius(this.form.radius*1000); this.circle.setRadius(this.form.radius * 1000);
if(!this.transferError){ if (!this.transferError) {
if (this.form.transferAddr) {
if(this.form.transferAddr){
let center = mapService.getLngLat(this.form.lng, this.form.lat); let center = mapService.getLngLat(this.form.lng, this.form.lat);
console.log(center) console.log(center);
this.circle.setCenter(center); this.circle.setCenter(center);
}else{ } else {
const circleCenter = this.mapObj.getCenter(); const circleCenter = this.mapObj.getCenter();
this.circle.setCenter(circleCenter); this.circle.setCenter(circleCenter);
this.form.lng = circleCenter.lng; this.form.lng = circleCenter.lng;
this.form.lat = circleCenter.lat; this.form.lat = circleCenter.lat;
this.transfer() this.transfer();
} }
mapService.setFitView();
mapService.setFitView()
this.mapObj.setZoom(14); this.mapObj.setZoom(14);
} }
} }
}); });
}, },
search(){ search() {
this.auto && AMap.event.trigger(this.auto, "select");
this.auto&&AMap.event.trigger(this.auto, 'select')
}, },
validateLngLat(){ validateLngLat() {
let pass = true; let pass = true;
this.$refs.fenceMapForm.validateField('lng', (error)=>{ this.$refs.fenceMapForm.validateField("lng", (error) => {
if(error){ if (error) {
pass = false; pass = false;
} }
}); });
this.$refs.fenceMapForm.validateField('lat', (error)=>{ this.$refs.fenceMapForm.validateField("lat", (error) => {
if(error){ if (error) {
pass = false; pass = false;
} }
}); });
return pass; return pass;
}, },
transfer(){ transfer() {
if(this.form.lng && this.form.lat && this.validateLngLat()){ if (this.form.lng && this.form.lat && this.validateLngLat()) {
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId); this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(()=>{ this.transferTimeoutId = window.setTimeout(() => {
const flag = new Date(); const flag = new Date();
this.transferFlag = flag; this.transferFlag = flag;
if(!this.geocoder){ if (!this.geocoder) {
mapService.getGeocoder().then((gc)=>{ mapService.getGeocoder().then((gc) => {
this.geocoder = gc; this.geocoder = gc;
this.getAddress(flag); this.getAddress(flag);
}); });
}else{ } else {
this.getAddress(flag); this.getAddress(flag);
} }
}, 500) }, 500);
} }
}, },
getAddress(flag){ getAddress(flag) {
const lnglatXY = [this.form.lng, this.form.lat]; const lnglatXY = [this.form.lng, this.form.lat];
this.transferAddr = ''; this.transferAddr = "";
this.geocoder.getAddress(lnglatXY, (status, result)=>{ this.geocoder.getAddress(lnglatXY, (status, result) => {
if(flag == this.transferFlag){ if (flag == this.transferFlag) {
if (status === 'complete' && result.info === 'OK') {//获取地址成功 if (status === "complete" && result.info === "OK") {
//获取地址成功
this.form.transferAddr = result.regeocode.formattedAddress; this.form.transferAddr = result.regeocode.formattedAddress;
this.transferError = false; this.transferError = false;
this.$refs.fenceMapForm.validateField('transferAddr'); this.$refs.fenceMapForm.validateField("transferAddr");
}else{ } else {
this.form.transferAddr = ''; this.form.transferAddr = "";
this.transferError = true; this.transferError = true;
this.$refs.fenceMapForm.validateField('transferAddr'); this.$refs.fenceMapForm.validateField("transferAddr");
} }
} }
}); });
}, },
refreshMap(){ refreshMap() {},
}
}, },
components:{ components: {
MapControll 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
...@@ -4,17 +4,24 @@ ...@@ -4,17 +4,24 @@
<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
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 <el-date-picker
style="width: 100%;" style="width: 100%"
v-model="form.dateRange" v-model="form.dateRange"
type="daterange" type="daterange"
size="small" size="small"
...@@ -24,7 +31,8 @@ ...@@ -24,7 +31,8 @@
: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>
...@@ -33,7 +41,12 @@ ...@@ -33,7 +41,12 @@
</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
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>
<el-option label="夜晚(21:00~06:00)" value="3"></el-option> <el-option label="夜晚(21:00~06:00)" value="3"></el-option>
...@@ -44,37 +57,73 @@ ...@@ -44,37 +57,73 @@
<el-row class="stay-ctrl pull-left"> <el-row class="stay-ctrl pull-left">
<el-col :span="8"> <el-col :span="8">
<el-form-item prop="stayMin"> <el-form-item prop="stayMin">
<el-input v-model.trim="form.stayMin" placeholder="最小值"></el-input> <el-input
v-model.trim="form.stayMin"
placeholder="最小值"
></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="2" class="text-center">~</el-col> <el-col :span="2" class="text-center">~</el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item prop="stayMax"> <el-form-item prop="stayMax">
<el-input v-model.trim="form.stayMax" placeholder="最大值"></el-input> <el-input
v-model.trim="form.stayMax"
placeholder="最大值"
></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<span class="unit">分钟</span> <span class="unit">分钟</span>
</el-row> </el-row>
</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
type="primary"
@click="searchSubmit"
size="small"
:loading="isSearching"
>查询</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
</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">导出Excel</el-button> class="pull-left"
<span>停留点({{resultList.length}})</span> 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>
<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, index) in resultList" :key="index" @click="openMapInfoWindow(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, 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>
<li v-show="!resultList.length"> <li v-show="!resultList.length">
<p class="text-center">无数据</p> <p class="text-center">无数据</p>
...@@ -91,77 +140,88 @@ ...@@ -91,77 +140,88 @@
</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)){ if (!moment.isMoment(min)) {
min = moment(min) min = moment(min);
} }
if(!moment.isMoment(max)){ if (!moment.isMoment(max)) {
max = moment(max) max = moment(max);
} }
if(min.isBefore(moment(Object.assign({},max)).subtract(29, 'days'), 'day')){ if (
cb(new Error('日期范围不能超过30天')) min.isBefore(
moment(Object.assign({}, max)).subtract(29, "days"),
"day"
)
) {
cb(new Error("日期范围不能超过30天"));
} }
} }
cb() cb();
} };
let checkStay = (rule, vaule, cb)=>{ let checkStay = (rule, vaule, cb) => {
const stayMin = this.form.stayMin; const stayMin = this.form.stayMin;
const stayMax = this.form.stayMax; const stayMax = this.form.stayMax;
if((stayMin && !/^(\d{1,4}|10000)$/.test(stayMin)) || (stayMax && !/^(\d{1,4}|10000)$/.test(stayMax))){ if (
cb(new Error('只能输入0~10000的正整数')) (stayMin && !/^(\d{1,4}|10000)$/.test(stayMin)) ||
}else if(stayMin!='' && stayMax!='' && parseInt(stayMin)>parseInt(stayMax)){ (stayMax && !/^(\d{1,4}|10000)$/.test(stayMax))
cb(new Error('最小值不可大于最大值')) ) {
} cb(new Error("只能输入0~10000的正整数"));
cb() } else if (
stayMin != "" &&
stayMax != "" &&
parseInt(stayMin) > parseInt(stayMax)
) {
cb(new Error("最小值不可大于最大值"));
} }
cb();
};
return { return {
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: [moment().subtract(7, 'days'),moment().subtract(1, 'days')], dateRange: [moment().subtract(7, "days"), moment().subtract(1, "days")],
timerange: '1', timerange: "1",
stayMin: '', stayMin: "",
stayMax: '' stayMax: "",
}, },
rules: { rules: {
dateRange: [{validator: checkDaterange}], dateRange: [{ validator: checkDaterange }],
stay: [{validator: checkStay}] stay: [{ validator: checkStay }],
}, },
needInfinite: true, needInfinite: true,
params: {}, params: {},
...@@ -175,104 +235,111 @@ ...@@ -175,104 +235,111 @@
standno: this.$route.query.standno, standno: this.$route.query.standno,
sortByTimeIsPositive: true, sortByTimeIsPositive: true,
sortByStayIsPositive: true, sortByStayIsPositive: true,
sortType: '', sortType: "",
pickerOptions: { pickerOptions: {
disabledDate(time){ disabledDate(time) {
return time.getTime() > ((new Date()).getTime()-24*60*60*1000) return time.getTime() > new Date().getTime() - 24 * 60 * 60 * 1000;
}, },
shortcuts: historyShortcuts shortcuts: historyShortcuts,
} },
} };
}, },
mounted(){ mounted() {
// store.dispatch('setFullsize', true) // store.dispatch('setFullsize', true)
let _this = this let _this = this;
AMapLoader.load({ _this.$mapInit({version:'1.4.2'}).then(AMap => {
key: CONSTANT.MAP_KEY, window.AMap = AMap;
version: '1.4.2', _this.initMap();
plugins: CONSTANT.MAP_PLUGINS
}).then((AMap) => {
window.AMap = AMap
_this.initMap()
}) })
}, },
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 (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap; window.AMap = AMap;
this.mapObj = mapService.init('map'); this.mapObj = mapService.init("map");
//this.bindEvent(); //this.bindEvent();
this.isInitMap = true; this.isInitMap = true;
// this.drawPoi() // this.drawPoi()
}else{ } else {
this.checkMapLoaded = check() this.checkMapLoaded = check();
}
}, 100)
} }
}, 100);
};
this.checkMapLoaded = check(); this.checkMapLoaded = check();
}, },
pickDate(beforeDays){ pickDate(beforeDays) {
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')] this.form.dateRange = [
moment().subtract(beforeDays, "days"),
moment().subtract(1, "days"),
];
}, },
searchSubmit(){ searchSubmit() {
this.$refs.form.validate((valid, field)=>{ this.$refs.form.validate((valid, field) => {
if(valid){ if (valid) {
this.isSearching = true; this.isSearching = true;
let params = { let params = {
sn: this.sn, sn: this.sn,
startTime: moment(this.form.dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss'), startTime: moment(this.form.dateRange[0])
endTime: moment(this.form.dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss'), .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, times: this.form.timerange,
} };
if(this.form.stayMax !== ''){ if (this.form.stayMax !== "") {
params.maxTime = this.form.stayMax; params.maxTime = this.form.stayMax;
} }
if(this.form.stayMin !== ''){ if (this.form.stayMin !== "") {
params.minTime = this.form.stayMin; params.minTime = this.form.stayMin;
} }
this.params = params this.params = params;
this.getSortParams() this.getSortParams();
EventBus.$emit('uiMap.historyLocation.destroy'); EventBus.$emit("uiMap.historyLocation.destroy");
GET_HISTORY_LOCATION({...this.params}).then((res)=>{ GET_HISTORY_LOCATION({ ...this.params }).then((res) => {
if(res.code == 200){ if (res.code == 200) {
const data = res.data; const data = res.data;
if(data.length){ if (data.length) {
data.forEach((item, idx)=>{ data.forEach((item, idx) => {
item.idx = idx; item.idx = idx;
item.name = item.ownerName || '--' item.name = item.ownerName || "--";
item.sn = item.sn || '--' item.sn = item.sn || "--";
item.vin = item.vin || '--' item.vin = item.vin || "--";
item.begintime = item.beginTime item.begintime = item.beginTime;
item.endtime = item.endTime item.endtime = item.endTime;
item.transferAddress = item.address || '--' // 取后端返回address item.transferAddress = item.address || "--"; // 取后端返回address
}); });
this.resultList = data; this.resultList = data;
EventBus.$emit('uiMap.historyLocation.draw', data); EventBus.$emit("uiMap.historyLocation.draw", data);
this.resultBoxHidden = false; this.resultBoxHidden = false;
}else{ } else {
this.$message({ this.$message({
type: 'info', type: "info",
message: '暂无数据' message: "暂无数据",
}); });
} }
this.isSearching = false; this.isSearching = false;
} }
}); });
}else{ } else {
return false; return false;
} }
}); });
}, },
infiniteHandler($state){ infiniteHandler($state) {
if(this.currentPage> this.maxPage){ if (this.currentPage > this.maxPage) {
$state.complete(); $state.complete();
return; return;
} }
...@@ -281,62 +348,72 @@ ...@@ -281,62 +348,72 @@
this.params.pageSize = this.pageSize; this.params.pageSize = this.pageSize;
this.params.status = 1; this.params.status = 1;
this.currentPage++; this.currentPage++;
$state.loaded(); $state.loaded();
setTimeout(()=>{ setTimeout(() => {
this.resultList = this.resultList.concat([{ this.resultList = this.resultList.concat([
addr: '甘肃省酒泉市肃州区海马福仕达中瑞汽车', {
date: '2018-11-20 15:19:21', addr: "甘肃省酒泉市肃州区海马福仕达中瑞汽车",
restTime: '25小时26分钟25秒' date: "2018-11-20 15:19:21",
}]) restTime: "25小时26分钟25秒",
},10000) },
]);
}, 10000);
return; return;
DEVICE_SERVICE.getDeviceList(this.params).then((res)=>{ DEVICE_SERVICE.getDeviceList(this.params).then((res) => {
const data = res.data; const data = res.data;
if(data && data.length){ if (data && data.length) {
const arr = [] const arr = [];
data.forEach((item) => { data.forEach((item) => {
arr.push({ arr.push({
label: item.name, label: item.name,
value: item.id value: item.id,
}) });
}) });
if(this.options[0] && 'label' in this.options[0]){ if (this.options[0] && "label" in this.options[0]) {
this.options = this.options.concat(arr); this.options = this.options.concat(arr);
}else{ } else {
this.options = arr this.options = arr;
} }
this.total = res.recordsTotal; this.total = res.recordsTotal;
this.maxPage = Math.ceil(this.total/this.pageSize); this.maxPage = Math.ceil(this.total / this.pageSize);
this.currentPage++; this.currentPage++;
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded'); this.$refs.infiniteLoading.$emit("$InfiniteLoading:loaded");
}else{ } else {
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete'); this.$refs.infiniteLoading.$emit("$InfiniteLoading:complete");
this.options = [] this.options = [];
} }
}) });
}, },
sortByTime(){ sortByTime() {
// let sortArr = this.resultList.sort((a,b)=>{ // let sortArr = this.resultList.sort((a,b)=>{
// return moment(a.begintime).isBefore(moment(b.begintime))?(this.sortByTimeIsPositive?-1:1):(this.sortByTimeIsPositive?1:-1); // return moment(a.begintime).isBefore(moment(b.begintime))?(this.sortByTimeIsPositive?-1:1):(this.sortByTimeIsPositive?1:-1);
// }); // });
this.sortByTimeIsPositive = !this.sortByTimeIsPositive; this.sortByTimeIsPositive = !this.sortByTimeIsPositive;
// this.resultList = [].concat(sortArr); // this.resultList = [].concat(sortArr);
this.sortType = 'beginTime' this.sortType = "beginTime";
this.getSortParams() this.getSortParams();
this.searchSubmit() this.searchSubmit();
}, },
getSortParams() { getSortParams() {
this.params.sort = this.sortType ? { this.params.sort = this.sortType
? {
filed: this.sortType, filed: this.sortType,
order: this.sortType === 'beginTime' ? (this.sortByTimeIsPositive ? 'ASC' : 'DESC') : (this.sortByStayIsPositive ? 'ASC' : 'DESC') order:
} : undefined this.sortType === "beginTime"
return this.params ? this.sortByTimeIsPositive
? "ASC"
: "DESC"
: this.sortByStayIsPositive
? "ASC"
: "DESC",
}
: undefined;
return this.params;
}, },
sortByStay(){ sortByStay() {
// let sortArr = this.resultList.sort((a,b)=>{ // let sortArr = this.resultList.sort((a,b)=>{
// let aTime = (new Date(a.endtime)).getTime() - (new Date(a.begintime)).getTime(); // let aTime = (new Date(a.endtime)).getTime() - (new Date(a.begintime)).getTime();
// let bTime = (new Date(b.endtime)).getTime() - (new Date(b.begintime)).getTime(); // let bTime = (new Date(b.endtime)).getTime() - (new Date(b.begintime)).getTime();
...@@ -344,11 +421,11 @@ ...@@ -344,11 +421,11 @@
// }); // });
this.sortByStayIsPositive = !this.sortByStayIsPositive; this.sortByStayIsPositive = !this.sortByStayIsPositive;
// this.resultList = [].concat(sortArr); // this.resultList = [].concat(sortArr);
this.sortType = 'duration' this.sortType = "duration";
this.getSortParams() this.getSortParams();
this.searchSubmit() this.searchSubmit();
}, },
exportExcel(){ exportExcel() {
// let arr = []; // let arr = [];
// this.resultList.forEach((item)=>{ // this.resultList.forEach((item)=>{
// item.address = item.transferAddress; // item.address = item.transferAddress;
...@@ -364,61 +441,58 @@ ...@@ -364,61 +441,58 @@
// filed: this.sortType, // filed: this.sortType,
// order: this.sortType === 'beginTime' ? (this.sortByTimeIsPositive ? 'ASC' : 'DESC') : (this.sortByStayIsPositive ? 'ASC' : 'DESC') // order: this.sortType === 'beginTime' ? (this.sortByTimeIsPositive ? 'ASC' : 'DESC') : (this.sortByStayIsPositive ? 'ASC' : 'DESC')
// } : undefined // } : undefined
this.getSortParams() this.getSortParams();
if (this.resultList.length) { if (this.resultList.length) {
exportExcel('/trialdrive/monitor/exportStayPoint', {...this.params}, 'post', '', true); exportExcel(
"/trialdrive/monitor/exportStayPoint",
{ ...this.params },
"post",
"",
true
);
} else { } else {
this.$message({ this.$message({
type: 'error', type: "error",
message: '导出数据为空' message: "导出数据为空",
}); });
} }
}, },
openMapInfoWindow(idx){ openMapInfoWindow(idx) {
EventBus.$emit('uiMap.historyLocation.openInfoWindow', idx) EventBus.$emit("uiMap.historyLocation.openInfoWindow", idx);
}, },
drawPoi(){ drawPoi() {
BUSINESS_SERVICE.getPOI({ BUSINESS_SERVICE.getPOI({
sn: this.sn sn: this.sn,
}).then((res)=>{ }).then((res) => {
if(res.returnCode === '0'){ if (res.returnCode === "0") {
if(res.data && res.data.length){ if (res.data && res.data.length) {
res.data.forEach((item)=>{ res.data.forEach((item) => {
let marker = mapService.createPOIMarker(mapService.getLngLat(item.lng, item.lat), this.mapObj) let marker = mapService.createPOIMarker(
let infoWindow = mapService.bindPOIInfoWindow(marker, this.mapObj, item) mapService.getLngLat(item.lng, item.lat),
}) this.mapObj
);
let infoWindow = mapService.bindPOIInfoWindow(
marker,
this.mapObj,
item
);
});
} }
} }
}) });
}
}, },
async created () { },
// if(window.AMap){ async created() {
// this.initMap(); EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
// }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); this.resultList = [].concat(data);
}); });
},
beforeDestroy(){
}, },
beforeDestroy() {},
components: { components: {
MapControll 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) => {
......
...@@ -4,16 +4,28 @@ ...@@ -4,16 +4,28 @@
<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
ref="form"
:model="form"
:rules="rules"
:inline="false"
size="mini"
class="form"
>
<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-select
v-model="form.daterange"
placeholder="请选择"
size="small"
style="width: 280px"
>
<el-option label="前一个月" value="1"></el-option> <el-option label="前一个月" value="1"></el-option>
<el-option label="前三个月" value="2"></el-option> <el-option label="前三个月" value="2"></el-option>
<el-option label="前六个月" value="3"></el-option> <el-option label="前六个月" value="3"></el-option>
...@@ -30,21 +42,47 @@ ...@@ -30,21 +42,47 @@
</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
type="primary"
@click="searchSubmit"
size="small"
:loading="isSearching"
>查询</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
</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">导出Excel</el-button> class="pull-left"
<span>常驻地({{resultList.length}})</span> 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>
<ul class="stay-list"> <ul class="stay-list">
<li class="stay-list-item" v-for="(item, index) in resultList" :key="index" @click="openMapInfoWindow(item.idx)"> <li
<p class="addr">{{item.transferAddress}}</p> class="stay-list-item"
<p class="datetime">驻留次数:<span>{{item.totalTimes}}次</span> | 驻留时长:<span>{{item.totalDurationString}}</span></p> 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>
<li v-show="!resultList.length"> <li v-show="!resultList.length">
<p class="text-center">无数据</p> <p class="text-center">无数据</p>
...@@ -61,23 +99,22 @@ ...@@ -61,23 +99,22 @@
</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,
...@@ -87,13 +124,13 @@ ...@@ -87,13 +124,13 @@
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: {},
...@@ -102,89 +139,96 @@ ...@@ -102,89 +139,96 @@
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;
AMapLoader.load({ _this.$mapInit({ version: "1.4.2" }).then((AMap) => {
key: CONSTANT.MAP_KEY, window.AMap = AMap;
version: '1.4.2', _this.initMap();
plugins: CONSTANT.MAP_PLUGINS });
}).then((AMap) => {
window.AMap = AMap
_this.initMap()
})
}, },
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 (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap; window.AMap = AMap;
this.mapObj = mapService.init('map'); this.mapObj = mapService.init("map");
//this.bindEvent(); //this.bindEvent();
this.isInitMap = true; this.isInitMap = true;
// this.drawPoi() // this.drawPoi()
}else{ } else {
this.checkMapLoaded = check() this.checkMapLoaded = check();
}
}, 100)
} }
}, 100);
};
this.checkMapLoaded = check(); this.checkMapLoaded = check();
}, },
pickDate(beforeDays){ pickDate(beforeDays) {
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')] this.form.dateRange = [
moment().subtract(beforeDays, "days"),
moment().subtract(1, "days"),
];
}, },
searchSubmit(){ searchSubmit() {
this.$refs.form.validate((valid, field)=>{ this.$refs.form.validate((valid, field) => {
if(valid){ if (valid) {
this.isSearching = true; this.isSearching = true;
let params = { let params = {
sn: this.sn, sn: this.sn,
timeRange: this.form.daterange, timeRange: this.form.daterange,
locationType: this.locationType === 'bsLocation' ? 2 : this.locationType === 'gpsLocation' ? 1 : '', locationType:
this.locationType === "bsLocation"
? 2
: this.locationType === "gpsLocation"
? 1
: "",
// times: this.form.timerange, // times: this.form.timerange,
times: 4 // 无时间段选项 默认传全天(4) times: 4, // 无时间段选项 默认传全天(4)
} };
this.params = params this.params = params;
GET_RESIDENT_LOCATION(params).then((res)=>{ GET_RESIDENT_LOCATION(params).then((res) => {
if(res.code == 200){ if (res.code == 200) {
const data = res.data; const data = res.data;
if(data.length){ if (data.length) {
data.forEach((item, idx)=>{ data.forEach((item, idx) => {
item.idx = idx; item.idx = idx;
item.name = item.ownerName || '--' item.name = item.ownerName || "--";
item.sn = item.sn || '--' item.sn = item.sn || "--";
item.vin = item.vin || '--' item.vin = item.vin || "--";
item.transferAddress = item.address || '--' // 取后端返回address item.transferAddress = item.address || "--"; // 取后端返回address
}); });
this.resultList = data; this.resultList = data;
EventBus.$emit('uiMap.resident.draw', data); EventBus.$emit("uiMap.resident.draw", data);
this.resultBoxHidden = false; this.resultBoxHidden = false;
}else{ } else {
this.$message({ this.$message({
type: 'info', type: "info",
message: '暂无数据' message: "暂无数据",
}); });
EventBus.$emit('uiMap.resident.destroy', data); EventBus.$emit("uiMap.resident.destroy", data);
} }
this.isSearching = false; this.isSearching = false;
} }
}); });
}else{ } else {
return false; return false;
} }
}); });
}, },
infiniteHandler($state){ infiniteHandler($state) {
if(this.currentPage> this.maxPage){ if (this.currentPage > this.maxPage) {
$state.complete(); $state.complete();
return; return;
} }
...@@ -193,47 +237,48 @@ ...@@ -193,47 +237,48 @@
this.params.pageSize = this.pageSize; this.params.pageSize = this.pageSize;
this.params.status = 1; this.params.status = 1;
this.currentPage++; this.currentPage++;
$state.loaded(); $state.loaded();
setTimeout(()=>{ setTimeout(() => {
this.resultList = this.resultList.concat([{ this.resultList = this.resultList.concat([
addr: '甘肃省酒泉市肃州区海马福仕达中瑞汽车', {
date: '2018-11-20 15:19:21', addr: "甘肃省酒泉市肃州区海马福仕达中瑞汽车",
restTime: '25小时26分钟25秒' date: "2018-11-20 15:19:21",
}]) restTime: "25小时26分钟25秒",
},10000) },
]);
}, 10000);
return; return;
DEVICE_SERVICE.getDeviceList(this.params).then((res)=>{ DEVICE_SERVICE.getDeviceList(this.params).then((res) => {
const data = res.data; const data = res.data;
if(data && data.length){ if (data && data.length) {
const arr = [] const arr = [];
data.forEach((item) => { data.forEach((item) => {
arr.push({ arr.push({
label: item.name, label: item.name,
value: item.id value: item.id,
}) });
}) });
if(this.options[0] && 'label' in this.options[0]){ if (this.options[0] && "label" in this.options[0]) {
this.options = this.options.concat(arr); this.options = this.options.concat(arr);
}else{ } else {
this.options = arr this.options = arr;
} }
this.total = res.recordsTotal; this.total = res.recordsTotal;
this.maxPage = Math.ceil(this.total/this.pageSize); this.maxPage = Math.ceil(this.total / this.pageSize);
this.currentPage++; this.currentPage++;
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded'); this.$refs.infiniteLoading.$emit("$InfiniteLoading:loaded");
}else{ } else {
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete'); this.$refs.infiniteLoading.$emit("$InfiniteLoading:complete");
this.options = [] this.options = [];
} }
}) });
}, },
exportExcel(){ exportExcel() {
if(this.exporting) return; if (this.exporting) return;
if(this.resultList.length){ if (this.resultList.length) {
// let paramArr = []; // let paramArr = [];
// this.resultList.forEach((dataItem)=>{ // this.resultList.forEach((dataItem)=>{
// let paramItem = {}; // let paramItem = {};
...@@ -263,59 +308,58 @@ ...@@ -263,59 +308,58 @@
// jsonStr: encodeURI(JSON.stringify(paramArr)), // jsonStr: encodeURI(JSON.stringify(paramArr)),
// vmExportType: 4 // vmExportType: 4
// }, 'post'); // }, 'post');
exportExcel('/trialdrive/monitor/exportResident', {...this.params}, 'get', '', true); exportExcel(
"/trialdrive/monitor/exportResident",
{ ...this.params },
"get",
"",
true
);
this.exporting = false; this.exporting = false;
}else{ } else {
this.$message({ this.$message({
type: 'error', type: "error",
message: '导出数据为空' message: "导出数据为空",
}); });
} }
}, },
openMapInfoWindow(idx){ openMapInfoWindow(idx) {
EventBus.$emit('uiMap.resident.openInfoWindow', idx) EventBus.$emit("uiMap.resident.openInfoWindow", idx);
}, },
drawPoi(){ drawPoi() {
BUSINESS_SERVICE.getPOI({ BUSINESS_SERVICE.getPOI({
sn: this.sn sn: this.sn,
}).then((res)=>{ }).then((res) => {
if(res.returnCode === '0'){ if (res.returnCode === "0") {
if(res.data && res.data.length){ if (res.data && res.data.length) {
res.data.forEach((item)=>{ res.data.forEach((item) => {
let marker = mapService.createPOIMarker(mapService.getLngLat(item.lng, item.lat), this.mapObj) let marker = mapService.createPOIMarker(
let infoWindow = mapService.bindPOIInfoWindow(marker, this.mapObj, item) mapService.getLngLat(item.lng, item.lat),
}) this.mapObj
} );
let infoWindow = mapService.bindPOIInfoWindow(
marker,
this.mapObj,
item
);
});
} }
})
} }
});
}, },
async created () { },
// if(window.AMap){ async created() {
// 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)=>{ EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
this.resultList = [].concat(data); this.resultList = [].concat(data);
}); });
}, },
beforeDestroy(){ beforeDestroy() {},
},
components: { components: {
MapControll 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,23 +253,11 @@ export default { ...@@ -254,23 +253,11 @@ export default {
"AMap.LabelsLayer", "AMap.LabelsLayer",
"AMap.LabelMarker", "AMap.LabelMarker",
]); ]);
if (window.AMap) {
window.AMap = null; _this.$mapInit({ plugins: plugins }).then((AMap) => {
}
AMapLoader.reset();
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: plugins, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then((AMap) => {
_this.mapLoading = false; _this.mapLoading = false;
window.AMap = AMap; window.AMap = AMap;
_this.map = mapService.init("map"); _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,20 +237,12 @@ export default { ...@@ -238,20 +237,12 @@ 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;
}
AMapLoader.reset();
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: plugins, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then((AMap) => {
_this.mapLoading = false; _this.mapLoading = false;
window.AMap = AMap; window.AMap = AMap;
_this.map = mapService.init("map", { zoom: 11 }); _this.map = mapService.init("map", { zoom: 11, showLabel: false });
_this.mouseTool = new AMap.MouseTool(_this.map); _this.mouseTool = new AMap.MouseTool(_this.map);
var autoComplete = new AMap.AutoComplete({ var autoComplete = new AMap.AutoComplete({
input: "tipInput", input: "tipInput",
...@@ -269,10 +260,9 @@ export default { ...@@ -269,10 +260,9 @@ export default {
if (_query.type == "full" && _query.leftLngLat) { if (_query.type == "full" && _query.leftLngLat) {
this.initPage(_query); this.initPage(_query);
} }
})
.catch((error) => { // 给地图添加文字图层
console.log(error); _this.map.add([new AMap.TileLayer()]);
window.location.reload();
}); });
}, },
......
...@@ -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){
console.log(status);
console.log(result);
if(status == 'complete'){
self.currentMarker && self.map.remove(self.currentMarker); self.currentMarker && self.map.remove(self.currentMarker);
AMap.event.addListener(self.geolocation, 'complete', function (e) {//返回定位信息 var lnglatXY = self.getLngLat(result.position.lng, result.position.lat);
var lnglatXY = self.getLngLat(e.position.lng, e.position.lat);
self.currentMarker = self.createMarker(lnglatXY); self.currentMarker = self.createMarker(lnglatXY);
//self.map.setCenter(lnglatXY);
self.setFitView() 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!