Commit 47d8ab18 by 前端

Merge branch 'change-map' into 'master'

上线合并

See merge request !49
2 parents 2df36f38 94b2ffb8
...@@ -2329,9 +2329,9 @@ ...@@ -2329,9 +2329,9 @@
"dev": true "dev": true
}, },
"clipboard": { "clipboard": {
"version": "2.0.4", "version": "2.0.11",
"resolved": "http://registry.npm.taobao.org/clipboard/download/clipboard-2.0.4.tgz", "resolved": "https://registry.npmmirror.com/clipboard/-/clipboard-2.0.11.tgz",
"integrity": "sha1-g22v1mzw/qXXHOXVsL9ulYAJES0=", "integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==",
"requires": { "requires": {
"good-listener": "^1.2.2", "good-listener": "^1.2.2",
"select": "^1.1.2", "select": "^1.1.2",
...@@ -3279,8 +3279,8 @@ ...@@ -3279,8 +3279,8 @@
}, },
"delegate": { "delegate": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "http://registry.npm.taobao.org/delegate/download/delegate-3.2.0.tgz", "resolved": "https://registry.npmmirror.com/delegate/-/delegate-3.2.0.tgz",
"integrity": "sha1-tmtxwxWFIuirV0T3INjKDCr1kWY=" "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
}, },
"delegates": { "delegates": {
"version": "1.0.0", "version": "1.0.0",
...@@ -5800,8 +5800,8 @@ ...@@ -5800,8 +5800,8 @@
}, },
"good-listener": { "good-listener": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "http://registry.npm.taobao.org/good-listener/download/good-listener-1.2.2.tgz", "resolved": "https://registry.npmmirror.com/good-listener/-/good-listener-1.2.2.tgz",
"integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", "integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==",
"requires": { "requires": {
"delegate": "^3.1.2" "delegate": "^3.1.2"
} }
...@@ -11687,8 +11687,8 @@ ...@@ -11687,8 +11687,8 @@
}, },
"select": { "select": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "http://registry.npm.taobao.org/select/download/select-1.1.2.tgz", "resolved": "https://registry.npmmirror.com/select/-/select-1.1.2.tgz",
"integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=" "integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA=="
}, },
"select-hose": { "select-hose": {
"version": "2.0.0", "version": "2.0.0",
...@@ -12918,8 +12918,8 @@ ...@@ -12918,8 +12918,8 @@
}, },
"tiny-emitter": { "tiny-emitter": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "http://registry.npm.taobao.org/tiny-emitter/download/tiny-emitter-2.1.0.tgz", "resolved": "https://registry.npmmirror.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
"integrity": "sha1-HRpW7fxRxD6GPLtTgqcjMONVVCM=" "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
}, },
"tmp": { "tmp": {
"version": "0.0.33", "version": "0.0.33",
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"calendar-months": "^1.0.1", "calendar-months": "^1.0.1",
"caniuse-lite": "^1.0.30001292", "caniuse-lite": "^1.0.30001292",
"chart.js": "^2.7.2", "chart.js": "^2.7.2",
"clipboard": "^2.0.4", "clipboard": "^2.0.11",
"dayjs": "^1.11.11", "dayjs": "^1.11.11",
"downloadjs": "^1.4.7", "downloadjs": "^1.4.7",
"echarts": "^5.5.0", "echarts": "^5.5.0",
......
...@@ -10,8 +10,8 @@ function request (data = {} , url, method = 'GET') { ...@@ -10,8 +10,8 @@ function request (data = {} , url, method = 'GET') {
url: url, url: url,
data: data, data: data,
success(data) { success(data) {
console.log(data) // console.log(data)
console.log('结束请求:',new Date().getTime()) // console.log('结束请求:',new Date().getTime())
resolve(data) resolve(data)
}, },
error(error) { error(error) {
......
...@@ -389,6 +389,7 @@ ...@@ -389,6 +389,7 @@
.map-infowindow-ct { .map-infowindow-ct {
&>p { &>p {
display: flex; display: flex;
min-width: 300px;
} }
// .lb {} // .lb {}
...@@ -396,7 +397,6 @@ ...@@ -396,7 +397,6 @@
.des { .des {
flex: 1; flex: 1;
word-break: break-all; word-break: break-all;
max-width: 160px;
} }
.icon { .icon {
...@@ -459,7 +459,7 @@ ...@@ -459,7 +459,7 @@
color: rgba(0, 153, 68, 0.8); color: rgba(0, 153, 68, 0.8);
margin: 2px; margin: 2px;
cursor: pointer; cursor: pointer;
white-space: nowrap;
&:hover { &:hover {
color: rgba(0, 153, 68, 1); color: rgba(0, 153, 68, 1);
border-color: rgba(0, 153, 68, 1); border-color: rgba(0, 153, 68, 1);
...@@ -569,10 +569,41 @@ ...@@ -569,10 +569,41 @@
cursor: pointer; cursor: pointer;
} }
.map-infowindow-title { .map-infowindow-title-other{
position: relative; position: relative;
padding-right: 30px; padding-right: 30px;
white-space: nowrap;
.question_icon {
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;
pointer-events: none;
p {
margin: 0;
}
}
}
.map-infowindow-title {
position: relative;
padding-right: 30px;
white-space: nowrap;
width:300px;
.question_icon { .question_icon {
display: inline-block; display: inline-block;
background: url('https://img01.glsx.com.cn/weapp/resource/e-shield/circle-question.png') no-repeat; background: url('https://img01.glsx.com.cn/weapp/resource/e-shield/circle-question.png') no-repeat;
...@@ -650,4 +681,7 @@ ...@@ -650,4 +681,7 @@
.resident_btn_hidden { .resident_btn_hidden {
display: none; display: none;
}
.BMap_bubble_top{
height: 7px !important;
} }
\ No newline at end of file \ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</template> </template>
<script> <script>
import '../../assets/spritesmith-generated/sprite.css' import '../../assets/spritesmith-generated/sprite.css'
import mapService from 'utils/mapService.js' import mapService from 'utils/mapBService.js'
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from 'vuex'
export default{ export default{
......
<!--
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-09 22:18:27
* @FilePath: \oEshield\src\pages\monitor\MapControll.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template> <template>
<div> <div>
<div :class="isTreeToright ? 'map-controll toleft' : 'map-controll'"> <div :class="isTreeToright ? 'map-controll toleft' : 'map-controll'">
...@@ -19,7 +27,7 @@ ...@@ -19,7 +27,7 @@
</template> </template>
<script> <script>
import store from '../../vuex/store.js' import store from '../../vuex/store.js'
import mapService from 'utils/mapService.js' import mapService from 'utils/mapBService.js'
export default{ export default{
props: ['isShowFullsize', 'isTreeToright'], props: ['isShowFullsize', 'isTreeToright'],
data(){ data(){
...@@ -43,7 +51,7 @@ ...@@ -43,7 +51,7 @@
}, },
toggleMap(ifSetTypeIsMap){ toggleMap(ifSetTypeIsMap){
if(ifSetTypeIsMap != this.isMapType){ if(ifSetTypeIsMap != this.isMapType){
mapService.toggleMapType(); mapService.toggleMapType(ifSetTypeIsMap);
this.isMapType = !this.isMapType; this.isMapType = !this.isMapType;
} }
}, },
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
</v-full-layout> </v-full-layout>
</template> </template>
<script> <script>
import mapService from "@/utils/mapService.js"; // import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js"; import "@/utils/mapEvent.js";
import EventBus from "@/event-bus"; import EventBus from "@/event-bus";
import remoteLoad from "@/utils/remoteLoad.js"; import remoteLoad from "@/utils/remoteLoad.js";
...@@ -59,57 +60,41 @@ export default { ...@@ -59,57 +60,41 @@ export default {
}; };
}, },
created() { created() {
console.log(history.state); // let _this = this;
let _this = this; // _this.$mapInit({ }).then((AMap) => {
_this.$mapInit({ }).then((AMap) => { // _this.initMap();
_this.initMap(); // });
}); this.initBMap();
}, },
methods: { methods: {
// 初始化地图 async initBMap() {
initMap() { this.mapObj = await mapService.init("map");
let check = () => { window.AMap = this.mapObj;
if (this.checkLoadedTimeoutId) { this.isInitMap = true;
window.clearTimeout(this.checkLoadedTimeoutId); let query = this.$route.query;
} let o = history.state;
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("map");
this.isInitMap = true;
let query = this.$route.query;
let o = history.state;
// 假性离线报警查看位置点 console.log(query);
if (query.sns) { // 假性离线报警查看位置点
this.getLocation(query.sns); if (query.sns) {
return false; this.getLocation(query.sns);
} return false;
}
// 兼容其他页面的跳转 // 兼容其他页面的跳转
if (query && query.sn) { if (query && query.sn) {
query.elat = query.lat; query.elat = query.lat;
query.elng = query.lng; query.elng = query.lng;
this.addLocation(query, true); this.addLocation(query, true);
return false; return false;
} }
console.log(o); console.log(o);
if (o.lng || o.bsLng) { if (o.lng || o.bsLng) {
o.elat = o.lat; o.elat = o.lat;
o.elng = o.lng; o.elng = o.lng;
this.addLocation(o, true); this.addLocation(o, true);
} }
} else {
this.checkLoadedTimeoutId = check();
}
}, 100);
};
this.checkLoadedTimeoutId = check();
}, },
// 添加位置点 // 添加位置点
...@@ -125,7 +110,6 @@ export default { ...@@ -125,7 +110,6 @@ export default {
oParams.deviceCode = "gps"; oParams.deviceCode = "gps";
GET_DEVICEINFO_BYSNS(oParams).then((res) => { GET_DEVICEINFO_BYSNS(oParams).then((res) => {
let list = res.data || []; let list = res.data || [];
// 循环标记车辆 // 循环标记车辆
list.map((k) => { list.map((k) => {
let o = this.getMapInfo(k); let o = this.getMapInfo(k);
...@@ -155,14 +139,14 @@ export default { ...@@ -155,14 +139,14 @@ export default {
oParams.source = row.source || ""; oParams.source = row.source || "";
// gps 信息 // gps 信息
oParams.lng = gpsInfo.elng; oParams.lng = gpsInfo.blng;
oParams.lat = gpsInfo.elat; oParams.lat = gpsInfo.blat;
oParams.address = gpsInfo.address || ""; oParams.address = gpsInfo.address || "";
oParams.time = gpsInfo.dateTime || ""; oParams.time = gpsInfo.dateTime || "";
//基站信息 //基站信息
oParams.bsLng = bsInfo.elng; oParams.bsLng = bsInfo.blng;
oParams.bsLat = bsInfo.elat; oParams.bsLat = bsInfo.blat;
oParams.bsAddress = bsInfo.address || ""; oParams.bsAddress = bsInfo.address || "";
oParams.bsTime = bsInfo.dateTime || ""; oParams.bsTime = bsInfo.dateTime || "";
......
<template> <template>
<div> <div>
<!-- 围栏调用地图弹框 --> <!-- 围栏调用地图弹框 -->
<div class="ibox-content" style="height: 500px; padding:0 10px;z-index: 100"> <div
<fence-map :mapData="mapData" @onUpdateMapData="updateMapData" :readonlyStatus="readonlyStatus" ref="fenceMap"> class="ibox-content"
style="height: 500px; padding: 0 10px; z-index: 100"
>
<fence-map
:mapData="mapData"
@onUpdateMapData="updateMapData"
:readonlyStatus="readonlyStatus"
ref="fenceMap"
>
</fence-map> </fence-map>
</div> </div>
<!-- 围栏调用地图弹框 /--> <!-- 围栏调用地图弹框 /-->
...@@ -12,7 +20,7 @@ ...@@ -12,7 +20,7 @@
<div class="fold_btn" @click="foldEvent"> <div class="fold_btn" @click="foldEvent">
<i class="el-icon-arrow-down" v-if="showContent"></i> <i class="el-icon-arrow-down" v-if="showContent"></i>
<i class="el-icon-arrow-up" v-else></i> <i class="el-icon-arrow-up" v-else></i>
<span>{{showContent?'收起':'展开'}}</span> <span>{{ showContent ? "收起" : "展开" }}</span>
</div> </div>
</div> </div>
<el-collapse-transition> <el-collapse-transition>
...@@ -20,66 +28,157 @@ ...@@ -20,66 +28,157 @@
<div class="tab_wrap"> <div class="tab_wrap">
<el-tabs type="card" v-show="hideTab"> <el-tabs type="card" v-show="hideTab">
<el-tab-pane label="围栏基础信息"> <el-tab-pane label="围栏基础信息">
<div class="ibox-content scrollbar" style="padding: 30px 20px;"> <div class="ibox-content scrollbar" style="padding: 30px 20px">
<el-form ref="fenceForm" :model="form" :rules="rules" :inline="false" size="mini" label-width="100px" class="fence_form" align="left"> <el-form
ref="fenceForm"
:model="form"
:rules="rules"
:inline="false"
size="mini"
label-width="100px"
class="fence_form"
align="left"
>
<el-form-item label="围栏名称" prop="fenceName"> <el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" placeholder="请输入围栏名称" minlength="2" maxlength="200" show-word-limit :disabled="readonlyStatus"></el-input> <el-input
v-model.trim="form.fenceName"
placeholder="请输入围栏名称"
minlength="2"
maxlength="200"
show-word-limit
:disabled="readonlyStatus"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="监控类型" prop="triggerType"> <el-form-item label="监控类型" prop="triggerType">
<el-select v-model="form.triggerType" placeholder="请选择" size="small"> <el-select
v-model="form.triggerType"
placeholder="请选择"
size="small"
>
<el-option label="驶入" :value="1"></el-option> <el-option label="驶入" :value="1"></el-option>
<el-option label="驶出" :value="2"></el-option> <el-option label="驶出" :value="2"></el-option>
<el-option label="驶入驶出" :value="3" v-if="form.source == 1"></el-option> <el-option
label="驶入驶出"
:value="3"
v-if="form.source == 1"
></el-option>
<!-- v1.25.0版本需求,驶入驶出监控类型只有有线设备才有 --> <!-- v1.25.0版本需求,驶入驶出监控类型只有有线设备才有 -->
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="围栏类型" prop="bizFenceType"> <el-form-item label="围栏类型" prop="bizFenceType">
<el-radio :label="14" v-model="form.bizFenceType">报警型</el-radio> <el-radio :label="14" v-model="form.bizFenceType"
>报警型</el-radio
>
</el-form-item> </el-form-item>
<el-form-item label="监控周期" prop="timeType"> <el-form-item label="监控周期" prop="timeType">
<el-radio-group v-model="form.timeType" @change="changeTimeType"> <el-radio-group
v-model="form.timeType"
@change="changeTimeType"
>
<el-radio :label="1">永久有效</el-radio> <el-radio :label="1">永久有效</el-radio>
<el-radio :label="2">指定区间</el-radio> <el-radio :label="2">指定区间</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="指定区间" class="is-required" prop="dateRange" v-if="form.timeType == 2"> <el-form-item
<el-date-picker v-model="form.dateRange" type="daterange" size="small" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd"> label="指定区间"
class="is-required"
prop="dateRange"
v-if="form.timeType == 2"
>
<el-date-picker
v-model="form.dateRange"
type="daterange"
size="small"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
>
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="区域类型" class="is-required"> <el-form-item label="区域类型" class="is-required">
<el-radio-group v-model="form.shapeType" @change="shapeTypeChange"> <el-radio-group
v-model="form.shapeType"
@change="shapeTypeChange"
>
<el-radio-button label="1">圆形</el-radio-button> <el-radio-button label="1">圆形</el-radio-button>
<el-radio-button label="3">多边形</el-radio-button> <el-radio-button label="3">多边形</el-radio-button>
<el-radio-button label="4">行政区域</el-radio-button> <el-radio-button label="4">行政区域</el-radio-button>
</el-radio-group> </el-radio-group>
<div class="shape_tip" v-show="form.shapeType==3">*注:地图任意位置,单击新增双击结束绘制。</div> <div class="shape_tip" v-show="form.shapeType == 3">
*注:地图任意位置,单击新增双击结束绘制。
</div>
</el-form-item> </el-form-item>
<el-form-item label="短信通知" prop="telNumbers"> <el-form-item label="短信通知" prop="telNumbers">
<el-input v-model.trim="form.telNumbers" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input> <el-input
v-model.trim="form.telNumbers"
maxlength="100"
placeholder="输入格式:手机号码,手机号码(支持双号)"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="围栏半径" prop="radius" v-if="form.shapeType == 1"> <el-form-item
label="围栏半径"
prop="radius"
v-if="form.shapeType == 1"
>
<div class="radius_box"> <div class="radius_box">
<el-input placeholder="请输入围栏半径" v-model.trim="form.radius"> <el-input
placeholder="请输入围栏半径"
v-model.trim="form.radius"
>
<template slot="append">米</template> <template slot="append">米</template>
</el-input> </el-input>
<el-button type="primary" class="btn" :disabled="!form.radius" @click="changeRadius">更新围栏</el-button> <el-button
type="primary"
class="btn"
:disabled="!form.radius"
@click="changeRadius"
>更新围栏</el-button
>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="" label-width="0" v-if="form.shapeType == 1"> <el-form-item
label=""
label-width="0"
v-if="form.shapeType == 1"
>
<div class="lnglat_box"> <div class="lnglat_box">
<el-form-item label="经度" prop="lng" class="is-required"> <el-form-item label="经度" prop="lng" class="is-required">
<el-input placeholder="请输入围栏经度" v-model="form.lng"></el-input> <el-input
placeholder="请输入围栏经度"
v-model="form.lng"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="纬度" prop="lat" class="is-required"> <el-form-item label="纬度" prop="lat" class="is-required">
<el-input placeholder="请输入围栏纬度" v-model="form.lat"></el-input> <el-input
placeholder="请输入围栏纬度"
v-model="form.lat"
></el-input>
</el-form-item> </el-form-item>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="经纬度解析" prop="analysisAddress" class="is-required" v-if="form.shapeType == 1"> <el-form-item
<el-input v-model="form.analysisAddress" readonly></el-input> label="经纬度解析"
prop="analysisAddress"
class="is-required"
v-if="form.shapeType == 1"
>
<el-input
v-model="form.analysisAddress"
readonly
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="省市区" class="is-required" v-if="form.shapeType==4" prop="areaCode"> <el-form-item
<city-select v-model="form.areaCode" :checkStrictly="true" @change="changeArea"></city-select> label="省市区"
class="is-required"
v-if="form.shapeType == 4"
prop="areaCode"
>
<city-select
v-model="form.areaCode"
:checkStrictly="true"
@change="changeArea"
></city-select>
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="enableStatus"> <el-form-item label="状态" prop="enableStatus">
...@@ -90,9 +189,20 @@ ...@@ -90,9 +189,20 @@
</el-form-item> </el-form-item>
<el-form-item label="描述" class="el_long_form_item"> <el-form-item label="描述" class="el_long_form_item">
<el-input type="textarea" v-model.trim="form.remark" resize="none" maxlength="500" show-word-limit placeholder="请输入围栏描述"></el-input> <el-input
type="textarea"
v-model.trim="form.remark"
resize="none"
maxlength="500"
show-word-limit
placeholder="请输入围栏描述"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="操作记录" class="el_long_form_item" v-show="isEditMode"> <el-form-item
label="操作记录"
class="el_long_form_item"
v-show="isEditMode"
>
<div class="record-list" v-html="form.record"></div> <div class="record-list" v-html="form.record"></div>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -100,53 +210,98 @@ ...@@ -100,53 +210,98 @@
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="监控对象"> <el-tab-pane label="监控对象">
<div class="links_group"> <div class="links_group">
<div>已关联{{tableData.length}}个设备</div> <div>已关联{{ tableData.length }}个设备</div>
<div> <div>
<el-button v-if="!readonlyStatus" type="primary" @click="userDate" size="small" :loading="submitting">关联设备</el-button> <el-button
<el-button size="small" :disabled="!selectedIds || selectedIds.length<=0" @click="batchRemove">批量删除</el-button> v-if="!readonlyStatus"
type="primary"
@click="userDate"
size="small"
:loading="submitting"
>关联设备</el-button
>
<el-button
size="small"
:disabled="!selectedIds || selectedIds.length <= 0"
@click="batchRemove"
>批量删除</el-button
>
</div> </div>
</div> </div>
<!-- <el-table class="el_table" :data="tableData" border height="300" size="small" v-loading="loading" @selection-change="selectChange" style="width: 100%;margin-bottom:40px"> <vxe-table
<el-table-column :disabled="readonlyStatus" type="selection" width="40"></el-table-column> :data="tableData"
<el-table-column fixed type="index" label="序号" :index="getIndex" width="70"></el-table-column> border
<el-table-column fixed prop="name" label="姓名" show-overflow-tooltip></el-table-column> show-overflow
<el-table-column fixed prop="vin" label="车架号" show-overflow-tooltip></el-table-column> ref="xTableComponent"
<el-table-column prop="sn" label="设备号" show-overflow-tooltip></el-table-column> max-height="300"
<el-table-column prop="time" label="GPS时间" show-overflow-tooltip></el-table-column> :row-config="{ isHover: true }"
<el-table-column prop="address" label="位置" show-overflow-tooltip></el-table-column> :sort-config="{ trigger: 'cell' }"
<el-table-column prop="userTel" label="联系方式" show-overflow-tooltip></el-table-column> @checkbox-change="selectChange"
</el-table> --> @checkbox-all="selectChange"
<vxe-table :data="tableData" border show-overflow ref="xTableComponent" max-height="300" :row-config="{isHover: true}" :sort-config="{trigger: 'cell'}" @checkbox-change="selectChange" @checkbox-all="selectChange"> >
<vxe-column type="checkbox" width="60"></vxe-column> <vxe-column type="checkbox" width="60"></vxe-column>
<vxe-column type="seq" title="序号" width="60"></vxe-column> <vxe-column type="seq" title="序号" width="60"></vxe-column>
<vxe-column field="name" title="姓名"></vxe-column> <vxe-column field="name" title="姓名"></vxe-column>
<vxe-column field="vin" title="车架号"></vxe-column> <vxe-column field="vin" title="车架号"></vxe-column>
<vxe-column field="sn" title="设备号" show-overflow></vxe-column> <vxe-column
<vxe-column field="time" title="GPS时间" show-overflow></vxe-column> field="sn"
<vxe-column field="address" title="位置" show-overflow></vxe-column> title="设备号"
<vxe-column field="userTel" title="联系方式" show-overflow></vxe-column> show-overflow
></vxe-column>
<vxe-column
field="time"
title="GPS时间"
show-overflow
></vxe-column>
<vxe-column
field="address"
title="位置"
show-overflow
></vxe-column>
<vxe-column
field="userTel"
title="联系方式"
show-overflow
></vxe-column>
</vxe-table> </vxe-table>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
<div class="fenceModalfooter"> <div class="fenceModalfooter">
<el-button v-if="!readonlyStatus" type="primary" @click="saveFence" size="small" :loading="submitting">保存</el-button> <el-button
v-if="!readonlyStatus"
type="primary"
@click="saveFence"
size="small"
:loading="submitting"
>保存</el-button
>
<el-button @click="cancel" size="small">取消</el-button> <el-button @click="cancel" size="small">取消</el-button>
</div> </div>
</div> </div>
</el-collapse-transition> </el-collapse-transition>
<!-- 围栏内容 end --> <!-- 围栏内容 end -->
<user-list v-if="userListModalVisible" @onUserListInit="(res)=>userListInit=res" :userData="tableData" @onUpdateUserData="updateUserData" :userListModalVisible="userListModalVisible" :shopId="form.specialShopId" :source="form.source" @onUserListModalChange="userListModalChange" ref="userList"> <user-list
v-if="userListModalVisible"
@onUserListInit="(res) => (userListInit = res)"
:userData="tableData"
@onUpdateUserData="updateUserData"
:userListModalVisible="userListModalVisible"
:shopId="form.specialShopId"
:source="form.source"
@onUserListModalChange="userListModalChange"
ref="userList"
>
</user-list> </user-list>
</div> </div>
</template> </template>
<script> <script>
import mapService from "@/utils/mapService.js"; // import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import fenceMap from "./fenceMap.vue"; import fenceMap from "./fenceMap.vue";
import userList from "./fence_userlist.vue"; import userList from "./fence_userlist.vue";
import InfiniteLoading from "vue-infinite-loading"; import InfiniteLoading, { nextTick } from "vue-infinite-loading";
import CitySelect from "@/components/area/index"; import CitySelect from "@/components/area/index";
import { deepClone, showToast, showModal } from "@/utils/utils"; import { deepClone, showToast, showModal } from "@/utils/utils";
import { import {
...@@ -245,7 +400,7 @@ export default { ...@@ -245,7 +400,7 @@ export default {
// 校验经度 // 校验经度
let checkLng = (rule, vaule, cb) => { let checkLng = (rule, vaule, cb) => {
let reg = let reg =
/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/; /^(-?180(?:\.\d{1,15})?|1[0-7]\d(?:\.\d{1,15})?|\d{1,2}(?:\.\d{1,15})?)$/;
if (this.form.shapeType == 1 && !reg.test(this.form.lng)) { if (this.form.shapeType == 1 && !reg.test(this.form.lng)) {
cb(new Error("请输入正确的格式")); cb(new Error("请输入正确的格式"));
} else { } else {
...@@ -254,8 +409,7 @@ export default { ...@@ -254,8 +409,7 @@ export default {
}; };
// 校验纬度 // 校验纬度
let checkLat = (rule, vaule, cb) => { let checkLat = (rule, vaule, cb) => {
let reg = let reg = /^(-?90(?:\.\d{1,15})?|[0-8]\d(?:\.\d{1,15})?)$/;
/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/;
if (this.form.shapeType == 1 && !reg.test(this.form.lat)) { if (this.form.shapeType == 1 && !reg.test(this.form.lat)) {
cb(new Error("请输入正确的格式")); cb(new Error("请输入正确的格式"));
} else { } else {
...@@ -282,7 +436,7 @@ export default { ...@@ -282,7 +436,7 @@ export default {
timeType: 2, timeType: 2,
enableStatus: 1, enableStatus: 1,
radius: 1000, radius: 1000,
source:1 source: 1,
}, },
restainFenceName: "", restainFenceName: "",
rules: { rules: {
...@@ -349,23 +503,38 @@ export default { ...@@ -349,23 +503,38 @@ export default {
}); });
}, },
}); });
}, },
mounted() { async mounted() {
await this.$refs.fenceMap.initBMap()
//this.listener(); //this.listener();
let _this = this; this.$nextTick(() => {
let query = this.$route.query; let check = () => {
this.$set(this.form,'source',query.source); this.checkLoadedTimeoutId &&
if (query.id) { window.clearTimeout(this.checkLoadedTimeoutId);
_this.fenceId = query.id; return setTimeout(() => {
_this.getFenceInfo(query.id); if ("AMap" in window) {
_this.getList(); window.AMap = AMap;
} else { let _this = this;
//this.$refs.fenceForm.clearValidate(); let query = this.$route.query;
_this.$refs.fenceMap.updateFence({ this.$set(this.form, "source", query.source);
fenceType: "circle",
}); if (query.id) {
} _this.fenceId = query.id;
_this.getFenceInfo(query.id);
_this.getList();
} else {
//this.$refs.fenceForm.clearValidate();
_this.$refs.fenceMap.updateFence({
fenceType: "circle",
});
}
} else {
this.checkLoadedTimeoutId = check();
}
}, 100);
};
this.checkLoadedTimeoutId = check();
});
}, },
methods: { methods: {
// 监听围栏类型变化 // 监听围栏类型变化
...@@ -389,7 +558,6 @@ export default { ...@@ -389,7 +558,6 @@ export default {
// 监听表格选择 // 监听表格选择
selectChange() { selectChange() {
const records = this.$refs.xTableComponent.getCheckboxRecords(); const records = this.$refs.xTableComponent.getCheckboxRecords();
console.log(records);
this.selectedIds = records; this.selectedIds = records;
}, },
...@@ -402,10 +570,8 @@ export default { ...@@ -402,10 +570,8 @@ export default {
updateUserData(data) { updateUserData(data) {
this.userArr = data; this.userArr = data;
this.tableData = data; this.tableData = data;
console.log(data);
}, },
updateMapData(data) { updateMapData(data) {
console.log(data);
if (data.radius) { if (data.radius) {
this.$set(this.form, "radius", data.radius); this.$set(this.form, "radius", data.radius);
} }
...@@ -538,8 +704,10 @@ export default { ...@@ -538,8 +704,10 @@ export default {
// 多边形围栏 // 多边形围栏
if (form.shapeType == 3) { if (form.shapeType == 3) {
//oParams.lnglat = this.polygonPath; let lnglats = this.polygonPath.map((item) => {
oParams.lnglat = this.polygonPath.join("|"); return item.lng + "," + item.lat;
});
oParams.lnglat = lnglats.join("|");
} }
// 行政区域围栏 // 行政区域围栏
...@@ -596,18 +764,14 @@ export default { ...@@ -596,18 +764,14 @@ export default {
// 解析经纬度地址 // 解析经纬度地址
getAddress(flag) { getAddress(flag) {
let _this = this; let _this = this;
const lnglatXY = [this.form.lng, this.form.lat]; const lnglatXY = mapService.getLngLat(this.form.lng, this.form.lat);
_this.$set(_this.form, "analysisAddress", ""); _this.$set(_this.form, "analysisAddress", "");
_this.geocoder.getAddress(lnglatXY, (status, result) => { _this.geocoder.getLocation(lnglatXY, (result) => {
if (flag == _this.transferFlag) { if (flag == _this.transferFlag) {
if (status === "complete" && result.info === "OK") { if (result) {
//获取地址成功 //获取地址成功
console.log(result.regeocode.formattedAddress); _this.$set(_this.form, "analysisAddress", result.address);
_this.$set(
_this.form,
"analysisAddress",
result.regeocode.formattedAddress
);
_this.transferError = false; _this.transferError = false;
_this.$refs.fenceForm.validateField("analysisAddress"); _this.$refs.fenceForm.validateField("analysisAddress");
//this.$refs.fenceMap.updateMap(this.form) //this.$refs.fenceMap.updateMap(this.form)
...@@ -642,12 +806,11 @@ export default { ...@@ -642,12 +806,11 @@ export default {
// 监听省市区改变 // 监听省市区改变
changeArea(e) { changeArea(e) {
console.log(e);
this.form.areaCode = e.code; this.form.areaCode = e.code;
this.form.areaText = e.name; this.form.areaText = e.name[e.name.length - 1];
this.$refs.fenceMap.updateFence({ this.$refs.fenceMap.updateFence({
fenceType: "area", fenceType: "area",
areaCode: e.code[e.code.length - 1], areaText: e.name[e.name.length - 1],
}); });
}, },
...@@ -679,6 +842,7 @@ export default { ...@@ -679,6 +842,7 @@ export default {
let oParams = {}; let oParams = {};
oParams.fenceId = id; oParams.fenceId = id;
GET_ELECFENCE_INFO(oParams).then((res) => { GET_ELECFENCE_INFO(oParams).then((res) => {
console.log(res);
if (res.code != 200) { if (res.code != 200) {
return false; return false;
} }
...@@ -694,7 +858,6 @@ export default { ...@@ -694,7 +858,6 @@ export default {
} }
if (obj.lnglat) { if (obj.lnglat) {
let lnglat = obj.lnglat.split(","); let lnglat = obj.lnglat.split(",");
console.log(lnglat);
obj.lng = lnglat[0]; obj.lng = lnglat[0];
obj.lat = lnglat[1]; obj.lat = lnglat[1];
} }
...@@ -704,18 +867,21 @@ export default { ...@@ -704,18 +867,21 @@ export default {
_this.form = obj; _this.form = obj;
mapData.fenceType = _typeList[obj.shapeType]; mapData.fenceType = _typeList[obj.shapeType];
// 地图画围栏 // 地图画围栏
switch (obj.shapeType) { switch (obj.shapeType) {
case 3: case 3:
let path = obj.lnglat.split("|").map((item) => { let path = obj.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]]; let arr = item.split(",");
console.log(arr);
return mapService.getLngLat(arr[0], arr[1]);
}); });
console.log(path);
mapData.polygonPath = path; mapData.polygonPath = path;
_this.polygonPath = path; _this.polygonPath = path;
break; break;
case 4: case 4:
mapData.areaCode = obj.areaCode; mapData.areaCode = obj.areaCode;
mapData.areaText = obj.areaText;
break; break;
default: default:
let lnglat = obj.lnglat ? obj.lnglat.split(",") : []; let lnglat = obj.lnglat ? obj.lnglat.split(",") : [];
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
</v-full-layout> </v-full-layout>
</template> </template>
<script> <script>
import mapService from "@/utils/mapService.js"; import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js"; import "@/utils/mapEvent.js";
import { STATICIMAGE } from "@/constant"; import { STATICIMAGE } from "@/constant";
import FenceMapControll from "./FenceMapControll"; import FenceMapControll from "./FenceMapControll";
...@@ -145,6 +145,8 @@ export default { ...@@ -145,6 +145,8 @@ export default {
}, },
], ],
}, },
markers: {},
infowins: {},
hideFooter: false, hideFooter: false,
poi: {}, poi: {},
poiMapSearch: "", poiMapSearch: "",
...@@ -158,43 +160,52 @@ export default { ...@@ -158,43 +160,52 @@ export default {
}, },
mounted() { mounted() {
console.log(STATICIMAGE); console.log(STATICIMAGE);
this.initMap(); this.initBMap();
EventBus.$on("uiMap.poi.marker.delete", this.removePoi); EventBus.$on("uiMap.poi.marker.delete", this.removePoi);
}, },
methods: { methods: {
// 地图初始化 async initBMap() {
initMap() { this.mapObj = await mapService.init("map");
let _this = this; this.mapLoading = false;
let plugins = ["AMap.LngLat", "AMap.MassMarks", "AMap.Geocoder"]; window.AMap = this.mapObj;
_this.$mapInit({ plugins: plugins }).then((AMap) => { this.autoComplete = AMap.invoke("Autocomplete", {
_this.mapLoading = false; input: "poiMapSearch",
window.AMap = AMap; });
_this.map = mapService.init("map", { AMap.invoke("LocalCity", (res) => {
zoom: 15, AMap.invoke('panTo',res.center)
showIndoorMap: false, });
showLabel: false, AMap.invoke("autocompleteShow");
}); AMap.invoke("autocompleteAddEventListener", "onconfirm", (e) => {
_this.bindSearch(); let _poi = e.item.value;
_this.initMapEvent(); // this.$set(this.form, "address", this.poi.address);
_this.getPoiTrack(); let _params = {};
_params.lng = _poi.location.lng;
_params.lat = _poi.location.lat;
this.addPoiMarker(_params, "search");
// this.$refs.poiMapSearch.focus();
}); });
this.initMapEvent();
this.getPoiTrack();
}, },
// 创建地图右键菜单 // 创建地图右键菜单
initMapEvent() { initMapEvent() {
let _this = this; const self = this;
let _map = this.map; const mapInstance = mapService.mapInstance;
var contextMenu = AMap.invoke("ContextMenu");
let _position = ""; let _position = "";
let _contextMenu = new AMap.ContextMenu();
//右键添加Marker标记 contextMenu.addItem(
_contextMenu.addItem("设置POI点", function () { AMap.invoke("MenuItem", "设置POI点", function () {
_contextMenu.close(); self.addPoiMarker(_position);
_this.addPoiMarker(_position); })
}); );
//地图绑定鼠标右击事件——弹出右键菜单
_map.on("rightclick", function (e) { AMap.invoke("mapAddEventListener", "rightclick", function (e) {
_contextMenu.open(_map, e.lnglat); console.log(e)
_position = e.lnglat; AMap.invoke("addContextMenu", contextMenu);
_position = e.latlng;
}); });
}, },
...@@ -202,73 +213,141 @@ export default { ...@@ -202,73 +213,141 @@ export default {
addMassMarkers(arr) { addMassMarkers(arr) {
let _this = this; let _this = this;
let _query = _this.$route.query; let _query = _this.$route.query;
let markers = []; // 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++) { for (let i = 0, len = arr.length; i < len; i++) {
let k = arr[i]; let k = arr[i];
if (k.lnglat) {
if (k.id != _query.id) { let m = k.lnglat.split(",");
if (k.lnglat) { let lnglatXY = mapService.getLngLat(m[0], m[1]);
let m = k.lnglat.split(","); // markers.push(lnglatXY);
k.lng = m[0]; let marker = mapService.createPoiMarker(lnglatXY, AMap);
k.lat = m[1]; marker.info=k
k.lnglat = m;
markers.push(k); this.markers[i] = marker;
} this.$set(this.markerList, k.id, marker);
// this.infowins[i] = infoWindow;
// AMap.invoke("addOverlay", marker);
// AMap.invoke("markerAddEventListener", "click", (e) => {
// let data = { ...e, ...k };
// this.markerEvent(data);
// });
} }
} }
let mass = new AMap.MassMarks(markers, { this.createClusterer();
opacity: 0.8, // AMap.invoke("setViewport", markers);
zIndex: 10, },
cursor: "pointer", createClusterer() {
style: _icon, var cluster,
}); markers = [];
mass.on("click", function (e) { for (let idx in this.markers) {
console.log(e); markers.push(this.markers[idx]);
_this.markerEvent(e.data); }
let icon=require('images/poi-marker-default.png')
this.cluster = AMap.invoke(
"Cluster",
markers,
(data) => {
console.log(data)
return {
point: [data.latLng.lng, data.latLng.lat],
properties: {
address: data.address,
near: data.near,
poiType: data.poiType,
// id: data.id,
// sn: data.sn,
// adcode: data.adcode,
marker: data,
},
};
},
{
clusterMinPoints: 2,
clusterMaxZoom: 18,
updateRealTime: true,
fitViewOnClick: true,
renderSingleStyle: {
type: Cluster.ClusterRender.WEBGL,
style: {
width: 14,
height: 19,
icon: icon
},
},
}
);
AMap.invoke("clusterSetData", this.cluster);
//click | mouseover | mouseout | change | destroy
AMap.invoke("clusterAddEventListener", "click", (e) => {
if (e.properties&&e.properties.marker) {
let data={...e.properties.marker,...e.properties.marker.info}
this.markerEvent(data);
// AMap.invoke(
// "infoWindowDisableCloseOnClick",
// e.properties.marker.openInfoWindow
// );
// AMap.invoke(
// "mapOpenInfoWindow",
// e.properties.marker.openInfoWindow,
// e.properties.marker.getPosition()
// );
}
}); });
mass.setMap(_this.map); // AMap.invoke("clusterAddEventListener", "mouseout", (e) => {
// AMap.invoke("mapCloseInfoWindow");
// });
}, },
// 地图右键添加poi点 // 地图右键添加poi点
addPoiMarker(options, type, isOpen) { addPoiMarker(options, type, isOpen) {
console.log(options,type, isOpen);
let _this = this; let _this = this;
let _map = _this.map; let _map = _this.map;
let _InfoWindow = _this.poiInfoWindow; let _InfoWindow = _this.poiInfoWindow;
if (_this.poiMarker) { if (_this.poiMarker) {
_map.remove(_this.poiMarker); AMap.invoke("removeOverlay", _this.poiMarker);
_InfoWindow && _InfoWindow.close(); _InfoWindow && AMap.invoke("mapCloseInfoWindow", _InfoWindow);
_this.poiMarker = null; _this.poiMarker = null;
} }
let _icon = new AMap.Icon({ let _icon = AMap.invoke(
image: STATICIMAGE.POI_MARKER, "Icon",
}); STATICIMAGE.POI_MARKER,
AMap.invoke("Size", 24, 24)
);
if (options.id) { if (options.id) {
_icon = new AMap.Icon({ _icon = AMap.invoke(
image: STATICIMAGE.POI_MASS_ICON, "Icon",
imageSize: new AMap.Size(16, 21), STATICIMAGE.POI_MASS_ICON,
}); AMap.invoke("Size", 16, 21)
);
} }
let lnglatXY=mapService.getLngLat(options.lng, options.lat);
let _marker = new AMap.Marker({ let _marker=AMap.invoke('Marker', lnglatXY, {
icon: _icon, icon:_icon
position: [options.lng, options.lat], })
extData: options, // let _marker = new AMap.Marker({
}); // icon: _icon,
// position: [options.lng, options.lat],
let _markerInfo = _marker.getExtData(); // extData: options,
//_marker.infoWindow = mapService.createPoiMarkerInfowindow(options); // });
_marker.on("click", function (e) { let _markerInfo=options
_this.markerEvent(_markerInfo); _markerInfo.latLng=mapService.getLngLat(options.lng, options.lat);
}); AMap.invoke("addOverlay", _marker);
_marker.setMap(_this.map); this.markerEvent(_markerInfo);
// AMap.invoke("mapOpenInfoWindow", infoWindow,lnglat)
AMap.invoke("markerAddEventListener", "click", (e) => {
_markerInfo = { ...e, ..._markerInfo };
this.markerEvent(_markerInfo);
});
// let _markerInfo = _marker.getExtData();
// //_marker.infoWindow = mapService.createPoiMarkerInfowindow(options);
// _marker.on("click", function (e) {
// _this.markerEvent(_markerInfo);
// });
// _marker.setMap(_this.map);
// 历史marker存储起来,以id为键值,方便后续删除用 // 历史marker存储起来,以id为键值,方便后续删除用
if (options.id) { if (options.id) {
...@@ -295,27 +374,18 @@ export default { ...@@ -295,27 +374,18 @@ export default {
// marker点击事件 // marker点击事件
markerEvent(e) { markerEvent(e) {
let _this = this;
console.log(e);
let _params = e; let _params = e;
const geocoder = new AMap.Geocoder({ this.setPoiInfo(e);
extensions: "all", let point = e.latLng;
AMap.invoke("getLocation", point, (res) => {
let _pois = res.surroundingPois || [];
_params.address = res.address;
_params.near = _pois[0] ? _pois[0].title : "";
let infoWindow = mapService.createPoiMarkerInfowindow(_params);
this.poiInfoWindow = infoWindow;
AMap.invoke("mapOpenInfoWindow", infoWindow, point);
AMap.invoke("centerAndZoom",point,14)
}); });
_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信息 // 设置poi信息
...@@ -338,26 +408,6 @@ export default { ...@@ -338,26 +408,6 @@ export default {
this.hideFooter = !this.hideFooter; 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() { goListPage() {
let path = `/trialRun#/poi/index`; let path = `/trialRun#/poi/index`;
...@@ -408,7 +458,6 @@ export default { ...@@ -408,7 +458,6 @@ export default {
// 删除poi点 // 删除poi点
removePoi(row) { removePoi(row) {
console.log(row);
let _this = this; let _this = this;
let _message = "确认删除该POI信息吗?"; let _message = "确认删除该POI信息吗?";
let _typeList = { let _typeList = {
...@@ -439,8 +488,8 @@ export default { ...@@ -439,8 +488,8 @@ export default {
let _InfoWindow = this.poiInfoWindow; let _InfoWindow = this.poiInfoWindow;
// id不存在,临时的poi点,删除marker就行了 // id不存在,临时的poi点,删除marker就行了
if (!row.id) { if (!row.id) {
_map.remove(_this.poiMarker); AMap.invoke('removeOverlay', _this.poiMarker)
_InfoWindow && _InfoWindow.close(); _InfoWindow && AMap.invoke('mapCloseInfoWindow', _InfoWindow);
_this.form = {}; _this.form = {};
setTimeout(function () { setTimeout(function () {
_this.$refs.poiForm.clearValidate(); _this.$refs.poiForm.clearValidate();
...@@ -450,9 +499,14 @@ export default { ...@@ -450,9 +499,14 @@ export default {
_params.id = row.id; _params.id = row.id;
DELETE_POI_INFO(_params).then((res) => { DELETE_POI_INFO(_params).then((res) => {
if (res.code == 200) { if (res.code == 200) {
// console.log(this.markerList,row)
let _marker = _this.markerList[row.id]; let _marker = _this.markerList[row.id];
_map.remove(_marker); AMap.invoke('removeOverlay', _marker)
_InfoWindow && _InfoWindow.close(); // AMap.invoke(
// "infoWindowDisableCloseOnClick",
// _InfoWindow
// );
_InfoWindow && AMap.invoke('mapCloseInfoWindow', _InfoWindow);
showToast({ showToast({
message: "删除成功", message: "删除成功",
type: "success", type: "success",
...@@ -470,16 +524,16 @@ export default { ...@@ -470,16 +524,16 @@ export default {
let _this = this; let _this = this;
let _query = _this.$route.query; let _query = _this.$route.query;
GET_POI_TRACK().then((res) => { GET_POI_TRACK().then((res) => {
console.log(res,'GET_POI_TRACK')
if (res.code == 200) { if (res.code == 200) {
let _list = res.data || []; let _list = res.data || [];
_this.addMassMarkers(_list); _this.addMassMarkers(_list);
// 编辑页面 // 编辑页面
if (_query.id) { if (_query.id) {
_this.getInfo(); _this.getInfo();
} }
_this.trackList = res.data || []; _this.trackList = res.data || [];
_this.showRoadTitle(); // _this.showRoadTitle();
} }
}); });
}, },
...@@ -526,7 +580,8 @@ export default { ...@@ -526,7 +580,8 @@ export default {
if (_map) { if (_map) {
console.log(lng, lat); console.log(lng, lat);
setTimeout(function () { setTimeout(function () {
_map.setCenter([lng, lat]); let lnglatXY = mapService.getLngLat(lng, lat);
AMap.invoke('panTo',lnglatXY)
}, 1000); }, 1000);
} }
}, },
......
<!--
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-30 15:11:15
* @FilePath: \oEshield\src\pages\monitor\alarmAnalysis.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template> <template>
<div class="main-container"> <div class="main-container">
<div id="alarmMap" class="map-container"></div> <div id="alarmMap" class="map-container"></div>
<div class="left-box" v-show="boxShow"> <div class="left-box" v-show="boxShow">
<!-- 饼图组件 --> <!-- 饼图组件 -->
<ParCharts class="pie" ref="pieChartsRef" id="pie-chart" height="220px" :list="pieList" /> <ParCharts
class="pie"
ref="pieChartsRef"
id="pie-chart"
height="220px"
:list="pieList"
/>
<!-- 风险分析 --> <!-- 风险分析 -->
<div class="analy-box"> <div class="analy-box">
<div class="top-box"> <div class="top-box">
<template v-if="alarmData.data.length"> <template v-if="alarmData.data.length">
<div v-for="item in alarmData.data" :key="item" class="top-box-item"> <div
v-for="item in alarmData.data"
:key="item"
class="top-box-item"
>
<div class="top-box-item-left">{{ item.alarmName }}</div> <div class="top-box-item-left">{{ item.alarmName }}</div>
<div :class="['top-box-item-right', 'item'+item.alarmLevel]"> <div :class="['top-box-item-right', 'item' + item.alarmLevel]">
<!-- <div :class="['item', item.alarmLevel <= 5 ? 'item1' : 'item1-grey']"></div> <!-- <div :class="['item', item.alarmLevel <= 5 ? 'item1' : 'item1-grey']"></div>
<div :class="['item', item.alarmLevel <= 4 ? 'item2' : 'item-grey']"></div> <div :class="['item', item.alarmLevel <= 4 ? 'item2' : 'item-grey']"></div>
<div :class="['item', item.alarmLevel <= 3 ? 'item3' : 'item-grey']"></div> <div :class="['item', item.alarmLevel <= 3 ? 'item3' : 'item-grey']"></div>
...@@ -53,30 +71,58 @@ ...@@ -53,30 +71,58 @@
<div class="bottom-box"> <div class="bottom-box">
<div class="bottom-box-item"> <div class="bottom-box-item">
<div class="bottom-box-item-left">常驻地:</div> <div class="bottom-box-item-left">常驻地:</div>
<div class="bottom-box-item-right">{{ alarmData.residence || '-' }}</div> <div class="bottom-box-item-right">
{{ alarmData.residence || "-" }}
</div>
</div> </div>
<div class="bottom-box-item"> <div class="bottom-box-item">
<div class="bottom-box-item-left">预测家庭地址:</div> <div class="bottom-box-item-left">预测家庭地址:</div>
<div class="bottom-box-item-right">{{ alarmData.homeAddress || '-' }}</div> <div class="bottom-box-item-right">
{{ alarmData.homeAddress || "-" }}
</div>
</div> </div>
<div class="bottom-box-item"> <div class="bottom-box-item">
<div class="bottom-box-item-left">预测工作地址:</div> <div class="bottom-box-item-left">预测工作地址:</div>
<div class="bottom-box-item-right">{{ alarmData.workAddress || '-' }}</div> <div class="bottom-box-item-right">
{{ alarmData.workAddress || "-" }}
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="right-box" v-show="boxShow"> <div class="right-box" v-show="boxShow">
<!-- 用车行为分析 --> <!-- 用车行为分析 -->
<div class="use-car-box"> <div class="use-car-box">
<div class="title">用车行为分析<div class="detail-btn" v-if="pieList && pieList.length" @click="goDetailPage()">风险评估详情</div></div> <div class="title">
<div class="x-name" v-if="xAxisDataList.length"><span>{{ linetype== 1 ? '周' : '天' }}</span><span v-if="lineChartsYear">-{{ lineChartsYear }}年</span></div> 用车行为分析
<div
class="detail-btn"
v-if="pieList && pieList.length"
@click="goDetailPage()"
>
风险评估详情
</div>
</div>
<div class="x-name" v-if="xAxisDataList.length">
<span>{{ linetype == 1 ? "周" : "天" }}</span
><span v-if="lineChartsYear">-{{ lineChartsYear }}年</span>
</div>
<div class="line-charts" v-if="xAxisDataList.length"> <div class="line-charts" v-if="xAxisDataList.length">
<LineCharts id="useCarCharts" ref="useCarChartsRef" height="250px" :linetype="linetype" :dataList="useCarData" <LineCharts
:xAxisData="xAxisDataList" :lineChartsYear="lineChartsYear"></LineCharts> id="useCarCharts"
ref="useCarChartsRef"
height="250px"
:linetype="linetype"
:dataList="useCarData"
:xAxisData="xAxisDataList"
:lineChartsYear="lineChartsYear"
></LineCharts>
</div> </div>
<div v-else class="empty-box"> <div v-else class="empty-box">
<img src="https://wx.glsx.com.cn/upload/biz/501829f0-6c34-443c-bf56-ae94072a6619.png" alt=""> <img
src="https://wx.glsx.com.cn/upload/biz/501829f0-6c34-443c-bf56-ae94072a6619.png"
alt=""
/>
<div>暂无里程数据</div> <div>暂无里程数据</div>
</div> </div>
</div> </div>
...@@ -86,36 +132,52 @@ ...@@ -86,36 +132,52 @@
<div> <div>
<div class="detail-msg"> <div class="detail-msg">
<div class="detail-msg-left">承租人姓名:</div> <div class="detail-msg-left">承租人姓名:</div>
<div class="detail-msg-right"> {{ basicData.lesseeName || '-' }}</div> <div class="detail-msg-right">
{{ basicData.lesseeName || "-" }}
</div>
</div> </div>
<div class="detail-msg"> <div class="detail-msg">
<div class="detail-msg-left">店面名称:</div> <div class="detail-msg-left">店面名称:</div>
<div class="detail-msg-right"> {{ basicData.shopName || '-' }}</div> <div class="detail-msg-right">{{ basicData.shopName || "-" }}</div>
</div> </div>
<div class="detail-msg"> <div class="detail-msg">
<div class="detail-msg-left">客户姓名:</div> <div class="detail-msg-left">客户姓名:</div>
<div class="detail-msg-right"> {{ basicData.userName || '-' }}</div> <div class="detail-msg-right">{{ basicData.userName || "-" }}</div>
</div> </div>
<div class="detail-msg"> <div class="detail-msg">
<div class="detail-msg-left">业务工单号:</div> <div class="detail-msg-left">业务工单号:</div>
<div class="detail-msg-right"> {{ basicData.workOrderNo || '-' }}</div> <div class="detail-msg-right">
{{ basicData.workOrderNo || "-" }}
</div>
</div> </div>
<div class="detail-msg"> <div class="detail-msg">
<div class="detail-msg-left">车架号:</div> <div class="detail-msg-left">车架号:</div>
<div class="detail-msg-right">{{ basicData.vin || '-' }} </div> <div class="detail-msg-right">{{ basicData.vin || "-" }}</div>
</div> </div>
<div class="detail-msg"> <div class="detail-msg">
<div class="detail-msg-left">创建时间:</div> <div class="detail-msg-left">创建时间:</div>
<div class="detail-msg-right">{{ basicData.createTime || '-' }} </div> <div class="detail-msg-right">
{{ basicData.createTime || "-" }}
</div>
</div> </div>
<div class="detail-msg"> <div class="detail-msg">
<div class="detail-msg-left">设备状态:</div> <div class="detail-msg-left">设备状态:</div>
<template v-if="basicData.deviceInformationVOList&&basicData.deviceInformationVOList.length"> <template
v-if="
basicData.deviceInformationVOList &&
basicData.deviceInformationVOList.length
"
>
<div class="detail-msg-right"> <div class="detail-msg-right">
<div class="detail-msg-desc" v-for="item in basicData.deviceInformationVOList"> <div
class="detail-msg-desc"
v-for="item in basicData.deviceInformationVOList"
>
<div class="sn">{{ item.sourceStr }}-{{ item.sn }}</div> <div class="sn">{{ item.sourceStr }}-{{ item.sn }}</div>
<div v-show="item.deviceStateStr">{{ item.deviceStateStr }}</div> <div v-show="item.deviceStateStr">
<div>定位-{{ item.address || ' --' }}</div> {{ item.deviceStateStr }}
</div>
<div>定位-{{ item.address || " --" }}</div>
</div> </div>
</div> </div>
</template> </template>
...@@ -125,7 +187,6 @@ ...@@ -125,7 +187,6 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- 热力图 --> <!-- 热力图 -->
<div class="hot-box">“历史停留”热力图</div> <div class="hot-box">“历史停留”热力图</div>
...@@ -133,16 +194,23 @@ ...@@ -133,16 +194,23 @@
</template> </template>
<script> <script>
import ParCharts from './ParCharts.vue'; import ParCharts from "./ParCharts.vue";
import mapService from "@/utils/mapService.js"; import mapService from "@/utils/mapBService.js";
import LineCharts from './LineCharts.vue'; import LineCharts from "./LineCharts.vue";
import { services } from "@/api"; import { services } from "@/api";
import "utils/mapEvent.js"; import "utils/mapEvent.js";
import EventBus from "../../event-bus"; import EventBus from "../../event-bus";
import { GET_STAY_POINTLIST, GET_BASIC_INFORMATION, GET_RESIDENT_INFORMATION, GET_ALARM_POINTLIST, GET_USER_BEHAVIOR_INFORMATION, GET_HISTORY_LOCATION } from "@/api/services/monitor"; import {
GET_STAY_POINTLIST,
GET_BASIC_INFORMATION,
GET_RESIDENT_INFORMATION,
GET_ALARM_POINTLIST,
GET_USER_BEHAVIOR_INFORMATION,
GET_HISTORY_LOCATION,
} from "@/api/services/monitor";
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
export default { export default {
name: 'OEshieldAlarmAnalysis', name: "OEshieldAlarmAnalysis",
components: { ParCharts, LineCharts }, components: { ParCharts, LineCharts },
data() { data() {
return { return {
...@@ -155,9 +223,9 @@ export default { ...@@ -155,9 +223,9 @@ export default {
basicData: {}, basicData: {},
alarmData: { alarmData: {
data: [], data: [],
residence: '', residence: "",
homeAddress: '', homeAddress: "",
workAddress: '', workAddress: "",
}, },
useCarData: [], useCarData: [],
xAxisDataList: [], xAxisDataList: [],
...@@ -165,94 +233,81 @@ export default { ...@@ -165,94 +233,81 @@ export default {
resultList: [], resultList: [],
linetype: 1, linetype: 1,
boxShow: false, boxShow: false,
lineChartsYear: '' lineChartsYear: "",
}; };
}, },
mounted() { mounted() {
let _this = this; const _vehicleId = this.$route.query.vehicleId
const _vehicleId = _this.$route.query.vehicleId
this.vehicleId = _vehicleId this.vehicleId = _vehicleId
_this.$mapInit({ version: '1.4.2' }).then(AMap => { this.initBMap();
// window.AMap = AMap; this.resetWidth();
_this.initMap();
})
this.resetWidth()
}, },
methods: { methods: {
goDetailPage() { goDetailPage() {
this.$router.push({name:'riskAssessDetail', query: { this.$router.push({
vehicleId: this.vehicleId, name: "riskAssessDetail",
vin :this.basicData.vin}}) query: {
vehicleId: this.vehicleId,
vin: this.basicData.vin,
},
});
}, },
resetWidth() { resetWidth() {
const homePage = document.querySelector('.desktop-left-sider'); const homePage = document.querySelector(".desktop-left-sider");
// 创建 ResizeObserver 对象 // 创建 ResizeObserver 对象
this.resizeObserver = new ResizeObserver(entries => { this.resizeObserver = new ResizeObserver((entries) => {
console.log(111111) console.log(111111);
// 当元素大小发生变化时执行的回调函数 // 当元素大小发生变化时执行的回调函数
for (let entry of entries) { for (let entry of entries) {
const width = entry.contentRect.width; const width = entry.contentRect.width;
let myElement = document.querySelector('.main-container'); let myElement = document.querySelector(".main-container");
if(width==0) { if (width == 0) {
myElement.style.width = '100%'; myElement.style.width = "100%";
myElement.style.left = '0'; myElement.style.left = "0";
} }
if(width==200) { if (width == 200) {
myElement.style.width = 'calc(100% - 200px)'; myElement.style.width = "calc(100% - 200px)";
myElement.style.left = '200px'; myElement.style.left = "200px";
} }
} }
}); });
// 开始观察目标元素的大小变化 // 开始观察目标元素的大小变化
homePage && this.resizeObserver.observe(homePage); homePage && this.resizeObserver.observe(homePage);
}, },
initMap() { async initBMap() {
let check = () => { this.mapObj = await mapService.init("alarmMap");
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); window.AMap = this.mapObj;
return setTimeout(() => { AMap.invoke("LocalCity", (res) => {
if ( AMap.invoke('panTo',res.center)
"AMap" in window && });
typeof AMap.Map == "function" && this.isInitMap = true;
!this.mapObj this.boxShow = true;
) { this.getStayPointList(this.vehicleId);
window.AMap = AMap; this.getBasicInformation(this.vehicleId);
this.mapObj = mapService.init("alarmMap"); this.getResidentInformation(this.vehicleId);
this.isInitMap = true; this.getAlarmInformation(this.vehicleId);
this.$nextTick(() => { this.getUserBehaviorInformation(this.vehicleId);
this.boxShow = true
this.getStayPointList(this.vehicleId)
this.getBasicInformation(this.vehicleId)
this.getResidentInformation(this.vehicleId)
this.getAlarmInformation(this.vehicleId)
this.getUserBehaviorInformation(this.vehicleId)
}, 500)
} else {
this.checkMapLoaded = check();
}
});
};
this.checkMapLoaded = check();
}, },
// 设备停留点查询 // 设备停留点查询
getStayPointList(vehicleId) { getStayPointList(vehicleId) {
EventBus.$emit("uiMap.historyLocation.destroy"); EventBus.$emit("uiMap.historyLocation.destroy");
GET_STAY_POINTLIST({ vehicleId }).then(res => { GET_STAY_POINTLIST({ vehicleId }).then((res) => {
if (res.code != 200) { if (res.code != 200) {
this.$message({ this.$message({
type: "error", type: "error",
message: res.message, message: res.message,
}) });
return return;
} }
let _data = res.data || [] let _data = res.data || [];
if (!_data.length) { if (!_data.length) {
this.$message({ this.$message({
type: "info", type: "info",
message: '暂无历史停留数据', message: "暂无历史停留数据",
}) });
return return;
} }
_data.forEach((item, idx) => { _data.forEach((item, idx) => {
item.idx = idx; item.idx = idx;
...@@ -265,86 +320,92 @@ export default { ...@@ -265,86 +320,92 @@ export default {
}); });
this.resultList = _data; this.resultList = _data;
EventBus.$emit("uiMap.historyLocation.draw", _data); EventBus.$emit("uiMap.historyLocation.draw", _data);
}) });
}, },
// 获取车辆基本信息 // 获取车辆基本信息
getBasicInformation(vehicleId) { getBasicInformation(vehicleId) {
GET_BASIC_INFORMATION({ vehicleId }).then(res => { GET_BASIC_INFORMATION({ vehicleId }).then((res) => {
if (res.code != 200) { if (res.code != 200) {
this.$message({ this.$message({
type: "error", type: "error",
message: res.message, message: res.message,
}) });
return return;
} }
this.basicData = res.data this.basicData = res.data;
}) });
}, },
// 预测家庭地址和预测工作地址查询 // 预测家庭地址和预测工作地址查询
getResidentInformation(vehicleId) { getResidentInformation(vehicleId) {
GET_RESIDENT_INFORMATION({ vehicleId }).then(res => { GET_RESIDENT_INFORMATION({ vehicleId }).then((res) => {
if (res.code != 200) { if (res.code != 200) {
this.$message({ this.$message({
type: "error", type: "error",
message: res.message, message: res.message,
}) });
return return;
} }
this.alarmData.residence = res.data.residence this.alarmData.residence = res.data.residence;
this.alarmData.homeAddress = res.data.homeAddress this.alarmData.homeAddress = res.data.homeAddress;
this.alarmData.workAddress = res.data.workAddress this.alarmData.workAddress = res.data.workAddress;
}) });
}, },
// 设备警情数据查询 // 设备警情数据查询
getAlarmInformation(vehicleId) { getAlarmInformation(vehicleId) {
GET_ALARM_POINTLIST({ vehicleId }).then(res => { GET_ALARM_POINTLIST({ vehicleId }).then((res) => {
if (res.code != 200) { if (res.code != 200) {
this.$message({ this.$message({
type: "error", type: "error",
message: res.message, message: res.message,
}) });
return return;
} }
this.alarmData.data = res.data.length > 6 ? res.data.slice(0, 6) : res.data this.alarmData.data =
let _list = res.data res.data.length > 6 ? res.data.slice(0, 6) : res.data;
let _list = res.data;
if (_list.length === 0) { if (_list.length === 0) {
this.$refs.pieChartsRef.draw() this.$refs.pieChartsRef.draw();
return return;
} }
_list[0].value = 1 / _list[0].alarmLevel * 100 _list[0].value = (1 / _list[0].alarmLevel) * 100;
this.pieList.push(_list[0]) this.pieList.push(_list[0]);
this.$refs.pieChartsRef.draw() this.$refs.pieChartsRef.draw();
}) });
}, },
// 用户行为数据查询 // 用户行为数据查询
getUserBehaviorInformation(vehicleId) { getUserBehaviorInformation(vehicleId) {
GET_USER_BEHAVIOR_INFORMATION({ vehicleId }).then(res => { GET_USER_BEHAVIOR_INFORMATION({ vehicleId }).then((res) => {
if (res.code != 200) { if (res.code != 200) {
this.$message({ this.$message({
type: "error", type: "error",
message: res.message, message: res.message,
}) });
return return;
} }
let _dataList = res.data.statisticsType == 1 ? res.data.userBehaviorWeekDTOList : res.data.userBehaviorDayDTOList let _dataList =
_dataList ? _dataList : [] res.data.statisticsType == 1
? res.data.userBehaviorWeekDTOList
: res.data.userBehaviorDayDTOList;
_dataList ? _dataList : [];
if (_dataList.length == 0) { if (_dataList.length == 0) {
this.useCarData = [] this.useCarData = [];
return return;
} }
this.linetype = res.data.statisticsType this.linetype = res.data.statisticsType;
let _int = res.data.statisticsType == 1 ? 'weekInt' : 'dayInt' let _int = res.data.statisticsType == 1 ? "weekInt" : "dayInt";
let _type = res.data.statisticsType == 1 ? 'weekNum' : 'dayNum' let _type = res.data.statisticsType == 1 ? "weekNum" : "dayNum";
this.lineChartsYear = _dataList[_dataList.length - 1].yearInt || '' this.lineChartsYear = _dataList[_dataList.length - 1].yearInt || "";
_dataList.forEach(item => { _dataList.forEach((item) => {
res.data.statisticsType == 1 ? this.xAxisDataList.push(item[_int]) : this.xAxisDataList.push(item.monthInt + '.' + item[_int]) res.data.statisticsType == 1
this.useCarData.push(item[_type]) ? this.xAxisDataList.push(item[_int])
}) : this.xAxisDataList.push(item.monthInt + "." + item[_int]);
this.useCarData.push(item[_type]);
});
setTimeout(() => { setTimeout(() => {
this.$refs.useCarChartsRef.drawBarLine() this.$refs.useCarChartsRef.drawBarLine();
}, 1000) }, 1000);
}) });
} },
}, },
// async created() { // async created() {
// EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => { // EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
...@@ -352,29 +413,30 @@ export default { ...@@ -352,29 +413,30 @@ export default {
// }); // });
// }, // },
beforeDestroy() { beforeDestroy() {
this.resizeObserver.disconnect() this.resizeObserver.disconnect();
// this.checkLoadedTimeoutId && window.clearTimeout(this.checkLoadedTimeoutId); // this.checkLoadedTimeoutId && window.clearTimeout(this.checkLoadedTimeoutId);
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.analy-box, .detail-box{ .analy-box,
.detail-box {
/* 修改垂直滚动条 */ /* 修改垂直滚动条 */
&::-webkit-scrollbar { &::-webkit-scrollbar {
width: 2px; /* 修改宽度 */ width: 2px; /* 修改宽度 */
} }
/* 修改滚动条轨道背景色 */ /* 修改滚动条轨道背景色 */
&::-webkit-scrollbar-track { &::-webkit-scrollbar-track {
background-color: #fff; background-color: #fff;
} }
/* 修改滚动条滑块颜色 */ /* 修改滚动条滑块颜色 */
&::-webkit-scrollbar-thumb { &::-webkit-scrollbar-thumb {
background-color: #181c36e6; background-color: #181c36e6;
} }
/* 修改滚动条滑块悬停时的颜色 */ /* 修改滚动条滑块悬停时的颜色 */
&::-webkit-scrollbar-thumb:hover { &::-webkit-scrollbar-thumb:hover {
background-color: #181c36e6; background-color: #181c36e6;
...@@ -384,7 +446,7 @@ export default { ...@@ -384,7 +446,7 @@ export default {
position: fixed; position: fixed;
width: calc(100% - 200px); width: calc(100% - 200px);
height: calc(100% - 60px); height: calc(100% - 60px);
top:60px; top: 60px;
left: 200px; left: 200px;
background: #fff; background: #fff;
padding: 0; padding: 0;
...@@ -410,7 +472,7 @@ export default { ...@@ -410,7 +472,7 @@ export default {
.pie { .pie {
width: 300px; width: 300px;
height: 270px; height: 270px;
background: #181C36; background: #181c36;
box-shadow: 0 4px 6px 0 #00000014; box-shadow: 0 4px 6px 0 #00000014;
z-index: 9999; z-index: 9999;
} }
...@@ -423,7 +485,7 @@ export default { ...@@ -423,7 +485,7 @@ export default {
box-sizing: border-box; box-sizing: border-box;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
background: rgba(24 ,28, 54 ,0.9); background: rgba(24, 28, 54, 0.9);
box-shadow: 0 4px 6px 0 #00000014; box-shadow: 0 4px 6px 0 #00000014;
box-sizing: border-box; box-sizing: border-box;
padding: 30px 16px 16px; padding: 30px 16px 16px;
...@@ -431,18 +493,18 @@ export default { ...@@ -431,18 +493,18 @@ export default {
.top-box { .top-box {
position: relative; position: relative;
.top-box-none{ .top-box-none {
position: relative; position: relative;
width: 100%; width: 100%;
height: 130px; height: 130px;
.dask-bg{ .dask-bg {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
} }
.dask{ .dask {
position: absolute; position: absolute;
z-index: 2; z-index: 2;
left: 0; left: 0;
...@@ -460,7 +522,7 @@ export default { ...@@ -460,7 +522,7 @@ export default {
justify-content: center; justify-content: center;
font-weight: 600; font-weight: 600;
font-size: 21px; font-size: 21px;
color: #FFFFFF; color: #ffffff;
} }
} }
&-item { &-item {
...@@ -471,7 +533,7 @@ export default { ...@@ -471,7 +533,7 @@ export default {
.top-box-item-left { .top-box-item-left {
font-weight: 400; font-weight: 400;
font-size: 12px; font-size: 12px;
color: #FFFFFF; color: #ffffff;
text-align: center; text-align: center;
width: 100px; width: 100px;
margin-right: 12px; margin-right: 12px;
...@@ -481,26 +543,26 @@ export default { ...@@ -481,26 +543,26 @@ export default {
width: 140px; width: 140px;
height: 12px; height: 12px;
border-radius: 6px; border-radius: 6px;
background: #46495E; background: #46495e;
} }
.item5 { .item5 {
background: #4ED5D7; background: #4ed5d7;
} }
.item4 { .item4 {
background: #58D068; background: #58d068;
} }
.item3 { .item3 {
background: #F7D310; background: #f7d310;
} }
.item2 { .item2 {
background: #F38906; background: #f38906;
} }
.item1 { .item1 {
background: #F23204; background: #f23204;
} }
&-right-none { &-right-none {
...@@ -521,8 +583,8 @@ export default { ...@@ -521,8 +583,8 @@ export default {
left: 158px; left: 158px;
font-weight: 600; font-weight: 600;
font-size: 14px; font-size: 14px;
color: #B5B5B5; color: #b5b5b5;
-webkit-text-stroke: 0.5px #181C36; -webkit-text-stroke: 0.5px #181c36;
} }
} }
...@@ -548,21 +610,20 @@ export default { ...@@ -548,21 +610,20 @@ export default {
} }
.dot-2 { .dot-2 {
background: #58D068; background: #58d068;
} }
.dot-3 { .dot-3 {
background: #F7D310; background: #f7d310;
} }
.dot-4 { .dot-4 {
background: #F38906; background: #f38906;
} }
.dot-5 { .dot-5 {
background: #F23204; background: #f23204;
} }
} }
.bottom-box { .bottom-box {
...@@ -578,7 +639,7 @@ export default { ...@@ -578,7 +639,7 @@ export default {
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-weight: 400; font-weight: 400;
font-size: 12px; font-size: 12px;
color: #A3A4AF; color: #a3a4af;
} }
&-right { &-right {
...@@ -586,11 +647,10 @@ export default { ...@@ -586,11 +647,10 @@ export default {
line-height: 17px; line-height: 17px;
font-weight: 400; font-weight: 400;
font-size: 12px; font-size: 12px;
color: #E5E5E8; color: #e5e5e8;
} }
} }
} }
} }
.right-box { .right-box {
...@@ -598,31 +658,30 @@ export default { ...@@ -598,31 +658,30 @@ export default {
top: 10px; top: 10px;
right: 26px; right: 26px;
z-index: 9999; z-index: 9999;
.title{ .title {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
.detail-btn{ .detail-btn {
cursor: pointer; cursor: pointer;
width: 116px; width: 116px;
text-align: center; text-align: center;
color: #fff; color: #fff;
height: 32px; height: 32px;
line-height: 32px; line-height: 32px;
background: #0077FF; background: #0077ff;
border-radius: 4px; border-radius: 4px;
} }
} }
} }
.detail-box { .detail-box {
margin-top: 8px; margin-top: 8px;
width: 300px; width: 300px;
max-height: 420px; max-height: 420px;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
background: rgba(24 ,28, 54 ,0.9); background: rgba(24, 28, 54, 0.9);
border-radius: 8px; border-radius: 8px;
box-shadow: 0 4px 6px 0 #00000014; box-shadow: 0 4px 6px 0 #00000014;
z-index: 9999; z-index: 9999;
...@@ -632,7 +691,7 @@ export default { ...@@ -632,7 +691,7 @@ export default {
.title { .title {
font-weight: 500; font-weight: 500;
font-size: 14px; font-size: 14px;
color: #158BFF; color: #158bff;
margin-bottom: 10px; margin-bottom: 10px;
} }
...@@ -642,14 +701,14 @@ export default { ...@@ -642,14 +701,14 @@ export default {
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
margin-bottom: 8px; margin-bottom: 8px;
&:last-child{ &:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
&-left { &-left {
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-weight: 400; font-weight: 400;
font-size: 12px; font-size: 12px;
color: #A3A4AF; color: #a3a4af;
min-width: 72px; min-width: 72px;
text-align: right; text-align: right;
} }
...@@ -659,15 +718,15 @@ export default { ...@@ -659,15 +718,15 @@ export default {
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-weight: 400; font-weight: 400;
font-size: 12px; font-size: 12px;
color: #E5E5E8; color: #e5e5e8;
} }
.detail-msg-desc { .detail-msg-desc {
color: #E5E5E8; color: #e5e5e8;
.sn{ .sn {
color: #2994FF; color: #2994ff;
} }
& div{ & div {
margin-bottom: 1px; margin-bottom: 1px;
line-height: 17px; line-height: 17px;
} }
...@@ -678,14 +737,14 @@ export default { ...@@ -678,14 +737,14 @@ export default {
.use-car-box { .use-car-box {
width: 300px; width: 300px;
height: 270px; height: 270px;
background: rgba(24 ,28, 54 ,0.9); background: rgba(24, 28, 54, 0.9);
border-radius: 8px; border-radius: 8px;
box-sizing: border-box; box-sizing: border-box;
padding: 16px; padding: 16px;
box-shadow: 0 4px 6px 0 #00000014; box-shadow: 0 4px 6px 0 #00000014;
z-index: 9999; z-index: 9999;
position: relative; position: relative;
.x-name{ .x-name {
color: #6e7079; color: #6e7079;
position: absolute; position: absolute;
right: 20px; right: 20px;
...@@ -694,7 +753,7 @@ export default { ...@@ -694,7 +753,7 @@ export default {
.title { .title {
font-weight: 500; font-weight: 500;
font-size: 14px; font-size: 14px;
color: #158BFF; color: #158bff;
} }
.empty-box { .empty-box {
...@@ -724,7 +783,7 @@ export default { ...@@ -724,7 +783,7 @@ export default {
border-radius: 24px 24px 0 0; border-radius: 24px 24px 0 0;
font-weight: 600; font-weight: 600;
font-size: 20px; font-size: 20px;
color: #FFFFFF; color: #ffffff;
text-align: center; text-align: center;
line-height: 48px; line-height: 48px;
z-index: 9999; z-index: 9999;
...@@ -732,4 +791,5 @@ export default { ...@@ -732,4 +791,5 @@ export default {
.line-charts { .line-charts {
padding-left: 10px; padding-left: 10px;
}</style>
\ No newline at end of file \ No newline at end of file
}
</style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<!-- 线路弹框 --> <!-- 线路弹框 -->
<!-- <el-dialog id="fenceModal" :visible="fenceModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="800px"> --> <!-- <el-dialog id="fenceModal" :visible="fenceModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="800px"> -->
<v-layout > <v-layout>
<template slot="breadcrumb"> <template slot="breadcrumb">
<el-breadcrumb-item>车辆监控</el-breadcrumb-item> <el-breadcrumb-item>车辆监控</el-breadcrumb-item>
<el-breadcrumb-item @click="addMode">{{isEditMode?'编辑线路':'新增线路'}}</el-breadcrumb-item> <el-breadcrumb-item @click="addMode">{{
</template> isEditMode ? "编辑线路" : "新增线路"
<template slot="main"> }}</el-breadcrumb-item>
<!-- 线路调用地图弹框 --> </template>
<div class="ibox-content" style="height: 500px; padding:0 20px;z-index: 100"> <template slot="main">
<fence-map <!-- 线路调用地图弹框 -->
:mapData="mapData" <div
@onUpdateMapData="updateMapData" class="ibox-content"
:readonlyStatus="readonlyStatus" style="height: 500px; padding: 0 20px; z-index: 100"
ref="fenceMap" >
> <fence-map
</fence-map> :mapData="mapData"
</div> @onUpdateMapData="updateMapData"
<!-- 线路调用地图弹框 /--> :readonlyStatus="readonlyStatus"
<div class="tab_wrap"> ref="fenceMap"
<el-tabs type="card" v-show="hideTab"> >
<el-tab-pane label="线路基础信息"> </fence-map>
<div class="ibox-content scrollbar" style="padding: 30px 20px; overflow-y:auto;height: 100px;"> </div>
<el-form ref="fenceForm" :model="form" :rules="rules" :inline="false" size="mini" label-width="100px"> <!-- 线路调用地图弹框 /-->
<el-row> <div class="tab_wrap">
<!-- <el-col :span="12"> <el-tabs type="card" v-show="hideTab">
<el-tab-pane label="线路基础信息">
<div
class="ibox-content scrollbar"
style="padding: 30px 20px; overflow-y: auto; height: 100px"
>
<el-form
ref="fenceForm"
:model="form"
:rules="rules"
:inline="false"
size="mini"
label-width="100px"
>
<el-row>
<!-- <el-col :span="12">
<el-form-item label="线路编号" prop="fenceNo"> <el-form-item label="线路编号" prop="fenceNo">
<el-input v-model="form.fenceNo" disabled></el-input> <el-input v-model="form.fenceNo" disabled></el-input>
</el-form-item> </el-form-item>
</el-col> --> </el-col> -->
<el-col :span="12"> <el-col :span="12">
<el-form-item label="线路名称" prop="fenceName"> <el-form-item label="线路名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" maxlength="200" :disabled="readonlyStatus"></el-input> <el-input
</el-form-item> v-model.trim="form.fenceName"
</el-col> maxlength="200"
<el-col :span="12"> :disabled="readonlyStatus"
<el-form-item label="线路类型" prop="bizFenceType"> ></el-input>
<el-radio value="12" label="12" :disabled="readonlyStatus">试驾线路</el-radio> </el-form-item>
<!-- <el-radio v-model="form.bizFenceType" :label="1" :disabled="isEditMode">试乘试驾型</el-radio> --> </el-col>
</el-form-item> <el-col :span="12">
</el-col> <el-form-item label="线路类型" prop="bizFenceType">
</el-row> <el-radio value="12" label="12" :disabled="readonlyStatus"
<el-row> >试驾线路</el-radio
<el-col :span="12"> >
<el-form-item label="区域类型" prop="shapeType"> <!-- <el-radio v-model="form.bizFenceType" :label="1" :disabled="isEditMode">试乘试驾型</el-radio> -->
<el-radio-group v-model="form.shapeType" @change="shapeTypeChange" > </el-form-item>
<!-- <el-radio-button label="4" value="4" >行政区域</el-radio-button> --> </el-col>
<!-- <el-radio-button label="1" value="1" :disabled="readonlyStatus">圆形</el-radio-button> --> </el-row>
<el-radio-button label="3" value="3" :disabled="readonlyStatus">多边形</el-radio-button> <el-row>
</el-radio-group> <el-col :span="12">
</el-form-item> <el-form-item label="区域类型" prop="shapeType">
</el-col> <el-radio-group
<el-col :span="12"> v-model="form.shapeType"
<el-form-item class="special-shop-input" label="特约店" prop="specialShop"> @change="shapeTypeChange"
<!-- <el-cascader >
<!-- <el-radio-button label="4" value="4" >行政区域</el-radio-button> -->
<!-- <el-radio-button label="1" value="1" :disabled="readonlyStatus">圆形</el-radio-button> -->
<el-radio-button
label="3"
value="3"
:disabled="readonlyStatus"
>多边形</el-radio-button
>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
class="special-shop-input"
label="特约店"
prop="specialShop"
>
<!-- <el-cascader
v-model="form.specialShopName" v-model="form.specialShopName"
:value="form.specialShopName" :value="form.specialShopName"
:placeholder="form.specialShopName || '请选择特约店名称'" :placeholder="form.specialShopName || '请选择特约店名称'"
...@@ -64,35 +97,53 @@ ...@@ -64,35 +97,53 @@
size="small" size="small"
:disabled="readonlyStatus" :disabled="readonlyStatus"
></el-cascader> --> ></el-cascader> -->
<el-popover <el-popover
v-model="filterVisible" v-model="filterVisible"
placement="top-end" placement="top-end"
width="400" width="400"
@show="selectStore" @show="selectStore"
trigger="click"> trigger="click"
<div v-loading="loading"> >
<el-input placeholder="输入关键字进行过滤" v-model="filterText" size="small"> <div v-loading="loading">
</el-input> <el-input
placeholder="输入关键字进行过滤"
v-model="filterText"
size="small"
>
</el-input>
<el-tree style="max-height:50vh;overflow:auto" class="filter-tree" :data="filterTextData" :filter-node-method="filterNode" highlight-current ref="tree" node-key="id" check-on-click-node> <el-tree
</el-tree> style="max-height: 50vh; overflow: auto"
<p style="text-align: right; margin-top: 10px"> class="filter-tree"
<el-button @click="filterConfirm" type="primary">确定</el-button> :data="filterTextData"
<el-button @click="closeFilter">取消</el-button> :filter-node-method="filterNode"
</p> highlight-current
</div> ref="tree"
<el-input node-key="id"
v-model="form.specialShopName" check-on-click-node
:placeholder="form.specialShopName || '请选择特约店名称'" >
slot="reference" </el-tree>
> <p style="text-align: right; margin-top: 10px">
</el-input> <el-button @click="filterConfirm" type="primary"
</el-popover> >确定</el-button
</el-form-item> >
</el-col> <el-button @click="closeFilter">取消</el-button>
</el-row> </p>
<!-- <el-row> --> </div>
<!-- <el-col :span="12"> <el-input
v-model="form.specialShopName"
:placeholder="
form.specialShopName || '请选择特约店名称'
"
slot="reference"
>
</el-input>
</el-popover>
</el-form-item>
</el-col>
</el-row>
<!-- <el-row> -->
<!-- <el-col :span="12">
<el-form-item label="监控类型" prop="electricFenceType"> <el-form-item label="监控类型" prop="electricFenceType">
<el-select v-model="form.electricFenceType" placeholder="请选择" size="small" style="width:100px;"> <el-select v-model="form.electricFenceType" placeholder="请选择" size="small" style="width:100px;">
<el-option label="驶入" :value="1"></el-option> <el-option label="驶入" :value="1"></el-option>
...@@ -101,8 +152,8 @@ ...@@ -101,8 +152,8 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> --> </el-col> -->
<!-- <el-col :span="12"> --> <!-- <el-col :span="12"> -->
<!-- <el-form-item label="监控时间" prop="electricTimeFenceType" class="is-required"> <!-- <el-form-item label="监控时间" prop="electricTimeFenceType" class="is-required">
<el-select v-model="form.electricTimeFenceType" placeholder="请选择时间" size="small" class="el-slect"> <el-select v-model="form.electricTimeFenceType" placeholder="请选择时间" size="small" class="el-slect">
<el-option <el-option
v-for="item in form.electricTimeFenceTypes" v-for="item in form.electricTimeFenceTypes"
...@@ -112,7 +163,7 @@ ...@@ -112,7 +163,7 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> --> </el-form-item> -->
<!-- <el-form-item label="监控时间" prop="timeType"> <!-- <el-form-item label="监控时间" prop="timeType">
<el-radio-group v-model="form.timeType"> <el-radio-group v-model="form.timeType">
<el-radio :label=1> <el-radio :label=1>
永久有效 永久有效
...@@ -138,8 +189,8 @@ ...@@ -138,8 +189,8 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> --> </el-row> -->
<!-- <el-row> <!-- <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="描述"> <el-form-item label="描述">
<el-input v-model.trim="form.des" type="textarea" rows="3" maxlength="500"></el-input> <el-input v-model.trim="form.des" type="textarea" rows="3" maxlength="500"></el-input>
...@@ -157,8 +208,8 @@ ...@@ -157,8 +208,8 @@
</el-col> </el-col>
</el-row> --> </el-row> -->
<!-- <el-row> <!-- <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="区域类型" class="is-required"> <el-form-item label="区域类型" class="is-required">
<el-radio-group v-model="form.shapeType" @change="shapeTypeChange"> <el-radio-group v-model="form.shapeType" @change="shapeTypeChange">
...@@ -170,11 +221,11 @@ ...@@ -170,11 +221,11 @@
<div class="tab-content" v-show="form.shapeType==3"> <div class="tab-content" v-show="form.shapeType==3">
<el-form-item prop="area"> --> <el-form-item prop="area"> -->
<!-- 监控省市区组件 --> <!-- 监控省市区组件 -->
<!-- <area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="areaCode"></area-select> --> <!-- <area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="areaCode"></area-select> -->
<!-- 监控省市区组件 /--> <!-- 监控省市区组件 /-->
<!-- </el-form-item> <!-- </el-form-item>
</div> </div>
<div class="tab-content" v-show="form.shapeType==2"> <div class="tab-content" v-show="form.shapeType==2">
...@@ -201,11 +252,13 @@ ...@@ -201,11 +252,13 @@
<el-button type="primary" @click="updateFence">更新线路</el-button> <el-button type="primary" @click="updateFence">更新线路</el-button>
</el-form-item> </el-form-item>
</el-col> --> </el-col> -->
<!-- </div> --> <!-- </div> -->
<div class="tab-content shape_tip" v-show="form.shapeType==3">*注:地图任意位置,单击新增双击结束绘制。</div> <div class="tab-content shape_tip" v-show="form.shapeType == 3">
<!-- </el-col> --> *注:地图任意位置,单击新增双击结束绘制。
<!-- <el-col :span="12"> </div>
<!-- </el-col> -->
<!-- <el-col :span="12">
<el-form-item label="短信通知" prop="msgtel"> <el-form-item label="短信通知" prop="msgtel">
<el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input> <el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item> </el-form-item>
...@@ -214,136 +267,194 @@ ...@@ -214,136 +267,194 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> --> </el-row> -->
</el-form> </el-form>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="关联对象" v-loadmore='loadMore'> <el-tab-pane label="关联对象" v-loadmore="loadMore">
<div style="float: right;"> <div style="float: right">
<el-button v-if="!readonlyStatus" type="primary" @click="userDate" size="small" :loading="submitting">关联用户</el-button> <el-button
<!-- <el-button size="small" @click="deleteFenceModel">批量删除</el-button> --> v-if="!readonlyStatus"
</div> type="primary"
<el-table @click="userDate"
:data="tableData" size="small"
border :loading="submitting"
height="300" >关联用户</el-button
size="small" >
v-loading="loading" <!-- <el-button size="small" @click="deleteFenceModel">批量删除</el-button> -->
</div>
@selection-change="selectChange" <el-table
style="width: 100%;margin-bottom:40px"> :data="tableData"
<el-table-column :disabled="readonlyStatus" type="selection" width="40" align="center"></el-table-column> border
<el-table-column fixed type="index" label="序号" :index="getIndex" align="center" width="70"></el-table-column> height="300"
size="small"
v-loading="loading"
@selection-change="selectChange"
style="width: 100%; margin-bottom: 40px"
>
<el-table-column
:disabled="readonlyStatus"
type="selection"
width="40"
align="center"
></el-table-column>
<el-table-column
fixed
type="index"
label="序号"
:index="getIndex"
align="center"
width="70"
></el-table-column>
<el-table-column fixed prop="name" label="姓名" min-width="80" align="center"></el-table-column> <el-table-column
<el-table-column fixed prop="vin" label="车架号" min-width="160" align="center"></el-table-column> fixed
prop="name"
label="姓名"
min-width="80"
align="center"
></el-table-column>
<el-table-column
fixed
prop="vin"
label="车架号"
min-width="160"
align="center"
></el-table-column>
<el-table-column prop="sn" label="设备号" min-width="160" align="center"> <el-table-column
prop="sn"
</el-table-column> label="设备号"
min-width="160"
align="center"
>
</el-table-column>
<!-- <el-table-column prop="gpsTime" label="GPS时间" min-width="100" align="center"> <!-- <el-table-column prop="gpsTime" label="GPS时间" min-width="100" align="center">
</el-table-column> </el-table-column>
<el-table-column prop="address" label="位置" min-width="200" align="center"></el-table-column> --> <el-table-column prop="address" label="位置" min-width="200" align="center"></el-table-column> -->
<el-table-column prop="userTel" label="联系方式" min-width="100" align="center"></el-table-column> <el-table-column
prop="userTel"
label="联系方式"
min-width="100"
</el-table> align="center"
</el-tab-pane> ></el-table-column>
</el-tabs> </el-table>
<!-- <div class="tab_ctrl"> </el-tab-pane>
</el-tabs>
<!-- <div class="tab_ctrl">
<el-button size="small" type="primary" :fenceMapModalVisible="fenceMapModalVisible" @click="changeStatus" style="width: 65px;">展开</el-button> <el-button size="small" type="primary" :fenceMapModalVisible="fenceMapModalVisible" @click="changeStatus" style="width: 65px;">展开</el-button>
<i :class="!hideTab?'fa fa-angle-double-up':'fa fa-angle-double-down'" style="position: absolute;top:9px;left:5px;color:#fff;"></i> <i :class="!hideTab?'fa fa-angle-double-up':'fa fa-angle-double-down'" style="position: absolute;top:9px;left:5px;color:#fff;"></i>
</div> --> </div> -->
</div> </div>
<div class="fenceModalfooter"> <div class="fenceModalfooter">
<el-button v-if="!readonlyStatus" type="primary" @click="saveFence" size="small" :loading="submitting">{{btnText}}</el-button> <el-button
<el-button @click="cancel" size="small">取消</el-button> v-if="!readonlyStatus"
</div> type="primary"
<user-list @click="saveFence"
:init="userListInit" size="small"
@onUserListInit="(res)=>userListInit=res" :loading="submitting"
:userData="userArr" >{{ btnText }}</el-button
@onUpdateUserData="updateUserData" >
:userListModalVisible="userListModalVisible" <el-button @click="cancel" size="small">取消</el-button>
:shopId="form.specialShopId" </div>
@onUserListModalChange="userListModalChange" <user-list
ref="userList"> :init="userListInit"
</user-list> @onUserListInit="(res) => (userListInit = res)"
</template> :userData="userArr"
<!-- </el-dialog> --> @onUpdateUserData="updateUserData"
<!-- 线路弹框 /--> :userListModalVisible="userListModalVisible"
</v-layout> :shopId="form.specialShopId"
@onUserListModalChange="userListModalChange"
ref="userList"
>
</user-list>
</template>
<!-- </el-dialog> -->
<!-- 线路弹框 /-->
</v-layout>
</template> </template>
<script> <script>
import {services} from '../../api' import { services } from "../../api";
import AreaSelect from './AreaSelect.vue' import AreaSelect from "./AreaSelect.vue";
import mapService from 'utils/mapService.js' import mapService from "utils/mapBService.js";
import fenceMap from './fenceMap.vue' import fenceMap from "./fenceMap.vue";
import userList from './userList.vue' import userList from "./userList.vue";
import InfiniteLoading from 'vue-infinite-loading'; import InfiniteLoading from "vue-infinite-loading";
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
export default{ export default {
props: ['fenceModalVisible', 'fenceId'], props: ["fenceModalVisible", "fenceId"],
data(){ data() {
let checkFenceName = (rule, vaule, cb)=>{ let checkFenceName = (rule, vaule, cb) => {
if(typeof this.restainFenceName != 'undefined' && this.form.fenceName === this.restainFenceName){ if (
cb(); typeof this.restainFenceName != "undefined" &&
} this.form.fenceName === this.restainFenceName
// MONITOR_SERVICE.checkFenceName({name: this.form.fenceName}).then((res)=>{ ) {
// if(res.returnCode == 0){ cb();
// if(res.data.isExist == 1){ }
// cb(new Error('该线路名已存在,请重新输入!')) // MONITOR_SERVICE.checkFenceName({name: this.form.fenceName}).then((res)=>{
// }else{ // if(res.returnCode == 0){
// cb(); // if(res.data.isExist == 1){
// } // cb(new Error('该线路名已存在,请重新输入!'))
// } // }else{
// }) // cb();
} // }
let checkMonitorTime = (rule, vaule, cb)=>{ // }
if(this.form.electricTimeFenceType==""){ // })
cb(new Error('请选择监控时间')) };
}else{ let checkMonitorTime = (rule, vaule, cb) => {
cb(); if (this.form.electricTimeFenceType == "") {
} cb(new Error("请选择监控时间"));
} } else {
cb();
}
};
let checkSpecialShop = (rule, vaule, cb)=>{ let checkSpecialShop = (rule, vaule, cb) => {
if(this.form.specialShopId == ""){ if (this.form.specialShopId == "") {
cb(new Error('请选择特约店')) cb(new Error("请选择特约店"));
}else{ } else {
cb(); cb();
} }
} };
let checkArea = (rule, vaule, cb)=>{ let checkArea = (rule, vaule, cb) => {
if(this.form.shapeType == 1 && !this.form.areaCode){ if (this.form.shapeType == 1 && !this.form.areaCode) {
cb(new Error('请选择行政区域')) cb(new Error("请选择行政区域"));
}else{ } else {
cb(); cb();
} }
} };
let checkLng = (rule, vaule, cb)=>{ let checkLng = (rule, vaule, cb) => {
if(this.form.shapeType == 2 && !/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(this.form.lng)){ if (
cb(new Error('请输入正确的格式')) this.form.shapeType == 2 &&
}else{ !/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(
cb(); this.form.lng
} )
} ) {
cb(new Error("请输入正确的格式"));
} else {
cb();
}
};
let checkLat = (rule, vaule, cb)=>{ let checkLat = (rule, vaule, cb) => {
if(this.form.shapeType == 2 && !/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(this.form.lat)){ if (
cb(new Error('请输入正确的格式')) this.form.shapeType == 2 &&
}else{ !/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(
cb(); this.form.lat
} )
} ) {
cb(new Error("请输入正确的格式"));
} else {
cb();
}
};
let checkTransferAddr = (rule, vaule, cb)=>{ let checkTransferAddr = (rule, vaule, cb) => {
/*if(this.form.shapeType == 2){ /*if(this.form.shapeType == 2){
if(this.transferError){ if(this.transferError){
cb(new Error('所填经纬度不能正确解析地址,请重新输入')) cb(new Error('所填经纬度不能正确解析地址,请重新输入'))
}else{ }else{
...@@ -352,205 +463,207 @@ export default{ ...@@ -352,205 +463,207 @@ export default{
}else{ }else{
cb(); cb();
}*/ }*/
if(this.form.shapeType == 1){ if (this.form.shapeType == 1) {
if(this.transferError){ if (this.transferError) {
cb(new Error('所填经纬度不能正确解析地址,请重新输入')); cb(new Error("所填经纬度不能正确解析地址,请重新输入"));
}else{ } else {
cb(); cb();
} }
}else{ } else {
cb() cb();
} }
};
} let checkRadius = (rule, vaule, cb) => {
let checkRadius = (rule, vaule, cb)=>{ if (this.form.shapeType == 1 && !/^\d+$/.test(this.form.radius)) {
if(this.form.shapeType == 1 && !/^\d+$/.test(this.form.radius)){console.log(this.form.radius) console.log(this.form.radius);
cb(new Error('请输入正确的格式,不能输入小数点')) cb(new Error("请输入正确的格式,不能输入小数点"));
}else{ } else {
cb(); cb();
} }
} };
let checkDaterange = (rule, vaule, 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];
const dateRange = this.form.dateRange; if (!moment.isMoment(min)) {
if(!dateRange || !dateRange.length){ min = moment(min);
cb(new Error('请选择日期')) }
}else{ if (!moment.isMoment(max)) {
let min = dateRange[0]; max = moment(max);
let max = dateRange[1]; }
if(!moment.isMoment(min)){ if (min.isBefore(moment(max).subtract(30 * 6, "days"), "minute")) {
min = moment(min) cb(new Error("日期范围不能超过180天"));
} }
if(!moment.isMoment(max)){ }
max = moment(max) cb();
} };
let checkMsgtel = (rule, vaule, cb) => {
if(min.isBefore( moment(max).subtract(30*6, 'days'), 'minute')){ if (this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)) {
cb(new Error('日期范围不能超过180天')) cb(new Error("请输入正确的格式"));
} } else {
} cb();
cb() }
} };
let checkMsgtel = (rule, vaule, cb)=>{ /*let checkMap = (rule, vaule, cb)=>{
if(this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)){
cb(new Error('请输入正确的格式'))
}else{
cb();
}
}
/*let checkMap = (rule, vaule, cb)=>{
if(this.form.shapeType == 2 && !this.mapData.lng && !this.mapData.lat && !this.mapData.radius && !this.mapData.address){ if(this.form.shapeType == 2 && !this.mapData.lng && !this.mapData.lat && !this.mapData.radius && !this.mapData.address){
cb(new Error('请打开地图自定义设置')) cb(new Error('请打开地图自定义设置'))
}else{ }else{
cb(); cb();
} }
} */ } */
return { return {
scrollToRef: '', scrollToRef: "",
tableData:[], tableData: [],
//dateRange: [], //dateRange: [],
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
maxPage:1, maxPage: 1,
submitting: false, submitting: false,
userArr:[], userArr: [],
userData:[], userData: [],
areaString:'', areaString: "",
hideTab:true, hideTab: true,
needInfinite: false, needInfinite: false,
fenceMapModalVisible:false, fenceMapModalVisible: false,
areaCode:null, areaCode: null,
btnText: '保存', btnText: "保存",
specialShopOptions: [], specialShopOptions: [],
specialShopDefaultProps: { specialShopDefaultProps: {
children: 'children', children: "children",
label: 'label', label: "label",
value: 'id' value: "id",
}, },
readonlyStatus: false, readonlyStatus: false,
form: { form: {
fenceName: '', fenceName: "",
bizFenceType: '12', bizFenceType: "12",
shapeType: 3, shapeType: 3,
specialShopId: '', specialShopId: "",
specialShopName: '', specialShopName: "",
// fenceNo: '', // fenceNo: '',
electricFenceType: 1, electricFenceType: 1,
startTime: '', startTime: "",
endTime: '', endTime: "",
des: '', des: "",
areaCode: '', areaCode: "",
analysisAddress: '', analysisAddress: "",
lng: '', lng: "",
lat: '', lat: "",
radius: 1000, radius: 1000,
status: 1, status: 1,
transferError: false, transferError: false,
timeType:2, timeType: 2,
electricTimeFenceType:'', electricTimeFenceType: "",
electricTimeFenceTypes: [ electricTimeFenceTypes: [
{ {
value: 1, value: 1,
label: '1个月' label: "1个月",
}, { },
value: 2, {
label: '2个月' value: 2,
}, { label: "2个月",
value: 3, },
label: '3个月' {
}, { value: 3,
value: 4, label: "3个月",
label: '4个月' },
}, { {
value: 5, value: 4,
label: '5个月' label: "4个月",
}, { },
value: 6, {
label: '6个月' value: 5,
} label: "5个月",
], },
dateRange: [], {
msgtel: '' value: 6,
}, label: "6个月",
restainFenceName: '', },
rules: { ],
// fenceNo: [ dateRange: [],
// {required: true, message: '线路编号不能为空', trigger: 'blur'}, msgtel: "",
// ], },
fenceName: [ restainFenceName: "",
{required: true, message: '请输入线路名称', trigger: 'blur'}, rules: {
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' }, // fenceNo: [
// {validator: checkFenceName, trigger: 'blur'} // {required: true, message: '线路编号不能为空', trigger: 'blur'},
], // ],
bizFenceType: [ fenceName: [
{required: true, message: '请选择线路类型', trigger: 'change'} { required: true, message: "请输入线路名称", trigger: "blur" },
], { pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
specialShop: [ // {validator: checkFenceName, trigger: 'blur'}
{required: true, validator: checkSpecialShop, trigger: 'change'} ],
], bizFenceType: [
shapeType: [ { required: true, message: "请选择线路类型", trigger: "change" },
{required: true} ],
] specialShop: [
// electricFenceType: [ { required: true, validator: checkSpecialShop, trigger: "change" },
// {required: true, message: '', trigger: 'blur'} ],
// ], shapeType: [{ required: true }],
// electricTimeFenceType:[ // electricFenceType: [
// {required: true, validator: checkMonitorTime, trigger: 'change'} // {required: true, message: '', trigger: 'blur'}
// ], // ],
// electricTimeFenceType:[
/*dateRange: [ // {required: true, validator: checkMonitorTime, trigger: 'change'}
// ],
/*dateRange: [
{validator: checkMonitorTime, trigger: 'change'} {validator: checkMonitorTime, trigger: 'change'}
],*/ ],*/
// area: [ // area: [
// {validator: checkArea, trigger: 'change'} // {validator: checkArea, trigger: 'change'}
// ], // ],
// lng: [ // lng: [
// {validator: checkLng, trigger: 'blur'} // {validator: checkLng, trigger: 'blur'}
// ], // ],
// lat: [ // lat: [
// {validator: checkLat, trigger: 'blur'} // {validator: checkLat, trigger: 'blur'}
// ], // ],
// analysisAddress: [ // analysisAddress: [
// {validator: checkTransferAddr, trigger: 'change'} // {validator: checkTransferAddr, trigger: 'change'}
// ], // ],
// radius: [ // radius: [
// {validator: checkRadius, trigger: 'blur'} // {validator: checkRadius, trigger: 'blur'}
// ], // ],
// daterange: [{validator: checkDaterange}], // daterange: [{validator: checkDaterange}],
// timeType:[{required: true, message: '请选择监控时间', trigger: 'change'}], // timeType:[{required: true, message: '请选择监控时间', trigger: 'change'}],
// msgtel: [ // msgtel: [
// {validator: checkMsgtel, trigger: 'blur'} // {validator: checkMsgtel, trigger: 'blur'}
// ], // ],
/*map: [ /*map: [
{validator: checkMap, trigger: 'blur'} {validator: checkMap, trigger: 'blur'}
]*/ ]*/
}, },
transferTimeoutId: undefined, transferTimeoutId: undefined,
geocoder: null, geocoder: null,
transferFlag: null, transferFlag: null,
transferError: false, transferError: false,
userListModalVisible:false, userListModalVisible: false,
selectedIds: [], selectedIds: [],
mapData: null, mapData: null,
polygonPath: [], polygonPath: [],
loading: true, loading: true,
filterVisible: false, filterVisible: false,
filterText: "", filterText: "",
filterTextData: [], filterTextData: [],
// polygonPath: [ // polygonPath: [
// ["113.989993", "22.588762"], // ["113.989993", "22.588762"],
// ["113.993298", "22.590585"], // ["113.993298", "22.590585"],
// ["113.996431", "22.58892"], // ["113.996431", "22.58892"],
// ["113.99274", "22.586622"], // ["113.99274", "22.586622"],
// ["113.99008", "22.585592"] // ["113.99008", "22.585592"]
// ] // ]
} };
}, },
watch: { watch: {
/*dateRange(newVal){ /*dateRange(newVal){
if(newVal && newVal.length){ if(newVal && newVal.length){
this.form.startTime = moment(newVal[0]).format('YYYY-MM-DD HH:mm:ss'); this.form.startTime = moment(newVal[0]).format('YYYY-MM-DD HH:mm:ss');
this.form.endTime = moment(newVal[1]).format('YYYY-MM-DD HH:mm:ss'); this.form.endTime = moment(newVal[1]).format('YYYY-MM-DD HH:mm:ss');
...@@ -559,65 +672,61 @@ export default{ ...@@ -559,65 +672,61 @@ export default{
this.form.endTime = ''; this.form.endTime = '';
} }
},*/ },*/
lng(newVal){ lng(newVal) {
//this.transfer() //this.transfer()
}, },
lat(newVal){ lat(newVal) {
//this.transfer() //this.transfer()
}, },
filterText(val) { filterText(val) {
this._timeout && clearTimeout(this._timeout);
this._timeout && clearTimeout(this._timeout) this._timeout = setTimeout(() => {
this._timeout = setTimeout(()=>{ this.$refs.tree.filter(val);
this.$refs.tree.filter(val) }, 500);
},500) },
},
} computed: {
isEditMode: {
}, get() {
computed: { return typeof this.fenceId != "undefined";
isEditMode:{ },
get(){ },
return typeof this.fenceId != 'undefined' },
} created() {
} let _this = this;
//this.getFenceSnsList();
}, //this.getSpecialShopList();
created(){ window.Vue.directive("loadmore", {
let _this=this; bind(el, binding) {
//this.getFenceSnsList(); const selectWrap = el.querySelector(".el-table__body-wrapper");
//this.getSpecialShopList(); selectWrap.addEventListener("scroll", function () {
window.Vue.directive('loadmore', { let sign = 0;
bind(el, binding) { const scrollDistance =
const selectWrap = el.querySelector('.el-table__body-wrapper') this.scrollHeight - this.scrollTop - this.clientHeight;
selectWrap.addEventListener('scroll', function() { if (scrollDistance == sign) {
let sign = 0 //binding.value()
const scrollDistance = this.scrollHeight - this.scrollTop - this.clientHeight //console.log(sign)
if (scrollDistance == sign) { // _this.currentPage++;
//binding.value() // _this.getFenceSnsList(_this.fenceId);
//console.log(sign) }
// _this.currentPage++; });
},
// _this.getFenceSnsList(_this.fenceId); });
}
})
}
})
this.getStoreList() this.getStoreList();
}, },
mounted() { mounted() {
this.listener(); this.listener();
}, },
methods: { methods: {
selectStore() { selectStore() {
if (this.isReadonly) return; if (this.isReadonly) return;
this.filterText = ""; this.filterText = "";
this.filterDialogTitle = "选择所属组织"; this.filterDialogTitle = "选择所属组织";
if(!this.filterTextData.length) { if (!this.filterTextData.length) {
this.getStoreList(); this.getStoreList();
} }
//this.closeFilter(); //this.closeFilter();
}, },
closeFilter() { closeFilter() {
...@@ -627,7 +736,7 @@ export default{ ...@@ -627,7 +736,7 @@ export default{
getStoreList() { getStoreList() {
let _this = this; let _this = this;
_this.loading = true; _this.loading = true;
MONITOR_SERVICE.getOrgTree({hasUserLeaf: true}).then((res) => { MONITOR_SERVICE.getOrgTree({ hasUserLeaf: true }).then((res) => {
const { code, data } = res; const { code, data } = res;
_this.loading = false; _this.loading = false;
if (code == 200) { if (code == 200) {
...@@ -637,15 +746,15 @@ export default{ ...@@ -637,15 +746,15 @@ export default{
}, },
filterConfirm() { filterConfirm() {
const { label, id, origin } = this.$refs.tree.getCurrentNode(); const { label, id, origin } = this.$refs.tree.getCurrentNode();
if (origin.type != 'u') { if (origin.type != "u") {
this.$message({ this.$message({
message: "请选择下级所属组织", message: "请选择下级所属组织",
type: "error", type: "error",
}); });
return; return;
} }
this.form.specialShopName = label.split('/')[1] this.form.specialShopName = label.split("/")[1];
this.form.specialShopCode = label.split('/')[0] this.form.specialShopCode = label.split("/")[0];
//this.$set(this, "form.specialShopName", label); //this.$set(this, "form.specialShopName", label);
this.form.specialShopId = id; this.form.specialShopId = id;
this.closeFilter(); this.closeFilter();
...@@ -655,172 +764,165 @@ export default{ ...@@ -655,172 +764,165 @@ export default{
if (!value) return true; if (!value) return true;
return data.label.indexOf(value) !== -1; return data.label.indexOf(value) !== -1;
}, },
listener() { async listener() {
const state = history.state; const state = history.state;
if(!state) { if (!state) {
this.init(null); this.init(null);
return; return;
} }
const { fenceId, readonlyStatus, btnRemark } = state; const { fenceId, readonlyStatus, btnRemark } = state;
if(readonlyStatus) { if (readonlyStatus) {
this.readonlyStatus = readonlyStatus; this.readonlyStatus = readonlyStatus;
this.fenceId = fenceId; this.fenceId = fenceId;
} }
this.init(btnRemark); await this.$refs.fenceMap.initBMap()
}, this.init(btnRemark);
init(btnRemark){ },
const { id, btnText } = this.$route.query; init(btnRemark) {
if(id) { const { id, btnText } = this.$route.query;
this.fenceId = id; if (id) {
this.btnText = btnText; this.fenceId = id;
} this.btnText = btnText;
if(typeof this.fenceId != 'undefined'){ }
btnRemark === 'viewUpdated' ? this.getUpdatedFenceDetail(this.fenceId) :this.getFenceDetail(this.fenceId);; if (typeof this.fenceId != "undefined") {
}else{ console.log(1)
// 线路编号无意义 屏蔽 btnRemark === "viewUpdated"
// MONITOR_SERVICE.getNewFenceId().then((res)=>{ ? this.getUpdatedFenceDetail(this.fenceId)
// if(res.returnCode == 0){ : this.getFenceDetail(this.fenceId);
// this.form.fenceNo = res.data.fenceNo; } else {
this.$refs.fenceMap.initFence({
fenceType: "polygon",
polygonPath: this.polygonPath,
});
// 新增定位到当前位置
AMap.invoke("LocalCity", (res) => {
AMap.invoke('panTo',res.center)
});
this.restainFenceName = undefined;
}
},
getSpecialShopList() {
MONITOR_SERVICE.getSpecialShopList().then((res) => {
const { code, data } = res;
if (code == 200) {
this.specialShopOptions = data;
}
});
},
getDetailData(res, id) {
if (res.code == 200) {
const form = this.form;
const data = res.data;
for (let key in data) {
form[key] = data[key];
}
this.form.shapeType = 3;
this.form.dateRange = [form.startTime, form.endTime];
this.areaCode = form.areaCode;
this.restainFenceName = form.fenceName;
this.form.fenceName = form.fenceName;
this.form.msgtel = data.telNumbers;
this.form.specialShopId = data.shopId;
this.form.specialShopName = data.shopName;
this.form.specialShopCode = data.shopCode;
this.getFenceSnsList(id, "", data.snList);
// this.$refs.fenceMap.initFence({ if (form.shapeType === 1) {
// fenceType: 'circle' this.mapData = {
// }); fenceType: "circle",
// } lng: form.lng,
// }); lat: form.lat,
radius: form.radius,
};
} else if (form.shapeType === 4) {
this.mapData = {
fenceType: "area",
areaCode: this.form.areaCode,
};
} else if (form.shapeType === 3) {
if (data.lnglat) {
this.polygonPath = data.lnglat.split("|").map((item) => {
let arr = item.split(",");
return mapService.getLngLat(arr[0], arr[1]);
});
}
this.$refs.fenceMap.initFence({ this.mapData = {
fenceType: 'polygon', fenceType: "polygon",
polygonPath: this.polygonPath polygonPath: this.polygonPath,
}); };
}
this.restainFenceName = undefined;
}
},
getSpecialShopList() {
MONITOR_SERVICE.getSpecialShopList().then(res => {
const { code, data } = res;
if(code == 200) {
this.specialShopOptions = data;
}
})
},
getDetailData(res, id) {
if(res.code == 200){
const form = this.form;
const data = res.data;
for(let key in data){
form[key] = data[key]
}
this.form.shapeType = 3;
this.form.dateRange = [form.startTime, form.endTime];
this.areaCode = form.areaCode
this.restainFenceName = form.fenceName;
this.form.fenceName = form.fenceName;
this.form.msgtel = data.telNumbers;
this.form.specialShopId = data.shopId;
this.form.specialShopName = data.shopName;
this.form.specialShopCode = data.shopCode;
this.getFenceSnsList(id, '', data.snList)
if(form.shapeType === 1){ this.$refs.fenceMap.initFence(this.mapData);
this.mapData = { }
fenceType: 'circle', },
lng: form.lng, getFenceDetail(id) {
lat: form.lat, MONITOR_SERVICE.getFenceDetailById({ fenceId: id }).then((res) => {
radius: form.radius, this.getDetailData(res, id);
} });
}else if(form.shapeType === 4){ },
this.mapData = { getUpdatedFenceDetail(id) {
fenceType: 'area', MONITOR_SERVICE.getUpdatedFenceDetail({ fenceId: id }).then((res) => {
areaCode: this.form.areaCode this.getDetailData(res, id);
} });
}else if(form.shapeType === 3){ },
if(data.lnglat){ getFenceSnsList(id, cur, resData) {
this.polygonPath = data.lnglat.split('|').map((item)=>{ let params = {};
return [item.split(',')[0], item.split(',')[1]] params.id = id;
}) this.tableData = this.tableData.concat(resData);
} this.$refs.userList.reset(resData);
// if(this.currentPage>this.maxPage){
// return;
// }
// if(cur){
console.log(this.polygonPath) // params.currentPage =cur;
this.mapData = { // params.pageSize = this.pageSize;
fenceType: 'polygon', // }else{
polygonPath: this.polygonPath // params.currentPage =this.currentPage;
} // params.pageSize = this.pageSize;
} // }
this.$refs.fenceMap.initFence(this.mapData); // params.id=id;
} // MONITOR_SERVICE.getFenceSnsList(params).then((res)=>{
}, // if(res.c == 0){
getFenceDetail(id){
MONITOR_SERVICE.getFenceDetailById({fenceId: id}).then((res)=>{ // this.tableData = this.tableData.concat(resData);
this.getDetailData(res, id); // this.maxPage = Math.ceil(resData.recordsTotal/this.pageSize);
}); // this.$refs.userList.reset(resData);
},
getUpdatedFenceDetail(id){ // }
MONITOR_SERVICE.getUpdatedFenceDetail({fenceId: id}).then((res)=>{ // });
this.getDetailData(res, id); },
}); shapeTypeChange() {
}, //console.log(this.form.shapeType)
getFenceSnsList(id, cur, resData){ if (this.form.shapeType == 4) {
let params = {}; //this.$refs.clearArea.rest();
params.id=id; this.$refs.fenceForm.clearValidate();
this.tableData = this.tableData.concat(resData); //this.$refs.fenceMap.updateSeach(this.form.areaCode);
this.$refs.userList.reset(resData); this.$refs.fenceMap.updateFence({
// if(this.currentPage>this.maxPage){ fenceType: "area",
// return; });
// } } else if (this.form.shapeType == 1) {
// if(cur){ this.$refs.fenceMap.updateFence({
fenceType: "circle",
// params.currentPage =cur; });
// params.pageSize = this.pageSize; } else if (this.form.shapeType == 3) {
// }else{ this.$refs.fenceMap.updateFence({
// params.currentPage =this.currentPage; fenceType: "polygon",
// params.pageSize = this.pageSize; });
// } }
// if(val=="3"){
//
// }
// params.id=id; },
// MONITOR_SERVICE.getFenceSnsList(params).then((res)=>{ selectChange(selection) {
// if(res.c == 0){ this.selectedIds = [];
selection.map((obj) => {
// this.tableData = this.tableData.concat(resData); this.selectedIds.push(obj.id);
// this.maxPage = Math.ceil(resData.recordsTotal/this.pageSize); });
// this.$refs.userList.reset(resData); },
/*deleteFenceModel(id){
// }
// });
},
shapeTypeChange(){
//console.log(this.form.shapeType)
if(this.form.shapeType == 4){
//this.$refs.clearArea.rest();
this.$refs.fenceForm.clearValidate();
//this.$refs.fenceMap.updateSeach(this.form.areaCode);
this.$refs.fenceMap.updateFence({
fenceType: 'area'
});
}else if(this.form.shapeType == 1){
this.$refs.fenceMap.updateFence({
fenceType: 'circle'
});
}else if(this.form.shapeType == 3){
this.$refs.fenceMap.updateFence({
fenceType: 'polygon'
});
}
// if(val=="3"){
//
// }
},
selectChange(selection){
this.selectedIds = [];
selection.map((obj)=>{
this.selectedIds.push(obj.id)
});
},
/*deleteFenceModel(id){
let params = {}; let params = {};
let cur = this.currentPage let cur = this.currentPage
if(this.selectedIds.length){ if(this.selectedIds.length){
...@@ -842,360 +944,357 @@ export default{ ...@@ -842,360 +944,357 @@ export default{
}); });
} }
},*/ },*/
userListModalChange(isOpen){ userListModalChange(isOpen) {
this.userListModalVisible = isOpen; this.userListModalVisible = isOpen;
}, },
userDate(){ userDate() {
this.userListModalVisible=true; this.userListModalVisible = true;
}, },
/*resetMapForm(){ /*resetMapForm(){
this.form.lng = ''; this.form.lng = '';
this.form.lat = ''; this.form.lat = '';
this.form.address = ''; this.form.address = '';
this.form.radius = ''; this.form.radius = '';
},*/ },*/
/*fenceModalChange(isOpen){ /*fenceModalChange(isOpen){
this.fenceModalVisible = isOpen; this.fenceModalVisible = isOpen;
}, },
fenceMapModalChange(isOpen, mapData){ fenceMapModalChange(isOpen, mapData){
this.fenceMapModalVisible = isOpen; this.fenceMapModalVisible = isOpen;
},*/ },*/
updateUserData(data){ updateUserData(data) {
this.userArr = data; this.userArr = data;
this.tableData = data; this.tableData = data;
//console.log(data) //console.log(data)
}, },
updateMapData(data){ updateMapData(data) {
if (data.radius) {
if(data.radius){ this.form.radius = data.radius;
this.form.radius = data.radius; }
} if (data.lng && data.lat) {
if(data.lng && data.lat){ this.form.lng = data.lng;
this.form.lng = data.lng; this.form.lat = data.lat;
this.form.lat = data.lat; this.transfer();
this.transfer() }
}
if(data.polygonPath && data.polygonPath.length){
this.polygonPath = data.polygonPath
}
},
changeStatus(){
if(this.hideTab==true){
this.hideTab=false;
}else if(this.hideTab==false){
this.hideTab=true
}
},
saveFence(){
if(this.form.shapeType == 3){
if(this.polygonPath.length === 0){
this.$message({
message: '请绘制线路',
type: 'error'
});
return;
}
}
this.$refs.fenceForm.validate((valid) => {
if(valid){
this.submitting = true;
const params = this.getParams();
params.snList.forEach(item => {
if(item.sns) {
delete item.sns;
}
})
if(typeof this.fenceId != 'undefined'){
params.id = this.fenceId;
MONITOR_SERVICE.updateFence(params).then((res)=>{
if(res.code == 200){
//this.closeDialog();
this.$message({
message: '提交成功',
type: 'success'
});
history.go(-1);
// this.$router.push({path:"fenceManagement"})
} else {
this.$message({
message: res.message,
type: 'error'
});
}
this.submitting = false;
});
}else{
MONITOR_SERVICE.saveFence(params).then((res)=>{
if(res.code == 200){ if (data.polygonPath && data.polygonPath.length) {
//this.closeDialog(); this.polygonPath = data.polygonPath;
this.$message({ }
message: '提交成功', },
type: 'success' changeStatus() {
}); if (this.hideTab == true) {
history.go(-1); this.hideTab = false;
} else { } else if (this.hideTab == false) {
this.$message({ this.hideTab = true;
message: res.message, }
type: 'error' },
}); saveFence() {
} if (this.form.shapeType == 3) {
this.submitting = false; if (this.polygonPath.length === 0) {
// this.$router.push({path:"fenceManagement"}) this.$message({
}); message: "请绘制线路",
} type: "error",
});
}else{ return;
return false; }
} }
}); this.$refs.fenceForm.validate((valid) => {
if (valid) {
this.submitting = true;
const params = this.getParams();
params.snList.forEach((item) => {
if (item.sns) {
delete item.sns;
}
});
if (typeof this.fenceId != "undefined") {
params.id = this.fenceId;
MONITOR_SERVICE.updateFence(params).then((res) => {
if (res.code == 200) {
//this.closeDialog();
this.$message({
message: "提交成功",
type: "success",
});
history.go(-1);
// this.$router.push({path:"fenceManagement"})
} else {
this.$message({
message: res.message,
type: "error",
});
}
this.submitting = false;
});
} else {
MONITOR_SERVICE.saveFence(params).then((res) => {
if (res.code == 200) {
//this.closeDialog();
this.$message({
message: "提交成功",
type: "success",
});
history.go(-1);
} else {
this.$message({
message: res.message,
type: "error",
});
}
this.submitting = false;
// this.$router.push({path:"fenceManagement"})
});
}
} else {
return false;
}
});
},
cancel() {
window.history.go(-1);
// this.$router.push({path:"fenceManagement"})
},
getParams() {
const form = this.form;
const params = {};
}, // params.fenceNo = form.fenceNo;
cancel(){ params.fenceName = form.fenceName;
window.history.go(-1); // params.electricFenceType = form.electricFenceType;
// this.$router.push({path:"fenceManagement"}) //params.electricTimeFenceType = form.electricTimeFenceType
}, //params.startTime = form.startTime;
getParams(){ //params.endTime = form.endTime;
const form = this.form; params.shopId = form.specialShopId;
const params = {}; // params.des = form.des;
params.shapeType = form.shapeType;
params.timeType = form.timeType;
if (params.shapeType == 4) {
params.areaCode = form.areaCode;
params.areaString = form.areaString;
} else if (params.shapeType == 1) {
params.lnglat = `${form.lng},${form.lat}`;
params.radius = form.radius;
params.analysisAddress = form.analysisAddress;
} else if (params.shapeType == 3) {
let lnglats = this.polygonPath.map((item) => {
return item.lng + "," + item.lat;
});
params.lnglat = lnglats.join("|");
}
params.bizFenceType = form.bizFenceType;
// params.status = form.status;
if (this.tableData) {
params.snList = this.tableData;
} else {
params.snList = this.userArr;
}
if (form.timeType == 1) {
params.startTime = moment().format("YYYY-MM-DD");
params.endTime = moment().add(10, "year").format("YYYY-MM-DD");
} else {
params.startTime = moment(this.form.dateRange[0]).format("YYYY-MM-DD");
params.endTime = moment(this.form.dateRange[1]).format("YYYY-MM-DD");
}
// params.fenceNo = form.fenceNo; if (form.msgtel) {
params.fenceName = form.fenceName; params.telNumbers = form.msgtel;
// params.electricFenceType = form.electricFenceType; }
//params.electricTimeFenceType = form.electricTimeFenceType
//params.startTime = form.startTime;
//params.endTime = form.endTime;
params.shopId = form.specialShopId;
// params.des = form.des;
params.shapeType = form.shapeType;
params.timeType = form.timeType;
if(params.shapeType == 4){
params.areaCode = form.areaCode;
params.areaString = form.areaString;
}else if(params.shapeType == 1){
params.lnglat = `${form.lng},${form.lat}`;
params.radius = form.radius;
params.analysisAddress = form.analysisAddress;
}else if(params.shapeType == 3){
params.lnglat = this.polygonPath.join('|')
}
params.bizFenceType = form.bizFenceType
// params.status = form.status;
if(this.tableData){
params.snList = this.tableData
}else{
params.snList = this.userArr;
}
if(form.timeType==1){
params.startTime = moment().format('YYYY-MM-DD');
params.endTime = moment().add(10, 'year').format('YYYY-MM-DD');
}else{
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
}
return params; return params;
},
}, /*closeDialog(){
/*closeDialog(){
this.resetForm(); this.resetForm();
this.$emit('onFenceModalChange', false); this.$emit('onFenceModalChange', false);
},*/ },*/
scrollTo(refName){ scrollTo(refName) {
this.scrollToRef = refName; this.scrollToRef = refName;
var element = this.$refs[refName]; var element = this.$refs[refName];
const top = element.offsetTop; const top = element.offsetTop;
window.document.getElementById('fenceModal').querySelector('form').scrollTo(0, top-80); window.document
}, .getElementById("fenceModal")
/*addMode(){ .querySelector("form")
.scrollTo(0, top - 80);
},
/*addMode(){
this.starMap=true; this.starMap=true;
},*/ },*/
areaChoose(id, str){ areaChoose(id, str) {
if(this.form.areaCode!=id){ if (this.form.areaCode != id) {
this.starMap=true; this.starMap = true;
} }
this.form.areaCode = id; this.form.areaCode = id;
this.form.areaString = str; this.form.areaString = str;
this.$refs.fenceForm.validateField('area'); this.$refs.fenceForm.validateField("area");
if(this.starMap){ if (this.starMap) {
this.district() this.district();
} }
//this.starMap = true; //this.starMap = true;
//} //}
}, },
district(){ district() {
console.log("district") console.log("district");
//this.starMap = true; //this.starMap = true;
this.$refs.fenceMap.updateFence({ this.$refs.fenceMap.updateFence({
fenceType: 'area', fenceType: "area",
areaCode: this.form.areaCode areaCode: this.form.areaCode,
}) });
}, },
/*openMapModal(){ /*openMapModal(){
this.$emit('onFenceMapModalChange', true); this.$emit('onFenceMapModalChange', true);
},*/ },*/
validateLngLat(){ validateLngLat() {
let pass = true; let pass = true;
this.$refs.fenceForm.validateField('lng', (error)=>{ this.$refs.fenceForm.validateField("lng", (error) => {
if(error){ if (error) {
pass = false; pass = false;
} }
}); });
this.$refs.fenceForm.validateField('lat', (error)=>{ this.$refs.fenceForm.validateField("lat", (error) => {
if(error){ if (error) {
pass = false; pass = false;
} }
}); });
this.$refs.fenceForm.validateField('radius', (error)=>{ this.$refs.fenceForm.validateField("radius", (error) => {
if(error){ if (error) {
pass = false; pass = false;
} }
}); });
return pass; return pass;
}, },
/*transfer(){ /*transfer(){
if(this.form.lng && this.form.lat && this.form.radius){ if(this.form.lng && this.form.lat && this.form.radius){
this.$refs.fenceMap.updateMap(this.form) this.$refs.fenceMap.updateMap(this.form)
} }
}*/ }*/
transfer(){ transfer() {
if(this.form.lng && this.form.lat && this.validateLngLat()){ if (this.form.lng && this.form.lat && this.validateLngLat()) {
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId); this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(()=>{ this.transferTimeoutId = window.setTimeout(() => {
const flag = new Date(); const flag = new Date();
this.transferFlag = flag; this.transferFlag = flag;
if(!this.geocoder){ if (!this.geocoder) {
mapService.getGeocoder().then((gc)=>{ mapService.getGeocoder().then((gc) => {
this.geocoder = gc; this.geocoder = gc;
this.getAddress(flag); this.getAddress(flag);
});
}else{
this.getAddress(flag);
}
}, 500)
}
},
getAddress(flag){
const lnglatXY = [this.form.lng, this.form.lat];
this.form.analysisAddress = ''
this.geocoder.getAddress(lnglatXY, (status, result)=>{
if(flag == this.transferFlag){
if (status === 'complete' && result.info === 'OK') {//获取地址成功
//console.log(result.regeocode.formattedAddress)
this.form.analysisAddress = result.regeocode.formattedAddress;
this.transferError = false;
this.$refs.fenceForm.validateField('analysisAddress');
//this.$refs.fenceMap.updateMap(this.form)
}else{
this.transferError = true;
this.$refs.fenceForm.validateField('analysisAddress');
}
}
}); });
}, } else {
updateFence(){ this.getAddress(flag);
this.$refs.fenceMap.updateFence({ }
fenceType: 'circle', }, 500);
lng: this.form.lng, }
lat: this.form.lat,
radius: this.form.radius
});
this.transfer()
},
handleSpecialShopChange(val) {
// 特约店级联选项
if(val && val.length > 1) {
this.form.specialShopId = val[1];
console.log(this.form.specialShopId)
}
}
}, },
components:{ getAddress(flag) {
AreaSelect, const lnglatXY = [this.form.lng, this.form.lat];
fenceMap, this.form.analysisAddress = "";
userList, this.geocoder.getAddress(lnglatXY, (status, result) => {
InfiniteLoading if (flag == this.transferFlag) {
} if (status === "complete" && result.info === "OK") {
} //获取地址成功
//console.log(result.regeocode.formattedAddress)
this.form.analysisAddress = result.regeocode.formattedAddress;
this.transferError = false;
this.$refs.fenceForm.validateField("analysisAddress");
//this.$refs.fenceMap.updateMap(this.form)
} else {
this.transferError = true;
this.$refs.fenceForm.validateField("analysisAddress");
}
}
});
},
updateFence() {
this.$refs.fenceMap.updateFence({
fenceType: "circle",
lng: this.form.lng,
lat: this.form.lat,
radius: this.form.radius,
});
this.transfer();
},
handleSpecialShopChange(val) {
// 特约店级联选项
if (val && val.length > 1) {
this.form.specialShopId = val[1];
console.log(this.form.specialShopId);
}
},
},
components: {
AreaSelect,
fenceMap,
userList,
InfiniteLoading,
},
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
h3{ h3 {
margin: 10px 0px; margin: 10px 0px;
} }
form { form {
height:100%; height: 100%;
overflow-y: auto; overflow-y: auto;
margin: -30px -20px; margin: -30px -20px;
padding: 10px 100px 20px 30px; padding: 10px 100px 20px 30px;
} }
.tab-content{ .tab-content {
margin-top: 20px; margin-top: 20px;
} }
.record-list{ .record-list {
padding-left: 20px; padding-left: 20px;
} }
.fenceModalfooter{ .fenceModalfooter {
margin: 0; margin: 0;
padding: 20px; padding: 20px;
padding-top: 10px; padding-top: 10px;
text-align: right; text-align: right;
box-sizing: border-box; box-sizing: border-box;
z-index: 500; z-index: 500;
position: fixed; position: fixed;
left:0; left: 0;
bottom: 0; bottom: 0;
width: 100%; width: 100%;
border-top: 1px solid #e7eaec; border-top: 1px solid #e7eaec;
background-color: #fdfdfd; background-color: #fdfdfd;
margin-left: 220px; margin-left: 220px;
padding-right: 260px; padding-right: 260px;
} }
.tab_wrap{ .tab_wrap {
position: relative; position: relative;
padding: 20px; padding: 20px;
.tab_ctrl{ .tab_ctrl {
position: absolute; position: absolute;
top: 20px; top: 20px;
right: 20px; right: 20px;
} }
} }
.shape_tip{ .shape_tip {
color:#999; color: #999;
line-height:1.5; line-height: 1.5;
margin-bottom: 10px; margin-bottom: 10px;
margin-left: 100px; margin-left: 100px;
} }
</style> </style>
<style > <style >
.scrollbar::-webkit-scrollbar{ .scrollbar::-webkit-scrollbar {
width: 4px; width: 4px;
} }
.scrollbar::-webkit-scrollbar-thumb{ .scrollbar::-webkit-scrollbar-thumb {
border-radius: 15px; border-radius: 15px;
box-shadow:inset 0 0 5px rgba(0,0,0,0.2); box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: rgba(255,255,255,0.1); background: rgba(255, 255, 255, 0.1);
} }
.scrollbar::-webkit-scrollbar-track{ .scrollbar::-webkit-scrollbar-track {
border-radius: 0; border-radius: 0;
box-shadow:inset 0 0 5px rgba(0,0,0,0.2); box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: rgba(255,255,255,255); background: rgba(255, 255, 255, 255);
} }
.special-shop-input .el-input__inner { .special-shop-input .el-input__inner {
cursor: pointer; cursor: pointer;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -183,7 +183,8 @@ ...@@ -183,7 +183,8 @@
</template> </template>
<script> <script>
import "@/assets/spritesmith-generated/sprite.css"; import "@/assets/spritesmith-generated/sprite.css";
import mapService from "@/utils/mapService.js"; // import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js"; import "@/utils/mapEvent.js";
import EventBus from "@/event-bus"; import EventBus from "@/event-bus";
import { services } from "@/api"; import { services } from "@/api";
...@@ -326,7 +327,8 @@ export default { ...@@ -326,7 +327,8 @@ export default {
let _query = this.$route.query; let _query = this.$route.query;
this.$set(this.form, "source", _query.source || 0); this.$set(this.form, "source", _query.source || 0);
this.initMap(); // this.initMap();
this.initBMap();
}, },
mounted() { mounted() {
//store.dispatch("setFullsize", true); //store.dispatch("setFullsize", true);
...@@ -340,15 +342,11 @@ export default { ...@@ -340,15 +342,11 @@ export default {
}, },
}, },
methods: { methods: {
// 初始化地图 //初始化百度地图
initMap() { async initBMap() {
let _this = this; this.mapObj = await mapService.init("map");
_this.$mapInit().then((AMap) => { window.AMap = this.mapObj;
window.AMap = AMap; this.getDevinceInfo();
window.AMap = AMap;
_this.map = mapService.init("map");
_this.getDevinceInfo();
});
}, },
// 获取设备信息 // 获取设备信息
...@@ -420,18 +418,17 @@ export default { ...@@ -420,18 +418,17 @@ export default {
// 在地图上画圆形围栏 // 在地图上画圆形围栏
drawFenceCircle(info) { drawFenceCircle(info) {
let _this = this; let _this = this;
_this.form.lng = info.elng; _this.form.lng = info.blng;
_this.form.lat = info.elat; _this.form.lat = info.blat;
EventBus.$emit("uiMap.fence.createFenceCircle", { EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: info.elng, lng: info.blng,
lat: info.elat, lat: info.blat,
radius: _this.form.radius, radius: _this.form.radius,
}); });
}, },
// 在地图上画行政区域 // 在地图上画行政区域
drawDistrict(areaCode) { drawDistrict(areaCode) {
console.log(areaCode);
EventBus.$emit("uiMap.fence.drawDistrict", areaCode); EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
}, },
...@@ -454,14 +451,14 @@ export default { ...@@ -454,14 +451,14 @@ export default {
}; };
// GPS信息 // GPS信息
option.lngGPS = g.elng; option.lngGPS = g.blng;
option.latGPS = g.elat; option.latGPS = g.blat;
option.timeGPS = g.dateTime; option.timeGPS = g.dateTime;
option.transferAddressGPS = g.address; option.transferAddressGPS = g.address;
// 基站信息 // 基站信息
option.lngBase = b.elng; option.lngBase = b.blng;
option.latBase = b.elat; option.latBase = b.blat;
option.timeBase = b.dateTime; option.timeBase = b.dateTime;
option.transferAddressBase = b.address; option.transferAddressBase = b.address;
...@@ -478,22 +475,24 @@ export default { ...@@ -478,22 +475,24 @@ export default {
// 监听圆形围栏直径变化 // 监听圆形围栏直径变化
onFenceRadiusChange(e) { onFenceRadiusChange(e) {
console.log("圆形围栏:", e); if (e) {
this.$set(this.form, "radius", e); this.$set(this.form, "radius", e);
}
}, },
// 监听围栏类型变化 // 监听围栏类型变化
changeShapeType(e) { changeShapeType(e) {
let _this = this; let _this = this;
let _info = this.deviceInfo; let _info = this.deviceInfo;
let areaCode = this.form.areaCode || []; let areaText = this.form.areaText || [];
// 1:圆形围栏 4:行政区域 3:多边形 // 1:圆形围栏 4:行政区域 3:多边形
console.log(_info);
switch (e) { switch (e) {
case 4: case 4:
_this.drawDistrict(areaCode); // AMap.invoke("removeContextMenu");
_this.drawDistrict(areaText);
break; break;
case 3: case 3:
// AMap.invoke("removeContextMenu");
_this.drawPolygon(); _this.drawPolygon();
break; break;
default: default:
...@@ -509,10 +508,9 @@ export default { ...@@ -509,10 +508,9 @@ export default {
// 监听行政区域 // 监听行政区域
changeArea(e) { changeArea(e) {
console.log(e);
this.form.areaCode = e.code; this.form.areaCode = e.code;
this.form.areaText = e.name; this.form.areaText = e.name;
this.drawDistrict(e.code); this.drawDistrict(e.name);
this.$refs.form.clearValidate(); this.$refs.form.clearValidate();
}, },
...@@ -521,7 +519,6 @@ export default { ...@@ -521,7 +519,6 @@ export default {
let _this = this; let _this = this;
let o = deepClone(_this.form); let o = deepClone(_this.form);
let query = this.$route.query; let query = this.$route.query;
console.log(o);
let oParams = {}; let oParams = {};
let deviceList = this.deviceList; let deviceList = this.deviceList;
...@@ -547,7 +544,10 @@ export default { ...@@ -547,7 +544,10 @@ export default {
// 多边形围栏 // 多边形围栏
if (o.shapeType == 3) { if (o.shapeType == 3) {
oParams.lnglat = this.polygonPath.join("|"); let lnglats = this.polygonPath.map((item) => {
return item.lng + "," + item.lat;
});
oParams.lnglat = lnglats.join("|");
} }
// 行政区域围栏 // 行政区域围栏
...@@ -562,8 +562,8 @@ export default { ...@@ -562,8 +562,8 @@ export default {
let cur = {}; let cur = {};
let _gps = k.gpsLocation || {}; let _gps = k.gpsLocation || {};
cur.address = _gps.address; cur.address = _gps.address;
cur.lat = _gps.elat; cur.lat = _gps.blat;
cur.lng = _gps.elng; cur.lng = _gps.blng;
cur.name = k.ownerName; cur.name = k.ownerName;
cur.sn = k.sn; cur.sn = k.sn;
cur.time = _gps.dateTime; cur.time = _gps.dateTime;
......
...@@ -57,7 +57,8 @@ ...@@ -57,7 +57,8 @@
</template> </template>
<script> <script>
import remoteLoad from "utils/remoteLoad.js"; import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js"; // import mapService from "utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import FenceMapControll from "./FenceMapControll.vue"; import FenceMapControll from "./FenceMapControll.vue";
import { CONSTANT } from "../../constant"; import { CONSTANT } from "../../constant";
export default { export default {
...@@ -90,24 +91,33 @@ export default { ...@@ -90,24 +91,33 @@ export default {
fenceType: "polygon", //'area' 'polygon' fenceType: "polygon", //'area' 'polygon'
lng: "", lng: "",
lat: "", lat: "",
radius: "", radius: 1000,
fenceCircle: null, fenceCircle: null,
fenceCenter: null, fenceCenter: null,
areaCode: "", areaCode: "",
isFenceInit: false, isFenceInit: false,
mapLoading: false, mapLoading: false,
polygonPath: [], polygonPath: [],
txtMenuItem: [
{
text: "设置围栏中心",
callback: function () {
map.zoomIn();
},
},
],
}; };
}, },
mounted() { mounted() {
let _this = this; // let _this = this;
let plugins = ["AMap.LngLat", "AMap.AutoComplete",'AMap.MouseTool','AMap.PolyEditor']; // let plugins = ["AMap.LngLat", "AMap.AutoComplete",'AMap.MouseTool','AMap.PolyEditor'];
_this.$mapInit({ version: "1.4.2", plugins: plugins }).then((AMap) => { // _this.$mapInit({ version: "1.4.2", plugins: plugins }).then((AMap) => {
window.AMap = AMap; // window.AMap = AMap;
_this.mapObj = mapService.init("mapContainer"); // _this.mapObj = mapService.init("mapContainer");
_this.bindContextMenu(); // _this.bindContextMenu();
_this.bindSearch(); // _this.bindSearch();
}); // });
// this.initBMap();
}, },
watch: { watch: {
lng(newVal) { lng(newVal) {
...@@ -116,17 +126,20 @@ export default { ...@@ -116,17 +126,20 @@ export default {
lat(newVal) { lat(newVal) {
//this.transfer() //this.transfer()
}, },
/* mapData(newVal){
const fenceData = newVal;
this.initMapPromise.then(()=>{console.log(fenceData)
if(fenceData.fenceType === 'circle'){
this.drawFence(fenceData)
}
})
} */
}, },
async created() {}, async created() {
// this.initBMap();
},
methods: { methods: {
async initBMap() {
this.mapObj = await mapService.init("mapContainer");
window.AMap = this.mapObj;
AMap.invoke("LocalCity", (res) => {
// AMap.invoke('panTo',res.center)
});
this.bindContextMenu();
this.bindSearch();
},
initMap() { initMap() {
this.initMapPromise = new Promise((resolve, reject) => { this.initMapPromise = new Promise((resolve, reject) => {
let check = () => { let check = () => {
...@@ -153,82 +166,52 @@ export default { ...@@ -153,82 +166,52 @@ export default {
}); });
}, },
bindSearch() { bindSearch() {
const self = this; let self = this,
AMap.plugin("AMap.Autocomplete", function () { url = require("images/auto-center-marker.gif"),
self.auto = new AMap.Autocomplete({ size = AMap.invoke("Size", 24, 24);
input: "fenceMapSearch", self.auto = AMap.invoke("Autocomplete", {
}); input: "fenceMapSearch",
});
self.autoCenterMarker = new AMap.Marker({ AMap.invoke("autocompleteShow");
icon: require("images/auto-center-marker.gif"), AMap.invoke("autocompleteAddEventListener", "onconfirm", (e) => {
map: self.mapObj, let location = e.item.value.location;
offset: new AMap.Pixel(-12, -12), AMap.invoke("panTo", location, true);
visible: false, self.autoCenterMarker = AMap.invoke("Marker", location, {
}); icon: AMap.invoke("Icon", url, size),
self.autoCenterMarker.on("rightclick", (e) => {
if (self.mapObj.getAllOverlays("circle").length) {
self.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
}); });
AMap.invoke("markerAddEventListener", "rightclick", (e) => {
self.auto.on("select", (e) => { // AMap.invoke("mapAddEventListener", "rightclick", function (e) {
console.log(e.poi); // console.log(e,'地图事件')
if (e.poi && e.poi.location) { // })
self.mapObj.setCenter(e.poi.location); // self.autoCenterMarker.setContextMenu(self.contextMenu)
self.autoCenterMarker.setPosition(e.poi.location); self.contextMenuPositon = e.latLng; //右键菜单位置
self.lng = e.poi.location.lng;
self.lat = e.poi.location.lat;
self.autoCenterMarker.show();
self.mapObj.add(self.autoCenterMarker);
}
self.mapObj.setZoom(14);
}); });
self.lng = location.lng;
// AMap.event.addListener(self.auto, "select", (e) => { self.lat = location.lat;
// console.log(e.poi); AMap.invoke("addOverlay", self.autoCenterMarker);
// if (e.poi && e.poi.location) { AMap.invoke('centerAndZoom', location, 15)
// self.mapObj.setCenter(e.poi.location);
// self.autoCenterMarker.setPosition(e.poi.location);
// /*for(var i = 0, l = this.polygons.length; i < l; i++) {
// this.polygons[i].setMap(null);
// }*/
// self.lng = e.poi.location.lng;
// self.lat = e.poi.location.lat;
// self.autoCenterMarker.show();
// self.mapObj.add(self.autoCenterMarker);
// }
// self.mapObj.setZoom(14);
// });
}); });
}, },
bindContextMenu() { bindContextMenu() {
const self = this; const self = this;
var contextMenu = new AMap.ContextMenu(); const MAP = mapService.map;
var contextMenu = MAP.invoke("ContextMenu");
contextMenu.addItem( contextMenu.addItem(
"设置围栏中心", MAP.invoke("MenuItem", "设置围栏中心", function () {
function () {
self.moveCenter(); self.moveCenter();
}, })
0
); );
//地图绑定鼠标右击事件——弹出右键菜单 MAP.invoke("mapAddEventListener", "rightclick", function (e) {
self.mapObj.on("rightclick", function (e) { MAP.invoke("addContextMenu", contextMenu);
contextMenu.open(self.mapObj, e.lnglat); self.contextMenuPositon = e.latlng;
self.contextMenuPositon = e.lnglat;
}); });
self.contextMenu = contextMenu; self.contextMenu = contextMenu;
//contextMenu.open(self.mapObj, lnglat);
}, },
drawFence() { drawFence() {
if (!this.lng && !this.lat) { if (!this.lng && !this.lat) {
this.mapLoading = true; this.mapLoading = true;
this.getCurrentPosition() this.getCurrentPosition()
.then((pos) => { .then((pos) => {
console.log(pos);
this.lng = pos.lng; this.lng = pos.lng;
this.lat = pos.lat; this.lat = pos.lat;
this.radius = 1000; this.radius = 1000;
...@@ -255,52 +238,40 @@ export default { ...@@ -255,52 +238,40 @@ export default {
} }
}, },
drawFenceCircle(fenceCenter) { drawFenceCircle(fenceCenter) {
const mapObj = this.mapObj;
if (this.fenceCircle) { if (this.fenceCircle) {
this.fenceCircle.setCenter(mapService.getLngLat(this.lng, this.lat)); this.fenceCircle.setCenter(mapService.getLngLat(this.lng, this.lat));
} else { } else {
this.fenceCircle = new AMap.Circle({ let options = {
map: mapObj,
center: fenceCenter,
radius: this.radius * 1,
strokeColor: "#F33", strokeColor: "#F33",
strokeOpacity: 1, strokeOpacity: 1,
strokeWeight: 3, strokeWeight: 3,
fillColor: "ee2200", fillColor: "ee2200",
fillOpacity: 0.35, fillOpacity: 0.35,
}); enableEditing: true,
mapObj.plugin(["AMap.CircleEditor"], () => { };
this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle); this.fenceCircle = AMap.invoke(
"Circle",
// this.circleEditor.on("adjust", function (e) { fenceCenter,
// console.log(e); this.radius * 1,
// }); options
AMap.event.addListener(this.circleEditor, "adjust", (e) => { );
this.radius = e.radius / 1; AMap.invoke('centerAndZoom', fenceCenter, 14)
this.$emit("onUpdateMapData", { AMap.invoke("addOverlay", this.fenceCircle);
lng: this.lng, AMap.invoke("circleAddEventListener", "lineupdate", (e) => {
lat: this.lat, let overlay = e.overlay;
radius: this.radius, this.radius = parseInt(overlay.getRadius() / 1);
}); this.lng = e.overlay.getCenter().lng;
}); this.lat = e.overlay.getCenter().lat;
this.$emit("onUpdateMapData", {
AMap.event.addListener(this.circleEditor, "move", (e) => { lng: this.lng,
this.lng = e.lnglat.lng; lat: this.lat,
this.lat = e.lnglat.lat; radius: this.radius,
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
});
}); });
this.circleEditor.open();
}); });
} }
mapService.setFitView();
mapObj.setZoom(14);
}, },
initFence(data) { initFence(data) {
console.log(data)
let _this = this; let _this = this;
this._mapPromiseTimeout = setInterval(function () { this._mapPromiseTimeout = setInterval(function () {
if (_this.mapObj) { if (_this.mapObj) {
...@@ -311,7 +282,7 @@ export default { ...@@ -311,7 +282,7 @@ export default {
this.fenceType = data.fenceType; this.fenceType = data.fenceType;
switch (data.fenceType) { switch (data.fenceType) {
case "area": case "area":
_this.areaCode = data.areaCode; _this.areaText = data.areaText;
_this.drawArea(); _this.drawArea();
break; break;
case "polygon": case "polygon":
...@@ -332,17 +303,14 @@ export default { ...@@ -332,17 +303,14 @@ export default {
}, },
// 更新围栏信息 // 更新围栏信息
updateFence(data) { updateFence(data) {
console.log("更新围栏信息", data);
let _this = this; let _this = this;
let mapInterval = setInterval(function () { let mapInterval = setInterval(function () {
if (_this.mapObj) { if (_this.mapObj) {
clearInterval(mapInterval); clearInterval(mapInterval);
_this.mapObj.clearMap(); AMap.invoke("clearOverlays");
_this.fenceType = data.fenceType; _this.fenceType = data.fenceType;
_this.polyEditor && _this.polyEditor.close();
_this.mouseTool && _this.mouseTool.close();
if (_this.fenceType === "circle") { if (_this.fenceType === "circle") {
_this.fenceCircle = null; _this.fenceCircle = null;
if (data.lng) { if (data.lng) {
...@@ -357,13 +325,14 @@ export default { ...@@ -357,13 +325,14 @@ export default {
_this.drawFence(); _this.drawFence();
} else if (_this.fenceType === "area") { } else if (_this.fenceType === "area") {
if (data.areaCode) { if (data.areaText) {
_this.areaCode = data.areaCode; _this.areaText = data.areaText;
} }
if (_this.areaCode) { if (_this.areaText) {
_this.drawArea(); _this.drawArea();
} }
} else if (_this.fenceType === "polygon") { } else if (_this.fenceType === "polygon") {
console.log()
_this.drawPolygon(); _this.drawPolygon();
} }
} }
...@@ -371,163 +340,125 @@ export default { ...@@ -371,163 +340,125 @@ export default {
}, },
drawArea() { drawArea() {
let _this = this; let _this = this;
let areaCode = this.areaCode ? this.areaCode.toString() : "中国";
this.mapObj.clearMap();
for (var i = 0, l = this.polygons.length; i < l; i++) { for (var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null); this.polygons[i].setMap(null);
} }
_this.mapLoading = true;
let district, lng, lat; AMap.invoke("clearOverlays");
this.mapLoading = true; if (this.dist) AMap.invoke("removeDistrictLayer", this.dist);
AMap.service("AMap.DistrictSearch", function () { this.dist = AMap.invoke("DistrictLayer", {
var opts = { name: `(${_this.areaText})`,
subdistrict: 1, //返回下一级行政区 fillOpacity: 0.7,
extensions: "all", fillColor: "#CCF3FF",
showbiz: false, //最后一级返回街道信息 strokeColor: "#CC66CC",
}; viewport: true,
areaCode === "中国" ? delete opts.extensions : delete opts.showbiz;
district = new AMap.DistrictSearch(opts);
district.setLevel("district");
district.search(areaCode, function (status, result) {
var bounds = result.districtList[0].boundaries;
lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat;
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
//生成行政区划polygon
let polygon = new AMap.Polygon({
map: _this.mapObj,
strokeWeight: 1,
path: bounds[i],
fillOpacity: 0.7,
fillColor: "#CCF3FF",
strokeColor: "#CC66CC",
});
_this.polygons.push(polygon);
}
lng = result.districtList[0].center.lng;
lat = result.districtList[0].center.lat;
let center = mapService.getLngLat(lng, lat);
mapService.setFitView();
//map.setZoom(10);
_this.mapLoading = false;
}
});
}); });
AMap.invoke("addDistrictLayer", this.dist);
_this.mapLoading = false;
}, },
moveCenter() { moveCenter() {
this.lng = this.contextMenuPositon.lng; this.lng = this.contextMenuPositon.lng;
this.lat = this.contextMenuPositon.lat; this.lat = this.contextMenuPositon.lat;
let center = mapService.getLngLat(this.lng, this.lat); if (this.fenceCircle) {
this.fenceCircle.setCenter(center); AMap.invoke("circleDisableEditing");
this.fenceCircle && this.fenceCircle.setCenter(this.contextMenuPositon);
this.$emit("onUpdateMapData", { AMap.invoke("removeOverlay", this.fenceCircle);
lng: this.lng, AMap.invoke("addOverlay", this.fenceCircle);
lat: this.lat, AMap.invoke("circleEnableEditing");
}); } else {
const lnglat = mapService.getLngLat(this.lng, this.lat);
this.drawFenceCircle(lnglat);
}
}, },
getCurrentPosition() { getCurrentPosition() {
const mapObj = this.mapObj;
const self = this; const self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
mapObj.plugin("AMap.Geolocation", function () { AMap.invoke("Geolocation", (res) => {
self.geolocation = new AMap.Geolocation(); var lnglatXY = mapService.getLngLat(res.longitude, res.latitude);
self.geolocation.getCurrentPosition(function (status, result) { resolve(lnglatXY);
if (status == "complete") {
var lnglatXY = mapService.getLngLat(
result.position.lng,
result.position.lat
);
resolve(lnglatXY);
}
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());
// });
}); });
}); });
}, },
drawPolygon() { drawPolygon() {
const mapObj = this.mapObj;
const self = this; const self = this;
console.log(this.polygonPath)
if (this.polygonPath.length) { if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({ let options = {
path: this.polygonPath, zIndex: 10,
strokeColor: "#FF33FF", strokeColor: "#FF33FF",
strokeWeight: 6, strokeWeight: 6,
strokeOpacity: 0.2, strokeOpacity: 0.2,
fillOpacity: 0.4, fillOpacity: 0.4,
fillColor: "#1791fc", fillColor: "#1791fc",
zIndex: 50, enableEditing: true,
};
self.polygon = AMap.invoke("Polygon", this.polygonPath, options);
//获取多边形的中间位置
let lnglat = self.polygon.getBounds().getCenter();
// AMap.invoke("panTo", lnglat, true);
AMap.invoke("centerAndZoom", lnglat, 14);
AMap.invoke("polygonAddEventListener", "lineupdate", function (e) {
let pathArr = self.polygon.getPath();
self.emitPolyEvent(pathArr);
}); });
mapObj.add(self.polygon); AMap.invoke("addOverlay", self.polygon);
mapObj.setFitView([self.polygon]); AMap.invoke('setZoom',17)
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon);
self.polyEditor.open();
self.bindPolyEvent(self.polyEditor);
} else { } else {
self.mouseTool = new AMap.MouseTool(mapObj); var styleOptions = {
strokeColor: "#FF33FF", // 边线颜色
self.mouseTool.polygon({ fillColor: "#1791fc", // 填充颜色。当参数为空时,圆形没有填充颜色
strokeColor: "#FF33FF", strokeWeight: 6, // 边线宽度,以像素为单位
strokeOpacity: 1, strokeOpacity: 0.2, // 边线透明度,取值范围0-1
strokeWeight: 6, fillOpacity: 0.4, // 填充透明度,取值范围0-1
strokeOpacity: 0.2, };
fillColor: "#1791fc", var labelOptions = {
fillOpacity: 0.4, borderRadius: "2px",
// 线样式还支持 'dashed' background: "#FF33FF",
strokeStyle: "solid", border: "1px solid #E1E1E1",
// strokeStyle是dashed时有效 color: "#703A04",
// strokeDasharray: [30,10], fontSize: "12px",
}); letterSpacing: "0",
padding: "5px",
self.mouseTool.on("draw", function (event) { };
// event.obj 为绘制出来的覆盖物对象 self.drawingManager = AMap.invoke(
self.polygon = event.obj; "DrawingManager",
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon); mapService.mapInstance,
self.polyEditor.open(); {
self.bindPolyEvent(self.polyEditor); isOpen: true, // 是否开启绘制模式
self.mouseTool.close(); enableDrawingTool: false,
self.emitPolyEvent(); enableCalculate: false, // 绘制是否进行测距测面
}); enableSorption: true, // 是否开启边界吸附功能
sorptiondistance: 20, // 边界吸附距离
circleOptions: styleOptions, // 圆的样式
polylineOptions: styleOptions, // 线的样式
polygonOptions: styleOptions, // 多边形的样式
rectangleOptions: styleOptions, // 矩形的样式
labelOptions: labelOptions, // label样式
}
);
AMap.invoke(
"drawingManagerAddEventListener",
"polygoncomplete",
function (e) {
let overlays = e;
let pathArr = e.getPath();
// let resultArr = pathArr.map((item) => {
// return item.latLng
// })
self.emitPolyEvent(pathArr);
}
);
AMap.invoke("setDrawingMode", "polygon");
} }
}, },
emitPolyEvent() { emitPolyEvent(resultArr) {
let pathArr = this.polygon.getPath();
let resultArr = pathArr.map((item) => {
return [item.lng, item.lat];
});
this.polygonPath = resultArr; this.polygonPath = resultArr;
this.$emit("onUpdateMapData", { this.$emit("onUpdateMapData", {
polygonPath: this.polygonPath, polygonPath: this.polygonPath,
}); });
console.log(resultArr.join("|"));
}, },
bindPolyEvent(polyEditor) { bindPolyEvent(polyEditor) {
const self = this; const self = this;
...@@ -634,4 +565,7 @@ export default { ...@@ -634,4 +565,7 @@ export default {
} }
} }
} }
.tangram-suggestion-main {
z-index: 9999 !important; /* 使用 !important 可以确保覆盖其他样式 */
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
<script> <script>
import store from "../../vuex/store.js"; import store from "../../vuex/store.js";
import remoteLoad from "utils/remoteLoad.js"; import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js"; import mapService from "utils/mapBService.js";
import "utils/mapEvent.js"; import "utils/mapEvent.js";
import EventBus from "../../event-bus"; import EventBus from "../../event-bus";
import { services } from "../../api"; import { services } from "../../api";
...@@ -246,13 +246,14 @@ export default { ...@@ -246,13 +246,14 @@ export default {
}, },
mounted() { mounted() {
// store.dispatch('setFullsize', true) // store.dispatch('setFullsize', true)
let _this = this; this.initBMap();
_this.$mapInit({version:'1.4.2'}).then(AMap => {
window.AMap = AMap;
_this.initMap();
})
}, },
methods: { methods: {
async initBMap() {
this.mapObj = await mapService.init("map");
window.AMap = this.mapObj;
this.isInitMap = true;
},
initMap() { initMap() {
let check = () => { let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
......
...@@ -20,15 +20,32 @@ ...@@ -20,15 +20,32 @@
:trigger-on-focus="false" :trigger-on-focus="false"
:placeholder="'请输入'+['6位以上设备号','6位以上车架号','2位以上姓名'][searchType-1]" :placeholder="'请输入'+['6位以上设备号','6位以上车架号','2位以上姓名'][searchType-1]"
@select="handleSelect"> --> @select="handleSelect"> -->
<el-input :placeholder="placeholderText" v-model.trim="searchText" size="small" class="input-with-select" <el-input
@keyup.enter.native="searchSubmit"> :placeholder="placeholderText"
<el-select v-model="searchType" @change="selectChange" slot="prepend" placeholder="请选择" size="small"> v-model.trim="searchText"
size="small"
class="input-with-select"
@keyup.enter.native="searchSubmit"
>
<el-select
v-model="searchType"
@change="selectChange"
slot="prepend"
placeholder="请选择"
size="small"
>
<el-option label="设备号" value="1"></el-option> <el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option> <el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option> <el-option label="姓名" value="3"></el-option>
<!-- <el-option label="工单号" value="4"></el-option> --> <!-- <el-option label="工单号" value="4"></el-option> -->
</el-select> </el-select>
<el-button icon="el-icon-search" size="mini" slot="append" :loading="isSearching" @click="searchSubmit"> <el-button
icon="el-icon-search"
size="mini"
slot="append"
:loading="isSearching"
@click="searchSubmit"
>
</el-button> </el-button>
<!-- <template slot-scope="{ item }"> <!-- <template slot-scope="{ item }">
<div style="margin: 0 -20px; font-size: 12px; " class="auto_item"> <div style="margin: 0 -20px; font-size: 12px; " class="auto_item">
...@@ -47,33 +64,74 @@ ...@@ -47,33 +64,74 @@
</div> </div>
<el-row type="flex" class="filter-entrance" justify="space-between"> <el-row type="flex" class="filter-entrance" justify="space-between">
<!-- <el-button type="text" @click="importDialogHidden=false;listDialogHidden=true;resultDialogHidden=true;">导入查询</el-button> --> <!-- <el-button type="text" @click="importDialogHidden=false;listDialogHidden=true;resultDialogHidden=true;">导入查询</el-button> -->
<el-button type="text" @click=" <el-button
treeHidden = false; type="text"
listDialogHidden = true; @click="
importDialogHidden = true; treeHidden = false;
resultDialogHidden = true; listDialogHidden = true;
">组织</el-button> importDialogHidden = true;
<el-button type="text" @click=" resultDialogHidden = true;
listDialogHidden = false; "
treeHidden = true; >组织</el-button
importDialogHidden = true; >
resultDialogHidden = true; <el-button
">监控列表({{ getMonitorListVisibleCount }})</el-button> type="text"
@click="
listDialogHidden = false;
treeHidden = true;
importDialogHidden = true;
resultDialogHidden = true;
"
>监控列表({{ getMonitorListVisibleCount }})</el-button
>
</el-row> </el-row>
<div class="filter-dialog-set"> <div class="filter-dialog-set">
<div class="filter-dialog animated" :class="importDialogHidden ? 'fadeOut' : 'active fadeIn'"> <div
class="filter-dialog animated"
:class="importDialogHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header"> <div class="filter-dialog-header">
导入查询 导入查询
<i class="el-icon-close pull-right" @click.stop="importDialogHidden = true"></i> <i
class="el-icon-close pull-right"
@click.stop="importDialogHidden = true"
></i>
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini"> <el-form
ref="form"
:model="form"
:rules="rules"
:inline="false"
size="mini"
>
<el-form-item label="" prop="filename"> <el-form-item label="" prop="filename">
<el-upload ref="upload" class="upload-wrap" action="vehicle/importSerchDevice" :on-change="changeFile" <el-upload
:before-upload="beforeUpload" :multiple="false" :show-file-list="false" :on-success="successUpload" ref="upload"
:on-error="errorUpload" :data="uploadData" accept=".xlsx" :auto-upload="false"> class="upload-wrap"
<el-input v-model="form.filename" placeholder="未选取任何文件" class="input-with-select" size="small"> action="vehicle/importSerchDevice"
<el-select v-model="form.uploadType" slot="prepend" placeholder="请选择" size="small"> :on-change="changeFile"
:before-upload="beforeUpload"
:multiple="false"
:show-file-list="false"
:on-success="successUpload"
:on-error="errorUpload"
:data="uploadData"
accept=".xlsx"
:auto-upload="false"
>
<el-input
v-model="form.filename"
placeholder="未选取任何文件"
class="input-with-select"
size="small"
>
<el-select
v-model="form.uploadType"
slot="prepend"
placeholder="请选择"
size="small"
>
<el-option label="设备号" value="1"></el-option> <el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option> <el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option> <el-option label="姓名" value="3"></el-option>
...@@ -87,48 +145,104 @@ ...@@ -87,48 +145,104 @@
</div> </div>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-button type="primary" class="upload-sure-btn" size="small" @click="submitUpload" <el-button
:loading="importing" :disabled="uploadDisabled">确认</el-button> type="primary"
<el-button size="mini" type="text" @click="downloadTpl" style="margin-left: 0px">下载模板</el-button> class="upload-sure-btn"
size="small"
@click="submitUpload"
:loading="importing"
:disabled="uploadDisabled"
>确认</el-button
>
<el-button
size="mini"
type="text"
@click="downloadTpl"
style="margin-left: 0px"
>下载模板</el-button
>
</el-form> </el-form>
</div> </div>
</div> </div>
<div class="filter-dialog animated" :class="listDialogHidden ? 'fadeOut' : 'active fadeIn'"> <div
class="filter-dialog animated"
:class="listDialogHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header monitor_dialog_header"> <div class="filter-dialog-header monitor_dialog_header">
<span>监控列表({{ monitorList.itemArr.length }})</span> <span>监控列表({{ monitorList.itemArr.length }})</span>
<i class="el-icon-close pull-right" @click.stop="listDialogHidden = true"></i> <i
class="el-icon-close pull-right"
@click.stop="listDialogHidden = true"
></i>
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
<el-row type="flex" class="sub-filter" justify="space-between"> <el-row type="flex" class="sub-filter" justify="space-between">
<el-select v-model="monitorFilterType" placeholder="请选择" size="small" style="width: 100px"> <el-select
v-model="monitorFilterType"
placeholder="请选择"
size="small"
style="width: 100px"
>
<el-option label="全部" value=""></el-option> <el-option label="全部" value=""></el-option>
<el-option label="有线" value="1"></el-option> <el-option label="有线" value="1"></el-option>
<el-option label="无线" value="0"></el-option> <el-option label="无线" value="0"></el-option>
</el-select> </el-select>
<el-button type="primary" plain size="small" <el-button
@click="removeMonitorByGroup(monitorList.itemArr)">批量删除</el-button> type="primary"
plain
size="small"
@click="removeMonitorByGroup(monitorList.itemArr)"
>批量删除</el-button
>
</el-row> </el-row>
<ul class="monitor-list" style="max-height: calc(100vh - 380px)"> <ul
class="monitor-list"
style="max-height: calc(100vh - 380px)"
>
<template v-for="(sn, key) in monitorList.itemArr"> <template v-for="(sn, key) in monitorList.itemArr">
<li class="monitor-list-item" :key="sn" @click="openMapInfoWindow(sn, monitorList[sn].source, monitorList[sn].vid)" v-if="key !== 'count' && <li
monitorList[sn] && class="monitor-list-item"
(monitorList[sn].source == monitorFilterType || :key="sn"
monitorFilterType == '') @click="
"> openMapInfoWindow(
<span class="device-icon" :class="monitorList[sn].online ? '' : 'offline'" sn,
v-show="monitorList[sn].online !== undefined"></span> monitorList[sn].source,
monitorList[sn].vid
)
"
v-if="
key !== 'count' &&
monitorList[sn] &&
(monitorList[sn].source == monitorFilterType ||
monitorFilterType == '')
"
>
<span
class="device-icon"
:class="monitorList[sn].online ? '' : 'offline'"
v-show="monitorList[sn].online !== undefined"
></span>
<div class="user-info"> <div class="user-info">
<p> <p>
<span class="name">{{ <span class="name">{{
monitorList[sn].name || "--" monitorList[sn].name || "--"
}}</span> }}</span>
<span>{{ sn }}({{ monitorList[sn].sourceType }})</span> <span
>{{ sn }}({{ monitorList[sn].sourceType }})</span
>
</p> </p>
<p>车架号:{{ monitorList[sn].standNo }}</p> <p>车架号:{{ monitorList[sn].standNo }}</p>
</div> </div>
<span class="none_tip" v-show="!monitorList[sn].isHasPosition">无定位信息</span> <span
<el-button type="text" @click.stop="removeMonitor(monitorList[sn], true)"><i class="none_tip"
class="fa fa-trash"></i></el-button> v-show="!monitorList[sn].isHasPosition"
>无定位信息</span
>
<el-button
type="text"
@click.stop="removeMonitor(monitorList[sn], true)"
><i class="fa fa-trash"></i
></el-button>
</li> </li>
</template> </template>
</ul> </ul>
...@@ -142,30 +256,56 @@ ...@@ -142,30 +256,56 @@
</div> </div>
</div> </div>
</div> </div>
<div class="filter-dialog animated" :class="resultDialogHidden ? 'fadeOut' : 'active fadeIn'"> <div
class="filter-dialog animated"
:class="resultDialogHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header"> <div class="filter-dialog-header">
查询结果 查询结果
<i class="el-icon-close pull-right" @click.stop="resultDialogHidden = true"></i> <i
class="el-icon-close pull-right"
@click.stop="resultDialogHidden = true"
></i>
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
<el-row type="flex" class="sub-filter" justify="space-between"> <el-row type="flex" class="sub-filter" justify="space-between">
<el-select v-model="resultFilterType" placeholder="请选择" size="small" style="width: 100px"> <el-select
v-model="resultFilterType"
placeholder="请选择"
size="small"
style="width: 100px"
>
<el-option label="全部" value=""></el-option> <el-option label="全部" value=""></el-option>
<el-option label="有线" value="1"></el-option> <el-option label="有线" value="1"></el-option>
<el-option label="无线" value="0"></el-option> <el-option label="无线" value="0"></el-option>
</el-select> </el-select>
<el-button type="primary" plain size="small" @click="addMonitorByGroup">批量监控</el-button> <el-button
type="primary"
plain
size="small"
@click="addMonitorByGroup"
>批量监控</el-button
>
</el-row> </el-row>
<ul class="monitor-list"> <ul class="monitor-list">
<li class="monitor-list-item" v-for="item in resultList" :key="item.id" v-show="item.source == resultFilterType || resultFilterType == '' <li
"> class="monitor-list-item"
v-for="item in resultList"
:key="item.id"
v-show="
item.source == resultFilterType || resultFilterType == ''
"
>
<div class="user-info"> <div class="user-info">
<p> <p>
<span class="name">{{ item.name }}</span><span>{{ item.sn }}({{ item.sourceType }})</span> <span class="name">{{ item.name }}</span
><span>{{ item.sn }}({{ item.sourceType }})</span>
</p> </p>
<p>车架号:{{ item.standNo }}</p> <p>车架号:{{ item.standNo }}</p>
</div> </div>
<el-button type="text" @click.prevent="addMonitor(item)">监控</el-button> <el-button type="text" @click.prevent="addMonitor(item)"
>监控</el-button
>
</li> </li>
<li v-show="!resultList.length"> <li v-show="!resultList.length">
<p class="text-center">无数据</p> <p class="text-center">无数据</p>
...@@ -173,24 +313,50 @@ ...@@ -173,24 +313,50 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="filter-dialog" :class="treeHidden ? 'fadeOut' : 'active fadeIn'"> <div
class="filter-dialog"
:class="treeHidden ? 'fadeOut' : 'active fadeIn'"
>
<div class="filter-dialog-header monitor_dialog_header"> <div class="filter-dialog-header monitor_dialog_header">
<i class="el-icon-refresh i_refresh" title="重置组织" @click.stop="restInitTree"></i> <i
class="el-icon-refresh i_refresh"
title="重置组织"
@click.stop="restInitTree"
></i>
<span>组织</span> <span>组织</span>
<i class="el-icon-close pull-right" @click.stop="treeHidden = true"></i> <i
class="el-icon-close pull-right"
@click.stop="treeHidden = true"
></i>
</div> </div>
<div class="filter-dialog-body"> <div class="filter-dialog-body">
<div class="monitor-list"> <div class="monitor-list">
<el-tree ref="tree" :key="treeKey" :data="treeData" :props="treeProps" lazy :load="loadNode" <el-tree
show-checkbox node-key="id" :default-expanded-keys="expandedKeys" :default-checked-keys="checkedKeys" ref="tree"
@check="handleCheck" v-loading="treeLoading" @check-change="handleCheckChange"> :key="treeKey"
:data="treeData"
:props="treeProps"
lazy
:load="loadNode"
show-checkbox
node-key="id"
:default-expanded-keys="expandedKeys"
:default-checked-keys="checkedKeys"
@check="handleCheck"
v-loading="treeLoading"
@check-change="handleCheckChange"
>
<span class="custom-tree-node" slot-scope="{ node, data }"> <span class="custom-tree-node" slot-scope="{ node, data }">
<div v-if="node.data.leaf"> <div v-if="node.data.leaf">
<div>姓名:{{ node.data.label1 || "--" }}</div> <div>姓名:{{ node.data.label1 || "--" }}</div>
<div>设备号:{{ node.data.label || "--" }}</div> <div>设备号:{{ node.data.label || "--" }}</div>
<div>车架号:{{ node.data.label2 }}</div> <div>车架号:{{ node.data.label2 }}</div>
<div class="load_more_link" v-if="data.showMore" v-loading="loadingMore" <div
@click="loadNext(node, data)"> class="load_more_link"
v-if="data.showMore"
v-loading="loadingMore"
@click="loadNext(node, data)"
>
查看更多 查看更多
</div> </div>
</div> </div>
...@@ -212,7 +378,8 @@ ...@@ -212,7 +378,8 @@
import "@/assets/spritesmith-generated/sprite.css"; import "@/assets/spritesmith-generated/sprite.css";
//import store from "@/vuex/store.js"; //import store from "@/vuex/store.js";
//import remoteLoad from "@/utils/remoteLoad.js"; //import remoteLoad from "@/utils/remoteLoad.js";
import mapService from "@/utils/mapService.js"; // import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js"; import "@/utils/mapEvent.js";
//import monitor from '@/utils/monitor' //import monitor from '@/utils/monitor'
import EventBus from "@/event-bus"; import EventBus from "@/event-bus";
...@@ -287,7 +454,7 @@ export default { ...@@ -287,7 +454,7 @@ export default {
loadingMore: false, loadingMore: false,
placeholderText: "请输入6位以上车架号", placeholderText: "请输入6位以上车架号",
vidCode: undefined, vidCode: undefined,
sourceType: 0 sourceType: 0,
}; };
}, },
computed: { computed: {
...@@ -443,7 +610,7 @@ export default { ...@@ -443,7 +610,7 @@ export default {
params = { uId: data.id }; params = { uId: data.id };
} }
console.log("勾选树:", data); // console.log("勾选树:", data);
params.termType = this.searchType; params.termType = this.searchType;
params.term = this.searchText; params.term = this.searchText;
...@@ -464,9 +631,9 @@ export default { ...@@ -464,9 +631,9 @@ export default {
//return false; //return false;
} }
console.log(list); // console.log(list);
let defaultVid = list && list.length ? list[list.length-1].vid : null let defaultVid = list && list.length ? list[list.length - 1].vid : null;
localStorage.setItem('vehicleId', defaultVid) localStorage.setItem("vehicleId", defaultVid);
let items = []; let items = [];
items = list.map((item) => { items = list.map((item) => {
return { return {
...@@ -477,7 +644,7 @@ export default { ...@@ -477,7 +644,7 @@ export default {
id: item.id, id: item.id,
source: item.source === "有线" ? "1" : "0", source: item.source === "有线" ? "1" : "0",
sourceType: item.source, sourceType: item.source,
vid: item.vid vid: item.vid,
}; };
}); });
...@@ -554,7 +721,7 @@ export default { ...@@ -554,7 +721,7 @@ export default {
node.data.test = true; node.data.test = true;
} else { } else {
if (origin.type === "u") { if (origin.type === "u") {
console.log("u"); // console.log("u");
let oParams = {}; let oParams = {};
oParams.uId = nodeData.id; oParams.uId = nodeData.id;
oParams.termType = this.searchType; oParams.termType = this.searchType;
...@@ -585,7 +752,7 @@ export default { ...@@ -585,7 +752,7 @@ export default {
return resolve(nodeData.children); return resolve(nodeData.children);
} else { } else {
if (origin.type === "u") { if (origin.type === "u") {
console.log("进入此处"); // console.log("进入此处");
let oParams = {}; let oParams = {};
oParams.uId = nodeData.id; oParams.uId = nodeData.id;
if (this.searchText) { if (this.searchText) {
...@@ -646,51 +813,33 @@ export default { ...@@ -646,51 +813,33 @@ export default {
resolve(data); resolve(data);
}, 500); }, 500);
}, },
initMap() { async initBMap() {
let check = () => { this.mapObj = await mapService.init("map");
this.checkLoadedTimeoutId && window.AMap = this.mapObj;
window.clearTimeout(this.checkLoadedTimeoutId); this.isInitMap = true;
if (this.$route.query.snArr) {
return setTimeout(() => { let routeQuery = JSON.parse(this.$route.query.snArr);
if ( if (routeQuery.length > 0) {
"AMap" in window && routeQuery.forEach((item) => {
typeof AMap.Map == "function" && this.addMonitor(item);
!this.mapObj });
) { this.autoOpenLastInfoWindow = true;
window.AMap = AMap; this.listDialogHidden = false;
this.mapObj = mapService.init("map"); }
this.isInitMap = true; }
if (this.$route.query.snArr) { if (this.$route.query.vin) {
let routeQuery = JSON.parse(this.$route.query.snArr); MONITOR_SERVICE.getVehicleTree({
if (routeQuery.length > 0) { termType: 2,
/* this.addMonitor(routeQuery[0]); term: this.$route.query.vin,
this.autoOpenLastInfoWindow = true; */ returnTrees: true,
routeQuery.forEach((item) => { }).then((res) => {
this.addMonitor(item); const items = res.data;
}); this.autoOpenLastInfoWindow = true;
this.autoOpenLastInfoWindow = true; this.expandTreeItems(items);
this.listDialogHidden = false; });
} this.treeHidden = false;
} this.listDialogHidden = true;
if (this.$route.query.vin) { }
MONITOR_SERVICE.getVehicleTree({
termType: 2,
term: this.$route.query.vin,
returnTrees: true,
}).then((res) => {
const items = res.data;
this.autoOpenLastInfoWindow = true;
this.expandTreeItems(items);
});
this.treeHidden = false;
this.listDialogHidden = true;
}
} else {
this.checkLoadedTimeoutId = check();
}
}, 100);
};
this.checkLoadedTimeoutId = check();
}, },
keyupSubmit() { keyupSubmit() {
document.onkeydown = (e) => { document.onkeydown = (e) => {
...@@ -773,13 +922,16 @@ export default { ...@@ -773,13 +922,16 @@ export default {
term: this.searchText, term: this.searchText,
}).then((res) => { }).then((res) => {
this.isSearching = false; this.isSearching = false;
console.log(res); // console.log(res);
let list = res.data || []; let list = res.data || [];
if (!list || list.length <= 0) { if (!list || list.length <= 0) {
return false; return false;
} }
this.vidCode = list[0].vid; this.vidCode = list[0].vid;
localStorage.setItem('vehicleId', list && list[0] ? list[0].vid : null) localStorage.setItem(
"vehicleId",
list && list[0] ? list[0].vid : null
);
for (var i = 0, len = list.length; i < len; i++) { for (var i = 0, len = list.length; i < len; i++) {
_this.handleSelect(list[i]); _this.handleSelect(list[i]);
} }
...@@ -807,12 +959,12 @@ export default { ...@@ -807,12 +959,12 @@ export default {
let _this = this; let _this = this;
arr.forEach((item) => { arr.forEach((item) => {
if (isDevice) { if (isDevice) {
console.log(item.id); // console.log(item.id);
let keys = _this.$refs.tree.getCheckedKeys(); let keys = _this.$refs.tree.getCheckedKeys();
console.log("keys", keys); // console.log("keys", keys);
//_this.$refs.tree.setCheckedKeys(keys); //_this.$refs.tree.setCheckedKeys(keys);
_this.checkedKeys.push(item.id); _this.checkedKeys.push(item.id);
console.log("勾选key:", _this.checkedKeys); // console.log("勾选key:", _this.checkedKeys);
_this.$refs.tree.setCheckedKeys(_this.checkedKeys); _this.$refs.tree.setCheckedKeys(_this.checkedKeys);
this.addMonitor({ this.addMonitor({
sn: item.label, sn: item.label,
...@@ -822,12 +974,12 @@ export default { ...@@ -822,12 +974,12 @@ export default {
id: item.id, id: item.id,
source: item.source === "有线" ? "1" : "0", source: item.source === "有线" ? "1" : "0",
sourceType: item.source, sourceType: item.source,
vid: item.vid vid: item.vid,
}); });
} else { } else {
console.log("展开节点", item); // console.log("展开节点", item);
this.expandedKeys.push(item.id); this.expandedKeys.push(item.id);
console.log(this.expandedKeys); // console.log(this.expandedKeys);
} }
if (item.children && item.children.length) { if (item.children && item.children.length) {
this.expandTreeItems( this.expandTreeItems(
...@@ -923,7 +1075,7 @@ export default { ...@@ -923,7 +1075,7 @@ export default {
_this.currentMessage = this.$message({ _this.currentMessage = this.$message({
type: "error", type: "error",
message: "该列表中有设备正在监控中,请勿重复监控", message: "该列表中有设备正在监控中,请勿重复监控",
onClose: function() { onClose: function () {
_this.currentMessage = ""; _this.currentMessage = "";
}, },
}); });
...@@ -941,15 +1093,6 @@ export default { ...@@ -941,15 +1093,6 @@ export default {
} }
this.getPositionData(); this.getPositionData();
}, },
// standNoMonitor(item){
// this.resetRefreshCount = true;
// this.monitorList.count++;
// for (let i in item) {
// this.monitorList[item.sn] = item[i].sn;
// }
// this.getPositionData();
// },
// 批量监控 // 批量监控
addMonitorByGroup(items) { addMonitorByGroup(items) {
...@@ -1034,8 +1177,6 @@ export default { ...@@ -1034,8 +1177,6 @@ export default {
// 获取设备位置点 // 获取设备位置点
getPositionData(arr) { getPositionData(arr) {
/* let _this = this;
arr = arr.filter((item)=>this.monitorList[item.sn]); */
let snStr = this.monitorList.itemArr.join(","); //arr.map((item)=>item.sn).join(','); let snStr = this.monitorList.itemArr.join(","); //arr.map((item)=>item.sn).join(',');
if (!snStr) return; if (!snStr) return;
if (this.resetRefreshCount || this.remainSearchSnStr != snStr) { if (this.resetRefreshCount || this.remainSearchSnStr != snStr) {
...@@ -1066,8 +1207,8 @@ export default { ...@@ -1066,8 +1207,8 @@ export default {
item = this.filterGpsBase(item); item = this.filterGpsBase(item);
item.isSource = relItem.source; item.isSource = relItem.source;
item.vidCode = this.vidCode item.vidCode = this.vidCode;
item.sourceType = this.sourceType item.sourceType = this.sourceType;
}); });
this.monitorList = Object.assign({}, this.monitorList); this.monitorList = Object.assign({}, this.monitorList);
let drawData = data.filter( let drawData = data.filter(
...@@ -1152,11 +1293,10 @@ export default { ...@@ -1152,11 +1293,10 @@ export default {
return item; return item;
}, },
errorUpload(err) { errorUpload(err) {
console.log(err); // console.log(err);
//window.location.href = '../ots/login'; //window.location.href = '../ots/login';
}, },
drawDoneCb() { drawDoneCb() {
console.log("drawDoneCb");
this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId); this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId);
/* let arr = []; /* let arr = [];
for(let key in this.monitorList){ for(let key in this.monitorList){
...@@ -1173,7 +1313,7 @@ export default { ...@@ -1173,7 +1313,7 @@ export default {
this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId); this._drawTimeoutId && window.clearTimeout(this._drawTimeoutId);
}, },
openMapInfoWindow(sn, source, vid) { openMapInfoWindow(sn, source, vid) {
localStorage.setItem('vehicleId', vid) localStorage.setItem("vehicleId", vid);
EventBus.$emit("uiMap.monitor.openInfoWindow", `${sn}:${source}`); EventBus.$emit("uiMap.monitor.openInfoWindow", `${sn}:${source}`);
}, },
downloadTpl() { downloadTpl() {
...@@ -1261,7 +1401,7 @@ export default { ...@@ -1261,7 +1401,7 @@ export default {
let oParams = {}; let oParams = {};
oParams.sns = sns; oParams.sns = sns;
GET_MONITOR_ONLINELIST(oParams).then((res) => { }); GET_MONITOR_ONLINELIST(oParams).then((res) => {});
}, },
}, },
created() { created() {
...@@ -1273,11 +1413,14 @@ export default { ...@@ -1273,11 +1413,14 @@ export default {
this.getTreeData(); this.getTreeData();
}, },
mounted() { mounted() {
let _this = this; // let _this = this;
_this.$mapInit({ version: "2.0" }).then((AMap) => { // _this.$mapInit({ version: "2.0" }).then((AMap) => {
window.AMap = AMap;
_this.initMap(); // window.AMap = AMap;
}); // console.log("AMap:", AMap,window);
// _this.initMap();
// });
this.initBMap();
}, },
beforeDestroy() { beforeDestroy() {
document.onkeydown = null; document.onkeydown = null;
...@@ -1316,7 +1459,7 @@ export default { ...@@ -1316,7 +1459,7 @@ export default {
line-height: 26px; line-height: 26px;
} }
.map-wrap .el-tree-node>.el-tree-node__children { .map-wrap .el-tree-node > .el-tree-node__children {
overflow: visible; overflow: visible;
} }
......
...@@ -188,7 +188,8 @@ ...@@ -188,7 +188,8 @@
<script> <script>
import store from "../../vuex/store.js"; import store from "../../vuex/store.js";
import remoteLoad from "utils/remoteLoad.js"; import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js"; // import mapService from "utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "utils/mapEvent.js"; import "utils/mapEvent.js";
import EventBus from "../../event-bus"; import EventBus from "../../event-bus";
import { services } from "../../api"; import { services } from "../../api";
...@@ -331,38 +332,17 @@ export default { ...@@ -331,38 +332,17 @@ export default {
}, },
}, },
methods: { methods: {
initMap() { async initBMap(){
let _this = this; this.mapObj = await mapService.init("map");
let check = () => { window.AMap = this.mapObj;
_this.checkMapLoaded && window.clearTimeout(_this.checkMapLoaded); this.isInitMap = true;
if (
return setTimeout(() => { this.isInitFence &&
if ( this.fenceId &&
"AMap" in window && this.fenceId != "undefined"
typeof AMap.Map == "function" &&
!_this.mapObj
) {
window.AMap = AMap;
_this.mapObj = mapService.init("map");
//this.bindEvent();
_this.isInitMap = true;
//_this.drawPoi();
console.log(_this.fenceId != "undefined");
if (
_this.isInitFence &&
_this.fenceId &&
_this.fenceId != "undefined"
) { ) {
//_this.drawFence(); this.getFence();
_this.getFence();
} }
} else {
_this.checkMapLoaded = check();
}
}, 100);
};
_this.checkMapLoaded = check();
}, },
pickDate(recentHoursOrDays) { pickDate(recentHoursOrDays) {
let unit = "days"; let unit = "days";
...@@ -590,7 +570,6 @@ export default { ...@@ -590,7 +570,6 @@ export default {
times: "0", times: "0",
locationType: this.form.replayType == "RtTrack" ? 0 : 1, locationType: this.form.replayType == "RtTrack" ? 0 : 1,
}).then((res) => { }).then((res) => {
console.log(res);
if (res.code == 200) { if (res.code == 200) {
const data = res.data; const data = res.data;
if (data.length) { if (data.length) {
...@@ -668,8 +647,6 @@ export default { ...@@ -668,8 +647,6 @@ export default {
drawPoi() { drawPoi() {
let _this = this; let _this = this;
BUSINESS_SERVICE.getPOI({ sn: _this.sn }).then((res) => { BUSINESS_SERVICE.getPOI({ sn: _this.sn }).then((res) => {
console.log("666666666666");
console.log(res);
if (res.returnCode === "0") { if (res.returnCode === "0") {
if (res.data && res.data.length) { if (res.data && res.data.length) {
res.data.forEach((item) => { res.data.forEach((item) => {
...@@ -687,48 +664,18 @@ export default { ...@@ -687,48 +664,18 @@ export default {
} }
}); });
}, },
drawFence() {
MONITOR_SERVICE.getSingleFence({
sn: this.sn,
fenceId: parseInt(this.fenceId),
}).then((res) => {
if (res.returnCode == 0) {
const data = res.data;
if (data) {
if (data.shapeType === 2) {
EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: data.lng,
lat: data.lat,
radius: data.radius,
isEdit: false,
});
} else if (data.shapeType === 3) {
this.drawDistrict(data.areaCode);
} else if (data.shapeType === 5) {
if (data.lnglat) {
let polygonPath = data.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
});
this.drawPolygon(polygonPath);
}
}
}
}
});
},
// 行政区域围栏 // 行政区域围栏
drawDistrict(areaCode) { drawDistrict(areaText) {
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId); this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
this._drawDistrictTimeoutId = setTimeout(() => { this._drawDistrictTimeoutId = setTimeout(() => {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode); EventBus.$emit("uiMap.fence.drawDistrict", areaText);
}, 500); }, 500);
}, },
// 多边形围栏 // 多边形围栏
drawPolygon(path) { drawPolygon(path) {
console.log("path");
EventBus.$emit("uiMap.fence.drawPolygon", { EventBus.$emit("uiMap.fence.drawPolygon", {
path, path,
isEdit: false, isEdit: false,
...@@ -741,7 +688,6 @@ export default { ...@@ -741,7 +688,6 @@ export default {
//sn: this.sn, //sn: this.sn,
fenceId: this.fenceId, fenceId: this.fenceId,
}).then((res) => { }).then((res) => {
console.log(res);
let list = res.data || []; let list = res.data || [];
if (res.code != 200) { if (res.code != 200) {
return false; return false;
...@@ -767,31 +713,23 @@ export default { ...@@ -767,31 +713,23 @@ export default {
// 行政区域围栏 // 行政区域围栏
if (obj.shapeType == 4) { if (obj.shapeType == 4) {
this.drawDistrict([obj.areaCode]); this.drawDistrict([obj.areaText]);
} }
}); });
}, },
}, },
created() { created() {
let _this = this; // let _this = this;
let _config = { version: "1.4.2" }; // let _config = { version: "1.4.2" };
_config.AMapUI = { // _config.AMapUI = {
version: "1.1", // version: "1.1",
plugins: ["/misc/PathSimplifier"], // plugins: ["/misc/PathSimplifier"],
}; // };
_this.$mapInit(_config).then((AMap) => { // _this.$mapInit(_config).then((AMap) => {
console.log(window.AMap); // _this.initMap();
_this.initMap(); // });
// if (AMap) { this.initBMap();
// remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
// () => {
// _this.initMap();
// }
// );
// }
});
//轨迹播放当前位置地址显示 //轨迹播放当前位置地址显示
EventBus.$on("uiMap.replay.currAddress", (adr) => { EventBus.$on("uiMap.replay.currAddress", (adr) => {
this.replayAddr = adr; this.replayAddr = adr;
...@@ -845,4 +783,5 @@ export default { ...@@ -845,4 +783,5 @@ export default {
.clearMargin { .clearMargin {
margin-left: 0px; margin-left: 0px;
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -101,7 +101,8 @@ ...@@ -101,7 +101,8 @@
<script> <script>
import store from "../../vuex/store.js"; import store from "../../vuex/store.js";
import remoteLoad from "utils/remoteLoad.js"; import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js"; // import mapService from "utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "utils/mapEvent.js"; import "utils/mapEvent.js";
import EventBus from "../../event-bus"; import EventBus from "../../event-bus";
import { services } from "../../api"; import { services } from "../../api";
...@@ -142,36 +143,13 @@ export default { ...@@ -142,36 +143,13 @@ export default {
}; };
}, },
mounted() { mounted() {
// store.dispatch('setFullsize', true) this.initBMap();
let _this = this;
_this.$mapInit({ version: "1.4.2" }).then((AMap) => {
window.AMap = AMap;
_this.initMap();
});
}, },
methods: { methods: {
initMap() { async initBMap() {
let check = () => { this.mapObj = await mapService.init("map");
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded); window.AMap = this.mapObj;
this.isInitMap = true;
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) { pickDate(beforeDays) {
this.form.dateRange = [ this.form.dateRange = [
...@@ -279,35 +257,6 @@ export default { ...@@ -279,35 +257,6 @@ export default {
exportExcel() { exportExcel() {
if (this.exporting) return; if (this.exporting) return;
if (this.resultList.length) { if (this.resultList.length) {
// let paramArr = [];
// this.resultList.forEach((dataItem)=>{
// let paramItem = {};
// for(let key in dataItem){
// switch(key){
// case 'name':
// case 'shopName':
// case 'sn':
// case 'sqbh':
// case 'standNo':
// case 'totalDurationString':
// case 'transferAddress':
// paramItem[key] = dataItem[key]?dataItem[key]:'';
// break;
// case 'totalTimes':
// paramItem[key] = dataItem[key]?(dataItem[key]+'次'):'';
// break;
// /*case 'transferAddress':
// paramItem.address = dataItem.transferAddress?dataItem.transferAddress:'';
// break;*/
// }
// }
// paramArr.push(paramItem);
// });
// exportExcel('track/exportVMData', {
// jsonStr: encodeURI(JSON.stringify(paramArr)),
// vmExportType: 4
// }, 'post');
exportExcel( exportExcel(
"/trialdrive/monitor/exportResident", "/trialdrive/monitor/exportResident",
{ ...this.params }, { ...this.params },
...@@ -330,6 +279,7 @@ export default { ...@@ -330,6 +279,7 @@ export default {
BUSINESS_SERVICE.getPOI({ BUSINESS_SERVICE.getPOI({
sn: this.sn, sn: this.sn,
}).then((res) => { }).then((res) => {
console.log(res)
if (res.returnCode === "0") { if (res.returnCode === "0") {
if (res.data && res.data.length) { if (res.data && res.data.length) {
res.data.forEach((item) => { res.data.forEach((item) => {
...@@ -349,7 +299,6 @@ export default { ...@@ -349,7 +299,6 @@ export default {
}, },
}, },
async created() { async created() {
EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => { EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
this.resultList = [].concat(data); this.resultList = [].concat(data);
}); });
......
...@@ -160,7 +160,8 @@ ...@@ -160,7 +160,8 @@
</v-full-layout> </v-full-layout>
</template> </template>
<script> <script>
import mapService from "@/utils/mapService.js"; // import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js"; import "@/utils/mapEvent.js";
import { CONSTANT } from "@/constant"; import { CONSTANT } from "@/constant";
import { import {
...@@ -222,48 +223,33 @@ export default { ...@@ -222,48 +223,33 @@ export default {
}; };
}, },
mounted() { mounted() {
this.initMap(); // this.initMap();
this.initBMap();
}, },
methods: { methods: {
// 地图初始化 async initBMap() {
initMap() { console.log(11111111111);
let _this = this; this.mapObj = await mapService.init("map");
let plugins = CONSTANT.MAP_PLUGINS.concat([ this.mapLoading = false;
"AMap.LngLat", window.AMap = this.mapObj;
"AMap.Rectangle", AMap.invoke("LocalCity", (res) => {
"AMap.LabelsLayer", AMap.invoke('panTo',res.center)
"AMap.LabelMarker", });
"AMap.AutoComplete", this.autoComplete = AMap.invoke("Autocomplete", {
"AMap.MassMarks", input: "tipInput",
"AMap.MarkerCluster", });
"AMap.Bounds", AMap.invoke("autocompleteShow");
"AMap.MouseTool" AMap.invoke("autocompleteAddEventListener", "onconfirm", (e) => {
]); this.poi = e.item.value;
_this.$mapInit({ plugins: plugins }).then((AMap) => { this.$set(this.form, "address", this.poi.address);
_this.mapLoading = false; this.$refs.addressInput.focus();
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()]);
}); });
// 判断是否为全屏,是否带参数,如果带了矩形参数,则默认画一个矩形
let _query = this.$route.query;
if (_query.type == "full" && _query.leftLngLat) {
this.initPage(_query);
}
}, },
// 获取地址 // 获取地址
...@@ -272,86 +258,142 @@ export default { ...@@ -272,86 +258,142 @@ export default {
let poi = this.poi; let poi = this.poi;
_this.clearMap(); _this.clearMap();
if (poi && poi.location) { if (poi && poi.location) {
AMap.invoke("panTo", poi.location, true);
_this.autoCenterMarker = mapService.createMarker(poi.location); _this.autoCenterMarker = mapService.createMarker(poi.location);
_this.map.setFitView(); AMap.invoke("addOverlay", _this.autoCenterMarker);
_this.map.add(_this.autoCenterMarker); AMap.invoke("setZoom", 16);
} }
}, },
// 选择区域 // 选择区域
async chooseArea() { async chooseArea() {
let _this = this; const _this = this;
let _map = this.map; const MAP = mapService.map;
let _zoom = _map.getZoom(); // let _zoom = _map.getZoom();
if (_this.rectangle) { if (_this.rectangle) {
showToast({ showToast({
message: "地图上已有矩形,请先清除再画", message: "地图上已有矩形,请先清除再画",
}); });
return false; return false;
} }
// if (_zoom < 11) {
// _this.map.setZoom(11);
// }
// _this.map.setZooms([11, 30]);
var styleOptions = {
fillColor: "#2C68FF",
strokeColor: "#2C68FF",
fillOpacity: 0.3, // 填充透明度,取值范围0-1
strokeWeight: 4, // 边线宽度,以像素为单位
strokeOpacity: 1, // 边线透明度,取值范围0-1
fillColor: "#1791fc", // 填充颜色。当参数为空时,圆形没有填充颜色
};
var labelOptions = {
borderRadius: "2px",
background: "#FF33FF",
border: "1px solid #E1E1E1",
color: "#703A04",
fontSize: "12px",
letterSpacing: "0",
padding: "5px",
};
_this.drawingManager = MAP.invoke(
"DrawingManager",
mapService.mapInstance,
{
isOpen: true, // 是否开启绘制模式
enableDrawingTool: false,
enableCalculate: true, // 绘制是否进行测距测面
enableSorption: true, // 是否开启边界吸附功能
sorptiondistance: 20, // 边界吸附距离
circleOptions: styleOptions, // 圆的样式
polylineOptions: styleOptions, // 线的样式
polygonOptions: styleOptions, // 多边形的样式
rectangleOptions: styleOptions, // 矩形的样式
labelOptions: labelOptions, // label样式
}
);
MAP.invoke(
"drawingManagerAddEventListener",
"rectanglecomplete",
function (e) {
console.log(e);
_this.rectangle = e;
let bounds = e.getBounds();
_this.calculateWidthHeight(bounds);
}
);
MAP.invoke("setDrawingMode", "rectangle");
// if (_this.mouseTool) { // if (_this.mouseTool) {
// _this.mouseTool.rectangle({
// fillColor: "#2C68FF",
// strokeColor: "#2C68FF",
// fillOpacity: 0.3,
// strokeWeight: 4,
// strokeOpacity: 1,
// draggable: true,
// });
// _this.mouseTool.on("draw", function (e) {
// let rectangle = e.obj;
// _this.mouseTool.close(); // _this.mouseTool.close();
// return false; // _this.rectangle = rectangle;
// _this.calculateWidthHeight(rectangle.getOptions().bounds);
// });
// } // }
if (_zoom < 11) {
_this.map.setZoom(11);
}
_this.map.setZooms([11, 30]);
if (_this.mouseTool) {
_this.mouseTool.rectangle({
fillColor: "#2C68FF",
strokeColor: "#2C68FF",
fillOpacity: 0.3,
strokeWeight: 4,
strokeOpacity: 1,
draggable: true,
});
_this.mouseTool.on("draw", function (e) {
let rectangle = e.obj;
_this.mouseTool.close();
_this.rectangle = rectangle;
_this.calculateWidthHeight(rectangle.getOptions().bounds);
});
}
}, },
getDistance(lat1, lon1, lat2, lon2) {
var R = 6371e3; // 地球半径,单位:米
var rad = Math.PI / 180;
var lat1Rad = lat1 * rad;
var lon1Rad = lon1 * rad;
var lat2Rad = lat2 * rad;
var lon2Rad = lon2 * rad;
var deltaLat = lat2Rad - lat1Rad;
var deltaLon = lon2Rad - lon1Rad;
var a =
Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) +
Math.cos(lat1Rad) *
Math.cos(lat2Rad) *
Math.sin(deltaLon / 2) *
Math.sin(deltaLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return R * c; // 距离,单位:米
},
// 计算矩形宽度、高度 // 计算矩形宽度、高度
calculateWidthHeight(lnglats) { calculateWidthHeight(lnglats) {
if (!lnglats) { if (!lnglats) {
return {}; return {};
} }
// 左下角点坐标 // 左下角点坐标
let southWest = lnglats.southWest || {}; let southWest = lnglats.getSouthWest() || {};
// 右上角点坐标 // 右上角点坐标
let northEast = lnglats.northEast || {}; let northEast = lnglats.getNorthEast() || {};
console.log(southWest, northEast);
// 计算高度 // 计算长和宽
let _height = AMap.GeometryUtil.distance( var width = this.getDistance(
[southWest.lng, southWest.lat], southWest.lat,
[southWest.lng, northEast.lat] southWest.lng,
); northEast.lat,
southWest.lng
// 计算宽度 ); // 西到东的距离
let _width = AMap.GeometryUtil.distance( var height = this.getDistance(
[southWest.lng, southWest.lat], southWest.lat,
[northEast.lng, southWest.lat] southWest.lng,
); southWest.lat,
this.rectangleHeight = _height.toFixed(0); northEast.lng
this.rectangleWidth = _width.toFixed(0); ); // 南到北的距离
console.log(width, height);
this.rectangleHeight = width.toFixed(0);
this.rectangleWidth = height.toFixed(0);
}, },
// 清空地图覆盖物 // 清空地图覆盖物
clearMap() { clearMap() {
if (this.map) { AMap.invoke("clearOverlays");
this.map.clearMap();
}
this.rectangleHeight = 0; this.rectangleHeight = 0;
this.rectangleWidth = 0; this.rectangleWidth = 0;
this.rectangle = null; this.rectangle = null;
//this.mouseTool = null;
this.deviceList = []; this.deviceList = [];
this.map.setZooms([2, 30]);
}, },
// 清空筛选条件 // 清空筛选条件
...@@ -361,10 +403,6 @@ export default { ...@@ -361,10 +403,6 @@ export default {
this.rectangleWidth = 0; this.rectangleWidth = 0;
this.form = {}; this.form = {};
this.deviceList = []; this.deviceList = [];
if (this.mouseTool) {
this.mouseTool.close(true);
//this.mouseTool = null;
}
}, },
// 展开 // 展开
...@@ -426,10 +464,22 @@ export default { ...@@ -426,10 +464,22 @@ export default {
return {}; return {};
} }
let params = {}; let params = {};
let o = this.rectangle.getOptions(); let bounds = this.rectangle.getBounds() || {};
let bounds = o.bounds || {}; params.leftLngLat = `${bounds.getSouthWest().lng},${
params.leftLngLat = `${bounds.southWest.lng},${bounds.southWest.lat}`; bounds.getSouthWest().lat
params.rightLngLat = `${bounds.northEast.lng},${bounds.northEast.lat}`; }`;
params.rightLngLat = `${bounds.getNorthEast().lng},${
bounds.getNorthEast().lat
}`;
console.log(this.rectangle.getPath());
let pathArr = this.rectangle.getPath();
try {
pathArr = pathArr.map((item) => {
return item.lng + "," + item.lat;
});
params.paths = pathArr.join("|");
} catch (error) {}
return params; return params;
}, },
...@@ -444,6 +494,7 @@ export default { ...@@ -444,6 +494,7 @@ export default {
} }
this.dloading = true; this.dloading = true;
delete params.paths;
let res = await GER_REGIONAL_EXPORT(params); let res = await GER_REGIONAL_EXPORT(params);
this.dloading = false; this.dloading = false;
if (res.code != 200) { if (res.code != 200) {
...@@ -504,8 +555,8 @@ export default { ...@@ -504,8 +555,8 @@ export default {
list.forEach((item) => { list.forEach((item) => {
let o = deepClone(item || {}); let o = deepClone(item || {});
let m = o.gpsLocation || {}; let m = o.gpsLocation || {};
o.lng = m.elng; o.lng = m.blng;
o.lat = m.elat; o.lat = m.blat;
o.address = m.address; o.address = m.address;
o.type = 2; o.type = 2;
o.time = m.dateTime; o.time = m.dateTime;
...@@ -517,19 +568,6 @@ export default { ...@@ -517,19 +568,6 @@ export default {
_this.addMarkers(arr); _this.addMarkers(arr);
}); });
}); });
// if (!this.form.sn) {
// showToast({
// message: "请输入设备号",
// });
// return false;
// }
// if (!Validator.ISDECIMAL.test(this.form.sn)) {
// showToast({
// message: "设备号必须为纯数字",
// });
// return false;
// }
}, },
// 区域查车 // 区域查车
...@@ -548,7 +586,7 @@ export default { ...@@ -548,7 +586,7 @@ export default {
_this.deviceList = []; _this.deviceList = [];
if (_this.mapMass) { if (_this.mapMass) {
_this.mapMass.clear(); AMap.invoke("clearOverlays");
_this.mapMass = null; _this.mapMass = null;
} }
if (_options.type != "full") { if (_options.type != "full") {
...@@ -557,7 +595,9 @@ export default { ...@@ -557,7 +595,9 @@ export default {
} }
_this.loading = true; _this.loading = true;
delete params.paths;
let res = await GER_REGIONAL_SEARCH(params); let res = await GER_REGIONAL_SEARCH(params);
console.log(res, "res");
_this.loading = false; _this.loading = false;
if (res.code != 200) { if (res.code != 200) {
showToast({ showToast({
...@@ -575,82 +615,39 @@ export default { ...@@ -575,82 +615,39 @@ export default {
drawDistrict(areaCode) { drawDistrict(areaCode) {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode); EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
}, },
// 添加海量点 聚合点方式
// addMarkers3(arr) {
// let _this = this;
// let markers = [];
// let icon = {
// url: require("images/icon_car.png"),
// size: new AMap.Size(24, 15),
// offset: new AMap.Pixel(4, 4),
// };
// let renderMarker = function (context) {
// console.log(context.data);
// var content = '<div style="background-color: hsla(180, 100%, 50%, 0.3); height: 18px; width: 18px; border: 1px solid hsl(180, 100%, 40%); border-radius: 12px; box-shadow: hsl(180, 100%, 50%) 0px 0px 3px;"></div>';
// //context.marker.setIcon(require("images/icon_car.png"))
// context.marker.setContent(content)
// context.marker.setSize(24,15);
// // let m = new AMap.Marker({
// // icon: require("images/icon_car.png"),
// // position: context.data[0].lnglat,
// // });
// };
// for (let i = 0, len = arr.length; i < len; i++) {
// let k = arr[i];
// k.lnglat = [k.lng, k.lat];
// markers.push(k);
// }
// let params = {
// gridSize: 60,
// renderMarker: renderMarker,
// };
// let cluster = new AMap.MarkerCluster(_this.map, markers, params);
// },
// 添加海量点 (MassMarks方式) // 添加海量点 (MassMarks方式)
addMarkers(arr) { addMarkers(arr) {
let _this = this; let _this = this;
let markers = []; let markers = [];
let icon = { console.log(arr);
type: "image",
url: require("images/icon_car.png"),
size: [24, 15],
anchor: new AMap.Pixel(4, 4),
};
for (let i = 0, len = arr.length; i < len; i++) { for (let i = 0, len = arr.length; i < len; i++) {
let k = arr[i]; let k = arr[i];
k.lnglat = [k.lng, k.lat]; console.log(k);
markers.push(k); let lnglat = mapService.getLngLat(k.lng, k.lat);
let marker = mapService.createCarMarker(lnglat);
markers.push(marker);
AMap.invoke("addOverlay", marker);
AMap.invoke("panTo", lnglat);
AMap.invoke("markerAddEventListener", "click", (e) => {
console.log(e);
let infoWindow = mapService.createAraeInfowindow(k);
AMap.invoke("mapOpenInfoWindow", infoWindow, e.target.getPosition());
});
} }
var mass = new AMap.MassMarks(markers, {
opacity: 0.8,
zIndex: 111,
cursor: "pointer",
style: icon,
alwaysRender: false,
});
mass.on("click", function (e) {
console.log(e);
let infoWindow = mapService.createAraeInfowindow(e.data);
infoWindow.open(_this.map);
});
mass.setMap(_this.map);
this.drawDone = true; this.drawDone = true;
if (arr && arr.length < 10) { // if (arr && arr.length < 10) {
this.map.setFitView(); // // this.map.setFitView();
} // }
this.mapMass = mass; this.mapMass = markers;
}, },
// 全屏状态下,根据参数初始化页面 // 全屏状态下,根据参数初始化页面
initPage(query) { initPage(query) {
console.log(query);
this.menuId = query.menuId; this.menuId = query.menuId;
if (query.address) { if (query.address) {
this.$set(this.form, "address", query.address); this.$set(this.form, "address", query.address);
} }
if (query.sn) { if (query.sn) {
this.$set(this.form, "sn", query.sn); this.$set(this.form, "sn", query.sn);
} }
...@@ -662,41 +659,57 @@ export default { ...@@ -662,41 +659,57 @@ export default {
// 如果是地址,则标记出对应的点 // 如果是地址,则标记出对应的点
if (query.menuId == 1 && query.lng) { if (query.menuId == 1 && query.lng) {
let poi = new AMap.LngLat(query.lng, query.lat); let poi = AMap.invoke("Point", query.lng, query.lat);
this.autoCenterMarker = mapService.createMarker(poi); this.autoCenterMarker = mapService.createMarker(poi);
this.map.add(this.autoCenterMarker); AMap.invoke("addOverlay", this.autoCenterMarker);
AMap.invoke("panTo", poi);
} }
this.drawRectangle(query); this.drawRectangle(query);
this.getAreaLocation(); this.getAreaLocation();
this.autoComplete.setInputValue(this.form.address);
}, },
// 绘画矩形 // 绘画矩形
drawRectangle(query) { drawRectangle(query) {
let leftLngLat = query.leftLngLat.split(","); const MAP = mapService.map;
let rightLngLat = query.rightLngLat.split(","); let arr = query.paths.split("|");
let southWest = new AMap.LngLat(leftLngLat[0], leftLngLat[1]); let pathArr = arr.map((item) => {
let northEast = new AMap.LngLat(rightLngLat[0], rightLngLat[1]); let lnglat = item.split(",");
let bounds = new AMap.Bounds(southWest, northEast); return mapService.getLngLat(lnglat[0], lnglat[1]);
let rectangle = new AMap.Rectangle({ });
bounds: bounds, console.log(pathArr);
const overlay = AMap.invoke("Polygon", pathArr, {
fillColor: "#2C68FF", fillColor: "#2C68FF",
strokeColor: "#2C68FF", strokeColor: "#2C68FF",
fillOpacity: 0.3, fillOpacity: 0.3,
strokeWeight: 4, strokeWeight: 4,
strokeOpacity: 1, strokeOpacity: 1,
draggable: true, enableLimit: false,
enableCalculate: false,
}); });
this.map.add(rectangle); AMap.invoke("addOverlay", overlay);
this.rectangle = rectangle; console.log(overlay);
this.calculateWidthHeight(rectangle.getOptions().bounds); AMap.invoke("rectOpenEdit", overlay, {
isOpen: false,
let _zoom = this.map.getZoom(); enableDragging: true,
}); //开启编辑
// AMap.invoke("rectCloseEdit"); //关闭编辑
// AMap.invoke("rectAddEventListener", "operate-change", (e) => {
// console.log(e.target);
// });
this.rectangle = overlay;
this.calculateWidthHeight(overlay.getBounds());
let _zoom = AMap.invoke("getZoom");
AMap.invoke("setZoom", 24);
console.log(_zoom);
if (_zoom < 11) { if (_zoom < 11) {
this.map.setZoom(11); AMap.invoke("setZoom", 11);
} }
this.map.setZooms([11, 30]);
this.map.setFitView(); AMap.invoke("panTo", pathArr[0], true);
}, },
// 跳转全屏页面 // 跳转全屏页面
...@@ -721,8 +734,7 @@ export default { ...@@ -721,8 +734,7 @@ export default {
if (this.form.sn) { if (this.form.sn) {
m.sn = this.form.sn; m.sn = this.form.sn;
} }
m.paths = params.paths;
console.log(qs.stringify(m));
let _path = `oEshield#/monitor/zoneCar?type=full&` + qs.stringify(m); let _path = `oEshield#/monitor/zoneCar?type=full&` + qs.stringify(m);
window.open(_path); window.open(_path);
}, },
......
/*
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-30 14:58:58
* @FilePath: \oEshield\src\utils\fence.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import EventBus from '@/event-bus' import EventBus from '@/event-bus'
import mapService from './mapService.js' // import mapService from './mapService.js'
import MAPGEO from './mapgeo' import mapService from './mapBService.js'
// import MAPGEO from './mapgeo'
import MAPGEO from './mapBgeo'
//电子围栏 //电子围栏
const fence = { const fence = {
polygons: [], polygons: [],
circle: null, circle: null,
dist:null,
drawingManager:null,
isEditMode: true, isEditMode: true,
marker:'',
bindEvent() { bindEvent() {
EventBus.$on('uiMap.fence.drawDistrict', (data) => { EventBus.$on('uiMap.fence.drawDistrict', (data) => {
this.drawDistrict(data) this.drawDistrict(data)
...@@ -32,13 +45,15 @@ const fence = { ...@@ -32,13 +45,15 @@ const fence = {
}); });
EventBus.$on('uiMap.fence.drawPolygon', (data) => { EventBus.$on('uiMap.fence.drawPolygon', (data) => {
if (data) { if (data) {
if (Array.isArray(data)) { if (Array.isArray(data)) {
this.polygonPath = data; this.polygonPath = data;
this.isEditMode = true; this.isEditMode = true;
} else if (('isEdit' in data) && !data.isEdit) { } else if (('isEdit' in data) && !data.isEdit) {
this.polygonPath = data.path; let arr= data.path.map(item=>{
return mapService.getLngLat(item[0], item[1])
})
this.polygonPath =arr;
this.isEditMode = false; this.isEditMode = false;
} }
} }
...@@ -53,129 +68,113 @@ const fence = { ...@@ -53,129 +68,113 @@ const fence = {
destroy() { destroy() {
const MAP = mapService.map; const MAP = mapService.map;
if (MAP) { if (MAP) {
this.polygons && MAP.remove(this.polygons); // // MAP.invoke('removeOverlay',this.polygons)
this.circle && MAP.remove(this.circle); // this.polygon &&MAP.invoke('removeOverlay',this.polygon);
this.circleEditor && this.circleEditor.close();//MAP.remove(this.circleEditor); // this.circle && MAP.invoke('removeOverlay',this.circle);
this.polygons = []; // this.drawingManager && MAP.invoke('removeOverlay',this.drawingManager);
this.polyEditor && this.polyEditor.close() AMap.invoke('clearOverlays');
this.mouseTool && this.mouseTool.close() AMap.invoke('addOverlay',this.marker)
this.polygon && MAP.remove(this.polygon) //清除多边形
if( this.drawingManager&&this.drawingManager.getOverlays().length){
let overlays=this.drawingManager.getOverlays()[0]
AMap.invoke('removeOverlay',overlays);
}
if(document.getElementById('cancelOperate')){
document.getElementById('cancelOperate').click()
}
this.dist&& MAP.invoke('removeDistrictLayer', this.dist)
// this.polygons = [];
// this.polyEditor && this.polyEditor.close()
// this.mouseTool && this.mouseTool.close()
} }
//this.clearTimeoutIds(); //this.clearTimeoutIds();
}, },
// 行政区域 // 行政区域
drawDistrict(data) { drawDistrict(data) {
const MAP = mapService.map;
this.destroy(); this.destroy();
if (!data || data.length <= 0) { if (!data || data.length <= 0) {
return false; return false;
} }
var opts = { if ( this.dist) AMap.invoke('removeDistrictLayer', this.dist)
subdistrict: 0, //返回下一级行政区 this.dist = AMap.invoke('DistrictLayer', {
extensions: 'all', name: `(${data[data.length-1]})`,
showbiz: false //最后一级返回街道信息 fillOpacity: 0.7,
}; fillColor: '#CCF3FF',
let oParams = data[data.length - 1]; strokeColor: '#CC66CC',
//data == "中国" ? delete opts.extensions : delete opts.showbiz; viewport: true
let district = new AMap.DistrictSearch(opts); });
switch (data.length) { AMap.invoke('addDistrictLayer', this.dist)
case 1:
district.setLevel('province'); },
break; updateFenceCircle(data){
case 2: console.log(data)
district.setLevel('city'); let center
break; AMap.invoke('circleDisableEditing')
default: if( data.radius&&this.circle){
district.setLevel('district'); this.circle.setRadius(data.radius * 1)
break;
} }
if(data.lng&&data.lat){
//EventBus.$emit('uiMap.fence.loading', true); center = mapService.getLngLat(data.lng, this.lat);
//行政区查询 this.circle&& this.circle.setCenter(center);
district.search(oParams, function (status, result) {
console.log(result) }
const dst = result.districtList[0]; center= this.circle&& this.circle.getCenter()
var bounds = dst.boundaries; AMap.invoke('removeOverlay', this.circle)
let lng = dst.center.lng; AMap.invoke('addOverlay', this.circle)
let lat = dst.center.lat; AMap.invoke('circleEnableEditing')
AMap.invoke('panTo',center,true)
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
//生成行政区划polygon
var polygon = new AMap.Polygon({
map: MAP,
strokeWeight: 1,
path: bounds[i],
fillOpacity: 0.7,
fillColor: '#CCF3FF',
strokeColor: '#CC66CC',
});
fence.polygons.push(polygon);
}
let center = mapService.getLngLat(lng, lat);
mapService.setFitView();
//EventBus.$emit('uiMap.fence.loading', false);
}
});
}, },
createFenceCircle(data) { createFenceCircle(data) {
let _this = this if(!this.circle){
const MAP = mapService.map; let _this = this
_this.destroy(); const mapInstance= mapService.mapInstance
let mapInterval = setInterval(() => { let mapInterval = setInterval(() => {
if (MAP) { if (AMap) {
clearInterval(mapInterval) clearInterval(mapInterval)
console.log(data) let lng = data.lng || _this.lng
let lng = data.lng || _this.lng let lat = data.lat || _this.lat
let lat = data.lat || _this.lat if (data.lng) {
if (data.lng) { _this.lng = data.lng
_this.lng = data.lng }
} if (data.lat) {
if (data.lat) { _this.lat = data.lat
_this.lat = data.lat }
} const lnglat=mapService.getLngLat(lng, lat)
_this.circle = new AMap.Circle({ let options={
map: MAP, strokeColor: "#F33",
center: mapService.getLngLat(lng, lat), strokeOpacity: 1,
radius: data.radius * 1, strokeWeight: 3,
strokeColor: "#F33", fillColor: "ee2200",
strokeOpacity: 1, fillOpacity: 0.35,
strokeWeight: 3, enableEditing:true
fillColor: "ee2200", }
fillOpacity: 0.35, if(!_this.isEditMode) options.enableEditing=false
zIndex: 0, _this.circle=AMap.invoke('Circle',lnglat,data.radius * 1,options)
}); AMap.invoke('panTo',lnglat,true)
AMap.invoke('addOverlay',_this.circle)
_this.circleEditor = new AMap.CircleEditor(MAP, _this.circle); AMap.invoke('setZoom',14)
_this.circleEditor.on('adjust', function (e) { _this.bindContextMenu()
console.log('监听圆心改变', e) AMap.invoke('circleAddEventListener','lineupdate',function(e){
EventBus.$emit('uiMap.fence.onFenceRadiusChange', e.radius / 1) let overlay=e.overlay
}) EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng:e.overlay.getCenter().lng,
_this.circleEditor.on('move', function (e) { lat:e.overlay.getCenter().lat
EventBus.$emit('uiMap.fence.onFenceLngLatChange', { });
lng: e.lnglat.lng, EventBus.$emit('uiMap.fence.onFenceRadiusChange', parseInt(overlay.getRadius() / 1))
lat: e.lnglat.lat })
});
})
if (_this.isEditMode) {
_this.circleEditor.open();
} else {
_this.circleEditor.close();
} }
mapService.setFitView() }, 2000);
MAP.setZoom(14); }else{
_this.bindContextMenu() this.destroy();
} this.updateFenceCircle(data)
}, 100); }
}, },
createFenceMarker(data) { createFenceMarker(data) {
this.data = [{ this.data = [{
elng: data.lngGPS, elng: data.lngGPS,
elat: data.latGPS elat: data.latGPS
...@@ -186,69 +185,78 @@ const fence = { ...@@ -186,69 +185,78 @@ const fence = {
elat: data.latBase elat: data.latBase
}); });
} }
const MAP = mapService.map; const getLngLat=mapService.getLngLat(data.lngGPS,data.latGPS)
//MAPGEO.transferAddressByGroup(this, ()=>{ this.marker = mapService.createCarMarker(getLngLat, AMap);
//data.transferAddressGPS = this.data[0].transferAddress; let infoWindow = mapService.bindFenceInfoWindow( this.marker, AMap, data);
// if(this.data.length > 1){ AMap.invoke('addOverlay',this.marker)
// data.transferAddressBase = this.data[1].transferAddress;
// }
console.log(data)
let marker = mapService.createCarMarker([data.lngGPS, data.latGPS], MAP);
let infoWindow = mapService.bindFenceInfoWindow(marker, MAP, data);
//});
}, },
drawPolygon() { drawPolygon() {
const MAP = mapService.map;
const self = this; const self = this;
this.destroy(); this.destroy();
if (this.polygonPath.length) { if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({ let options={
path: this.polygonPath, zIndex: 10,
strokeColor: "#FF33FF", strokeColor: "#FF33FF",
strokeWeight: 6, strokeWeight: 6,
strokeOpacity: 0.2, strokeOpacity: 0.2,
fillOpacity: 0.4, fillOpacity: 0.4,
fillColor: '#1791fc', fillColor: '#1791fc',
zIndex: 50, enableEditing:true
})
MAP.add(self.polygon)
MAP.setFitView([self.polygon])
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
if (self.isEditMode) {
self.polyEditor.open()
} else {
self.polyEditor.close()
} }
if(!self.isEditMode){
self.bindPolyEvent(self.polyEditor) options.enableEditing=false
} else if (self.isEditMode) { }
self.mouseTool = new AMap.MouseTool(MAP) self.polygon=AMap.invoke('Polygon',this.polygonPath,options)
//获取多边形的中间位置
self.mouseTool.polygon({ let lnglat=self.polygon.getBounds().getCenter()
strokeColor: "#FF33FF", //地图的中心点更改为给定的点
strokeOpacity: 1, AMap.invoke('panTo',lnglat,true)
strokeWeight: 6, AMap.invoke('polygonAddEventListener','lineupdate',function(e){
strokeOpacity: 0.2, let pathArr = self.polygon.getPath()
fillColor: '#1791fc', self.emitPolyEvent(pathArr)
fillOpacity: 0.4,
// 线样式还支持 'dashed'
strokeStyle: "solid",
// strokeStyle是dashed时有效
// strokeDasharray: [30,10],
})
self.mouseTool.on('draw', function (event) {
// event.obj 为绘制出来的覆盖物对象
self.polygon = event.obj;
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
self.polyEditor.open()
self.bindPolyEvent(self.polyEditor)
self.mouseTool.close()
self.emitPolyEvent()
}) })
AMap.invoke('addOverlay', self.polygon)
AMap.invoke('setZoom',17)
} else if (self.isEditMode) {
var styleOptions = {
strokeColor: '#FF33FF', // 边线颜色
fillColor: '#1791fc', // 填充颜色。当参数为空时,圆形没有填充颜色
strokeWeight: 6, // 边线宽度,以像素为单位
strokeOpacity: 0.2, // 边线透明度,取值范围0-1
fillOpacity: 0.4 // 填充透明度,取值范围0-1
};
var labelOptions = {
borderRadius: '2px',
background: '#FF33FF',
border: '1px solid #E1E1E1',
color: '#703A04',
fontSize: '12px',
letterSpacing: '0',
padding: '5px'
};
self.drawingManager = AMap.invoke('DrawingManager', mapService.mapInstance, {
isOpen: true, // 是否开启绘制模式
enableDrawingTool: true,
enableCalculate: false, // 绘制是否进行测距测面
enableSorption: true, // 是否开启边界吸附功能
sorptiondistance: 20, // 边界吸附距离
circleOptions: styleOptions, // 圆的样式
polylineOptions: styleOptions, // 线的样式
polygonOptions: styleOptions, // 多边形的样式
rectangleOptions: styleOptions, // 矩形的样式
labelOptions: labelOptions, // label样式
})
AMap.invoke('drawingManagerAddEventListener','polygoncomplete',function(e){
let overlays=e
let pathArr = e.getPath()
console.log(pathArr)
// let resultArr = pathArr.map((item) => {
// return item.latLng
// })
self.emitPolyEvent(pathArr)
})
AMap.invoke('setDrawingMode', 'polygon')
} }
...@@ -256,38 +264,27 @@ const fence = { ...@@ -256,38 +264,27 @@ const fence = {
bindPolyEvent(polyEditor) { bindPolyEvent(polyEditor) {
const self = this const self = this
polyEditor.on('addnode', function (event) { polyEditor.on('addnode', function (event) {
console.log('触发事件:addnode')
self.emitPolyEvent() self.emitPolyEvent()
}) })
polyEditor.on('adjust', function (event) { polyEditor.on('adjust', function (event) {
console.log('触发事件:adjust')
self.emitPolyEvent() self.emitPolyEvent()
}) })
polyEditor.on('removenode', function (event) { polyEditor.on('removenode', function (event) {
console.log('触发事件:removenode')
self.emitPolyEvent() self.emitPolyEvent()
}) })
polyEditor.on('end', function (event) { polyEditor.on('end', function (event) {
console.log('触发事件: end')
self.emitPolyEvent() self.emitPolyEvent()
// event.target 即为编辑后的多边形对象 // event.target 即为编辑后的多边形对象
}) })
}, },
emitPolyEvent() { emitPolyEvent(resultArr) {
let pathArr = this.polygon.getPath()
let resultArr = pathArr.map((item) => {
return [item.lng, item.lat]
})
this.polygonPath = resultArr this.polygonPath = resultArr
EventBus.$emit('uiMap.fence.polygonChange', { EventBus.$emit('uiMap.fence.polygonChange', {
polygonPath: this.polygonPath polygonPath: this.polygonPath
}); });
console.log(resultArr.join('|'))
}, },
clearTimeoutIds() { clearTimeoutIds() {
this.timeoutIds && this.timeoutIds.forEach((item) => { this.timeoutIds && this.timeoutIds.forEach((item) => {
...@@ -299,32 +296,27 @@ const fence = { ...@@ -299,32 +296,27 @@ const fence = {
// 地图增加右键功能 // 地图增加右键功能
bindContextMenu() { bindContextMenu() {
const self = this; const self = this;
const MAP = mapService.map; const mapInstance = mapService.mapInstance;
var contextMenu = new AMap.ContextMenu(); var contextMenu = AMap.invoke('ContextMenu');
contextMenu.addItem( contextMenu.addItem(
"设置围栏中心", AMap.invoke('MenuItem',"设置围栏中心", function () {
function () { self.moveCenter();
self.moveCenter(); })
},
0
); );
//地图绑定鼠标右击事件——弹出右键菜单 AMap.invoke('mapAddEventListener','rightclick',function (e) {
MAP.on("rightclick", function (e) { AMap.invoke('addContextMenu',contextMenu)
contextMenu.open(MAP, e.lnglat); self.contextMenuPositon = e.latlng
self.contextMenuPositon = e.lnglat; })
});
}, },
// 改变圆心 // 改变圆心
moveCenter() { moveCenter() {
this.lng = this.contextMenuPositon.lng; const MAP = mapService.map;
this.lat = this.contextMenuPositon.lat; AMap.invoke('circleDisableEditing')
let center = mapService.getLngLat(this.lng, this.lat); this.circle&& this.circle.setCenter(this.contextMenuPositon);
this.circle.setCenter(center); AMap.invoke('removeOverlay', this.circle)
EventBus.$emit('uiMap.fence.onFenceLngLatChange', { AMap.invoke('addOverlay', this.circle)
lng: this.lng, AMap.invoke('circleEnableEditing')
lat: this.lat,
});
}, },
// 更新围栏 // 更新围栏
...@@ -332,10 +324,10 @@ const fence = { ...@@ -332,10 +324,10 @@ const fence = {
let _this = this; let _this = this;
const MAP = mapService.map; const MAP = mapService.map;
let mapInterval = setInterval(function () { let mapInterval = setInterval(function () {
if (MAP) { if (AMap) {
clearInterval(mapInterval); clearInterval(mapInterval);
if (_this.fenceCircle) { if (_this.fenceCircle) {
MAP.remove(_this.fenceCircle) AMap.remove(_this.fenceCircle)
} }
_this.fenceType = data.fenceType; _this.fenceType = data.fenceType;
_this.polyEditor && _this.polyEditor.close(); _this.polyEditor && _this.polyEditor.close();
...@@ -353,12 +345,14 @@ const fence = { ...@@ -353,12 +345,14 @@ const fence = {
if (data.radius) { if (data.radius) {
_this.radius = Number(data.radius); _this.radius = Number(data.radius);
} }
console.log(data)
_this.createFenceCircle(data); // _this.createFenceCircle(data);
_this.updateFenceCircle(data)
return false; return false;
} }
mapService.setFitView() // mapService.setFitView()
MAP.setZoom(14); MAP.setZoom(14);
AMap.invoke('setZoom',14)
} }
}, 100); }, 100);
} }
......
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).GlMap=r()}(this,(function(){"use strict";function t(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function r(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function e(t,r,e){return r&&function(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(){n=function(){return r};var t,r={},e=Object.prototype,o=e.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(t){l=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=r&&r.prototype instanceof g?r:g,a=Object.create(o.prototype),c=new P(n||[]);return i(a,"_invoke",{value:O(t,e,c)}),a}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=s;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",m={};function g(){}function w(){}function b(){}var L={};l(L,c,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(T([])));E&&E!==e&&o.call(E,c)&&(L=E);var j=b.prototype=g.prototype=Object.create(L);function G(t){["next","throw","return"].forEach((function(r){l(t,r,(function(t){return this._invoke(r,t)}))}))}function S(t,r){function e(n,i,a,c){var u=h(t[n],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==typeof l&&o.call(l,"__await")?r.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(l).then((function(t){f.value=t,a(f)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function O(r,e,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var f=h(r,e,n);if("normal"===f.type){if(o=n.done?d:y,f.arg===m)continue;return{value:f.arg,done:n.done}}"throw"===f.type&&(o=d,n.method="throw",n.arg=f.arg)}}}function _(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,_(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function k(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function A(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(o.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return w.prototype=b,i(j,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:w,configurable:!0}),w.displayName=l(b,f,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,f,"GeneratorFunction")),t.prototype=Object.create(j),t},r.awrap=function(t){return{__await:t}},G(S.prototype),l(S.prototype,u,(function(){return this})),r.AsyncIterator=S,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new S(s(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},G(j),l(j,f,"Generator"),l(j,c,(function(){return this})),l(j,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,P.prototype={constructor:P,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!r)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),f=o.call(a,"finallyLoc");if(u&&f){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!f)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),A(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;A(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:T(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function o(r){return function(r){if(Array.isArray(r))return t(r)}(r)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(r,e){if(r){if("string"==typeof r)return t(r,e);var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(r,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t){var r=function(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,r);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof r?r:r+""}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}var c={1:"develop",2:"test",3:"production",4:"beta"},u=function(){return e((function t(){var e=this;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t);var o,i,u={env:3,version:3},f=arguments[0];if(arguments.length>1&&(u="object"==a(arguments[0])?arguments[0]:u,f=arguments[1],null!==(o=u)&&void 0!==o&&o.env||(u.env=3),null!==(i=u)&&void 0!==i&&i.version||(u.version=3)),"undefined"!=typeof window){var l=function(){var t,o=(t=n().mark((function t(){var r,o,i,a;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=map-api-js&env=".concat(c[u.env]));case 3:return r=t.sent,t.next=6,r.json();case 6:o=t.sent,i=Array.from(document.head.getElementsByTagName("script")).some((function(t){return t.src===o.apiUrl})),i?f&&"function"==typeof f&&(e.GLMap=new window.$GlMapApi(u,(function(){f&&"function"==typeof f&&f(e)}))):((a=document.createElement("script")).src=o.apiUrl,document.head.appendChild(a),a.onload=function(){e.GLMap=new window.$GlMapApi(u,(function(){f&&"function"==typeof f&&f(e)}))}),t.next=14;break;case 11:t.prev=11,t.t0=t.catch(0),console.error("Failed to fetch configuration:",t.t0);case 14:case"end":return t.stop()}}),t,null,[[0,11]])})),function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))});return function(){return o.apply(this,arguments)}}();l()}}),[{key:"invoke",value:function(t){var r,e=Array.prototype.slice.call(arguments,1);return(r=this.GLMap)[t].apply(r,o(e))}},{key:"map",get:function(){return this.GLMap._BMAP}},{key:"mapGL",get:function(){return this.GLMap._BMapGL}}])}();return u}));
import EventBus from '../event-bus' import EventBus from '../event-bus'
import mapService from './mapService.js' import mapService from './mapBService.js'
import MAPGEO from './mapgeo' import MAPGEO from './mapgeo'
//历史停留 //历史停留
const historyLocation = { const historyLocation = {
data: [], data: [],
points:[],
cluster:'',
markers: {}, markers: {},
infowins: {}, infowins: {},
bindEvent(){ bindEvent(){
EventBus.$on('uiMap.historyLocation.draw', (data)=>{ EventBus.$on('uiMap.historyLocation.draw', (data)=>{
console.log(data, '--------');
this.destroy(); this.destroy();
const MAP = mapService.map;
this.data = data; this.data = data;
let markers=[]
// MAPGEO.transferAddressByGroup(this, ()=>{
// EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
// this.data.forEach((item)=>{
// let marker = mapService.createHistoryLocationMarker([item.elng, item.elat], MAP);
// let infoWindow = mapService.bindLocationInfoWindow(marker, MAP, item);
// this.markers[item.idx] = marker;
// this.infowins[item.idx] = infoWindow;
// });
// console.log(this.markers)
// mapService.setFitView(MAP);
// this.createClusterer();
// });
// v1.7.0历史停留为保证地址信息显示与导出一致 取后端返回的address 不需高德逆地址解析 // v1.7.0历史停留为保证地址信息显示与导出一致 取后端返回的address 不需高德逆地址解析
EventBus.$emit('uiMap.historyLocation.transferSuccess', data); EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
this.data.forEach((item)=>{ this.data.forEach((item)=>{
let marker = mapService.createHistoryLocationMarker([item.elng, item.elat], MAP); let lnglatXY=mapService.getLngLat(item.blng, item.blat);
let infoWindow = mapService.bindLocationInfoWindow(marker, MAP, item); markers.push(lnglatXY)
let marker = mapService.createHistoryLocationMarker(lnglatXY, AMap);
let infoWindow = mapService.bindLocationInfoWindow(marker, AMap, item);
this.markers[item.idx] = marker; this.markers[item.idx] = marker;
this.infowins[item.idx] = infoWindow; this.infowins[item.idx] = infoWindow;
// AMap.invoke('addOverlay',this.markers[item.idx])
}); });
console.log(this.markers)
mapService.setFitView(MAP); AMap.invoke('setViewport',markers)
this.points=markers
this.createClusterer(); this.createClusterer();
}); });
...@@ -47,105 +39,52 @@ const historyLocation = { ...@@ -47,105 +39,52 @@ const historyLocation = {
if(this.markers[idx]){ if(this.markers[idx]){
const MAP = mapService.map; const MAP = mapService.map;
const lnglat = this.markers[idx].getPosition(); const lnglat = this.markers[idx].getPosition();
this.infowins[idx].open(MAP, lnglat); // this.infowins[idx].open(MAP, lnglat);
MAP.setZoomAndCenter(MAP.getZoom(), lnglat); AMap.invoke("mapOpenInfoWindow", this.infowins[idx],lnglat)
AMap.invoke('centerAndZoom',lnglat,10)
} }
}); });
}, },
createClusterer(){ createClusterer(){
let map=mapService.mapInstance;
var cluster, markers = []; var cluster, markers = [];
for(let idx in this.markers){ for(let idx in this.markers){
markers.push(this.markers[idx]); markers.push(this.markers[idx]);
} }
this.cluster = AMap.invoke('Cluster', markers, data => {
var self = this; return {
var map = mapService.map; point: [data.latLng.lng, data.latLng.lat],
properties: {
marker: data
var count = markers.length; }
var _renderClusterMarker = function (context) {
var factor = Math.pow(context.count / count, 1 / 18);
var div = document.createElement('div');
var Hue = 180 - factor * 180;
var bgColor = 'hsla(' + Hue + ',100%,50%,0.7)';
var fontColor = 'hsla(' + Hue + ',100%,20%,1)';
var borderColor = 'hsla(' + Hue + ',100%,40%,1)';
var shadowColor = 'hsla(' + Hue + ',100%,50%,1)';
div.style.backgroundColor = bgColor;
var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20);
div.style.width = div.style.height = size + 'px';
div.style.border = 'solid 1px ' + borderColor;
div.style.borderRadius = size / 2 + 'px';
div.style.boxShadow = '0 0 1px ' + shadowColor;
div.innerHTML = context.count;
div.style.lineHeight = size + 'px';
div.style.color = fontColor;
div.style.fontSize = '14px';
div.style.textAlign = 'center';
context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2));
context.marker.setContent(div)
};
addCluster(2);
function addCluster(tag) {
if (self.cluster) {
self.cluster.setMap(null);
}
if (tag == 2) {//完全自定义
self.cluster = new AMap.MarkerClusterer(map, markers, {
gridSize: 80,
maxZoom: 16,
renderClusterMarker: _renderClusterMarker
});
} else if (tag == 1) {//自定义图标
var sts = [{
url: "https://a.amap.com/jsapi_demos/static/images/blue.png",
size: new AMap.Size(32, 32),
offset: new AMap.Pixel(-16, -16)
}, {
url: "https://a.amap.com/jsapi_demos/static/images/green.png",
size: new AMap.Size(32, 32),
offset: new AMap.Pixel(-16, -16)
}, {
url: "https://a.amap.com/jsapi_demos/static/images/orange.png",
size: new AMap.Size(36, 36),
offset: new AMap.Pixel(-18, -18)
}, {
url: "https://a.amap.com/jsapi_demos/static/images/red.png",
size: new AMap.Size(48, 48),
offset: new AMap.Pixel(-24, -24)
}, {
url: "https://a.amap.com/jsapi_demos/static/images/darkRed.png",
size: new AMap.Size(48, 48),
offset: new AMap.Pixel(-24, -24)
}];
self.cluster = new AMap.MarkerClusterer(map, markers, {
styles: sts,
gridSize: 80
});
} else {//默认样式
self.cluster = new AMap.MarkerClusterer(map, markers, {gridSize: 80});
} }
} })
AMap.invoke('clusterSetData', this.cluster)
AMap.invoke('clusterAddEventListener', 'click', (e) => {
AMap.invoke('infoWindowDisableCloseOnClick', e.properties.marker.openInfoWindow)
AMap.invoke("mapOpenInfoWindow", e.properties.marker.openInfoWindow,e.properties.marker.getPosition() )
})
}, },
destroy: function(){ destroy: function(){
const MAP = mapService.map; const MAP = mapService.map;
//MAP.clearMap();
this.data = []; this.data = [];
for(let idx in this.markers){ for(let idx in this.markers){
MAP.remove(this.markers[idx]) AMap.invoke('removeOverlay',this.markers[idx])
} }
for(let idx in this.infowins){ for(let idx in this.infowins){
MAP.remove(this.infowins[idx]) AMap.invoke('mapCloseInfoWindow')
} }
this.markers = {}; this.markers = {};
this.infowins = {}; this.infowins = {};
if (this.cluster) { if (this.cluster) {
this.cluster.setMap(null); AMap.invoke('clusterDestroy')
self.cluster = null; this.cluster = null;
} }
this.clearTimeoutIds(); this.clearTimeoutIds();
}, },
......
/*
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-12-06 14:10:32
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2025-01-16 11:18:23
* @FilePath: \oEshield\src\utils\mapBService.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import ClipboardJS from 'clipboard'
window.ClipboardJS = ClipboardJS
import EventBus from '../event-bus'
import { Message } from "element-ui";
import store from '../vuex/store.js'
import vue from 'vue'
import GLMapSdk from "@/utils/glsk-map-sdk";
EventBus.$on('uiMap.copySuccess', (data) => {
Message({
type: 'success',
message: '已复制内容至粘贴板'
});
});
var clipboard = null;
function MapService() {
this.map = null;
this.restainLayer = null;
this.mapInstance=null
}
var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据
MapService.prototype = {
init: function(id, options) {
var self = this;
let params = options || {}
if (self.map) {
self.map=null
}
return new Promise((resolve)=>{
new GLMapSdk({
env:3,
version:1
}, async (mapapi) => {
console.log('mapapi',mapapi)
self.map = mapapi;
this.mapInstance= await mapapi.invoke("Map", id);
this.mapInstance.enableScrollWheelZoom()//启用滚轮放大缩小
this.mapInstance.enableAutoResize()//启用自动适应容器尺寸变化
mapapi.invoke(
"centerAndZoom",
mapapi.invoke("Point", 116.404, 39.915),
params.zoom || 13
);
// 添加比例尺
mapapi.invoke("ScaleControl")
// 距离测量
mapapi.invoke('DistanceTool',this.mapInstance)
resolve(mapapi)
// //距离测量
// map.plugin(["AMap.RangingTool"], function() {
// self.ruler = new AMap.RangingTool(map);
// });
// //定位
// map.plugin('AMap.Geolocation', function() {
// self.geolocation = new AMap.Geolocation();
// });
// mapapi.invoke("enableScrollWheelZoom");
});
})
// self.map = map;
// return self.map;
},
toggleMapType: function(type) {
var self = this;
console.log(type,888)
if (type) {
// 构造官方卫星、路网图层
self.mapInstance.setMapType(BMAP_NORMAL_MAP);
} else {
// 地图上设置图层
self.mapInstance.setMapType(BMAP_SATELLITE_MAP);
}
},
rulerTurnOn: function() {
// this.ruler.turnOn();
this.map.invoke('distanceToolOpen') // 开启测距
},
rulerTurnOff: function() {
// this.ruler.turnOff();
this.map.invoke('distanceToolclose') // 关闭测距
},
getCurrentLocation: function() {
var self = this
const { map } = this
self.currentMarker && map.invoke('removeOverlay', self.currentMarker)
map.invoke('Geolocation', res => {
console.log(res, 'Geolocation')
const lngLatXY = self.getLngLat(res.longitude, res.latitude)
self.currentMarker = self.createMarker(lngLatXY)
console.log(self.currentMarker, 'self.currentMarker')
map.invoke('addOverlay', self.currentMarker)
})
},
createMarker: function(lnglatXY) {
let that=this,
url=require('images/mapLocation.gif'),
size=that.map.invoke('Size', 24, 24)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
return marker;
},
createPointMarker: function(lnglatXY) {
let that=this,
url=require('images/point.png'),
size=that.map.invoke('Size', 18, 18)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
return marker;
},
createConstantMarker: function(lnglatXY, map) {
let that=this,
url=require('images/icon_constant.png'),
size=that.map.invoke('Size', 24, 34)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
return marker;
},
createCarMarker: function(lnglatXY, map) {
let that=this,
url=require('@/assets/images/icon_car.png'),
size=that.map.invoke('Size', 36, 22)
var marker=that.map.invoke('Marker',lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
marker.setAnimation(BMAP_ANIMATION_DROP)
return marker;
},
createPOIMarker(lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
content: `<span class="poi_marker"></span>`,
//icon: require('images/poi-marker-default.png'),
map: map,
autoRotation: true,
offset: new AMap.Pixel(-20, -50),
zIndex: 1020,
animation: 'AMAP_ANIMATION_DROP'
});
return marker;
},
createPOIInfo(info) {
return `<div class="poi_infowin">
<h3 class="map-infowindow-title">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><span>${info.poiName}</span></p>
<p class="poi_item"><label>解析地址:</label><span>${info.address}</span>
</div></div>`
},
bindPOIInfoWindow(marker, map, info) {
var infoDiv = document.createElement('div'),
self=this;
infoDiv.innerHTML = this.createPOIInfo(info);
var infoWindow=self.map.invoke('InfoWindow',infoDiv,{
offset:self.map.invoke('Size',0, -48),
enableAutoPan:true
})
marker.infoWindow = infoWindow;
self.map.invoke('markerAddEventListener','click',markerClick)
function markerClick(e) {
self.map.invoke("mapOpenInfoWindow", infoWindow,e.target.getPosition())
// infoWindow.open(map, e.target.getPosition());
}
return infoWindow;
},
setAlarmIcon(marker) {
let that=this,
url=require('@/assets/images/icon_car_alarm.png'),
size=that.map.invoke('Size', 36, 22)
marker.setIcon(that.map.invoke('Icon', url,size))
},
setDefaultIcon(marker) {
let that=this,
url=require('@/assets/images/icon_car.png'),
size=that.map.invoke('Size', 36, 22)
marker.setIcon(that.map.invoke('Icon', url,size))
},
createHistoryLocationMarker(lnglatXY, map) {
let that=this,
url=require('images/icon_location.png'),
size=that.map.invoke('Size', 24, 34)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
marker.setAnimation(BMAP_ANIMATION_DROP)
return marker;
},
createPoiMarker(lnglatXY, map) {
let that=this,
url=require('images/poi-marker-default.png'),
size=that.map.invoke('Size', 24, 34)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
marker.setAnimation(BMAP_ANIMATION_DROP)
return marker;
},
createStartMarker: function(lnglatXY, map) {
let that=this,
url=require('images/icon_start.png'),
size=that.map.invoke('Size', 24, 34)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
marker.setAnimation(BMAP_ANIMATION_DROP)
return marker;
},
createEndMarker: function(lnglatXY, map) {
let that=this,
url=require('images/icon_end.png'),
size=that.map.invoke('Size', 24, 34)
var marker=that.map.invoke('Marker', lnglatXY, {
icon:that.map.invoke('Icon', url,size)
})
marker.setAnimation(BMAP_ANIMATION_DROP)
return marker;
},
createPolyline: function(map) {
// return new AMap.Polyline({
// map: map,
// strokeWeight: 2,
// strokeColor: '#009944'
// });
let that=this,
polyline=that.map.invoke('Polyline','',{
strokeWeight: 2,
strokeColor: '#009944'
})
return polyline
},
createCircle: function(lnglatXY, map, radius) {
let that=this,
Circle= that.map.invoke('Circle', lnglatXY, radius, {
strokeColor: '#094',
fillColor: '#094',
strokeWeight: 1,
strokeOpacity: 0.8,
fillOpacity: 0.1
})
return Circle
},
createPoint: function(lnglatXY, map) {
let that=this,
Circle= that.map.invoke('Circle', lnglatXY, 3, {
strokeColor: '#094',
fillColor: '#094',
strokeWeight: 3,
strokeOpacity: 1,
fillOpacity: 1
})
return Circle
},
createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
console.log(div,'div')
var self = this;
var infoWindow=self.map.invoke('InfoWindow',div,{
enableAutoPan:!!isInfoAutoMove
})
marker.openInfoWindow = infoWindow;
if (clipboard) {
clipboard.destroy();
}
if (isInfoOpen) {
infoWindow.redraw();
}
//给Marker绑定单击事件
// marker.addEventListener('click', markerClick);
self.map.invoke('markerAddEventListener','click',markerClick)
self.map.invoke('infoWindowAddEventListener','open',()=>{
clipboard = new ClipboardJS(document.querySelectorAll('.copy-btn'), {
text: function(trigger) {
console.log(trigger,trigger.getAttribute('aria-label'),'trigger')
return trigger.getAttribute('aria-label');
}
})
clipboard.on('success', function(e) {
e.clearSelection();
EventBus.$emit('uiMap.copySuccess');
});
clipboard.on('error', function(e) {
console.log(e,'err')
});
})
function markerClick(e) {
//infoWindow.setContent(e.target.content);
self.map.invoke("mapOpenInfoWindow", infoWindow,e.target.getPosition())
// infoWindow.open(map, e.target.getPosition());
}
return infoWindow;
},
// 车辆监控-查看位置点
bindMonitorInfoWindow: function(marker, map, info, isInfoOpen, isInfoAutoMove) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createMonitorInfo(info);
let eLocation = info[info.eLocateType];
var statusArr = ['行驶中', '静止', '离线', '在线']
if (info.status === 2) {
let _msg = `${statusArr[info.status]} | 已离线${info.statusTime && info.statusTime != null ? info.statusTime : ''}`;
infoDiv.querySelector('[data-status]').textContent = _msg;
infoDiv.querySelector('[data-status]').setAttribute('aria-label', _msg)
} else {
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
infoDiv.querySelector('[data-status]').setAttribute('aria-label', statusArr[info.status]);
}
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
infoDiv.querySelector('[data-time').setAttribute('aria-label', eLocation.dateTime);
infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
infoDiv.querySelector('[data-transferAddress').setAttribute('aria-label', eLocation.transferAddress);
//infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', eLocation.transferAddress);
infoDiv.querySelector('[data-address-icon').setAttribute('aria-label', eLocation.transferAddress);
if (info.battery) {
infoDiv.querySelector('[data-battery]').classList.remove('hide');
infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery;
infoDiv.querySelector('[data-battery-text]').textContent = info.battery;
} else {
infoDiv.querySelector('[data-battery]').classList.add('hide');
}
let gpsBtn = infoDiv.querySelector('[data-gps]')
let baseBtn = infoDiv.querySelector('[data-base]')
let wifiBtn = infoDiv.querySelector('[data-wifi]')
//console.log(info.eLocateType)
if (info.eLocateType === 'bsLocation') {
gpsBtn && gpsBtn.classList.remove('el-button--primary');
baseBtn.classList.add('el-button--primary');
} else {
gpsBtn && gpsBtn.classList.add('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary');
}
// 基站
baseBtn && (baseBtn.onclick = function(e) {
if (info.eLocateType === 'bsLocation') return;
info.eLocateType = 'bsLocation'
eLocation = info[info.eLocateType];
if (!eLocation.elng || !eLocation.elat) {
Message({
type: 'info',
message: '暂无基站数据'
});
return;
}
gpsBtn && gpsBtn.classList.remove('el-button--primary');
wifiBtn && wifiBtn.classList.remove('el-button--primary');
baseBtn && baseBtn.classList.add('el-button--primary');
infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
infoDiv.querySelector('[data-transferAddress').setAttribute('aria-label', eLocation.transferAddress);
infoDiv.querySelector('[data-address-icon').setAttribute('aria-label', eLocation.transferAddress);
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
infoDiv.querySelector('[data-time').setAttribute('aria-label', eLocation.dateTime);
EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone');
self.setFitView()
})
// gps
gpsBtn && (gpsBtn.onclick = function(e) {
if (info.eLocateType === 'gpsLocation') return;
info.eLocateType = 'gpsLocation'
eLocation = info[info.eLocateType];
if (!eLocation.elng || !eLocation.elat) {
Message({
type: 'info',
message: '暂无GPS数据'
});
return;
}
gpsBtn && gpsBtn.classList.add('el-button--primary');
wifiBtn && wifiBtn.classList.remove('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary');
infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
infoDiv.querySelector('[data-transferAddress').setAttribute('aria-label', eLocation.transferAddress);
infoDiv.querySelector('[data-address-icon').setAttribute('aria-label', eLocation.transferAddress);
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
infoDiv.querySelector('[data-time').setAttribute('aria-label', eLocation.dateTime);
EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone');
//self.setFitView()
})
// wifi数据
wifiBtn && (wifiBtn.onclick = function(e) {
if (info.wifiLocation && info.wifiLocation.elng) {
// console.log(info)
if (info.eLocateType === 'wifiLocation') return;
info.eLocateType = 'wifiLocation'
gpsBtn && gpsBtn.classList.remove('el-button--primary');
wifiBtn && wifiBtn.classList.add('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary');
infoDiv.querySelector('[data-transferAddress]').textContent = info.wifiLocation.transferAddress;
infoDiv.querySelector('[data-transferAddress').setAttribute('aria-label', info.wifiLocation.transferAddress);
infoDiv.querySelector('[data-time]').textContent = info.wifiLocation.dateTime;
infoDiv.querySelector('[data-time').setAttribute('aria-label', info.wifiLocation.dateTime);
EventBus.$emit('uiMap.monitor.changeELocate', info)
EventBus.$emit('uiMap.monitor.drawDone');
self.setFitView()
}
//EventBus.$emit('uiMap.monitor.wifiLocate', { info, infoDiv, gpsBtn, baseBtn, wifiBtn })
})
if (info.alarmTypeSet && info.alarmTypeSet.length) {
let _html = '<i class="icon icon-info_device_alarm"></i>报警状态:'
info.alarmTypeSet.forEach((alarmType) => {
if (alarmType === 1) {
_html += `<button type="button" class="el-button el-button--mini el-button--danger" data-alarmoff >断电</button>`
} else if (alarmType === 99) {
_html += `<button type="button" class="el-button el-button--mini el-button--danger" data-alarmlight >光感</button>`
}
});
infoDiv.querySelector('[data-alarm]').innerHTML = _html;
/* if(infoDiv.querySelector('[data-alarmoff]')){
infoDiv.querySelector('[data-alarmoff]').onclick = function(e){
console.log(e.target.dataset)
window.open(`#/report/antiOffAlarm?type=1&time=${e.target.dataset.alarmtime}&sn=${info.sn}`)
}
}
if(infoDiv.querySelector('[data-alarmlight]')){
infoDiv.querySelector('[data-alarmlight]').onclick = function(e){
console.log(e.target.dataset)
window.open(`#/report/antiOffAlarm?type=99&time=${e.target.dataset.alarmtime}&sn=${info.sn}`)
}
} */
infoDiv.querySelector('[data-alarm]').style.display = 'block';
} else {
infoDiv.querySelector('[data-alarm]').style.display = 'none';
}
// 通用参数
let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`;
// 跳转到历史停留页面 无线设备不能跳转历史停留 isSource:1有线,其他无线
let historyBtn = infoDiv.querySelector('[data-history]');
if (historyBtn) {
if (info.isSource != 1) {
historyBtn.classList.add('history_btn_grey');
}
historyBtn.onclick = function() {
if (info.isSource == 1) {
mapService.openPage(`#/monitor/historyLocation?${queryCode}`)
}
}
}
// 跳转到常住地 无线设备不能跳转常住地 isSource:1有线,其他无线
let residentBtn = infoDiv.querySelector('[data-resident]');
if (residentBtn) {
//注意去掉!
if (info.isSource != 1) {
residentBtn.classList.add('resident_btn_grey');
}
residentBtn.onclick = function() {
if (info.isSource == 1) {
queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}&locationType=${info.eLocateType}`
mapService.openPage(`#/monitor/resident?${queryCode}`)
}
}
}
// 跳转到轨迹回放页面
let replayBtn = infoDiv.querySelector('[data-replay]');
if (replayBtn) {
replayBtn.onclick = function() {
mapService.openPage(`#/monitor/replay?${queryCode}`)
}
}
// 跳转到风险评估页面 无线设备不显示按钮 info.deviceCompose=010/020/011/012/013/022,需要有风险评估按钮出现
let riskBtn = infoDiv.querySelector('[data-risk]');
if (riskBtn) {
if (info.deviceCompose != '010' && info.deviceCompose != '020' && info.deviceCompose != '011' && info.deviceCompose != '012' && info.deviceCompose != '013' && info.deviceCompose != '022') {
riskBtn.classList.add('resident_btn_hidden');
}
riskBtn.onclick = function() {
let id = localStorage.getItem('vehicleId');
queryCode = `vehicleId=${id}`
mapService.openPage(`#/monitor/alarmAnalysis?${queryCode}`)
}
}
// 跳转到电子围栏页面 无线设备不能跳转电子围栏 isSource:1有线,其他无线
let fenceBtn = infoDiv.querySelector('[data-fence]');
// 判断是否分配了电子围栏按钮权限
//let fencePermission = vue.prototype.$parentCommon.isPermission('ADD_WIRELESS_DEVICE_FENCE');
//console.log(vue.$parentCommon.hasPermission);
//console.log(fencePermission);
if (fenceBtn) {
// 判断是否分配了电子围栏按钮权限
vue.prototype.$parentCommon.isPermission('ADD_WIRELESS_DEVICE_FENCE').then(fencePermission => {
if (!fencePermission) {
fenceBtn.classList.add('fence_btn_grey');
}
// v1.25.0版本需求,无线设备和有线设备都支持围栏
queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}&source=${info.isSource}`;
fenceBtn.onclick = function() {
if (fencePermission) {
mapService.openPage(`#/monitor/fence?${queryCode}`)
}
}
})
}
const snSourceType = `${info.sn}:${info.isSource}`
/* EventBus.$on(`uiMap.monitor.changeStatus.${snSourceType}`, (status)=>{
if(status === 2){
infoDiv.querySelector('[data-status]').textContent = `${statusArr[info.status]} | 已离线${info.deadline}`;
}else{
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
}
}) */
// 浮窗点击事件
let questionIcon = infoDiv.querySelector('.question_icon');
if (questionIcon) {
let _obj = infoDiv.querySelector('.popover_box');
questionIcon.addEventListener('mouseenter', function(e) {
console.log(e.stopPropagation)
_obj.style.display = 'block';
e.stopPropagation()
})
questionIcon.addEventListener('mouseleave', function(e) {
_obj.style.display = 'none';
e.stopPropagation()
})
}
return this.createInfoWindow(marker, map, infoDiv, isInfoOpen, isInfoAutoMove);
},
bindLocationInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createLocationInfo(info);
// let addressCopyBtn = infoDiv.querySelector('[address-copy]');
let addressCopyBtn = new ClipboardJS(infoDiv.querySelector('.address-copy'));
console.log(addressCopyBtn, 'addressCopyBtn');
addressCopyBtn.on('success', function(e) {
e.clearSelection();
EventBus.$emit('uiMap.copySuccess');
});
addressCopyBtn.on('error', function(e) {
});
return this.createInfoWindow(marker, map, infoDiv);
},
bindResidentInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createResidentInfo(info);
return this.createInfoWindow(marker, map, infoDiv);
},
bindFenceInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createFenceInfo(info);
var statusArr = ['行驶中', '静止', '离线', '在线'];
function fillGPS() {
infoDiv.querySelector('[data-time]').textContent = info.timeGPS;
infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressGPS;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressGPS);
infoDiv.querySelector('#locateTypeGps').classList.add('active');
infoDiv.querySelector('#locateTypeBase').classList.remove('active');
marker.setPosition(self.getLngLat(info.lngGPS, info.latGPS));
marker.infoWindow && marker.openInfoWindow(marker.infoWindow);
// marker.openInfoWindow()
}
function fillBase() {
infoDiv.querySelector('[data-time]').textContent = info.timeBase;
infoDiv.querySelector('[data-transferAddress]').textContent = info.transferAddressBase;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', info.transferAddressBase);
infoDiv.querySelector('#locateTypeGps').classList.remove('active');
infoDiv.querySelector('#locateTypeBase').classList.add('active');
marker.setPosition(self.getLngLat(info.lngBase, info.latBase));
// marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
marker.infoWindow && marker.openInfoWindow(marker.infoWindow);
}
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
if (info.battery) {
infoDiv.querySelector('[data-battery]').classList.remove('hide');
infoDiv.querySelector('[data-battery-percentage]').style.width = info.battery;
infoDiv.querySelector('[data-battery-text]').textContent = info.battery;
} else {
infoDiv.querySelector('[data-battery]').classList.add('hide');
}
infoDiv.querySelector('#locateTypeGps').onclick = function(e) {
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function(e) {
fillBase()
}
fillGPS();
return this.createInfoWindow(marker, map, infoDiv);
},
//经纬度坐标
getLngLat: function(lng, lat) {
return this.map.invoke('Point',lng, lat)
// return new AMap.LngLat(lng, lat);
},
getGeocoder: function() {
return new Promise((resolve) => {
var geocoder= AMap.invoke('Geocoder');
resolve(geocoder);
})
},
getAddress: function(geocoder, lnglatXY) {
geocoder.getAddress(lnglatXY, function(status, result) {
if (status === 'complete' && result.info === 'OK') {
//获得了有效的地址信息:
//即,result.regeocode.formattedAddress
} else {
//获取地址失败
}
});
},
zoomIn: function() {
this.mapInstance.zoomIn();
},
zoomOut: function() {
this.mapInstance.zoomOut();
},
// 监控弹框
createMonitorInfo: function(info) {
/*var _html = '<h3 class="uimap-info-title">'+ info.name+'/'+ info.standNo +'</h3><div class="uimap-info-ct"><p><span><i class="fa fa-inbox"></i></span>'+ info.sn +'</p>';
if(info.time){
_html += '<p><span><i class="fa fa-clock-o"></i></span>'+ info.time +'</p>';
}
_html += '<p><span><i class="fa fa-map-marker"></i></span>'+ info.transferAddress +'</p>';
_html += '<p><span><i class="fa fa-car"></i></span>'+ '驻留次数:' +(info.totalTimes?info.totalTimes:'1')+'</p>';
return _html;*/
let _this = this;
let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`;
var _html = `<div class="map-infowindow-title"><span class="copy-btn" aria-label="${info.name}">${info.name}</span><span>/</span><span class="copy-btn" aria-label="${info.standNo}">${info.standNo}</span><span class="question_icon"></span>`;
_html += '<div class="popover_box" style="display:none;"><div class="title">信息复制说明:</div><p>非标题类文字,支持“单击”复制,已复制信息可用快捷键或者鼠标有键“粘贴”功能进行使用。</p></div>'
_html += '</div>'
_html += `<div class="map-infowindow-ct map_info_window">`;
if (zhongliType == 'yes') {
_html += `<div>`;
if (info.shopName) {
_html += `<p><i class="icon icon-icon_store"></i> 店面名称: <span class="des copy-btn" aria-label="${info.shopName}">${info.shopName}</span></p>`;
}
if (info.shopContacts) {
_html += `<p style="margin-left:29px;"> 店面联系人: <span class="des copy-btn" aria-label="${info.shopContacts}">${info.shopContacts}</span></p>`;
}
if (info.contactsPhone) {
_html += `<p style="margin-left:29px;"> 联系方式: <span class="des copy-btn" aria-label="${info.contactsPhone}">${info.contactsPhone}</span></p>`;
}
if (info.idnum) {
_html += `<p style="margin-left:29px;"> 车牌号: <span class="des copy-btn" aria-label="${info.idnum}">${info.idnum}</span></p>`;
}
_html += `</div>`;
}
// 根据权限-显示店面名称、车牌号
let list = vue.prototype.$parentCommon.getAuthData();
console.log(list,'list')
let o = list.find(k => k.origin.permissionTag == 'oEshield_monitor_store_name');
let n = list.find(k => k.origin.permissionTag == 'oEshield_monitor_plate_number');
if (o && info.shopName) {
_html += `<p><i class="icon_info_shop"></i> 店面名称: <span class="des copy-btn" aria-label="${info.shopName}">${info.shopName || '--'}</span></p>`;
}
if (n && info.licensePlate) {
_html += `<p><i class="icon_info_plate"></i>车牌号: <span class="des copy-btn" aria-label="${info.licensePlate}">${info.licensePlate || '--'}</span></p>`;
}
console.log(info,'info')
_html += `<p class="" aria-label="${info.sn}"><i class="icon icon-info_device"></i> 设备号:<span class="des copy-btn" aria-label="${info.sn}(${info.isSource === '1' ? '有线' : '无线'})"> ${info.sn} (${info.isSource === '1' ? '有线' : '无线'})</span>
<span class="battery" data-battery>
<i class="fill"><i class="fill-percentage" data-battery-percentage></i></i>
<i class="icon icon-battery_enough"></i>
<i class="text" data-battery-text></i>
</span></p>
<p><i class="icon icon-info_device_status"></i> 设备状态: <span class="des copy-btn" data-status aria-label=""></span></p>
<p data-alarm>
<button type="button" class="el-button el-button--mini el-button--primary" data-alarmoff>断电</button>
<button type="button" class="el-button el-button--mini el-button--primary" data-alarmlight>光感</button>
</p>
<p><i class="icon icon-info_time"></i> 最后上点时间: <span class="des copy-btn" data-time aria-label=""></span></p>
<p><i class="icon icon-info_location"></i> 最后上点地址: <span class="des adr copy-btn" data-transferAddress aria-label="${info.transferAddress}">${info.transferAddress}</span>
<a class="" data-clipboard-text="${info.transferAddress}"><i class="icon icon-info_copy copy-btn copy-btn1" data-address-icon aria-label="${info.transferAddress}"></i></a>
</p>
<p><i class="icon icon-info_type"></i> 定位类型:<span class="el-button-group">`
// 是否有gps按钮
if (info.gpsLocation && info.gpsLocation.elng) {
_html += `<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button> `
}
// 是否有基站按钮
if (info.bsLocation && info.bsLocation.elng) {
_html += `<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button>`
}
// 是否有wifi按钮
if (info.hasWifi) {
if (info.wifiLocation && info.wifiLocation.elng) {
_html += `<button type="button" class="el-button el-button--mini" data-wifi>wifi</button>`
} else {
_html += `<button type="button" class="el-button el-button--mini history_btn_grey" data-wifi>wifi</button>`
}
}
_html += ` </p>
<p class="redirect-row">
<a class="redirect-btn" id="btn_replay" data-replay>轨迹回放</a>
<a class="redirect-btn" id="btn_fence" data-fence>电子围栏</a>
<a class="redirect-btn" id="btn_resident" data-resident>常驻地</a>
<a class="redirect-btn" id="btn_history" data-history>历史停留</a>
<a class="redirect-btn" id="btn_risk" data-risk>风险评估</a>
</p>
</div>`;
return _html;
},
createFenceInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.standno}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn} (${info.sourceString})</span>
<span class="battery hide" data-battery>
<i class="fill"><i class="fill-percentage" data-battery-percentage></i></i>
<i class="icon icon-battery_enough"></i>
<i class="text" data-battery-text></i>
</span></p>
<p><i class="icon icon-info_device_status"></i> 设备状态: <span class="des" data-status></span></p>
<p><i class="icon icon-info_time"></i> 最后上点时间: <span class="des" data-time></span></p>
<p><i class="icon icon-info_location"></i> 最后上点地址: <span class="des adr" data-transferAddress>${info.transferAddress}</span>
<a class="copy-btn" data-clipboard-text=""><i class="icon icon-info_copy"></i></a>
</p>
<p>
<i class="icon icon-info_type"></i>
定位类型:
<a class="locate-btn active" id="locateTypeGps">GPS</a>
<a class="locate-btn" id="locateTypeBase">基站</a>
</p>
</div>`;
},
createLocationInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.vin}/${info.sn}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_time"></i> 停留时间: <span class="des">${info.begintime}</span></p>
<p><i class="icon icon-info_location"></i> 停留地址: <span class="des adr" >${info.transferAddress}</span>
<a class=" address-copy" id="address-copy" address-copy data-clipboard-text="${info.transferAddress}"><i class="icon icon-info_copy" aria-label="${info.transferAddress}"></i></a>
</p>
<p><i class="icon icon-info_stop"></i> 停留时长: <span class="des">${info.duration}</span></p>
</div>`;
},
createResidentInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.vin}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号: <span class="des">${info.sn}</span></p>
<p><i class="icon icon-info_location"></i> 常驻地址: <span class="des adr" >${info.transferAddress}</span>
<a data-clipboard-text="${info.transferAddress}"><i class="copy-btn icon icon-info_copy" aria-label="${info.transferAddress}"></i></a>
</p>
<p><i class="icon icon-info_device"></i> 驻留次数: <span class="des">${info.totalTimes}次</span></p>
<p><i class="icon icon-info_stop"></i> 驻留时长: <span class="des">${info.totalDurationString}</span></p>
</div>`;
},
clearMap: function(map) {
this.map.clearMap();
},
setFitView: function(map) {
this.mapInstance.setZoom();
},
bindClickEvent() {
},
// 创建位置点弹框
createActiveInfo(info) {
let msg = '报警'
// 激活
if (info.type == 1) {
msg = '激活'
}
// 定位
if (info.type == 2) {
msg = '定位'
}
return `<h3 class="map-infowindow-title-other">${info.name || '--'}/${info.standNo || '--'}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号: <span class="des">${info.sn} (${info.source == 1 ? '有线' : '无线'})</span></p>
<p><i class="icon icon-info_time"></i>${msg}时间: <span class="des"data-time>${info.time}</span></p>
<div style="display:${info.bsLng ? 'block' : 'none'}"><i class="icon icon-info_type"></i>定位类型: <a class="locate-btn active" id="locateTypeGps">GPS</a><a class="locate-btn" id="locateTypeBase">基站</a></div>
<p><i class="icon icon-info_location"></i> ${msg}地址: <span class="des" data-transferAddress>${info.address}</span></p>
</div>`
},
// 位置点弹框
bindActiveLocationInfoWindow(marker, map, info) {
var self = this
var infoDiv = document.createElement('div')
infoDiv.innerHTML = self.createActiveInfo(info)
// gps位置信息
function fillGPS() {
infoDiv.querySelector('[data-time]').textContent = info.time;
infoDiv.querySelector('[data-transferAddress]').textContent = info.address;
infoDiv.querySelector('#locateTypeGps').classList.add('active');
infoDiv.querySelector('#locateTypeBase').classList.remove('active');
marker.setPosition(self.getLngLat(info.lng, info.lat));
self.setFitView()
// marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
marker.infoWindow && marker.openInfoWindow(marker.infoWindow);
}
// 基站位置信息
function fillBase() {
infoDiv.querySelector('[data-time]').textContent = info.bsTime;
infoDiv.querySelector('[data-transferAddress]').textContent = info.bsAddress;
infoDiv.querySelector('#locateTypeGps').classList.remove('active');
infoDiv.querySelector('#locateTypeBase').classList.add('active');
marker.setPosition(self.getLngLat(info.bsLng, info.bsLat));
console.log(marker,self.getLngLat(info.bsLng, info.bsLat))
self.setFitView()
// marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
marker.infoWindow && marker.openInfoWindow(marker.infoWindow);
}
infoDiv.querySelector('#locateTypeGps').onclick = function(e) {
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function(e) {
console.log('-----------------------------------基站')
fillBase()
}
if (info.lng) {
fillGPS()
}
if (!info.lng && info.bsLng) {
fillBase()
}
return this.createActiveInfoWindow(marker, map, infoDiv)
},
// 创建位置点弹框
createActiveInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var self = this;
var infoWindow=self.map.invoke('InfoWindow',div,{
offset:self.map.invoke('Size',0,0),
enableAutoPan:!!isInfoAutoMove
})
marker.infoWindow = infoWindow
console.log(isInfoOpen,'-----------------------------------isInfoOpen')
if (isInfoOpen) {
infoWindow.open(map, marker.getPosition())
}
//给Marker绑定单击事件
self.map.invoke('markerAddEventListener','click',markerClick)
function markerClick(e) {
self.map.invoke("mapOpenInfoWindow", infoWindow,e.target.getPosition())
//infoWindow.setContent(e.target.content);
// infoWindow.open(map, e.target.getPosition())
}
return infoWindow
},
// 页面跳转,打开新窗口
openPage(path) {
vue.prototype.$parentCommon.setBreadCrumbs(path);
window.open(path)
},
// 区域查车弹框
createAraeInfowindow(info) {
console.log(info,'info')
let self=this;
let _types = {
1: '有线设备',
0: '无线设备'
}
let _div = `<h3 class="map-infowindow-title">${info.ownerName || '--'}/${info.vin || '--'}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn || '--'} (${_types[info.source] || '--'})</span>
<span class="battery" data-battery style="display:${info.battery ? 'block' : 'none'}">
<i class="fill"><i class="fill-percentage" data-battery-percentage style="width:${info.battery}%;"></i></i>
<i class="icon icon-battery_enough"></i>
<i class="text" data-battery-text>${info.battery}</i>
</span></p>
</div>`;
// var infoWindow = new AMap.InfoWindow({
// offset: new AMap.Pixel(0, -20),
// content: _div,
// autoMove: true,
// position: [info.lng, info.lat]
// })
var infoWindow=self.map.invoke('InfoWindow',_div,{
offset:self.map.invoke('Size',0,-20),
enableAutoPan:true
})
return infoWindow
},
// 创建poi信息弹框
createPoiMarkerInfowindow(info) {
console.log(info)
let self=this;
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],
// })
var infoWindow=self.map.invoke('InfoWindow',infoDiv,{
offset:self.map.invoke('Size',12, -5),
enableAutoPan:true
})
return infoWindow
},
}
const mapService = new MapService();
export default mapService
\ No newline at end of file \ No newline at end of file
/*
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2025-01-16 11:15:49
* @FilePath: \oEshield\src\utils\mapgeo.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const MAPGEO = {
geocoder: null,
getGeocoder: function () {
return new Promise((resolve) => {
var geocoder= AMap.invoke('Geocoder');
// AMap.plugin('AMap.Geocoder', function () {//回调函数
// var geocoder = new AMap.Geocoder({
// batch: true
// });
MAPGEO.geocoder = geocoder;
resolve(geocoder);
});
// })
},
transferAddressByGroup(obj, cb) {
console.log(obj,'obj')
if (!this.geocoder) {
this.getGeocoder().then(() => {
this.transfer(obj, cb)
})
} else {
this.transfer(obj, cb)
}
},
transfer(obj, cb) {
const data = obj.data;
obj.len = data.length;
obj.times = obj.len > 20 ? Math.ceil(obj.len / 20) : 1;
obj.totalNum = 0;
obj.realNum = 0; //为了剔除脏数据,脏数据导致解析不回调
for (let i = 0; i < obj.times; i++) {
let lnglatArr = [];
let initIdx = i * 20;
let maxIdx = i === obj.times - 1 ? obj.len : (i + 1) * 20;
for (let idx = initIdx; idx < maxIdx; idx++) {
// 防止出现gps点:.00000的错误
if (Number(data[idx].blng) > 0 && Number(data[idx].blat) > 0) {
lnglatArr.push([data[idx].blng, data[idx].blat])
obj.realNum++;
}
}
(function (initIdx) {
geocoderGetAdr(lnglatArr, initIdx)
})(initIdx)
}
function fixed6(num) {
return Number(num).toFixed(6);
}
// 循环设置地址,修复数组中相同经纬度只设置第一个的bug jack 20230720
function setAddress(row, item) {
const {content: {poi_desc, address_detail: {province, city, district, town, street}}} = item
const _list = data.filter(
(k) =>
fixed6(k.blng) == fixed6(row.lng) && fixed6(k.blat) == fixed6(row.lat)
)
_list.map((k) => {
k.transferAddress = province + city + district + town + street + poi_desc
})
}
function geocoderGetAdr(arr, initIdx) {
if (!arr || arr.length <= 0) {
return false;
}
const timeoutId = window.setTimeout(() => {
arr.forEach(item=>{
let o=AMap.invoke('Point',...item)
MAPGEO.geocoder.getLocation( o,function(res){
setAddress(o, res);
obj.totalNum++;
if (obj.totalNum === obj.realNum) {
console.log('geocoderGetAdr', data)
cb && cb(data)
}
})
})
// MAPGEO.geocoder.getAddress(arr, function (status, result) {
// if (status === 'complete' && result.info === 'OK') {//获取地址成功
// result.regeocodes.forEach((item, idx) => {
// let o = arr[idx]
// setAddress(o, item);
// obj.totalNum++;
// });
// if (obj.totalNum === obj.realNum) {
// cb && cb(data)
// }
// } else {
// // geocoderGetAdr(arr, initIdx)
// }
// });
});
if (!obj.timeoutIds) {
obj.timeoutIds = []
}
obj.timeoutIds.push(timeoutId)
}
}
}
export default MAPGEO
\ No newline at end of file \ No newline at end of file
...@@ -22,6 +22,7 @@ function MapService() { ...@@ -22,6 +22,7 @@ function MapService() {
var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据 var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据
MapService.prototype = { MapService.prototype = {
init: function(id, options) { init: function(id, options) {
console.log('init map',id, options)
var self = this; var self = this;
let params = options || {} let params = options || {}
if (self.map) { if (self.map) {
......
...@@ -52,8 +52,8 @@ const MAPGEO = { ...@@ -52,8 +52,8 @@ const MAPGEO = {
for (let idx = initIdx; idx < maxIdx; idx++) { for (let idx = initIdx; idx < maxIdx; idx++) {
// 防止出现gps点:.00000的错误 // 防止出现gps点:.00000的错误
if (Number(data[idx].elng) > 0 && Number(data[idx].elat) > 0) { if (Number(data[idx].blng) > 0 && Number(data[idx].blat) > 0) {
lnglatArr.push([data[idx].elng, data[idx].elat]) lnglatArr.push([data[idx].blng, data[idx].blat])
obj.realNum++; obj.realNum++;
} }
} }
...@@ -68,9 +68,10 @@ const MAPGEO = { ...@@ -68,9 +68,10 @@ const MAPGEO = {
// 循环设置地址,修复数组中相同经纬度只设置第一个的bug jack 20230720 // 循环设置地址,修复数组中相同经纬度只设置第一个的bug jack 20230720
function setAddress(row, item) { function setAddress(row, item) {
console.log('setAddress', row, item)
let _list = data.filter( let _list = data.filter(
(k) => (k) =>
fixed6(k.elng) == fixed6(row.lng) && fixed6(k.elat) == fixed6(row.lat) fixed6(k.blng) == fixed6(row.lng) && fixed6(k.blat) == fixed6(row.lat)
); );
_list.map((k) => { _list.map((k) => {
k.transferAddress = item.formattedAddress; k.transferAddress = item.formattedAddress;
...@@ -85,9 +86,10 @@ const MAPGEO = { ...@@ -85,9 +86,10 @@ const MAPGEO = {
MAPGEO.geocoder.getAddress(arr, function (status, result) { MAPGEO.geocoder.getAddress(arr, function (status, result) {
if (status === 'complete' && result.info === 'OK') {//获取地址成功 if (status === 'complete' && result.info === 'OK') {//获取地址成功
console.log('geocoderGetAdr', result)
result.regeocodes.forEach((item, idx) => { result.regeocodes.forEach((item, idx) => {
let o = arr[idx] let o = arr[idx]
// let _idx = data.findIndex(k => k.elng == o.lng && k.elat == o.lat); // let _idx = data.findIndex(k => k.blng == o.lng && k.blat == o.lat);
// //data[initIdx + idx].transferAddress = item.formattedAddress; // //data[initIdx + idx].transferAddress = item.formattedAddress;
// data[_idx].transferAddress = item.formattedAddress; // data[_idx].transferAddress = item.formattedAddress;
setAddress(o, item); setAddress(o, item);
......
import EventBus from '../event-bus' import EventBus from '../event-bus'
import mapService from './mapService.js' // import mapService from './mapService.js'
import MAPGEO from './mapgeo' import mapService from './mapBService.js'
// import MAPGEO from './mapgeo'
import MAPGEO from './mapBgeo'
import { Message } from "element-ui"; import { Message } from "element-ui";
import { services } from '../api' import { services } from '../api'
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
...@@ -17,6 +20,7 @@ const monitor = { ...@@ -17,6 +20,7 @@ const monitor = {
compareText: null, compareText: null,
bindEvent() { bindEvent() {
EventBus.$on('uiMap.monitor.draw', (data, autoOpenLastInfoWindow) => { EventBus.$on('uiMap.monitor.draw', (data, autoOpenLastInfoWindow) => {
// console.log('监听围栏更新', data)
this.draw(data, autoOpenLastInfoWindow); this.draw(data, autoOpenLastInfoWindow);
}); });
...@@ -24,11 +28,11 @@ const monitor = { ...@@ -24,11 +28,11 @@ const monitor = {
const MAP = mapService.map; const MAP = mapService.map;
if (snSourceType) { if (snSourceType) {
if (this.markers[snSourceType]) { if (this.markers[snSourceType]) {
MAP.remove(this.markers[snSourceType]) AMap.invoke('removeOverlay',this.markers[snSourceType])
} }
if (this.infowins[snSourceType]) { if (this.infowins[snSourceType]) {
MAP.remove(this.infowins[snSourceType]) AMap.invoke('mapCloseInfoWindow',this.infowins[snSourceType])
} }
delete this.markers[snSourceType]; delete this.markers[snSourceType];
delete this.infowins[snSourceType]; delete this.infowins[snSourceType];
...@@ -36,12 +40,12 @@ const monitor = { ...@@ -36,12 +40,12 @@ const monitor = {
} else { } else {
for (let snSourceType in this.markers) { for (let snSourceType in this.markers) {
if (this.markers[snSourceType]) { if (this.markers[snSourceType]) {
MAP.remove(this.markers[snSourceType]) AMap.invoke('removeOverlay',this.markers[snSourceType])
} }
} }
for (let snSourceType in this.infowins) { for (let snSourceType in this.infowins) {
if (this.markers[snSourceType]) { if (this.markers[snSourceType]) {
MAP.remove(this.infowins[snSourceType]) AMap.invoke('mapCloseInfoWindow',this.infowins[snSourceType])
EventBus.$off(`uiMap.monitor.changeStatus.${snSourceType}`) EventBus.$off(`uiMap.monitor.changeStatus.${snSourceType}`)
} }
} }
...@@ -58,11 +62,11 @@ const monitor = { ...@@ -58,11 +62,11 @@ const monitor = {
}) })
EventBus.$on('uiMap.monitor.changeSourceType', (sourceType) => { EventBus.$on('uiMap.monitor.changeSourceType', (sourceType) => {
const MAP = mapService.map;
let rourceReg = /^\d+\:(\d)$/; let rourceReg = /^\d+\:(\d)$/;
if (sourceType === '') { if (sourceType === '') {
for (let snSourceType in this.markers) { for (let snSourceType in this.markers) {
this.markers[snSourceType].show(); AMap.invoke('addOverlay',this.markers[snSourceType])
// this.markers[snSourceType].show();
} }
} else { } else {
...@@ -70,9 +74,12 @@ const monitor = { ...@@ -70,9 +74,12 @@ const monitor = {
let execResult = rourceReg.exec(snSourceType); let execResult = rourceReg.exec(snSourceType);
if (execResult) { if (execResult) {
if (execResult[1] === sourceType) { if (execResult[1] === sourceType) {
this.markers[snSourceType].show(); AMap.invoke('addOverlay',this.markers[snSourceType])
// this.markers[snSourceType].show();
} else { } else {
this.markers[snSourceType].hide(); AMap.invoke('removeOverlay',this.markers[snSourceType])
} }
} }
} }
...@@ -84,21 +91,24 @@ const monitor = { ...@@ -84,21 +91,24 @@ const monitor = {
EventBus.$on('uiMap.monitor.openInfoWindow', (snSourceType) => { EventBus.$on('uiMap.monitor.openInfoWindow', (snSourceType) => {
if (this.markers[snSourceType]) { if (this.markers[snSourceType]) {
const MAP = mapService.map;
const lnglat = this.markers[snSourceType].getPosition(); const lnglat = this.markers[snSourceType].getPosition();
this.infowins[snSourceType].open(MAP, lnglat); AMap.invoke("mapOpenInfoWindow", this.infowins[snSourceType],lnglat)
MAP.setZoomAndCenter(MAP.getZoom(), lnglat,true); AMap.invoke('addOverlay',this.markers[snSourceType])
AMap.invoke('panTo',lnglat)
} }
}); });
EventBus.$on('uiMap.monitor.changeELocate', (item) => { EventBus.$on('uiMap.monitor.changeELocate', (item) => {
const snSourceType = `${item.sn}:${item.isSource}` const snSourceType = `${item.sn}:${item.isSource}`;
let eLocation = item[item.eLocateType]; let eLocation = item[item.eLocateType];
console.log(eLocation)
if (this.markers[snSourceType]) { if (this.markers[snSourceType]) {
this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat))); this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(eLocation.blng), parseFloat(eLocation.blat)));
this.infowins[snSourceType].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat))); AMap.invoke("mapOpenInfoWindow", this.infowins[snSourceType],mapService.getLngLat(parseFloat(eLocation.blng), parseFloat(eLocation.blat)))
AMap.invoke('addOverlay',this.markers[snSourceType])
// this.infowins[snSourceType].setPosition();
} }
this.isCompare && this.compareLocation() this.isCompare && this.compareLocation()
...@@ -119,7 +129,7 @@ const monitor = { ...@@ -119,7 +129,7 @@ const monitor = {
if (res.returnCode == 0) { if (res.returnCode == 0) {
const data = res.data const data = res.data
if (data) { if (data) {
const transferObj = { elat: data.wifiLat, elng: data.wifiLng } const transferObj = { blat: data.wifiLat, blng: data.wifiLng }
MAPGEO.transferAddressByGroup({ data: [transferObj] }, () => { MAPGEO.transferAddressByGroup({ data: [transferObj] }, () => {
infoDiv.querySelector('[data-transferAddress]').textContent = transferObj.transferAddress; infoDiv.querySelector('[data-transferAddress]').textContent = transferObj.transferAddress;
infoDiv.querySelector('[data-time]').textContent = data.lastReportTime; infoDiv.querySelector('[data-time]').textContent = data.lastReportTime;
...@@ -127,8 +137,9 @@ const monitor = { ...@@ -127,8 +137,9 @@ const monitor = {
const snSourceType = `${info.sn}:${info.isSource}` const snSourceType = `${info.sn}:${info.isSource}`
if (this.markers[snSourceType]) { if (this.markers[snSourceType]) {
this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(transferObj.elng), parseFloat(transferObj.elat))); this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(transferObj.blng), parseFloat(transferObj.blat)));
this.infowins[snSourceType].setPosition(mapService.getLngLat(parseFloat(transferObj.elng), parseFloat(transferObj.elat))); AMap.invoke("mapOpenInfoWindow", this.infowins[snSourceType],mapService.getLngLat(parseFloat(transferObj.blng)))
AMap.invoke('addOverlay',this.markers[snSourceType])
} }
gpsBtn && gpsBtn.classList.remove('el-button--primary'); gpsBtn && gpsBtn.classList.remove('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary'); baseBtn && baseBtn.classList.remove('el-button--primary');
...@@ -150,43 +161,49 @@ const monitor = { ...@@ -150,43 +161,49 @@ const monitor = {
EventBus.$on("uiMap.monitor.drawMaker", this.drawMaker); EventBus.$on("uiMap.monitor.drawMaker", this.drawMaker);
}, },
draw(data, autoOpenLastInfoWindow) { draw(data, autoOpenLastInfoWindow) {
const MAP = mapService.map; console.log(data)
this.data = data; this.data = data;
const transferObj = [] const transferObj = []
data.forEach((item) => { data.forEach((item) => {
if (item.gpsLocation && item.gpsLocation.elat && item.gpsLocation.elng) { if (item.gpsLocation && item.gpsLocation.blat && item.gpsLocation.blng) {
transferObj.push(item.gpsLocation) transferObj.push(item.gpsLocation)
} }
if (item.bsLocation && item.bsLocation.elat && item.bsLocation.elng) { if (item.bsLocation && item.bsLocation.blat && item.bsLocation.blng) {
transferObj.push(item.bsLocation) transferObj.push(item.bsLocation)
} }
if (item.wifiLocation && item.wifiLocation.blat && item.bsLocation.blng) {
transferObj.push(item.wifiLocation)
}
}) })
MAPGEO.transferAddressByGroup({ data: transferObj }, () => { MAPGEO.transferAddressByGroup({ data: transferObj }, () => {
this.data.forEach((item, idx) => { this.data.forEach((item, idx) => {
let eLocation = item[item.eLocateType]; let eLocation = item[item.eLocateType];
if (!eLocation.elng && !eLocation.elat) return; if (!eLocation.blng && !eLocation.blat) return;
let isInfoOpen = false; let isInfoOpen = false;
let tag = `${item.sn}:${item.isSource}`; let tag = `${item.sn}:${item.isSource}`;
if (this.infowins[tag] && this.infowins[tag].getIsOpen()) { if (this.infowins[tag] && this.infowins[tag].isOpen()) {
isInfoOpen = true; isInfoOpen = true;
} }
let infoWindow; let infoWindow;
let snSourceType = `${item.sn}:${item.isSource}` let snSourceType = `${item.sn}:${item.isSource}`
if (this.markers[tag]) { if (this.markers[tag]) {
this.markers[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat))); this.markers[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.blng), parseFloat(eLocation.blat)));
//this.infowins[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat))); //this.infowins[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.blng), parseFloat(eLocation.blat)));
//infoWindow = mapService.bindMonitorInfoWindow(this.markers[tag], MAP, item, isInfoOpen); //infoWindow = mapService.bindMonitorInfoWindow(this.markers[tag], MAP, item, isInfoOpen);
this.infowins[tag] = mapService.bindMonitorInfoWindow(this.markers[tag], MAP, item, isInfoOpen, this.isCompare ? true : false); console.log(this.markers,'markers')
this.infowins[tag] = mapService.bindMonitorInfoWindow(this.markers[tag], AMap, item, isInfoOpen, this.isCompare ? true : false);
AMap.invoke('addOverlay', this.markers[tag])
EventBus.$emit(`uiMap.monitor.changeStatus.${snSourceType}`) EventBus.$emit(`uiMap.monitor.changeStatus.${snSourceType}`)
} else { } else {
this.infowins[tag] && MAP.remove(this.infowins[tag]); this.infowins[tag] && MAP.remove(this.infowins[tag]);
let marker = mapService.createCarMarker([parseFloat(eLocation.elng), parseFloat(eLocation.elat)], MAP); const getLngLat=mapService.getLngLat(parseFloat(eLocation.blng),parseFloat(eLocation.blat))
infoWindow = mapService.bindMonitorInfoWindow(marker, MAP, item, isInfoOpen, this.isCompare ? true : false); let marker = mapService.createCarMarker(getLngLat, AMap);
infoWindow = mapService.bindMonitorInfoWindow(marker, AMap, item, isInfoOpen, this.isCompare ? true : false);
this.markers[tag] = marker; this.markers[tag] = marker;
this.infowins[tag] = infoWindow; this.infowins[tag] = infoWindow;
AMap.invoke('addOverlay', this.markers[tag])
} }
if (item.alarmModelList && item.alarmModelList.length) { if (item.alarmModelList && item.alarmModelList.length) {
...@@ -194,7 +211,6 @@ const monitor = { ...@@ -194,7 +211,6 @@ const monitor = {
} else { } else {
mapService.setDefaultIcon(this.markers[tag]) mapService.setDefaultIcon(this.markers[tag])
} }
if (autoOpenLastInfoWindow && idx === 0) { if (autoOpenLastInfoWindow && idx === 0) {
EventBus.$emit('uiMap.monitor.openInfoWindow', snSourceType) EventBus.$emit('uiMap.monitor.openInfoWindow', snSourceType)
} }
...@@ -223,7 +239,7 @@ const monitor = { ...@@ -223,7 +239,7 @@ const monitor = {
const MAP = mapService.map; const MAP = mapService.map;
if (!this.compareLine) { if (!this.compareLine) {
this.compareLine = new AMap.Polyline({ this.compareLine = new AMap.Polyline({
map: MAP, map: AMap,
strokeColor: '#80d8ff', strokeColor: '#80d8ff',
isOutline: true, isOutline: true,
outlineColor: 'white' outlineColor: 'white'
...@@ -231,7 +247,7 @@ const monitor = { ...@@ -231,7 +247,7 @@ const monitor = {
} }
if (!this.compareText) { if (!this.compareText) {
this.compareText = new AMap.Text({ this.compareText = new AMap.Text({
map: MAP, map: AMap,
text: '', text: '',
style: { style: {
'background-color': '#29b6f6', 'background-color': '#29b6f6',
...@@ -272,13 +288,12 @@ const monitor = { ...@@ -272,13 +288,12 @@ const monitor = {
}, },
compareDestroy: function () { compareDestroy: function () {
const MAP = mapService.map;
for (let snSourceType in this.markers) { for (let snSourceType in this.markers) {
MAP.remove(this.markers[snSourceType]) AMap.remove(this.markers[snSourceType])
} }
for (let snSourceType in this.infowins) { for (let snSourceType in this.infowins) {
MAP.remove(this.infowins[snSourceType]) AMap.remove(this.infowins[snSourceType])
} }
this.markers = {}; this.markers = {};
this.infowins = {}; this.infowins = {};
...@@ -302,15 +317,16 @@ const monitor = { ...@@ -302,15 +317,16 @@ const monitor = {
// 激活位置 // 激活位置
drawMaker(data, autoOpenLastInfoWindow) { drawMaker(data, autoOpenLastInfoWindow) {
console.log('drawMaker', data)
let tag = `${data.sn}-${data.standNo}`; let tag = `${data.sn}-${data.standNo}`;
const MAP = mapService.map const getLngLat=mapService.getLngLat(parseFloat(data.lng || data.bsLng),parseFloat(data.lat || data.bsLat))
const marker = mapService.createCarMarker( const marker = mapService.createCarMarker(
[parseFloat(data.lng || data.bsLng), parseFloat(data.lat || data.bsLat)], getLngLat,
MAP AMap
) )
const infoWindow = mapService.bindActiveLocationInfoWindow( const infoWindow = mapService.bindActiveLocationInfoWindow(
marker, marker,
MAP, AMap,
data, data,
true true
) )
...@@ -324,17 +340,16 @@ const monitor = { ...@@ -324,17 +340,16 @@ const monitor = {
// /EventBus.$emit("uiMap.monitor.openInfoWindow"); // /EventBus.$emit("uiMap.monitor.openInfoWindow");
monitor.openActiveInfoWindow(marker, infoWindow) monitor.openActiveInfoWindow(marker, infoWindow)
} }
AMap.invoke('addOverlay',marker)
// mapService.setFitView(MAP); // mapService.setFitView(MAP);
EventBus.$emit('uiMap.monitor.drawDone') EventBus.$emit('uiMap.monitor.drawDone')
}, },
// 打开激活位置点弹框 // 打开激活位置点弹框
openActiveInfoWindow(makers, infoWindow) { openActiveInfoWindow(makers, infoWindow) {
const MAP = mapService.map
const lnglat = makers.getPosition() const lnglat = makers.getPosition()
infoWindow.open(MAP, lnglat) AMap.invoke("mapOpenInfoWindow", infoWindow,lnglat)
MAP.setZoomAndCenter(MAP.getZoom(), lnglat,true) // infoWindow.open(MAP, lnglat)
AMap.invoke("centerAndZoom",lnglat,14)
} }
} }
......
import EventBus from '../event-bus' import EventBus from '../event-bus'
import mapService from './mapService.js' import mapService from './mapBService.js'
import MAPGEO from './mapgeo' import MAPGEO from './mapBgeo'
//单个地址解析容器 //单个地址解析容器
const transferObj = { const transferObj = {
data: [], data: [],
...@@ -21,9 +21,12 @@ const replay = { ...@@ -21,9 +21,12 @@ const replay = {
times: 1, times: 1,
timeoutIds: [], timeoutIds: [],
data: [], data: [],
dis:[],
distance:'',
markers: {}, markers: {},
infowins: {}, infowins: {},
speed: 1, speed: 1,
idx:0,
transferAddressByGroup(ifPlay){ transferAddressByGroup(ifPlay){
const data = replay.data; const data = replay.data;
...@@ -34,141 +37,89 @@ const replay = { ...@@ -34,141 +37,89 @@ const replay = {
}, },
init(){ init(){
if(!replay.pathSPromise){ var replayData = [];
replay.pathSPromise = new Promise(function(resolve, reject){ replay.data.reduce(function(prev ,item ){
AMapUI.load(['ui/misc/PathSimplifier'], function(PathSimplifier) { // console.log(prev ,item)
let prevLnglat=mapService.getLngLat(prev.blng,prev.blat)
if (!PathSimplifier.supportCanvas) { let lnglat=mapService.getLngLat(item.blng,item.blat)
alert('当前环境不支持 Canvas!'); replay.dis.push(replay.getDistance(prevLnglat,lnglat))
return; replayData.push(lnglat)
} return item
replay.PathS = PathSimplifier;
resolve()
});
})
}
var replayData = []
replay.data.forEach(function(item){
var arr = [];
arr.push(item.elng)
arr.push(item.elat)
replayData.push(arr)
}); });
const MAP = mapService.map; let p1=replayData[0];
replay.pathSPromise.then(()=>{ let p2=replayData[replayData.length-1];
if(replay.PathS){ let line = AMap.invoke('Polyline', replayData, { strokeColor: '#0b94db',strokeWeight: 6 })
replay.pathSimplifierIns = new replay.PathS({ replay.startMarker = mapService.createStartMarker(p1, AMap);
zIndex: 100, replay.endMarker = mapService.createEndMarker(p2, AMap);
map: MAP, //所属的地图实例 // replay.dis = AMap.invoke('getDistance', p1, p2)/1000 // 算出轨迹的距离(km)
getPath: function(pathData, pathIndex) { AMap.invoke('setViewport',replayData);
//返回轨迹数据中的节点坐标信息,[AMap.LngLat, AMap.LngLat...] 或者 [[lng|number,lat|number],...] AMap.invoke('addOverlay', line)
return pathData.path; AMap.invoke('addOverlay', replay.startMarker)
}, AMap.invoke('addOverlay', replay.endMarker )
getHoverTitle(){ replay.distance=replay.dis.reduce(function (prev, cur, index, arr) {
return '' return prev + cur;
}, });
clickToSelectPath: false, // replay.distance= parseInt(replay.distance/1000)//算出轨迹的距离(km)
renderOptions: {
//轨迹线的样式 const firstItem = replay.data[0];
pathLineStyle: { replay.navg= AMap.invoke('LuShu', replayData, {
strokeStyle: '#0b94db', defaultContent: replay.getNavgInfoContent(firstItem),
lineWidth: 6, autoView: true, // 是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整
dirArrowStyle: true speed: replay.getSpeed(replay.speed, replay.distance),
} icon: AMap.invoke('Icon', 'https://e-shield-old.glsx.com.cn/images/icon_car.png', AMap.invoke('Size', 36, 22),{ anchor: AMap.invoke('Size',18, 11) }),
} enableRotation: true, // 是否设置marker随着道路的走向进行旋转
})
}); AMap.invoke('lushuStart') //开始
replay.dis = AMap.GeometryUtil.distanceOfLine(replayData) / 1000 // 算出轨迹的距离(km) // AMap.invoke('lushuStop') //停止
replay.pathSimplifierIns.setData([{ // AMap.invoke('lushuPause') //暂停
path: replayData // AMap.invoke('lushuShowInfoWindow') //打开信息窗口
}]); EventBus.$emit('uiMap.replay.initDone')
replay.pathSimplifierIns.show(); AMap.invoke('lushuAddEventListener','move', (e) =>{
this.idx = e.target.i;
//创建一个巡航器 let lnglat = replayData[this.idx]
replay.navg = replay.pathSimplifierIns.createPathNavigator(0, //关联第1条轨迹 let item=replay.data[this.idx]
{ AMap.invoke('lushuSetContent',replay.getNavgInfoContent(item)) //设置信息窗口文案
loop: false, //循环播放 EventBus.$emit('uiMap.replay.currAddress', '');
speed: replay.getSpeed(replay.speed, replay.dis), if(this.idx >= replay.data.length-2){
pathNavigatorStyle: { EventBus.$emit('uiMap.replay.done');
width: 36, }
height: 22, });
//使用图片
content: replay.PathS.Render.Canvas.getImageContent('https://e-shield-old.glsx.com.cn/images/icon_car.png'), },
initRotateDegree: -90 getDistance (p1, p2) {
} return AMap.invoke('getDistance', p1, p2);
});
const firstItem = replay.data[0];
const lnglat = new AMap.LngLat(firstItem.elng, firstItem.elat);
replay.navgInfoWindow = new AMap.InfoWindow({
isCustom: true,
position: lnglat,
content: replay.getNavgInfoContent(firstItem),
offset: new AMap.Pixel(80, -20)
});
replay.navgInfoWindow.open(MAP)
replay.navg.start();
replay.navg.on('move', function(e){
replay.navgTimeoutId && clearTimeout(replay.navgTimeoutId);
replay.navgTimeoutId = setTimeout(()=>{
let idx = replay.navg.getCursor().idx;
let lnglat = replay.navg.getPosition();
let item = replay.data[idx]
replay.navgInfoWindow.setContent(replay.getNavgInfoContent(item));
replay.navgInfoWindow.open(MAP)
replay.navgInfoWindow.setPosition(lnglat);
EventBus.$emit('uiMap.replay.currAddress', '');
}, 0)
let idx = replay.navg.getCursor().idx;
if(idx === replay.data.length-1){
EventBus.$emit('uiMap.replay.done');
}
//$playBtn.addClass('active');
//$pauseBtn.removeClass('active');
/**/
});
let startPoint = replay.data[0];
let endPoint = replay.data[replay.data.length-1];
replay.startMarker = mapService.createStartMarker([startPoint.elng, startPoint.elat], MAP);
replay.endMarker = mapService.createEndMarker([endPoint.elng, endPoint.elat], MAP);
EventBus.$emit('uiMap.replay.initDone')
}
})
}, },
getNavgInfoContent(item){ getNavgInfoContent(item){
return `<div class="navg-info-window"> return `<div class="navg-info-window">
<div class="tit">${item.dateTime}</div> <div class="tit">${item.dateTime}</div>
<div class="main"> <div class="main">
<p><span class="lb">经度</span>${item.elng}</p> <p><span class="lb">经度</span>${item.blng}</p>
<p><span class="lb">纬度</span>${item.elat}</p> <p><span class="lb">纬度</span>${item.blat}</p>
<p><span class="lb">速度</span>${item.speed} km/h</p> <p><span class="lb">速度</span>${item.speed} km/h</p>
</div> </div>
</div>` </div>`
}, },
destroy: function(){ destroy: function(){
const MAP = mapService.map; AMap.invoke('clearOverlays');
if(replay.pathSimplifierIns){ // const MAP = mapService.map;
replay.pathSimplifierIns.hide(); // if(replay.pathSimplifierIns){
replay.pathSimplifierIns.clearPathNavigators(); // replay.pathSimplifierIns.hide();
MAP.remove(replay.navgInfoWindow); // replay.pathSimplifierIns.clearPathNavigators();
} // MAP.remove(replay.navgInfoWindow);
// }
replay.startMarker && MAP.remove(replay.startMarker); // replay.startMarker && MAP.remove(replay.startMarker);
replay.endMarker && MAP.remove(replay.endMarker); // replay.endMarker && MAP.remove(replay.endMarker);
replay.data = []; // replay.data = [];
EventBus.$emit('uiMap.transfer.currAddress', '') // EventBus.$emit('uiMap.transfer.currAddress', '')
this.clearTimeoutIds() // this.clearTimeoutIds()
}, },
bindEvent(){ bindEvent(){
//解析轨迹地址 //解析轨迹地址
EventBus.$on('uiMap.replay.transferAdr', function(data){ EventBus.$on('uiMap.replay.transferAdr', function(data){
// console.log(data)
replay.data = data; replay.data = data;
replay.transferAddressByGroup(); replay.transferAddressByGroup();
}); });
...@@ -183,24 +134,24 @@ const replay = { ...@@ -183,24 +134,24 @@ const replay = {
}); });
//播放轨迹 //播放轨迹
EventBus.$on('uiMap.replay.play', function(){ EventBus.$on('uiMap.replay.play', ()=>{
if(replay.navg){ if(replay.navg){
if(replay.navg.getCursor().idx === replay.navg.getPathEndIdx()){ if(this.idx === replay.data.length-1){
replay.navg.start(); AMap.invoke('stop')
}else if(replay.navg.getNaviStatus()==='pause'){ AMap.invoke('lushuStart') //开始
replay.navg.resume(); }else {
}else{ AMap.invoke('lushuStart');
replay.navg.start();
} }
} }
}); });
//轨迹暂停 //轨迹暂停
EventBus.$on('uiMap.replay.pause', function(ifShowAddr){ EventBus.$on('uiMap.replay.pause', (ifShowAddr)=>{
console.log(this.idx)
if(replay.navg){ if(replay.navg){
replay.navg.pause(); AMap.invoke('lushuPause')
if(ifShowAddr){ if(ifShowAddr){
let idx = replay.navg.getCursor().idx; let idx =this.idx
if(replay.data[idx].transferAddress){ if(replay.data[idx].transferAddress){
EventBus.$emit('uiMap.replay.currAddress', replay.data[idx].transferAddress); EventBus.$emit('uiMap.replay.currAddress', replay.data[idx].transferAddress);
}else{ }else{
...@@ -216,16 +167,16 @@ const replay = { ...@@ -216,16 +167,16 @@ const replay = {
//轨迹刷新 //轨迹刷新
EventBus.$on('uiMap.replay.refresh', function(){ EventBus.$on('uiMap.replay.refresh', function(){
if(replay.navg){ if(replay.navg){
replay.navg.start(); AMap.invoke('lushuStop') //停止
AMap.invoke('lushuStart') //开始
} }
}); });
//播放轨迹,速度改变 //播放轨迹,速度改变
EventBus.$on('uiMap.replay.speedChange', function(data){ EventBus.$on('uiMap.replay.speedChange', function(data){
let speed = replay.getSpeed(data, replay.dis) let speed = replay.getSpeed(data, replay.dis)
if(replay.navg){ if(replay.navg){
replay.navg.setSpeed(speed) AMap.invoke('lushuSetSpeed',speed)
} }
}); });
...@@ -236,10 +187,12 @@ const replay = { ...@@ -236,10 +187,12 @@ const replay = {
EventBus.$on('uiMap.replay.drawLocation', (data)=>{ EventBus.$on('uiMap.replay.drawLocation', (data)=>{
const MAP = mapService.map; const MAP = mapService.map;
for(let idx in this.markers){ for(let idx in this.markers){
MAP.remove(this.markers[idx]) // MAP.remove(this.markers[idx])
AMap.invoke('removeOverlay', this.markers[idx])
} }
for(let idx in this.infowins){ for(let idx in this.infowins){
MAP.remove(this.infowins[idx]) // MAP.remove(this.infowins[idx])
AMap.invoke('removeOverlay', this.infowins[idx])
} }
this.markers = {}; this.markers = {};
this.infowins = {}; this.infowins = {};
...@@ -257,35 +210,54 @@ const replay = { ...@@ -257,35 +210,54 @@ const replay = {
if(this.markers[idx]){ if(this.markers[idx]){
const MAP = mapService.map; const MAP = mapService.map;
const lnglat = this.markers[idx].getPosition(); const lnglat = this.markers[idx].getPosition();
this.infowins[idx].open(MAP, lnglat); AMap.invoke('mapOpenInfoWindow', this.infowins[idx], lnglat)
// this.infowins[idx].open(MAP, lnglat);
EventBus.$emit('uiMap.replay.pause'); EventBus.$emit('uiMap.replay.pause');
EventBus.$emit('uiMap.replay.replayIng', false); EventBus.$emit('uiMap.replay.replayIng', false);
MAP.setZoomAndCenter(MAP.getZoom(), lnglat); // MAP.setZoomAndCenter(MAP.getZoom(), lnglat);
AMap.invoke('panTo', lnglat)
} }
}); });
}, },
drawLocation(data){ drawLocation(data) {
const MAP = mapService.map; // console.log(data)
EventBus.$emit('uiMap.historyLocation.transferSuccess', data); const { MAP, mapapi } = mapService
data.forEach((item)=>{ EventBus.$emit('uiMap.historyLocation.transferSuccess', data)
let marker = mapService.createPointMarker([item.elng, item.elat], MAP); data.forEach((item) => {
let infoWindow = mapService.bindLocationInfoWindow(marker, MAP, item); const marker = mapService.createPointMarker(mapService.getLngLat(item.blng, item.blat), MAP)
this.markers[item.idx] = marker; AMap.invoke('addOverlay', marker)
this.infowins[item.idx] = infoWindow; const infoWindow = mapService.bindLocationInfoWindow(marker, MAP, item)
}); this.markers[item.idx] = marker
this.infowins[item.idx] = infoWindow
})
// console.log(this.markers, 'markers')
const points = Object.values(this.markers).map(item => item.latLng)
// console.log(points)
AMap.invoke('setViewport', points)
// mapService.setFitView(MAP);
},
// drawLocation(data){
// EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
// data.forEach((item)=>{
// let lnglatXY=mapService.getLngLat(item.elng, item.elat);
// let marker = mapService.createPointMarker(lnglatXY, MAP);
// let infoWindow = mapService.bindLocationInfoWindow(marker, MAP, item);
// this.markers[item.idx] = marker;
// this.infowins[item.idx] = infoWindow;
// });
//mapService.setFitView(MAP); // //mapService.setFitView(MAP);
}, // },
speedEvent(idx, dis) { speedEvent(idx, dis) {
let timeArr = [[40, 30, 16], [30, 20, 12], [20, 12, 8], [5, 3, 2]] // 慢 正常 快 很快 let timeArr = [[40, 30, 16], [30, 20, 12], [20, 12, 8], [5, 3, 2]] // 慢 正常 快 很快
let speed let speed
if (dis >= 100) { // 100公里以上 if (dis >= 100) { // 100公里以上
speed = Math.floor((dis / timeArr[idx][0]) * 3600) speed = Math.floor((dis / timeArr[idx][0]))
} else if (dis > 10 && dis < 100) { // 10-100公里 } else if (dis > 10 && dis < 100) { // 10-100公里
speed = Math.floor((dis / timeArr[idx][1]) * 3600) speed = Math.floor((dis / timeArr[idx][1]))
} else { // 10公里以内 } else { // 10公里以内
speed = Math.floor((dis / timeArr[idx][2]) * 3600) speed = Math.floor((dis / timeArr[idx][2]))
} }
return speed return speed
}, },
......
/*
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-30 15:13:49
* @FilePath: \oEshield\src\utils\resident.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import EventBus from '../event-bus' import EventBus from '../event-bus'
import mapService from './mapService.js' import mapService from './mapBService.js'
import MAPGEO from './mapgeo' import MAPGEO from './mapgeo'
//常驻地 //常驻地
...@@ -19,56 +27,42 @@ const resident = { ...@@ -19,56 +27,42 @@ const resident = {
EventBus.$on('uiMap.resident.openInfoWindow', (idx)=>{ EventBus.$on('uiMap.resident.openInfoWindow', (idx)=>{
if(this.markers[idx]){ if(this.markers[idx]){
const MAP = mapService.map;
const lnglat = this.markers[idx].getPosition(); const lnglat = this.markers[idx].getPosition();
this.infowins[idx].open(MAP, lnglat); AMap.invoke("mapOpenInfoWindow", this.infowins[idx],lnglat)
MAP.setZoomAndCenter(MAP.getZoom(), lnglat); AMap.invoke('centerAndZoom',lnglat,13)
} }
}); });
}, },
draw(data){ draw(data){
const MAP = mapService.map; const MAP = mapService.map;
this.data = data; this.data = data;
let paths=[]
// MAPGEO.transferAddressByGroup(this, ()=>{
// EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
// this.data.forEach((item)=>{
// if(parseFloat(item.elng) === 0 && parseFloat(item.elat) === 0) return;
// let marker = mapService.createConstantMarker([parseFloat(item.elng), parseFloat(item.elat)], MAP);
// let infoWindow = mapService.bindResidentInfoWindow(marker, MAP, item);
// this.markers[item.idx] = marker;
// this.infowins[item.idx] = infoWindow;
// });
// mapService.setFitView(MAP);
// });
// v1.7.0常驻地为保证导出内容与显示一致 取后端返回的address 不需高德逆地址解析 // v1.7.0常驻地为保证导出内容与显示一致 取后端返回的address 不需高德逆地址解析
EventBus.$emit('uiMap.historyLocation.transferSuccess', data); EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
this.data.forEach((item)=>{ this.data.forEach((item)=>{
if(parseFloat(item.elng) === 0 && parseFloat(item.elat) === 0) return; if(parseFloat(item.blng) === 0 && parseFloat(item.blat) === 0) return;
let lnglatXY=mapService.getLngLat(parseFloat(item.blng), parseFloat(item.blat));
let marker = mapService.createConstantMarker([parseFloat(item.elng), parseFloat(item.elat)], MAP); paths.push(lnglatXY)
let marker = mapService.createConstantMarker(lnglatXY, MAP);
let infoWindow = mapService.bindResidentInfoWindow(marker, MAP, item); let infoWindow = mapService.bindResidentInfoWindow(marker, MAP, item);
this.markers[item.idx] = marker; this.markers[item.idx] = marker;
this.infowins[item.idx] = infoWindow; this.infowins[item.idx] = infoWindow;
MAP.invoke('addOverlay',this.markers[item.idx])
}); });
AMap.invoke('setViewport',paths)
mapService.setFitView(MAP); // mapService.invoke('panTo', MAP.getCenter())
}, },
intervalDraw(){ intervalDraw(){
}, },
destroy: function(){ destroy: function(){
const MAP = mapService.map;
for(let idx in this.markers){ for(let idx in this.markers){
MAP.remove(this.markers[idx]) AMap.invoke('removeOverlay',this.markers[idx])
} }
for(let idx in this.infowins){ for(let idx in this.infowins){
MAP.remove(this.infowins[idx]) AMap.invoke('mapCloseInfoWindow')
} }
this.markers = {}; this.markers = {};
this.infowins = {}; this.infowins = {};
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!