Commit 2b355927 by 张杰

Merge branch 'v1.23.0' into 'develop'

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

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