Commit be63bdeb by wangzhihui

高德地图替换百度地图

1 parent 2917f8e2
......@@ -99,7 +99,7 @@
</v-full-layout>
</template>
<script>
import mapService from "@/utils/mapService.js";
import mapService from "@/utils/mapBService.js";
import "@/utils/mapEvent.js";
import { STATICIMAGE } from "@/constant";
import FenceMapControll from "./FenceMapControll";
......@@ -145,6 +145,8 @@ export default {
},
],
},
markers: {},
infowins: {},
hideFooter: false,
poi: {},
poiMapSearch: "",
......@@ -158,43 +160,44 @@ export default {
},
mounted() {
console.log(STATICIMAGE);
this.initMap();
this.initBMap();
EventBus.$on("uiMap.poi.marker.delete", this.removePoi);
},
methods: {
// 地图初始化
initMap() {
let _this = this;
let plugins = ["AMap.LngLat", "AMap.MassMarks", "AMap.Geocoder"];
_this.$mapInit({ plugins: plugins }).then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map", {
zoom: 15,
showIndoorMap: false,
showLabel: false,
});
_this.bindSearch();
_this.initMapEvent();
_this.getPoiTrack();
async initBMap() {
this.mapObj = await mapService.init("map");
this.mapLoading = false;
window.AMap = this.mapObj;
this.autoComplete = AMap.invoke("Autocomplete", {
input: "poiMapSearch",
});
AMap.invoke("autocompleteShow");
AMap.invoke("autocompleteAddEventListener", "onconfirm", (e) => {
this.poi = e.item.value;
this.$set(this.form, "address", this.poi.address);
this.$refs.addressInput.focus();
});
this.initMapEvent();
this.getPoiTrack();
},
// 创建地图右键菜单
initMapEvent() {
let _this = this;
let _map = this.map;
const self = this;
const mapInstance = mapService.mapInstance;
var contextMenu = AMap.invoke("ContextMenu");
let _position = "";
let _contextMenu = new AMap.ContextMenu();
//右键添加Marker标记
_contextMenu.addItem("设置POI点", function () {
_contextMenu.close();
_this.addPoiMarker(_position);
});
//地图绑定鼠标右击事件——弹出右键菜单
_map.on("rightclick", function (e) {
_contextMenu.open(_map, e.lnglat);
_position = e.lnglat;
contextMenu.addItem(
AMap.invoke("MenuItem", "设置POI点", function () {
self.addPoiMarker(_position);
})
);
AMap.invoke("mapAddEventListener", "rightclick", function (e) {
console.log(e)
AMap.invoke("addContextMenu", contextMenu);
_position = e.latlng;
});
},
......@@ -203,72 +206,71 @@ export default {
let _this = this;
let _query = _this.$route.query;
let markers = [];
let _icon = {
url: STATICIMAGE.POI_MASS_ICON,
size: new AMap.Size(16, 21),
anchor: new AMap.Pixel(3, 3),
};
for (let i = 0, len = arr.length; i < len; i++) {
let k = arr[i];
if (k.id != _query.id) {
if (k.lnglat) {
let m = k.lnglat.split(",");
k.lng = m[0];
k.lat = m[1];
k.lnglat = m;
markers.push(k);
}
if (k.lnglat) {
let m = k.lnglat.split(",");
let lnglatXY = mapService.getLngLat(m[0], m[1]);
markers.push(lnglatXY);
let marker = mapService.createPoiMarker(lnglatXY, AMap);
AMap.invoke("addOverlay", marker);
AMap.invoke("markerAddEventListener", "click", (e) => {
let data = { ...e, ...k };
this.markerEvent(data);
});
}
}
let mass = new AMap.MassMarks(markers, {
opacity: 0.8,
zIndex: 10,
cursor: "pointer",
style: _icon,
});
mass.on("click", function (e) {
console.log(e);
_this.markerEvent(e.data);
});
mass.setMap(_this.map);
AMap.invoke("setViewport", markers);
},
// 地图右键添加poi点
addPoiMarker(options, type, isOpen) {
console.log(options,type, isOpen);
let _this = this;
let _map = _this.map;
let _InfoWindow = _this.poiInfoWindow;
if (_this.poiMarker) {
_map.remove(_this.poiMarker);
_InfoWindow && _InfoWindow.close();
AMap.invoke("removeOverlay", _this.poiMarker);
_InfoWindow && AMap.invoke("mapCloseInfoWindow", _InfoWindow);
_this.poiMarker = null;
}
let _icon = new AMap.Icon({
image: STATICIMAGE.POI_MARKER,
});
let _icon = AMap.invoke(
"Icon",
STATICIMAGE.POI_MARKER,
AMap.invoke("Size", 24, 24)
);
if (options.id) {
_icon = new AMap.Icon({
image: STATICIMAGE.POI_MASS_ICON,
imageSize: new AMap.Size(16, 21),
});
_icon = AMap.invoke(
"Icon",
STATICIMAGE.POI_MASS_ICON,
AMap.invoke("Size", 16, 21)
);
}
let _marker = new AMap.Marker({
icon: _icon,
position: [options.lng, options.lat],
extData: options,
});
let _markerInfo = _marker.getExtData();
//_marker.infoWindow = mapService.createPoiMarkerInfowindow(options);
_marker.on("click", function (e) {
_this.markerEvent(_markerInfo);
});
_marker.setMap(_this.map);
let lnglatXY=mapService.getLngLat(options.lng, options.lat);
let _marker=AMap.invoke('Marker', lnglatXY, {
icon:_icon
})
// let _marker = new AMap.Marker({
// icon: _icon,
// position: [options.lng, options.lat],
// extData: options,
// });
let _markerInfo=options
_markerInfo.latLng=mapService.getLngLat(options.lng, options.lat);
AMap.invoke("addOverlay", _marker);
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为键值,方便后续删除用
if (options.id) {
......@@ -295,27 +297,20 @@ export default {
// marker点击事件
markerEvent(e) {
let _this = this;
console.log(e);
console.log(e)
let _params = e;
const geocoder = new AMap.Geocoder({
extensions: "all",
this.setPoiInfo(e);
let point = e.latLng;
AMap.invoke("getLocation", point, (res) => {
console.log(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信息
......@@ -439,8 +434,8 @@ export default {
let _InfoWindow = this.poiInfoWindow;
// id不存在,临时的poi点,删除marker就行了
if (!row.id) {
_map.remove(_this.poiMarker);
_InfoWindow && _InfoWindow.close();
AMap.invoke('removeOverlay', _this.poiMarker)
_InfoWindow && AMap.invoke('mapCloseInfoWindow', _InfoWindow);
_this.form = {};
setTimeout(function () {
_this.$refs.poiForm.clearValidate();
......@@ -451,8 +446,8 @@ export default {
DELETE_POI_INFO(_params).then((res) => {
if (res.code == 200) {
let _marker = _this.markerList[row.id];
_map.remove(_marker);
_InfoWindow && _InfoWindow.close();
AMap.invoke('removeOverlay', _marker)
_InfoWindow && AMap.invoke('mapCloseInfoWindow', _InfoWindow);
showToast({
message: "删除成功",
type: "success",
......@@ -473,13 +468,12 @@ export default {
if (res.code == 200) {
let _list = res.data || [];
_this.addMassMarkers(_list);
// 编辑页面
if (_query.id) {
_this.getInfo();
}
_this.trackList = res.data || [];
_this.showRoadTitle();
// _this.showRoadTitle();
}
});
},
......@@ -526,7 +520,8 @@ export default {
if (_map) {
console.log(lng, lat);
setTimeout(function () {
_map.setCenter([lng, lat]);
let lnglatXY = mapService.getLngLat(lng, lat);
AMap.invoke('panTo',lnglatXY)
}, 1000);
}
},
......
<template>
<!-- 线路弹框 -->
<!-- <el-dialog id="fenceModal" :visible="fenceModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="800px"> -->
<v-layout >
<template slot="breadcrumb">
<el-breadcrumb-item>车辆监控</el-breadcrumb-item>
<el-breadcrumb-item @click="addMode">{{isEditMode?'编辑线路':'新增线路'}}</el-breadcrumb-item>
</template>
<template slot="main">
<!-- 线路调用地图弹框 -->
<div class="ibox-content" style="height: 500px; padding:0 20px;z-index: 100">
<fence-map
:mapData="mapData"
@onUpdateMapData="updateMapData"
:readonlyStatus="readonlyStatus"
ref="fenceMap"
>
</fence-map>
</div>
<!-- 线路调用地图弹框 /-->
<div class="tab_wrap">
<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-dialog id="fenceModal" :visible="fenceModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="800px"> -->
<v-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>车辆监控</el-breadcrumb-item>
<el-breadcrumb-item @click="addMode">{{
isEditMode ? "编辑线路" : "新增线路"
}}</el-breadcrumb-item>
</template>
<template slot="main">
<!-- 线路调用地图弹框 -->
<div
class="ibox-content"
style="height: 500px; padding: 0 20px; z-index: 100"
>
<fence-map
:mapData="mapData"
@onUpdateMapData="updateMapData"
:readonlyStatus="readonlyStatus"
ref="fenceMap"
>
</fence-map>
</div>
<!-- 线路调用地图弹框 /-->
<div class="tab_wrap">
<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-input v-model="form.fenceNo" disabled></el-input>
</el-form-item>
</el-col> -->
<el-col :span="12">
<el-form-item label="线路名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" maxlength="200" :disabled="readonlyStatus"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="线路类型" prop="bizFenceType">
<el-radio value="12" label="12" :disabled="readonlyStatus">试驾线路</el-radio>
<!-- <el-radio v-model="form.bizFenceType" :label="1" :disabled="isEditMode">试乘试驾型</el-radio> -->
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="区域类型" prop="shapeType">
<el-radio-group v-model="form.shapeType" @change="shapeTypeChange" >
<!-- <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
<el-col :span="12">
<el-form-item label="线路名称" prop="fenceName">
<el-input
v-model.trim="form.fenceName"
maxlength="200"
:disabled="readonlyStatus"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="线路类型" prop="bizFenceType">
<el-radio value="12" label="12" :disabled="readonlyStatus"
>试驾线路</el-radio
>
<!-- <el-radio v-model="form.bizFenceType" :label="1" :disabled="isEditMode">试乘试驾型</el-radio> -->
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="区域类型" prop="shapeType">
<el-radio-group
v-model="form.shapeType"
@change="shapeTypeChange"
>
<!-- <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"
:value="form.specialShopName"
:placeholder="form.specialShopName || '请选择特约店名称'"
......@@ -64,35 +97,53 @@
size="small"
:disabled="readonlyStatus"
></el-cascader> -->
<el-popover
v-model="filterVisible"
placement="top-end"
width="400"
@show="selectStore"
trigger="click">
<div v-loading="loading">
<el-input placeholder="输入关键字进行过滤" v-model="filterText" size="small">
</el-input>
<el-popover
v-model="filterVisible"
placement="top-end"
width="400"
@show="selectStore"
trigger="click"
>
<div v-loading="loading">
<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>
<p style="text-align: right; margin-top: 10px">
<el-button @click="filterConfirm" type="primary">确定</el-button>
<el-button @click="closeFilter">取消</el-button>
</p>
</div>
<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-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>
<p style="text-align: right; margin-top: 10px">
<el-button @click="filterConfirm" type="primary"
>确定</el-button
>
<el-button @click="closeFilter">取消</el-button>
</p>
</div>
<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-select v-model="form.electricFenceType" placeholder="请选择" size="small" style="width:100px;">
<el-option label="驶入" :value="1"></el-option>
......@@ -101,8 +152,8 @@
</el-select>
</el-form-item>
</el-col> -->
<!-- <el-col :span="12"> -->
<!-- <el-form-item label="监控时间" prop="electricTimeFenceType" class="is-required">
<!-- <el-col :span="12"> -->
<!-- <el-form-item label="监控时间" prop="electricTimeFenceType" class="is-required">
<el-select v-model="form.electricTimeFenceType" placeholder="请选择时间" size="small" class="el-slect">
<el-option
v-for="item in form.electricTimeFenceTypes"
......@@ -112,7 +163,7 @@
</el-option>
</el-select>
</el-form-item> -->
<!-- <el-form-item label="监控时间" prop="timeType">
<!-- <el-form-item label="监控时间" prop="timeType">
<el-radio-group v-model="form.timeType">
<el-radio :label=1>
永久有效
......@@ -138,8 +189,8 @@
</el-form-item>
</el-col>
</el-row> -->
<!-- <el-row>
<!-- <el-row>
<el-col :span="12">
<el-form-item label="描述">
<el-input v-model.trim="form.des" type="textarea" rows="3" maxlength="500"></el-input>
......@@ -157,8 +208,8 @@
</el-col>
</el-row> -->
<!-- <el-row>
<!-- <el-row>
<el-col :span="12">
<el-form-item label="区域类型" class="is-required">
<el-radio-group v-model="form.shapeType" @change="shapeTypeChange">
......@@ -170,11 +221,11 @@
<div class="tab-content" v-show="form.shapeType==3">
<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 class="tab-content" v-show="form.shapeType==2">
......@@ -201,11 +252,13 @@
<el-button type="primary" @click="updateFence">更新线路</el-button>
</el-form-item>
</el-col> -->
<!-- </div> -->
<div class="tab-content shape_tip" v-show="form.shapeType==3">*注:地图任意位置,单击新增双击结束绘制。</div>
<!-- </el-col> -->
<!-- <el-col :span="12">
<!-- </div> -->
<div class="tab-content shape_tip" v-show="form.shapeType == 3">
*注:地图任意位置,单击新增双击结束绘制。
</div>
<!-- </el-col> -->
<!-- <el-col :span="12">
<el-form-item label="短信通知" prop="msgtel">
<el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item>
......@@ -214,136 +267,194 @@
</el-form-item>
</el-col>
</el-row> -->
</el-form>
</div>
</el-tab-pane>
<el-tab-pane label="关联对象" v-loadmore='loadMore'>
<div style="float: right;">
<el-button v-if="!readonlyStatus" type="primary" @click="userDate" size="small" :loading="submitting">关联用户</el-button>
<!-- <el-button size="small" @click="deleteFenceModel">批量删除</el-button> -->
</div>
<el-table
:data="tableData"
border
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-form>
</div>
</el-tab-pane>
<el-tab-pane label="关联对象" v-loadmore="loadMore">
<div style="float: right">
<el-button
v-if="!readonlyStatus"
type="primary"
@click="userDate"
size="small"
:loading="submitting"
>关联用户</el-button
>
<!-- <el-button size="small" @click="deleteFenceModel">批量删除</el-button> -->
</div>
<el-table
:data="tableData"
border
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 fixed prop="vin" label="车架号" min-width="160" align="center"></el-table-column>
<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>
<el-table-column
prop="sn"
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 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>
</el-tab-pane>
</el-tabs>
<!-- <div class="tab_ctrl">
<el-table-column
prop="userTel"
label="联系方式"
min-width="100"
align="center"
></el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
<!-- <div class="tab_ctrl">
<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>
</div> -->
</div>
<div class="fenceModalfooter">
<el-button v-if="!readonlyStatus" type="primary" @click="saveFence" size="small" :loading="submitting">{{btnText}}</el-button>
<el-button @click="cancel" size="small">取消</el-button>
</div>
<user-list
:init="userListInit"
@onUserListInit="(res)=>userListInit=res"
:userData="userArr"
@onUpdateUserData="updateUserData"
:userListModalVisible="userListModalVisible"
:shopId="form.specialShopId"
@onUserListModalChange="userListModalChange"
ref="userList">
</user-list>
</template>
<!-- </el-dialog> -->
<!-- 线路弹框 /-->
</v-layout>
</div>
<div class="fenceModalfooter">
<el-button
v-if="!readonlyStatus"
type="primary"
@click="saveFence"
size="small"
:loading="submitting"
>{{ btnText }}</el-button
>
<el-button @click="cancel" size="small">取消</el-button>
</div>
<user-list
:init="userListInit"
@onUserListInit="(res) => (userListInit = res)"
:userData="userArr"
@onUpdateUserData="updateUserData"
:userListModalVisible="userListModalVisible"
:shopId="form.specialShopId"
@onUserListModalChange="userListModalChange"
ref="userList"
>
</user-list>
</template>
<!-- </el-dialog> -->
<!-- 线路弹框 /-->
</v-layout>
</template>
<script>
import {services} from '../../api'
import AreaSelect from './AreaSelect.vue'
import mapService from 'utils/mapService.js'
import fenceMap from './fenceMap.vue'
import userList from './userList.vue'
import InfiniteLoading from 'vue-infinite-loading';
const MONITOR_SERVICE = services.monitor;
import { services } from "../../api";
import AreaSelect from "./AreaSelect.vue";
import mapService from "utils/mapBService.js";
import fenceMap from "./fenceMap.vue";
import userList from "./userList.vue";
import InfiniteLoading from "vue-infinite-loading";
const MONITOR_SERVICE = services.monitor;
export default{
props: ['fenceModalVisible', 'fenceId'],
data(){
let checkFenceName = (rule, vaule, cb)=>{
if(typeof this.restainFenceName != 'undefined' && this.form.fenceName === this.restainFenceName){
cb();
}
// MONITOR_SERVICE.checkFenceName({name: this.form.fenceName}).then((res)=>{
// if(res.returnCode == 0){
// if(res.data.isExist == 1){
// cb(new Error('该线路名已存在,请重新输入!'))
// }else{
// cb();
// }
// }
// })
}
let checkMonitorTime = (rule, vaule, cb)=>{
if(this.form.electricTimeFenceType==""){
cb(new Error('请选择监控时间'))
}else{
cb();
}
}
export default {
props: ["fenceModalVisible", "fenceId"],
data() {
let checkFenceName = (rule, vaule, cb) => {
if (
typeof this.restainFenceName != "undefined" &&
this.form.fenceName === this.restainFenceName
) {
cb();
}
// MONITOR_SERVICE.checkFenceName({name: this.form.fenceName}).then((res)=>{
// if(res.returnCode == 0){
// if(res.data.isExist == 1){
// cb(new Error('该线路名已存在,请重新输入!'))
// }else{
// cb();
// }
// }
// })
};
let checkMonitorTime = (rule, vaule, cb) => {
if (this.form.electricTimeFenceType == "") {
cb(new Error("请选择监控时间"));
} else {
cb();
}
};
let checkSpecialShop = (rule, vaule, cb)=>{
if(this.form.specialShopId == ""){
cb(new Error('请选择特约店'))
}else{
cb();
}
}
let checkSpecialShop = (rule, vaule, cb) => {
if (this.form.specialShopId == "") {
cb(new Error("请选择特约店"));
} else {
cb();
}
};
let checkArea = (rule, vaule, cb)=>{
if(this.form.shapeType == 1 && !this.form.areaCode){
cb(new Error('请选择行政区域'))
}else{
cb();
}
}
let checkArea = (rule, vaule, cb) => {
if (this.form.shapeType == 1 && !this.form.areaCode) {
cb(new Error("请选择行政区域"));
} else {
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)){
cb(new Error('请输入正确的格式'))
}else{
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
)
) {
cb(new Error("请输入正确的格式"));
} else {
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)){
cb(new Error('请输入正确的格式'))
}else{
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
)
) {
cb(new Error("请输入正确的格式"));
} else {
cb();
}
};
let checkTransferAddr = (rule, vaule, cb)=>{
/*if(this.form.shapeType == 2){
let checkTransferAddr = (rule, vaule, cb) => {
/*if(this.form.shapeType == 2){
if(this.transferError){
cb(new Error('所填经纬度不能正确解析地址,请重新输入'))
}else{
......@@ -352,205 +463,207 @@ export default{
}else{
cb();
}*/
if(this.form.shapeType == 1){
if(this.transferError){
cb(new Error('所填经纬度不能正确解析地址,请重新输入'));
}else{
cb();
}
}else{
cb()
}
}
let checkRadius = (rule, vaule, cb)=>{
if(this.form.shapeType == 1 && !/^\d+$/.test(this.form.radius)){console.log(this.form.radius)
cb(new Error('请输入正确的格式,不能输入小数点'))
}else{
cb();
}
}
let checkDaterange = (rule, vaule, cb)=>{
if (this.form.shapeType == 1) {
if (this.transferError) {
cb(new Error("所填经纬度不能正确解析地址,请重新输入"));
} else {
cb();
}
} else {
cb();
}
};
let checkRadius = (rule, vaule, cb) => {
if (this.form.shapeType == 1 && !/^\d+$/.test(this.form.radius)) {
console.log(this.form.radius);
cb(new Error("请输入正确的格式,不能输入小数点"));
} else {
cb();
}
};
let checkDaterange = (rule, vaule, cb) => {
const dateRange = this.form.dateRange;
if (!dateRange || !dateRange.length) {
cb(new Error("请选择日期"));
} else {
let min = dateRange[0];
let max = dateRange[1];
const dateRange = this.form.dateRange;
if(!dateRange || !dateRange.length){
cb(new Error('请选择日期'))
}else{
let min = dateRange[0];
let max = dateRange[1];
if(!moment.isMoment(min)){
min = moment(min)
}
if(!moment.isMoment(max)){
max = moment(max)
}
if(min.isBefore( moment(max).subtract(30*6, 'days'), 'minute')){
cb(new Error('日期范围不能超过180天'))
}
}
cb()
}
let checkMsgtel = (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 (!moment.isMoment(min)) {
min = moment(min);
}
if (!moment.isMoment(max)) {
max = moment(max);
}
if (min.isBefore(moment(max).subtract(30 * 6, "days"), "minute")) {
cb(new Error("日期范围不能超过180天"));
}
}
cb();
};
let checkMsgtel = (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){
cb(new Error('请打开地图自定义设置'))
}else{
cb();
}
} */
return {
scrollToRef: '',
tableData:[],
//dateRange: [],
currentPage: 1,
pageSize: 10,
maxPage:1,
submitting: false,
userArr:[],
userData:[],
areaString:'',
hideTab:true,
needInfinite: false,
fenceMapModalVisible:false,
areaCode:null,
btnText: '保存',
specialShopOptions: [],
specialShopDefaultProps: {
children: 'children',
label: 'label',
value: 'id'
},
readonlyStatus: false,
form: {
fenceName: '',
bizFenceType: '12',
shapeType: 3,
specialShopId: '',
specialShopName: '',
// fenceNo: '',
electricFenceType: 1,
startTime: '',
endTime: '',
des: '',
areaCode: '',
analysisAddress: '',
lng: '',
lat: '',
radius: 1000,
status: 1,
transferError: false,
timeType:2,
electricTimeFenceType:'',
electricTimeFenceTypes: [
{
value: 1,
label: '1个月'
}, {
value: 2,
label: '2个月'
}, {
value: 3,
label: '3个月'
}, {
value: 4,
label: '4个月'
}, {
value: 5,
label: '5个月'
}, {
value: 6,
label: '6个月'
}
],
dateRange: [],
msgtel: ''
},
restainFenceName: '',
rules: {
// fenceNo: [
// {required: true, message: '线路编号不能为空', trigger: 'blur'},
// ],
fenceName: [
{required: true, message: '请输入线路名称', trigger: 'blur'},
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' },
// {validator: checkFenceName, trigger: 'blur'}
],
bizFenceType: [
{required: true, message: '请选择线路类型', trigger: 'change'}
],
specialShop: [
{required: true, validator: checkSpecialShop, trigger: 'change'}
],
shapeType: [
{required: true}
]
// electricFenceType: [
// {required: true, message: '', trigger: 'blur'}
// ],
// electricTimeFenceType:[
// {required: true, validator: checkMonitorTime, trigger: 'change'}
// ],
/*dateRange: [
return {
scrollToRef: "",
tableData: [],
//dateRange: [],
currentPage: 1,
pageSize: 10,
maxPage: 1,
submitting: false,
userArr: [],
userData: [],
areaString: "",
hideTab: true,
needInfinite: false,
fenceMapModalVisible: false,
areaCode: null,
btnText: "保存",
specialShopOptions: [],
specialShopDefaultProps: {
children: "children",
label: "label",
value: "id",
},
readonlyStatus: false,
form: {
fenceName: "",
bizFenceType: "12",
shapeType: 3,
specialShopId: "",
specialShopName: "",
// fenceNo: '',
electricFenceType: 1,
startTime: "",
endTime: "",
des: "",
areaCode: "",
analysisAddress: "",
lng: "",
lat: "",
radius: 1000,
status: 1,
transferError: false,
timeType: 2,
electricTimeFenceType: "",
electricTimeFenceTypes: [
{
value: 1,
label: "1个月",
},
{
value: 2,
label: "2个月",
},
{
value: 3,
label: "3个月",
},
{
value: 4,
label: "4个月",
},
{
value: 5,
label: "5个月",
},
{
value: 6,
label: "6个月",
},
],
dateRange: [],
msgtel: "",
},
restainFenceName: "",
rules: {
// fenceNo: [
// {required: true, message: '线路编号不能为空', trigger: 'blur'},
// ],
fenceName: [
{ required: true, message: "请输入线路名称", trigger: "blur" },
{ pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
// {validator: checkFenceName, trigger: 'blur'}
],
bizFenceType: [
{ required: true, message: "请选择线路类型", trigger: "change" },
],
specialShop: [
{ required: true, validator: checkSpecialShop, trigger: "change" },
],
shapeType: [{ required: true }],
// electricFenceType: [
// {required: true, message: '', trigger: 'blur'}
// ],
// electricTimeFenceType:[
// {required: true, validator: checkMonitorTime, trigger: 'change'}
// ],
/*dateRange: [
{validator: checkMonitorTime, trigger: 'change'}
],*/
// area: [
// {validator: checkArea, trigger: 'change'}
// ],
// lng: [
// {validator: checkLng, trigger: 'blur'}
// ],
// lat: [
// {validator: checkLat, trigger: 'blur'}
// ],
// analysisAddress: [
// {validator: checkTransferAddr, trigger: 'change'}
// ],
// radius: [
// {validator: checkRadius, trigger: 'blur'}
// ],
// daterange: [{validator: checkDaterange}],
// timeType:[{required: true, message: '请选择监控时间', trigger: 'change'}],
// msgtel: [
// {validator: checkMsgtel, trigger: 'blur'}
// ],
/*map: [
// area: [
// {validator: checkArea, trigger: 'change'}
// ],
// lng: [
// {validator: checkLng, trigger: 'blur'}
// ],
// lat: [
// {validator: checkLat, trigger: 'blur'}
// ],
// analysisAddress: [
// {validator: checkTransferAddr, trigger: 'change'}
// ],
// radius: [
// {validator: checkRadius, trigger: 'blur'}
// ],
// daterange: [{validator: checkDaterange}],
// timeType:[{required: true, message: '请选择监控时间', trigger: 'change'}],
// msgtel: [
// {validator: checkMsgtel, trigger: 'blur'}
// ],
/*map: [
{validator: checkMap, trigger: 'blur'}
]*/
},
transferTimeoutId: undefined,
geocoder: null,
transferFlag: null,
transferError: false,
userListModalVisible:false,
selectedIds: [],
mapData: null,
polygonPath: [],
},
transferTimeoutId: undefined,
geocoder: null,
transferFlag: null,
transferError: false,
userListModalVisible: false,
selectedIds: [],
mapData: null,
polygonPath: [],
loading: true,
loading: true,
filterVisible: false,
filterText: "",
filterTextData: [],
// polygonPath: [
// ["113.989993", "22.588762"],
// ["113.993298", "22.590585"],
// ["113.996431", "22.58892"],
// ["113.99274", "22.586622"],
// ["113.99008", "22.585592"]
// ]
}
},
// polygonPath: [
// ["113.989993", "22.588762"],
// ["113.993298", "22.590585"],
// ["113.996431", "22.58892"],
// ["113.99274", "22.586622"],
// ["113.99008", "22.585592"]
// ]
};
},
watch: {
/*dateRange(newVal){
watch: {
/*dateRange(newVal){
if(newVal && newVal.length){
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');
......@@ -559,65 +672,61 @@ export default{
this.form.endTime = '';
}
},*/
lng(newVal){
//this.transfer()
},
lat(newVal){
//this.transfer()
},
filterText(val) {
this._timeout && clearTimeout(this._timeout)
this._timeout = setTimeout(()=>{
this.$refs.tree.filter(val)
},500)
}
},
computed: {
isEditMode:{
get(){
return typeof this.fenceId != 'undefined'
}
}
},
created(){
let _this=this;
//this.getFenceSnsList();
//this.getSpecialShopList();
window.Vue.directive('loadmore', {
bind(el, binding) {
const selectWrap = el.querySelector('.el-table__body-wrapper')
selectWrap.addEventListener('scroll', function() {
let sign = 0
const scrollDistance = this.scrollHeight - this.scrollTop - this.clientHeight
if (scrollDistance == sign) {
//binding.value()
//console.log(sign)
// _this.currentPage++;
// _this.getFenceSnsList(_this.fenceId);
}
})
}
})
lng(newVal) {
//this.transfer()
},
lat(newVal) {
//this.transfer()
},
filterText(val) {
this._timeout && clearTimeout(this._timeout);
this._timeout = setTimeout(() => {
this.$refs.tree.filter(val);
}, 500);
},
},
computed: {
isEditMode: {
get() {
return typeof this.fenceId != "undefined";
},
},
},
created() {
let _this = this;
//this.getFenceSnsList();
//this.getSpecialShopList();
window.Vue.directive("loadmore", {
bind(el, binding) {
const selectWrap = el.querySelector(".el-table__body-wrapper");
selectWrap.addEventListener("scroll", function () {
let sign = 0;
const scrollDistance =
this.scrollHeight - this.scrollTop - this.clientHeight;
if (scrollDistance == sign) {
//binding.value()
//console.log(sign)
// _this.currentPage++;
// _this.getFenceSnsList(_this.fenceId);
}
});
},
});
this.getStoreList()
},
mounted() {
this.listener();
},
methods: {
selectStore() {
this.getStoreList();
},
mounted() {
this.listener();
},
methods: {
selectStore() {
if (this.isReadonly) return;
this.filterText = "";
this.filterDialogTitle = "选择所属组织";
if(!this.filterTextData.length) {
if (!this.filterTextData.length) {
this.getStoreList();
}
//this.closeFilter();
},
closeFilter() {
......@@ -627,7 +736,7 @@ export default{
getStoreList() {
let _this = this;
_this.loading = true;
MONITOR_SERVICE.getOrgTree({hasUserLeaf: true}).then((res) => {
MONITOR_SERVICE.getOrgTree({ hasUserLeaf: true }).then((res) => {
const { code, data } = res;
_this.loading = false;
if (code == 200) {
......@@ -637,15 +746,15 @@ export default{
},
filterConfirm() {
const { label, id, origin } = this.$refs.tree.getCurrentNode();
if (origin.type != 'u') {
if (origin.type != "u") {
this.$message({
message: "请选择下级所属组织",
type: "error",
});
return;
}
this.form.specialShopName = label.split('/')[1]
this.form.specialShopCode = label.split('/')[0]
this.form.specialShopName = label.split("/")[1];
this.form.specialShopCode = label.split("/")[0];
//this.$set(this, "form.specialShopName", label);
this.form.specialShopId = id;
this.closeFilter();
......@@ -655,172 +764,172 @@ export default{
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
listener() {
const state = history.state;
if(!state) {
this.init(null);
return;
}
const { fenceId, readonlyStatus, btnRemark } = state;
if(readonlyStatus) {
this.readonlyStatus = readonlyStatus;
this.fenceId = fenceId;
}
this.init(btnRemark);
},
init(btnRemark){
const { id, btnText } = this.$route.query;
if(id) {
this.fenceId = id;
this.btnText = btnText;
}
if(typeof this.fenceId != 'undefined'){
btnRemark === 'viewUpdated' ? this.getUpdatedFenceDetail(this.fenceId) :this.getFenceDetail(this.fenceId);;
}else{
// 线路编号无意义 屏蔽
// MONITOR_SERVICE.getNewFenceId().then((res)=>{
// if(res.returnCode == 0){
// this.form.fenceNo = res.data.fenceNo;
listener() {
const state = history.state;
if (!state) {
this.init(null);
return;
}
const { fenceId, readonlyStatus, btnRemark } = state;
if (readonlyStatus) {
this.readonlyStatus = readonlyStatus;
this.fenceId = fenceId;
}
this.init(btnRemark);
},
init(btnRemark) {
const { id, btnText } = this.$route.query;
if (id) {
this.fenceId = id;
this.btnText = btnText;
}
if (typeof this.fenceId != "undefined") {
btnRemark === "viewUpdated"
? this.getUpdatedFenceDetail(this.fenceId)
: this.getFenceDetail(this.fenceId);
} else {
// 线路编号无意义 屏蔽
// MONITOR_SERVICE.getNewFenceId().then((res)=>{
// if(res.returnCode == 0){
// this.form.fenceNo = res.data.fenceNo;
// this.$refs.fenceMap.initFence({
// fenceType: 'circle'
// });
// }
// });
// this.$refs.fenceMap.initFence({
// fenceType: 'circle'
// });
// }
// });
this.$refs.fenceMap.initFence({
fenceType: 'polygon',
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)
this.$refs.fenceMap.initFence({
fenceType: "polygon",
polygonPath: this.polygonPath,
});
if(form.shapeType === 1){
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)=>{
return [item.split(',')[0], item.split(',')[1]]
})
}
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);
console.log(this.polygonPath)
this.mapData = {
fenceType: 'polygon',
polygonPath: this.polygonPath
}
}
this.$refs.fenceMap.initFence(this.mapData);
}
},
getFenceDetail(id){
MONITOR_SERVICE.getFenceDetailById({fenceId: id}).then((res)=>{
this.getDetailData(res, id);
});
},
getUpdatedFenceDetail(id){
MONITOR_SERVICE.getUpdatedFenceDetail({fenceId: id}).then((res)=>{
this.getDetailData(res, id);
});
},
getFenceSnsList(id, cur, resData){
let params = {};
params.id=id;
this.tableData = this.tableData.concat(resData);
this.$refs.userList.reset(resData);
// if(this.currentPage>this.maxPage){
// return;
// }
// if(cur){
// params.currentPage =cur;
// params.pageSize = this.pageSize;
// }else{
// params.currentPage =this.currentPage;
// params.pageSize = this.pageSize;
// }
// params.id=id;
// MONITOR_SERVICE.getFenceSnsList(params).then((res)=>{
// if(res.c == 0){
// this.tableData = this.tableData.concat(resData);
// this.maxPage = Math.ceil(resData.recordsTotal/this.pageSize);
// this.$refs.userList.reset(resData);
// }
// });
},
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){
if (form.shapeType === 1) {
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(",");
console.log(arr);
return mapService.getLngLat(arr[0], arr[1]);
});
}
this.mapData = {
fenceType: "polygon",
polygonPath: this.polygonPath,
};
}
this.$refs.fenceMap.initFence(this.mapData);
}
},
getFenceDetail(id) {
MONITOR_SERVICE.getFenceDetailById({ fenceId: id }).then((res) => {
this.getDetailData(res, id);
});
},
getUpdatedFenceDetail(id) {
MONITOR_SERVICE.getUpdatedFenceDetail({ fenceId: id }).then((res) => {
this.getDetailData(res, id);
});
},
getFenceSnsList(id, cur, resData) {
let params = {};
params.id = id;
this.tableData = this.tableData.concat(resData);
this.$refs.userList.reset(resData);
// if(this.currentPage>this.maxPage){
// return;
// }
// if(cur){
// params.currentPage =cur;
// params.pageSize = this.pageSize;
// }else{
// params.currentPage =this.currentPage;
// params.pageSize = this.pageSize;
// }
// params.id=id;
// MONITOR_SERVICE.getFenceSnsList(params).then((res)=>{
// if(res.c == 0){
// this.tableData = this.tableData.concat(resData);
// this.maxPage = Math.ceil(resData.recordsTotal/this.pageSize);
// this.$refs.userList.reset(resData);
// }
// });
},
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 cur = this.currentPage
if(this.selectedIds.length){
......@@ -842,360 +951,357 @@ export default{
});
}
},*/
userListModalChange(isOpen){
this.userListModalVisible = isOpen;
},
userDate(){
this.userListModalVisible=true;
},
userListModalChange(isOpen) {
this.userListModalVisible = isOpen;
},
userDate() {
this.userListModalVisible = true;
},
/*resetMapForm(){
/*resetMapForm(){
this.form.lng = '';
this.form.lat = '';
this.form.address = '';
this.form.radius = '';
},*/
/*fenceModalChange(isOpen){
/*fenceModalChange(isOpen){
this.fenceModalVisible = isOpen;
},
fenceMapModalChange(isOpen, mapData){
this.fenceMapModalVisible = isOpen;
},*/
updateUserData(data){
this.userArr = data;
this.tableData = data;
//console.log(data)
},
updateMapData(data){
if(data.radius){
this.form.radius = data.radius;
}
if(data.lng && data.lat){
this.form.lng = data.lng;
this.form.lat = data.lat;
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)=>{
updateUserData(data) {
this.userArr = data;
this.tableData = data;
//console.log(data)
},
updateMapData(data) {
if (data.radius) {
this.form.radius = data.radius;
}
if (data.lng && data.lat) {
this.form.lng = data.lng;
this.form.lat = data.lat;
this.transfer();
}
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;
}
});
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) {
//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 = {};
},
cancel(){
window.history.go(-1);
// this.$router.push({path:"fenceManagement"})
},
getParams(){
const form = this.form;
const params = {};
// params.fenceNo = form.fenceNo;
params.fenceName = form.fenceName;
// 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) {
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;
params.fenceName = form.fenceName;
// 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
}
if (form.msgtel) {
params.telNumbers = form.msgtel;
}
return params;
return params;
},
},
/*closeDialog(){
/*closeDialog(){
this.resetForm();
this.$emit('onFenceModalChange', false);
},*/
scrollTo(refName){
this.scrollToRef = refName;
var element = this.$refs[refName];
const top = element.offsetTop;
window.document.getElementById('fenceModal').querySelector('form').scrollTo(0, top-80);
},
/*addMode(){
scrollTo(refName) {
this.scrollToRef = refName;
var element = this.$refs[refName];
const top = element.offsetTop;
window.document
.getElementById("fenceModal")
.querySelector("form")
.scrollTo(0, top - 80);
},
/*addMode(){
this.starMap=true;
},*/
areaChoose(id, str){
if(this.form.areaCode!=id){
this.starMap=true;
}
this.form.areaCode = id;
this.form.areaString = str;
this.$refs.fenceForm.validateField('area');
if(this.starMap){
this.district()
}
//this.starMap = true;
//}
},
district(){
console.log("district")
//this.starMap = true;
this.$refs.fenceMap.updateFence({
fenceType: 'area',
areaCode: this.form.areaCode
})
},
/*openMapModal(){
areaChoose(id, str) {
if (this.form.areaCode != id) {
this.starMap = true;
}
this.form.areaCode = id;
this.form.areaString = str;
this.$refs.fenceForm.validateField("area");
if (this.starMap) {
this.district();
}
//this.starMap = true;
//}
},
district() {
console.log("district");
//this.starMap = true;
this.$refs.fenceMap.updateFence({
fenceType: "area",
areaCode: this.form.areaCode,
});
},
/*openMapModal(){
this.$emit('onFenceMapModalChange', true);
},*/
validateLngLat(){
let pass = true;
this.$refs.fenceForm.validateField('lng', (error)=>{
if(error){
pass = false;
}
});
this.$refs.fenceForm.validateField('lat', (error)=>{
if(error){
pass = false;
}
});
this.$refs.fenceForm.validateField('radius', (error)=>{
if(error){
pass = false;
}
});
return pass;
},
/*transfer(){
validateLngLat() {
let pass = true;
this.$refs.fenceForm.validateField("lng", (error) => {
if (error) {
pass = false;
}
});
this.$refs.fenceForm.validateField("lat", (error) => {
if (error) {
pass = false;
}
});
this.$refs.fenceForm.validateField("radius", (error) => {
if (error) {
pass = false;
}
});
return pass;
},
/*transfer(){
if(this.form.lng && this.form.lat && this.form.radius){
this.$refs.fenceMap.updateMap(this.form)
}
}*/
transfer(){
if(this.form.lng && this.form.lat && this.validateLngLat()){
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(()=>{
const flag = new Date();
this.transferFlag = flag;
if(!this.geocoder){
mapService.getGeocoder().then((gc)=>{
this.geocoder = gc;
this.getAddress(flag);
});
}else{
this.getAddress(flag);
}
}, 500)
}
},
getAddress(flag){
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');
}
}
transfer() {
if (this.form.lng && this.form.lat && this.validateLngLat()) {
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(() => {
const flag = new Date();
this.transferFlag = flag;
if (!this.geocoder) {
mapService.getGeocoder().then((gc) => {
this.geocoder = gc;
this.getAddress(flag);
});
},
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)
}
}
} else {
this.getAddress(flag);
}
}, 500);
}
},
components:{
AreaSelect,
fenceMap,
userList,
InfiniteLoading
}
}
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");
}
}
});
},
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>
<style scoped lang="scss">
h3{
margin: 10px 0px;
}
form {
height:100%;
overflow-y: auto;
margin: -30px -20px;
padding: 10px 100px 20px 30px;
}
.tab-content{
margin-top: 20px;
}
.record-list{
padding-left: 20px;
}
.fenceModalfooter{
margin: 0;
padding: 20px;
padding-top: 10px;
text-align: right;
box-sizing: border-box;
z-index: 500;
position: fixed;
left:0;
bottom: 0;
width: 100%;
border-top: 1px solid #e7eaec;
background-color: #fdfdfd;
margin-left: 220px;
padding-right: 260px;
}
.tab_wrap{
position: relative;
padding: 20px;
.tab_ctrl{
position: absolute;
top: 20px;
right: 20px;
}
}
.shape_tip{
color:#999;
line-height:1.5;
margin-bottom: 10px;
margin-left: 100px;
}
h3 {
margin: 10px 0px;
}
form {
height: 100%;
overflow-y: auto;
margin: -30px -20px;
padding: 10px 100px 20px 30px;
}
.tab-content {
margin-top: 20px;
}
.record-list {
padding-left: 20px;
}
.fenceModalfooter {
margin: 0;
padding: 20px;
padding-top: 10px;
text-align: right;
box-sizing: border-box;
z-index: 500;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
border-top: 1px solid #e7eaec;
background-color: #fdfdfd;
margin-left: 220px;
padding-right: 260px;
}
.tab_wrap {
position: relative;
padding: 20px;
.tab_ctrl {
position: absolute;
top: 20px;
right: 20px;
}
}
.shape_tip {
color: #999;
line-height: 1.5;
margin-bottom: 10px;
margin-left: 100px;
}
</style>
<style >
.scrollbar::-webkit-scrollbar{
width: 4px;
}
.scrollbar::-webkit-scrollbar-thumb{
border-radius: 15px;
box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
background: rgba(255,255,255,0.1);
.scrollbar::-webkit-scrollbar {
width: 4px;
}
.scrollbar::-webkit-scrollbar-thumb {
border-radius: 15px;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: rgba(255, 255, 255, 0.1);
}
.scrollbar::-webkit-scrollbar-track{
border-radius: 0;
box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
background: rgba(255,255,255,255);
.scrollbar::-webkit-scrollbar-track {
border-radius: 0;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: rgba(255, 255, 255, 255);
}
.special-shop-input .el-input__inner {
cursor: pointer;
cursor: pointer;
}
</style>
\ No newline at end of file
......@@ -343,10 +343,10 @@ export default {
},
methods: {
//初始化百度地图
async initBMap(){
async initBMap() {
this.mapObj = await mapService.init("map");
window.AMap = this.mapObj;
this.getDevinceInfo()
window.AMap = this.mapObj;
this.getDevinceInfo();
},
// 获取设备信息
......@@ -476,10 +476,9 @@ export default {
// 监听圆形围栏直径变化
onFenceRadiusChange(e) {
if(e){
if (e) {
this.$set(this.form, "radius", e);
}
},
// 监听围栏类型变化
......@@ -490,9 +489,11 @@ export default {
// 1:圆形围栏 4:行政区域 3:多边形
switch (e) {
case 4:
// AMap.invoke("removeContextMenu");
_this.drawDistrict(areaText);
break;
case 3:
// AMap.invoke("removeContextMenu");
_this.drawPolygon();
break;
default:
......
......@@ -40,8 +40,8 @@ const historyLocation = {
const MAP = mapService.map;
const lnglat = this.markers[idx].getPosition();
// this.infowins[idx].open(MAP, lnglat);
MAP.invoke("mapOpenInfoWindow", this.infowins[idx],lnglat)
MAP.invoke('centerAndZoom',lnglat,10)
AMap.invoke("mapOpenInfoWindow", this.infowins[idx],lnglat)
AMap.invoke('centerAndZoom',lnglat,10)
}
});
......@@ -49,9 +49,11 @@ const historyLocation = {
createClusterer(){
let map=mapService.mapInstance;
var cluster, markers = [];
for(let idx in this.markers){
markers.push(this.markers[idx]);
}
console.log(markers)
this.cluster = AMap.invoke('Cluster', markers, data => {
return {
point: [data.latLng.lng, data.latLng.lat],
......
......@@ -2,7 +2,7 @@
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-12-06 14:10:32
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2024-12-20 11:23:44
* @LastEditTime: 2024-12-21 15:52:17
* @FilePath: \oEshield\src\utils\mapBService.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -214,6 +214,16 @@ MapService.prototype = {
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'),
......@@ -945,6 +955,8 @@ MapService.prototype = {
// 创建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">
......
......@@ -66,6 +66,7 @@ const replay = {
EventBus.$emit('uiMap.replay.initDone')
AMap.invoke('lushuAddEventListener','move', (e) =>{
this.idx = e.target.i;
console.log(this.idx)
let lnglat = replayData[this.idx]
let item=replay.data[this.idx]
AMap.invoke('lushuSetContent',replay.getNavgInfoContent(item)) //设置信息窗口文案
......@@ -133,6 +134,7 @@ const replay = {
//轨迹暂停
EventBus.$on('uiMap.replay.pause', (ifShowAddr)=>{
console.log(this.idx)
if(replay.navg){
AMap.invoke('lushuPause')
if(ifShowAddr){
......@@ -172,10 +174,12 @@ const replay = {
EventBus.$on('uiMap.replay.drawLocation', (data)=>{
const MAP = mapService.map;
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){
MAP.remove(this.infowins[idx])
// MAP.remove(this.infowins[idx])
AMap.invoke('removeOverlay', this.infowins[idx])
}
this.markers = {};
this.infowins = {};
......@@ -193,26 +197,45 @@ const replay = {
if(this.markers[idx]){
const MAP = mapService.map;
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.replayIng', false);
MAP.setZoomAndCenter(MAP.getZoom(), lnglat);
// MAP.setZoomAndCenter(MAP.getZoom(), lnglat);
AMap.invoke('panTo', lnglat)
}
});
},
drawLocation(data){
const MAP = mapService.map;
EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
data.forEach((item)=>{
let marker = mapService.createPointMarker([item.elng, item.elat], MAP);
let infoWindow = mapService.bindLocationInfoWindow(marker, MAP, item);
this.markers[item.idx] = marker;
this.infowins[item.idx] = infoWindow;
});
drawLocation(data) {
// console.log(data)
const { MAP, mapapi } = mapService
EventBus.$emit('uiMap.historyLocation.transferSuccess', data)
data.forEach((item) => {
const marker = mapService.createPointMarker(mapService.getLngLat(item.elng, item.elat), MAP)
AMap.invoke('addOverlay', marker)
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) {
console.log(idx, dis)
let timeArr = [[40, 30, 16], [30, 20, 12], [20, 12, 8], [5, 3, 2]] // 慢 正常 快 很快
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!