Commit 62cd1a97 by 张杰

v1.6.0版本需求

1 parent f7b29813
This diff could not be displayed because it is too large.
......@@ -11,6 +11,7 @@
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules --config config/webpack.config.js"
},
"dependencies": {
"@amap/amap-jsapi-loader": "^1.0.1",
"animate.css": "^3.7.0",
"axios": "^0.18.0",
"calendar-months": "^1.0.1",
......@@ -22,14 +23,13 @@
"es6-promise": "^4.2.4",
"font-awesome": "^4.7.0",
"moment": "^2.22.0",
"node-sass": "^7.0.1",
"qs": "^6.5.1",
"sass": "^1.45.1",
"vue": "^2.5.11",
"vue-infinite-loading": "^2.3.1",
"vue-router": "^3.0.1",
"vuex": "^3.0.1",
"xlsx": "^0.14.0",
"node-sass":"7.0.1"
"xlsx": "^0.14.0"
},
"browserslist": [
"> 1%",
......
......@@ -25,26 +25,26 @@
</template>
<script>
import store from './vuex/store.js'
import { mapGetters, mapActions } from 'vuex'
import vSideBar from 'components/SideBar.vue'
import store from "./vuex/store.js";
import { mapGetters, mapActions } from "vuex";
import vSideBar from "components/SideBar.vue";
export default {
name: 'app',
name: "app",
data() {
return {
isQiankun: window.__POWERED_BY_QIANKUN__,
logo: require('images/logo.png')
}
return {
isQiankun: window.__POWERED_BY_QIANKUN__,
logo: require("images/logo.png"),
};
},
watch: {
$route(to, from) {
if(this.isQiankun) {
if (this.isQiankun) {
this.getBreadcrumb();
}
}
},
},
mounted(){
mounted() {
// store.dispatch('getDeviceResources')
// store.dispatch('getLoginUser').then((res)=>{
// if(store.state.common.username === 'gqgdcx'){
......@@ -62,90 +62,107 @@ export default {
// g = d.getElementsByTagName('body')[0],
// x = w.innerWidth || e.clientWidth || g.clientWidth,
// y = w.innerHeight|| e.clientHeight|| g.clientHeight;
// d.getElementsByTagName('main')[0].style['minHeight'] = y+'px'
// }
// window.onresize()
this.$onGlobalStateChange((state, prev) => {
if(state.isCollapsed != this.isCollapse) {
this.toggleCollapse()
if (state.isCollapsed != this.isCollapse) {
this.toggleCollapse();
}
})
});
},
computed: {
...mapGetters([
'isCollapse',
'isFullsize'
])
...mapGetters(["isCollapse", "isFullsize"]),
},
methods: {
getBreadcrumb() {
const { getters: {curBreadCrumb}} = this.$root.parentVuex;
let matched = this.$route.matched.filter(item => item.name); // this.$route.matched 可以获取到一个数组,包含当前路由的所有嵌套路径片段的路由记录
const {
getters: { curBreadCrumb },
} = this.$root.parentVuex;
let matched = this.$route.matched.filter((item) => item.name); // this.$route.matched 可以获取到一个数组,包含当前路由的所有嵌套路径片段的路由记录
const first = matched[0];
const { meta, path } = first;
const basePath = '/oEshield#';
const basePath = "/oEshield#";
let breadcrumb = [];
if(meta) {
if (meta) {
const { title, pushState } = meta;
if(pushState && title) {
if (pushState && title) {
breadcrumb.push({
name: title,
path: basePath + path
})
path: basePath + path,
});
history.state.pushState = pushState;
history.state.breadcrumb = [...curBreadCrumb, breadcrumb[0]];
// this.$root.parentVuex.dispatch('menu/setBreadCrumb', [...curBreadCrumb, breadcrumb]);
}
}
},
toggle(){
this.toggleCollapse()
toggle() {
this.toggleCollapse();
},
...mapActions([
'toggleCollapse'
]),
navigate(){
let routeData = this.$router.resolve({
path: '/notice',
query: {
}
...mapActions(["toggleCollapse"]),
navigate() {
let routeData = this.$router.resolve({
path: "/notice",
query: {},
});
window.open(routeData.href, '_blank');
}
window.open(routeData.href, "_blank");
},
},
components: {
vSideBar
vSideBar,
},
store
}
store,
};
</script>
<style scoped>
.topbar {
min-height: 50px;
padding: 15px 10px;
}
.toggle-btn, .logo{
vertical-align: middle;
}
.logo{
margin-left: 10px;
}
a.right-link{
color: #999;
font-size: 14px;
margin-right: 20px;
line-height: 30px;
text-decoration: none;
}
.full-size main{
margin: 0;
.topbar {
min-height: 50px;
padding: 15px 10px;
}
.toggle-btn,
.logo {
vertical-align: middle;
}
.logo {
margin-left: 10px;
}
a.right-link {
color: #999;
font-size: 14px;
margin-right: 20px;
line-height: 30px;
text-decoration: none;
}
.full-size main {
margin: 0;
}
.full-size .sidebar,
.full-size .topbar {
display: none;
}
</style>
<style lang="scss">
.el_table {
thead {
th {
background: rgba($color: #f2f2f2, $alpha: 0.5) !important;
}
}
.full-size .sidebar, .full-size .topbar{
display: none;
}
.links_group {
position: relative;
display: flex;
align-items: flex-end;
justify-content: space-between;
padding: 10px 0;
.name {
font-size: 18px;
font-weight: bold;
color: #666;
}
}
</style>
import request from './request'
// 新增围栏
export const SAVE_ELECFENCE_INFO = params => {
return request(params, '/trialdrive/elecfence/add', 'POST')
}
// 更新围栏
export const UPDATE_ELECFENCE_INFO = params => {
return request(params, '/trialdrive/elecfence/edit', 'POST')
}
// 获取围栏详情
export const GET_ELECFENCE_INFO = params => {
return request(params, '/trialdrive/elecfence/info')
}
//新增、编辑围栏-获取关联设备列表
export const GET_ELECFENCE_LINKEDDEVICES = params => {
return request(params, '/trialdrive/elecfence/linkedDevices')
}
//新增、编辑围栏-关联设备-获取用户权限设备列表接口
export const GET_VEHICLE_LINKSNS = params => {
return request(params, '/trialdrive/vehicle/linksns/search')
}
//新增、编辑围栏-批量删除关联设备
export const REMOVE_ELECFENCE_LINKEDDEVICES = params => {
return request(params, '/trialdrive/elecfence/batchUnlink')
}
//新增、编辑围栏-批量导入关联设备
export const IMPORT_ELECFENCE_LINKEDDEVICES = '/trialdrive/elecfence/batchImport'
\ No newline at end of file
......@@ -142,3 +142,8 @@ export default {
export const GET_DEVICEINFO_BYSNS = params => {
return request(params, '/trialdrive/monitor/vehiclelocation')
}
// 批量查询设备位置点
export const GET_DEVICE_LOCATION = params => {
return request(params, '/trialdrive/monitor/vehiclelocation', 'get')
}
\ No newline at end of file
This diff could not be displayed because it is too large.
......@@ -43,4 +43,7 @@
.icon-zoom_in.active { width: 19px; height: 19px; background-position: -57px -60px; }
.icon-zoom_in:active { width: 19px; height: 19px; background-position: -57px -60px; }
.icon-zoom_in:hover { background-position: -57px -60px; }
.icon-zoom_in { width: 19px; height: 19px; background-position: -82px 0px; }
\ No newline at end of file
.icon-zoom_in { width: 19px; height: 19px; background-position: -82px 0px; }
.icon-info_shop { width: 24px; height: 24px; background:url('./shop.png') no-repeat;background-size:24px auto; }
.icon-info_plate { width: 24px; height: 24px; background:url('./plate.png') no-repeat;background-size:24px auto; }
\ No newline at end of file
<template>
<el-cascader v-model="city" :options="cityList" :props="cascaderProps" :disabled="disabled" @change="onChange"></el-cascader>
</template>
<script>
import cityJson from "@/assets/json/city.json";
export default {
name: "CitySelect",
props: {
value: {
type: [String, Number],
default: "",
},
checkStrictly: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
},
data() {
return {
cityList: cityJson,
city: "",
cascaderProps: {
value: "code",
label: "name",
children: "children",
checkStrictly: this.checkStrictly,
},
};
},
watch: {
value: {
handler: function (n, o) {
if (n) {
this.init();
}
},
immediate: true,
},
},
mounted() {
//this.city = this.value;
},
methods: {
onChange(e) {
console.log(e);
let list = this.cityList;
let m = list.find((k) => k.code == e[0]);
let n = m.children.find((k) => k.code == e[1]);
let b = (n.children || []).find((k) => k.code == e[2]);
if (n) {
this.$emit("input", n.name);
}
this.$emit("change", { code: e, name: [m.name, n.name, b.name] });
},
// 初始化
init() {
let o = this.value;
let list = this.cityList;
let arr = [];
if (!o) {
return false;
}
let m = list.find((k) => {
let n = k.children.find((j) => j.name == o);
if (n) {
arr.push(k.code);
arr.push(n.code);
}
});
this.city = arr;
console.log(arr);
},
},
};
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file
const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899'
export const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899'
// 地图插件
export const MAP_PLUGINS = [
'AMap.PolyEditor',
'AMap.CircleEditor',
'AMap.DistrictSearch',
'AMap.Autocomplete',
'AMap.MarkerClusterer',
'AMap.MouseTool',
'AMap.Text',
"AMap.RangingTool",
"AMap.Geolocation",
"AMap.PolygonEditor",
"AMap.PolylineEditor",
]
export const CONSTANT = {
//ROOT: process.env.NODE_ENV === 'development'?'ots/':'',
API_URL: '/ots/',
MAP_KEY,
MAP_PLUGINS,
AMAP_URL: `https://webapi.amap.com/maps?v=1.4.2&key=${MAP_KEY}&plugin=AMap.PolyEditor,AMap.CircleEditor,AMap.DistrictSearch,AMap.Autocomplete,AMap.MarkerClusterer,AMap.MouseTool,AMap.Text`
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ import vFullLayout from 'pages/FullWidthLayout.vue'
import store from './vuex/store.js'
import App from './App.vue'
import Vue from 'vue'
Vue.component('vLayout',vLayout)
......@@ -40,6 +41,9 @@ function render({ data = {} , container } = {}) {
routes
});
store.commit('SET_BASE_URL', data.baseURL);
Vue.prototype.$parentCommon = data.common;
Vue.prototype.$parentRouter = data.router;
Vue.prototype.$parentVuex = data.store;
instance = new Vue({
router,
store,
......
<template>
<div>
<!-- 线路调用地图弹框 -->
<div class="ibox-content" style="height: 500px; padding:0 10px;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;">
<el-form ref="fenceForm" :model="form" :rules="rules" :inline="false" size="mini" label-width="100px" class="fence_form">
<el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" placeholder="请输入围栏名称" maxlength="200" :disabled="readonlyStatus"></el-input>
</el-form-item>
<el-form-item label="监控类型" prop="triggerType">
<el-select v-model="form.triggerType" placeholder="请选择" size="small">
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入驶出" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="监控周期" prop="timeType">
<el-radio-group v-model="form.timeType" @change="changeTimeType">
<el-radio :label="1">永久有效</el-radio>
<el-radio :label="2">指定区间</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="指定区间" 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-form-item>
<el-form-item label="区域类型" class="is-required">
<el-radio-group v-model="form.shapeType" @change="shapeTypeChange">
<el-radio-button label="1">圆形</el-radio-button>
<el-radio-button label="3">多边形</el-radio-button>
<el-radio-button label="4">行政区域</el-radio-button>
</el-radio-group>
<div class="shape_tip" v-show="form.shapeType==3">*注:地图任意位置,单击新增双击结束绘制。</div>
</el-form-item>
<el-form-item label="省市区" class="is-required" v-if="form.shapeType==4" prop="areaName">
<city-select v-model="form.areaName" :checkStrictly="true" @change="changeArea"></city-select>
</el-form-item>
<el-form-item label="围栏类型" prop="bizFenceType">
<el-radio :label="14" v-model="form.bizFenceType">报警型</el-radio>
</el-form-item>
<el-form-item label="状态" prop="enableStatus">
<el-radio-group v-model="form.enableStatus">
<el-radio :label="1">启用</el-radio>
<el-radio :label="0">停用</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="短信通知" prop="telNumbers">
<el-input v-model.trim="form.telNumbers" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item>
<el-form-item label="描述" class="el_long_form_item">
<el-input type="textarea" v-model.trim="form.remark" resize="none" maxlength="100" placeholder="请输入围栏描述"></el-input>
</el-form-item>
<el-form-item label="操作记录" class="el_long_form_item" v-show="isEditMode">
<div class="record-list" v-html="form.record"></div>
</el-form-item>
</el-form>
</div>
</el-tab-pane>
<el-tab-pane label="关联对象">
<div class="links_group">
<div></div>
<div>
<el-button v-if="!readonlyStatus" type="primary" @click="userDate" size="small" :loading="submitting">关联用户</el-button>
<el-button size="small">批量删除</el-button>
</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">
<el-table-column :disabled="readonlyStatus" type="selection" width="40"></el-table-column>
<el-table-column fixed type="index" label="序号" :index="getIndex" width="70"></el-table-column>
<el-table-column fixed prop="name" label="姓名" min-width="80"></el-table-column>
<el-table-column fixed prop="vin" label="车架号" min-width="160"></el-table-column>
<el-table-column prop="sn" label="设备号" min-width="160"></el-table-column>
<el-table-column prop="userTel" label="联系方式" min-width="100"></el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
</div>
<div class="fenceModalfooter">
<el-button v-if="!readonlyStatus" type="primary" @click="saveFence" size="small" :loading="submitting">保存</el-button>
<el-button @click="cancel" size="small">取消</el-button>
</div>
<user-list :init="userListInit" @onUserListInit="(res)=>userListInit=res" :userData="tableData" @onUpdateUserData="updateUserData" :userListModalVisible="userListModalVisible" :shopId="form.specialShopId" @onUserListModalChange="userListModalChange" ref="userList">
</user-list>
</div>
</template>
<script>
import { services } from "@/api";
import mapService from "@/utils/mapService.js";
import fenceMap from "./fenceMap.vue";
import userList from "./fence_userlist.vue";
import InfiniteLoading from "vue-infinite-loading";
import CitySelect from "@/components/area";
const MONITOR_SERVICE = services.monitor;
import { deepClone, showToast } from "@/utils/utils";
import {
GET_ELECFENCE_LINKEDDEVICES,
GET_ELECFENCE_INFO,
SAVE_ELECFENCE_INFO,
UPDATE_ELECFENCE_INFO,
} from "@/api/services/fence";
export default {
props: ["fenceModalVisible", "fenceId"],
components: {
CitySelect,
fenceMap,
userList,
InfiniteLoading,
},
data() {
let checkFenceName = (rule, vaule, cb) => {
if (
typeof this.restainFenceName != "undefined" &&
this.form.fenceName === this.restainFenceName
) {
cb();
}
};
let checkArea = (rule, vaule, cb) => {
if (this.form.shapeType == 4 && !this.form.areaCode) {
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];
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();
}
};
return {
scrollToRef: "",
tableData: [],
//dateRange: [],
currentPage: 1,
pageSize: 10,
maxPage: 1,
submitting: false,
userArr: [],
userData: [],
hideTab: true,
btnText: "保存",
readonlyStatus: false,
form: {
bizFenceType: 14,
shapeType: 1,
triggerType: 1,
timeType: 2,
enableStatus: 1,
},
restainFenceName: "",
rules: {
fenceName: [
{ required: true, message: "请输入围栏名称", trigger: "blur" },
{ pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
// {validator: checkFenceName, trigger: 'blur'}
],
triggerType: [
{ required: true, message: "请选择监控类型", trigger: "change" },
],
timeType: [
{ required: true, message: "请选择监控周期", trigger: "change" },
],
areaName: [{ validator: checkArea, trigger: "blur" }],
bizFenceType: [
{ required: true, message: "请选择围栏类型", trigger: "change" },
],
shapeType: [
{ required: true, message: "请选择区域类型", trigger: "change" },
],
enableStatus: [
{ required: true, message: "请选择状态", trigger: "change" },
],
telNumbers: [{ validator: checkMsgtel, trigger: "blur" }],
dateRange: [
{ required: true, message: "请选择指定区间", trigger: "change" },
],
},
transferTimeoutId: undefined,
geocoder: null,
transferFlag: null,
transferError: false,
userListModalVisible: false,
selectedIds: [],
mapData: null,
polygonPath: [],
loading: false,
};
},
computed: {
isEditMode: {
get() {
return typeof this.fenceId != "undefined";
},
},
},
created() {
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);
}
});
},
});
},
mounted() {
//this.listener();
let _this = this;
let query = this.$route.query;
if (query.id) {
_this.fenceId = query.id;
_this.getFenceInfo(query.id);
_this.getList();
} else {
//this.$refs.fenceForm.clearValidate();
_this.$refs.fenceMap.updateFence({
fenceType: "circle",
});
}
},
methods: {
// 监听围栏类型变化
shapeTypeChange() {
if (this.form.shapeType == 4) {
this.$refs.fenceForm.clearValidate();
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",
});
}
},
// 监听表格选择
selectChange(selection) {
this.selectedIds = [];
selection.map((obj) => {
this.selectedIds.push(obj.id);
});
},
userListModalChange(isOpen) {
this.userListModalVisible = isOpen;
},
userDate() {
this.userListModalVisible = true;
},
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() {
let _this = this;
if (this.form.shapeType == 3) {
if (this.polygonPath.length === 0) {
this.$message({
message: "请绘制线路",
type: "error",
});
return;
}
}
_this.$refs.fenceForm.validate((valid) => {
if (!valid) {
return false;
}
_this.submitting = true;
let oParams = _this.getParams();
console.log(oParams);
// 编辑围栏
if (_this.fenceId) {
UPDATE_ELECFENCE_INFO(oParams).then((res) => {
if (res.code == 200) {
_this.$message({
message: "编辑成功",
type: "success",
});
_this.cancel();
}
});
return false;
}
// 新增围栏
SAVE_ELECFENCE_INFO(oParams).then((res) => {
if (res.code == 200) {
_this.$message({
message: "新增成功",
type: "success",
});
_this.cancel();
}
});
});
},
// 返回上一页
cancel() {
//window.history.go(-1);
// this.$router.push({path:"fenceManagement"})
let path = `/trialRun#/fence/index`;
history.pushState({}, path, path);
},
// 获取参数
getParams() {
let _this = this;
let form = deepClone(_this.form);
let oParams = {};
// 围栏基础信息
oParams.fenceName = form.fenceName;
oParams.shapeType = form.shapeType;
oParams.timeType = form.timeType;
oParams.triggerType = form.triggerType;
oParams.enableStatus = form.enableStatus;
oParams.bizFenceType = 14;
oParams.telNumbers = form.telNumbers;
oParams.remark = form.remark;
// 编辑围栏特有参数
if (_this.fenceId) {
oParams.id = _this.fenceId;
}
// 圆形围栏
if (form.shapeType == 1) {
oParams.radius = form.radius;
oParams.lnglat = `${form.lng},${form.lat}`;
}
// 多边形围栏
if (form.shapeType == 3) {
//oParams.lnglat = this.polygonPath;
oParams.lnglat = this.polygonPath.join("|");
}
// 行政区域围栏
if (form.shapeType == 4) {
oParams.areaCode = form.areaCode[form.areaCode.length - 1];
oParams.areaText = form.areaText[form.areaText.length - 1];
}
// 监控周期 1:永久有效,2:指定区间
if (form.timeType == 1) {
oParams.startTime = moment().format("YYYY-MM-DD");
oParams.endTime = moment().add(50, "year").format("YYYY-MM-DD");
} else {
oParams.startTime = form.dateRange[0];
oParams.endTime = form.dateRange[1];
}
// 用户设备列表
if (this.tableData) {
oParams.snList = this.tableData;
} else {
oParams.snList = this.userArr;
}
return oParams;
},
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");
}
}
});
},
// 监听省市区改变
changeArea(e) {
console.log(e);
this.form.areaCode = e.code;
this.form.areaText = e.name;
this.$refs.fenceMap.updateFence({
fenceType: "area",
areaCode: e.code[e.code.length - 1],
});
},
// 监听监控周期
changeTimeType(e) {
if (e == 1) {
delete this.rules.dateRange;
return false;
}
let oParams = [
{ required: true, message: "请选择指定区间", trigger: "change" },
];
this.$set(this.rules, "dateRange", oParams);
},
// 获取关联设备列表
getList() {
let _this = this;
let oParams = {};
oParams.fenceId = this.fenceId;
GET_ELECFENCE_LINKEDDEVICES(oParams).then((res) => {
_this.tableData = res.data || [];
});
},
// 获取围栏信息
getFenceInfo(id) {
let _this = this;
let oParams = {};
oParams.fenceId = id;
GET_ELECFENCE_INFO(oParams).then((res) => {
if (res.code != 200) {
return false;
}
let _typeList = {
1: "circle",
3: "polygon",
4: "area",
};
let obj = res.data || {};
let mapData = {};
if (obj.startTime) {
obj.dateRange = [obj.startTime, obj.endTime];
}
_this.form = obj;
mapData.fenceType = _typeList[obj.shapeType];
// 地图画围栏
switch (obj.shapeType) {
case 3:
let path = obj.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
});
mapData.polygonPath = path;
_this.polygonPath = path;
break;
case 4:
mapData.areaCode = obj.areaCode;
break;
default:
mapData.lng = obj.lng;
mapData.lat = obj.lat;
mapData.radius = obj.radius;
break;
}
_this.mapData = mapData;
_this.$refs.fenceMap.initFence(mapData);
});
},
},
};
</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: 10px;
.tab_ctrl {
position: absolute;
top: 20px;
right: 20px;
}
}
.shape_tip {
color: #999;
line-height: 2;
font-size: 12px;
}
.fence_form {
display: flex;
flex-wrap: wrap;
.el-form-item {
flex: 0 0 50%;
}
.el_long_form_item {
flex: 0 0 100%;
}
}
</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-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;
}
</style>
\ No newline at end of file
<template>
<v-full-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>电子围栏</el-breadcrumb-item>
</template>
<template slot="main">
<div class="map-wrap" >
<div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll>
<div class="controll-wrap">
<div class="search-box active side_auto_h">
<h3>电子围栏</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form">
<el-form-item label="定位方式">
<el-select v-model="form.locationType" placeholder="请选择" size="small" style="width: 280px">
<el-option label="GPS" :value="1"></el-option>
<el-option label="基站" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="围栏名称" prop="electricFenceName">
<el-input v-model.trim="form.electricFenceName" maxlength="200"></el-input>
</el-form-item>
<el-form-item label="触发类型">
<el-select v-model="form.triggerType" placeholder="请选择" size="small" style="width: 280px">
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶入驶出" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="指定区间" prop="daterange">
<el-date-picker
style="width: 100%;"
v-model="form.dateRange"
type="daterange"
size="small"
:clearable="false"
:editable="false"
:unlink-panels="true"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="监控区域" class="row-form-item">
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="2">圆形</el-radio>
</el-col>
<el-col :span="16">
<el-form-item label="" prop="fenceRadius">
<el-input v-model.trim="form.fenceRadius" style="width: 80px;" maxlength="200"></el-input>米
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="5">多边形</el-radio>
</el-col>
<el-col :span="16" class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="3">行政区域</el-radio>
</el-col>
<el-col :span="16">
<el-form-item label="">
<!-- 监控省市区组件 -->
<!-- <area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="form.areaCode"></area-select> -->
<!-- 监控省市区组件 /-->
</el-form-item>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="短信通知" prop="msgtel">
<el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item>
<el-form-item label="围栏状态">
<el-radio v-model="form.status" :label="1">启用</el-radio>
<el-radio v-model="form.status" :label="0">停用</el-radio>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
</v-full-layout>
</template>
<script>
import '@/assets/spritesmith-generated/sprite.css'
import store from '@/vuex/store.js'
import remoteLoad from '@/utils/remoteLoad.js'
import mapService from '@/utils/mapService.js'
import '@/utils/mapEvent.js'
import EventBus from '@/event-bus'
import {services} from '@/api'
const MONITOR_SERVICE = services.monitor;
import {CONSTANT} from '@/constant'
import AreaSelect from './AreaSelect.vue'
import MAPGEO from '@/utils/mapgeo'
import MapControll from './MapControll.vue'
export default{
data(){
let checkFenceName = (rule, vaule, cb)=>{
if(typeof this.restainFenceName != 'undefined' && this.form.electricFenceName === this.restainFenceName){
cb();
}
MONITOR_SERVICE.checkFenceName({name: this.form.electricFenceName}).then((res)=>{
if(res.returnCode == 0){
if(res.data.isExist == 1){
cb(new Error('该围栏名已存在,请重新输入!'))
}else{
cb();
}
}
})
}
let checkDaterange = (rule, vaule, cb)=>{
const dateRange = this.form.dateRange;
if(!dateRange || !dateRange.length){
cb(new Error('请选择日期'))
}else{
let min = dateRange[0];
let max = dateRange[1];
if(!moment.isMoment(min)){
min = moment(min)
}
if(!moment.isMoment(max)){
max = moment(max)
}
if(min.isBefore( moment(max).subtract(30*6, 'days'), 'minute')){
cb(new Error('日期范围不能超过180天'))
}
}
cb()
}
let checkRadius = (rule, vaule, cb)=>{
const fenceRadius = this.form.fenceRadius;
if(this.form.shapeType == 2 && (!/^\d+$/.test(fenceRadius) || fenceRadius<1000)){
cb(new Error('请输入整数且不小于1000'))
}else{
cb();
}
}
let checkMsgtel = (rule, vaule, cb)=>{
if(this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)){
cb(new Error('请输入正确的格式'))
}else{
cb();
}
}
return {
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: '',
searchType: 'sn',
isSearching: false,
areaId: '',
areaStr: '',
isSubmitting: false,
form: {
fenceNo: '',
electricFenceName: '',
locationType: 1,
triggerType: 3,
dateRange: [],
shapeType: 2,
fenceRadius: '1000',
status: 1,
areaCode: '',
lng: '',
lat: '',
analysisAddress: '',
msgtel: ''
},
rules: {
electricFenceName: [
{required: true, message: '请输入围栏名称', trigger: 'blur'},
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' },
{validator: checkFenceName, trigger: 'blur'}
],
daterange: [{validator: checkDaterange}],
fenceRadius: [
{validator: checkRadius, trigger: 'blur'}
],
msgtel: [{validator: checkMsgtel, trigger: 'blur'}],
},
fenceId: undefined,
restainFenceName: '',
polygonPath: []
}
},
mounted(){
store.dispatch('setFullsize', true)
},
watch: {
'form.fenceRadius'(newVal){
if(this.form.shapeType === 2){
if(this._updateFenceRadiusTimeoutId){
clearTimeout(this._updateFenceRadiusTimeoutId)
}
this._updateFenceRadiusTimeoutId = setTimeout(()=>{
this.$refs.form.validateField('fenceRadius', (error)=>{
if(error){
return false;
}else{
this.updateFenceRadius(newVal)
}
});
/*this.$refs.form.validate((valid, field)=>{
if(valid){
this.updateFenceRadius(newVal)
}else{
return false;
}
});*/
}, 500);
}
},
'form.shapeType'(newVal){
this._shapeTypeTimeoutId && clearTimeout(this._shapeTypeTimeoutId);
this._shapeTypeTimeoutId = setTimeout(()=>{
console.log(newVal)
if(newVal === 2){
this.$refs.form.validateField('fenceRadius', (error)=>{
if(error){
EventBus.$emit('uiMap.fence.destroy');
return false;
}else{
this.drawFenceCircle()
}
});
}else if(newVal === 3){
if(this.areaId){
this.drawDistrict(this.areaId)
}else{
EventBus.$emit('uiMap.fence.destroy');
}
}else if(newVal === 5){
this.drawPolygon()
}
}, 500)
}
},
methods: {
initMap(){
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(()=>{
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
window.AMap = AMap;
this.mapObj = mapService.init('map');
//this.bindEvent();
this.isInitMap = true;
this.initFence();
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
},
initFence(){
MONITOR_SERVICE.getSingleFence({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
if(data){
this.fenceId = data.fenceId;
const form = this.form;
form.locationType = data.locationType;
form.electricFenceName = data.electricFenceName;
this.restainFenceName = form.electricFenceName;
form.triggerType = data.electricFenceType;
form.dateRange = [moment(data.startTime),moment(data.endTime)];
form.shapeType = data.shapeType;
form.status = data.status;
form.areaCode = data.areaCode;
form.msgtel = data.telNumbers;
if(form.shapeType === 2){
form.fenceRadius = data.radius;
form.lng = data.lng;
form.lat = data.lat;
EventBus.$emit('uiMap.fence.createFenceCircle', {
lng: data.lng,
lat: data.lat,
radius: data.radius
});
}else if(form.shapeType === 3){
this.drawDistrict(data.areaCode)
}else if(form.shapeType === 5){
if(data.lnglat){
this.polygonPath = data.lnglat.split('|').map((item)=>{
return [item.split(',')[0], item.split(',')[1]]
})
}
this.drawPolygon()
}
}else{
this.restainFenceName = undefined;
}
this.initDetail();
}
});
},
initDetail(){
MONITOR_SERVICE.getTrackBySn({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
const form = this.form;
if(!this.restainFenceName){
form.electricFenceName = '单设备围栏-'+this.name;
}
if(!form.lng && !form.lat){
form.lng = data.lngGPS;
form.lat = data.latGPS;
this.drawFenceCircle();
}
EventBus.$emit('uiMap.fence.createFenceMarker', data);
}
});
},
pickDate(beforeDays){
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')]
},
submit(){
if(this.form.shapeType == 5){
if(this.polygonPath.length === 0){
this.$message({
message: '请绘制围栏',
type: 'error'
});
return;
}
}
this.$refs.form.validate((valid, field)=>{
if(valid){
this.isSubmitting = true;
this.getParams().then((data)=>{
let params = data;
if(typeof this.fenceId != 'undefined'){
params.id = this.fenceId;
MONITOR_SERVICE.updateFence(JSON.stringify(params)).then((res)=>{
if(res.returnCode == 0){
//this.closeDialog();
this.$message({
message: res.message,
type: 'success'
});
}
this.isSubmitting = false;
});
}else{
MONITOR_SERVICE.getNewFenceId().then((res)=>{
if(res.returnCode == 0){
params.fenceNo = res.data.fenceNo;
MONITOR_SERVICE.saveFence(JSON.stringify(params)).then((res)=>{
if(res.returnCode == 0){
//this.closeDialog();
this.$message({
message: res.message,
type: 'success'
});
this.fenceId = res.data;
this.restainFenceName = this.form.electricFenceName;
}
this.isSubmitting = false;
});
}
});
}
});
}else{
return false;
}
});
},
getParams(){
return new Promise((resolve, reject)=>{
const form = this.form;
const params = {};
const transferItem = {
data: [{
elng: form.lng,
elat: form.lat
}]
}
MAPGEO.transferAddressByGroup(transferItem, ()=>{
params.electricFenceName = form.electricFenceName;
params.electricFenceType = form.triggerType;
params.shapeType = form.shapeType;
params.locationType = form.locationType;
if(params.shapeType == 3){
params.areaCode = this.areaId;
params.areaString = this.areaStr;
}else if(params.shapeType == 2){
params.lng = form.lng;
params.lat = form.lat;
params.radius = form.fenceRadius;
params.analysisAddress = transferItem.data[0].transferAddress;
}else if(params.shapeType == 5){
params.lnglat = this.polygonPath.join('|')
}
params.status = form.status;
params.snList = [{sn: this.sn}]
params.startTime = moment(this.form.dateRange[0]).format('YYYY-MM-DD');
params.endTime = moment(this.form.dateRange[1]).format('YYYY-MM-DD');
if(form.msgtel){
params.telNumbers = form.msgtel
}
params.timeType = 2
resolve(params)
});
});
},
areaChoose(areaId, areaStr){
this.areaId = areaId;
this.areaStr = areaStr;
if(this.form.shapeType === 3){
this.drawDistrict(areaId)
}
},
updateFenceRadius(radius){
EventBus.$emit('uiMap.fence.updateFenceRadius', radius)
},
drawFenceCircle(){
EventBus.$emit('uiMap.fence.createFenceCircle', {
lng: this.form.lng,
lat: this.form.lat,
radius: this.form.fenceRadius
});
},
drawDistrict(areaCode){
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
this._drawDistrictTimeoutId = setTimeout(()=>{
EventBus.$emit('uiMap.fence.drawDistrict', areaCode);
}, 500);
},
drawPolygon(){
EventBus.$emit('uiMap.fence.drawPolygon', this.polygonPath)
}
},
created () {
if(window.AMap){
this.initMap();
}else{
remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{
this.initMap();
})
})
}
EventBus.$on('uiMap.fence.loading', (isLoading)=>{
this.mapLoading = isLoading;
});
EventBus.$on('uiMap.fence.onFenceRadiusChange', (radius)=>{
this.form.fenceRadius = radius;
//this.$refs.form.validateField('fenceRadius');
});
EventBus.$on('uiMap.fence.onFenceLngLatChange', (data)=>{
this.form.lng = data.lng;
this.form.lat = data.lat;
});
EventBus.$on('uiMap.fence.polygonChange', (data)=>{
this.polygonPath = data.polygonPath
});
},
beforeDestroy(){
},
components: {
AreaSelect,
MapControll
}
}
</script>
<style scoped>
/*样式写在 scss/monitor.scss*/
.side_auto_h{
max-height: calc(100vh - 100px);
overflow: auto;
}
.shape_tip{
color:#999;
line-height:1.5;
margin-bottom: 10px;
}
</style>
\ No newline at end of file
<template>
<v-full-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>电子围栏</el-breadcrumb-item>
</template>
<template slot="main">
<div class="map-wrap" >
<div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll>
<div class="controll-wrap">
<div class="search-box active side_auto_h">
<h3>电子围栏</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form">
<el-form-item label="定位方式">
<el-select v-model="form.locationType" placeholder="请选择" size="small" style="width: 280px">
<el-option label="GPS" :value="1"></el-option>
<el-option label="基站" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="围栏名称" prop="electricFenceName">
<el-input v-model.trim="form.electricFenceName" maxlength="200"></el-input>
</el-form-item>
<el-form-item label="触发类型">
<el-select v-model="form.triggerType" placeholder="请选择" size="small" style="width: 280px">
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶入驶出" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="指定区间" prop="daterange">
<el-date-picker
style="width: 100%;"
v-model="form.dateRange"
type="daterange"
size="small"
:clearable="false"
:editable="false"
:unlink-panels="true"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="监控区域" class="row-form-item">
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="2">圆形</el-radio>
</el-col>
<el-col :span="16">
<el-form-item label="" prop="fenceRadius">
<el-input v-model.trim="form.fenceRadius" style="width: 80px;" maxlength="200"></el-input>米
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="5">多边形</el-radio>
</el-col>
<el-col :span="16" class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-radio v-model="form.shapeType" :label="3">行政区域</el-radio>
</el-col>
<el-col :span="16">
<el-form-item label="">
<!-- 监控省市区组件 -->
<area-select ref="clearArea" @onChangArea="areaChoose" :prependFirst="true" :id="form.areaCode"></area-select>
<!-- 监控省市区组件 /-->
</el-form-item>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="短信通知" prop="msgtel">
<el-input v-model.trim="form.msgtel" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item>
<el-form-item label="围栏状态">
<el-radio v-model="form.status" :label="1">启用</el-radio>
<el-radio v-model="form.status" :label="0">停用</el-radio>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
</v-full-layout>
<v-full-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>电子围栏</el-breadcrumb-item>
</template>
<template slot="main">
<div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll>
<div class="controll-wrap">
<el-scrollbar class="el_scrollbar">
<div class="search-box">
<h3>电子围栏</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<el-form ref="form" :model="form" :rules="rules" size="mini" class="form" label-position="top">
<el-form-item label="定位方式">
<el-select v-model="form.locationType" class="a_select" placeholder="请选择" size="small" :disabled="true">
<el-option label="GPS" :value="1"></el-option>
<el-option label="基站" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" maxlength="200"></el-input>
</el-form-item>
<el-form-item label="触发类型">
<el-select v-model="form.triggerType" class="a_select" placeholder="请选择" size="small">
<el-option label="驶出" :value="2"></el-option>
<el-option label="驶入" :value="1"></el-option>
<el-option label="驶入驶出" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="指定区间" prop="daterange">
<el-date-picker style="width: 100%;" v-model="form.dateRange" type="daterange" size="small" :clearable="false" :editable="false" :unlink-panels="true" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="监控区域" class="row-form-item">
<div class="el_radio_group">
<div class="radio_cell">
<el-radio :label="1" v-model="form.shapeType">圆形</el-radio>
<el-form-item label="" prop="radius">
<el-input v-model.trim="form.radius" style="width: 80px;" maxlength="200"></el-input>米
</el-form-item>
</div>
<div class="radio_cell">
<el-radio :label="3" v-model="form.shapeType">多边形</el-radio>
<div class="shape_tip">*注:地图任意位置,单击新增双击结束绘制。</div>
</div>
<div class="radio_cell">
<el-radio :label="4" v-model="form.shapeType">行政区域</el-radio>
<el-form-item label="" prop="radius">
<city-select v-model="form.areaName" :checkStrictly="true" :disabled="form.shapeType != 3" @change="changeArea"></city-select>
</el-form-item>
</div>
</div>
</el-form-item>
<el-form-item label="短信通知" prop="msgtel">
<el-input v-model.trim="form.telNumbers" maxlength="100" placeholder="输入格式:手机号码,手机号码(支持双号)"></el-input>
</el-form-item>
<el-form-item label="围栏状态">
<el-radio v-model="form.enableStatus" :label="1">启用</el-radio>
<el-radio v-model="form.enableStatus" :label="0">停用</el-radio>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit" size="small" :loading="isSubmitting">保存</el-button>
</el-form-item>
</el-form>
</div>
</el-scrollbar>
</div>
</div>
</template>
</v-full-layout>
</template>
<script>
import '../../assets/spritesmith-generated/sprite.css'
import store from '../../vuex/store.js'
import remoteLoad from 'utils/remoteLoad.js'
import mapService from 'utils/mapService.js'
import 'utils/mapEvent.js'
import EventBus from '../../event-bus'
import {services} from '../../api'
import mock from '../../mock'
const MONITOR_SERVICE = services.monitor;
import "@/assets/spritesmith-generated/sprite.css";
import store from "@/vuex/store.js";
import remoteLoad from "@/utils/remoteLoad.js";
import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js";
import EventBus from "@/event-bus";
import { services } from "@/api";
const MONITOR_SERVICE = services.monitor;
import { CONSTANT } from "@/constant";
import { deepClone } from "@/utils/utils";
import AreaSelect from "./AreaSelect.vue";
import MAPGEO from "@/utils/mapgeo";
import MapControll from "./MapControll.vue";
import AMapLoader from "@amap/amap-jsapi-loader";
import { GET_DEVICE_LOCATION } from "@/api/services/monitor";
import CitySelect from "@/components/area";
export default {
components: {
AreaSelect,
MapControll,
CitySelect,
},
data() {
let checkFenceName = (rule, vaule, cb) => {
if (
typeof this.restainFenceName != "undefined" &&
this.form.electricFenceName === this.restainFenceName
) {
cb();
}
MONITOR_SERVICE.checkFenceName({
name: this.form.electricFenceName,
}).then((res) => {
if (res.returnCode == 0) {
if (res.data.isExist == 1) {
cb(new Error("该围栏名已存在,请重新输入!"));
} else {
cb();
}
}
});
};
let checkDaterange = (rule, vaule, cb) => {
const dateRange = this.form.dateRange;
if (!dateRange || !dateRange.length) {
cb(new Error("请选择日期"));
} else {
let min = dateRange[0];
let max = dateRange[1];
if (!moment.isMoment(min)) {
min = moment(min);
}
if (!moment.isMoment(max)) {
max = moment(max);
}
if (min.isBefore(moment(max).subtract(30 * 6, "days"), "minute")) {
cb(new Error("日期范围不能超过180天"));
}
}
cb();
};
let checkRadius = (rule, vaule, cb) => {
const fenceRadius = this.form.fenceRadius;
if (
this.form.shapeType == 2 &&
(!/^\d+$/.test(fenceRadius) || fenceRadius < 1000)
) {
cb(new Error("请输入整数且不小于1000"));
} else {
cb();
}
};
let checkMsgtel = (rule, vaule, cb) => {
if (this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)) {
cb(new Error("请输入正确的格式"));
} else {
cb();
}
};
return {
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: "",
searchType: "sn",
isSearching: false,
areaId: "",
areaStr: "",
isSubmitting: false,
form: {
locationType: 1,
triggerType: 3,
shapeType: 2,
radius: 1000,
status: 1,
},
rules: {
fenceName: [
{ required: true, message: "请输入围栏名称", trigger: "blur" },
{ pattern: /^\S{2,200}$/, message: "至少2字", trigger: "blur" },
{ validator: checkFenceName, trigger: "blur" },
],
daterange: [{ validator: checkDaterange }],
fenceRadius: [{ validator: checkRadius, trigger: "blur" }],
msgtel: [{ validator: checkMsgtel, trigger: "blur" }],
},
fenceId: undefined,
restainFenceName: "",
polygonPath: [],
deviceInfo: {}, // 设备信息
deviceList: [], // 设备列表
};
},
created() {
EventBus.$on("uiMap.fence.onFenceRadiusChange", this.onFenceRadiusChange);
EventBus.$on("uiMap.fence.polygonChange", this.onFencePolyChange);
this.initMap();
},
mounted() {
//store.dispatch("setFullsize", true);
},
watch: {
"form.shapeType": {
handler: function (n, o) {
this.changeShapeType(n);
},
immediate: true,
},
},
methods: {
// 初始化地图
initMap() {
let _this = this;
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: CONSTANT.MAP_PLUGINS, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((AMap) => {
window.AMap = AMap;
_this.map = mapService.init("map");
_this.getDevinceInfo();
});
},
// 获取设备信息
getDevinceInfo() {
let oParams = {};
oParams.sns = this.$route.query.sn;
oParams.deviceCode = "gps";
GET_DEVICE_LOCATION(oParams).then((res) => {
if (!res.data || res.data.length <= 0) {
return false;
}
let obj = res.data[0] || {};
this.deviceInfo = obj;
this.deviceList = res.data || [];
this.drawMarker(res);
this.drawFenceCircle(obj.gpsLocation);
});
},
pickDate(beforeDays) {},
submit() {},
updateFenceRadius(radius) {},
// 在地图上画圆形围栏
drawFenceCircle(info) {
let _this = this;
EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: info.elng,
lat: info.elat,
radius: _this.form.radius,
});
},
// 在地图上画行政区域
drawDistrict(areaCode) {
console.log(areaCode);
EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
},
// 在地图上画多边形
drawPolygon() {
EventBus.$emit("uiMap.fence.destroy");
EventBus.$emit("uiMap.fence.drawPolygon", this.polygonPath);
},
// 根据设备地址,在地图上画车辆
drawMarker(res) {
let query = this.$route.query;
let obj = res.data[0] || {};
let g = obj.gpsLocation || {};
let b = obj.bsLocation || {};
let option = {};
let sourceType = {
1: "有线",
2: "无线",
};
// GPS信息
option.lngGPS = g.elng;
option.latGPS = g.elat;
option.timeGPS = g.dateTime;
option.transferAddressGPS = g.address;
// 基站信息
option.lngBase = b.elng;
option.latBase = b.elat;
option.timeBase = b.dateTime;
option.transferAddressBase = b.address;
import {CONSTANT} from '../../constant'
option.name = query.name;
option.standno = query.standno;
option.sn = query.sn;
option.sourceString = sourceType[obj.source] || "--";
option.status = obj.status;
option.battery = obj.battery;
import AreaSelect from './AreaSelect.vue'
import MAPGEO from 'utils/mapgeo'
import MapControll from './MapControll.vue'
// 标记车辆信息
EventBus.$emit("uiMap.fence.createFenceMarker", option);
},
export default{
data(){
let checkFenceName = (rule, vaule, cb)=>{
if(typeof this.restainFenceName != 'undefined' && this.form.electricFenceName === this.restainFenceName){
cb();
}
MONITOR_SERVICE.checkFenceName({name: this.form.electricFenceName}).then((res)=>{
if(res.returnCode == 0){
if(res.data.isExist == 1){
cb(new Error('该围栏名已存在,请重新输入!'))
}else{
cb();
}
}
})
}
let checkDaterange = (rule, vaule, cb)=>{
// 监听圆形围栏直径变化
onFenceRadiusChange(e) {
console.log(e);
this.$set(this.form, "radius", e);
},
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()
}
// 监听围栏类型变化
changeShapeType(e) {
let _this = this;
let _info = this.deviceInfo;
let areaCode = this.form.areaCode || [];
// 1:圆形围栏 4:行政区域 3:多边形
console.log(_info);
switch (e) {
case 4:
_this.drawDistrict(areaCode);
break;
case 3:
_this.drawPolygon();
break;
default:
_this.drawFenceCircle(_info.gpsLocation || {});
break;
}
},
let checkRadius = (rule, vaule, cb)=>{
const fenceRadius = this.form.fenceRadius;
if(this.form.shapeType == 2 && (!/^\d+$/.test(fenceRadius) || fenceRadius<1000)){
cb(new Error('请输入整数且不小于1000'))
}else{
cb();
}
}
// 监听多边形围栏变化
onFencePolyChange(e) {
this.polygonPath = e.polygonPath;
},
let checkMsgtel = (rule, vaule, cb)=>{
if(this.form.msgtel && !/^1\d{10}(\,1\d{10})?$/.test(this.form.msgtel)){
cb(new Error('请输入正确的格式'))
}else{
cb();
}
}
return {
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: '',
searchType: 'sn',
isSearching: false,
areaId: '',
areaStr: '',
isSubmitting: false,
form: {
fenceNo: '',
electricFenceName: '',
locationType: 1,
triggerType: 3,
dateRange: [],
shapeType: 2,
fenceRadius: '1000',
status: 1,
areaCode: '',
lng: '',
lat: '',
analysisAddress: '',
msgtel: ''
},
rules: {
electricFenceName: [
{required: true, message: '请输入围栏名称', trigger: 'blur'},
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' },
{validator: checkFenceName, trigger: 'blur'}
],
daterange: [{validator: checkDaterange}],
fenceRadius: [
{validator: checkRadius, trigger: 'blur'}
],
msgtel: [{validator: checkMsgtel, trigger: 'blur'}],
},
fenceId: undefined,
restainFenceName: '',
polygonPath: []
}
},
mounted(){
store.dispatch('setFullsize', true)
},
watch: {
'form.fenceRadius'(newVal){
if(this.form.shapeType === 2){
if(this._updateFenceRadiusTimeoutId){
clearTimeout(this._updateFenceRadiusTimeoutId)
}
this._updateFenceRadiusTimeoutId = setTimeout(()=>{
this.$refs.form.validateField('fenceRadius', (error)=>{
if(error){
return false;
}else{
this.updateFenceRadius(newVal)
}
});
/*this.$refs.form.validate((valid, field)=>{
if(valid){
this.updateFenceRadius(newVal)
}else{
return false;
}
});*/
}, 500);
}
},
'form.shapeType'(newVal){
this._shapeTypeTimeoutId && clearTimeout(this._shapeTypeTimeoutId);
this._shapeTypeTimeoutId = setTimeout(()=>{
if(newVal === 2){
this.$refs.form.validateField('fenceRadius', (error)=>{
if(error){
EventBus.$emit('uiMap.fence.destroy');
return false;
}else{
this.drawFenceCircle()
}
});
}else if(newVal === 3){
if(this.areaId){
this.drawDistrict(this.areaId)
}else{
EventBus.$emit('uiMap.fence.destroy');
}
}else if(newVal === 5){
this.drawPolygon()
}
}, 500)
}
},
methods: {
initMap(){
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
// 监听行政区域
changeArea(e) {
console.log(e);
this.form.areaCode = e.code;
this.form.areaText = e.name;
this.drawDistrict(e.code);
},
return setTimeout(()=>{
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
window.AMap = AMap;
this.mapObj = mapService.init('map');
//this.bindEvent();
this.isInitMap = true;
this.initFence();
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
},
initFence(){
MONITOR_SERVICE.getSingleFence({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
if(data){
this.fenceId = data.fenceId;
const form = this.form;
form.locationType = data.locationType;
form.electricFenceName = data.electricFenceName;
this.restainFenceName = form.electricFenceName;
// 获取参数
getParams() {
let _this = this;
let o = deepClone(_this.form);
console.log(o);
let oParams = {};
let device = this.deviceInfo;
let deviceList = this.deviceList;
form.triggerType = data.electricFenceType;
form.dateRange = [moment(data.startTime),moment(data.endTime)];
form.shapeType = data.shapeType;
form.status = data.status;
form.areaCode = data.areaCode;
form.msgtel = data.telNumbers;
if(form.shapeType === 2){
form.fenceRadius = data.radius;
form.lng = data.lng;
form.lat = data.lat;
EventBus.$emit('uiMap.fence.createFenceCircle', {
lng: data.lng,
lat: data.lat,
radius: data.radius
});
}else if(form.shapeType === 3){
this.drawDistrict(data.areaCode)
}else if(form.shapeType === 5){
if(data.lnglat){
this.polygonPath = data.lnglat.split('|').map((item)=>{
return [item.split(',')[0], item.split(',')[1]]
})
}
this.drawPolygon()
}
}else{
this.restainFenceName = undefined;
}
this.initDetail();
}
});
},
initDetail(){
MONITOR_SERVICE.getTrackBySn({
sn: this.sn
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
const form = this.form;
if(!this.restainFenceName){
form.electricFenceName = '单设备围栏-'+this.name;
}
if(!form.lng && !form.lat){
form.lng = data.lngGPS;
form.lat = data.latGPS;
this.drawFenceCircle();
}
EventBus.$emit('uiMap.fence.createFenceMarker', data);
}
});
},
pickDate(beforeDays){
this.form.dateRange = [moment().subtract(beforeDays, 'days'),moment().subtract(1, 'days')]
},
submit(){
if(this.form.shapeType == 5){
if(this.polygonPath.length === 0){
this.$message({
message: '请绘制围栏',
type: 'error'
});
return;
}
}
this.$refs.form.validate((valid, field)=>{
if(valid){
this.isSubmitting = true;
this.getParams().then((data)=>{
let params = data;
oParams.fenceName = o.fenceName;
oParams.bizFenceType = 14;
oParams.triggerType = o.triggerType;
oParams.enableStatus = o.enableStatus;
oParams.timeType = 2;
oParams.shapeType = o.shapeType;
oParams.telNumbers = o.telNumbers;
if(typeof this.fenceId != 'undefined'){
params.id = this.fenceId;
MONITOR_SERVICE.updateFence(JSON.stringify(params)).then((res)=>{
if(res.returnCode == 0){
//this.closeDialog();
this.$message({
message: res.message,
type: 'success'
});
}
this.isSubmitting = false;
});
}else{
MONITOR_SERVICE.getNewFenceId().then((res)=>{
if(res.returnCode == 0){
params.fenceNo = res.data.fenceNo;
MONITOR_SERVICE.saveFence(JSON.stringify(params)).then((res)=>{
if(res.returnCode == 0){
//this.closeDialog();
this.$message({
message: res.message,
type: 'success'
});
this.fenceId = res.data;
this.restainFenceName = this.form.electricFenceName;
}
this.isSubmitting = false;
});
}
});
}
});
}else{
return false;
}
});
},
getParams(){
return new Promise((resolve, reject)=>{
const form = this.form;
const params = {};
const transferItem = {
data: [{
elng: form.lng,
elat: form.lat
}]
}
MAPGEO.transferAddressByGroup(transferItem, ()=>{
params.electricFenceName = form.electricFenceName;
params.electricFenceType = form.triggerType;
params.shapeType = form.shapeType;
params.locationType = form.locationType;
// 指定区间
if (o.dateRange && o.dateRange.length > 0) {
oParams.startTime = o.dateRange[0];
oParams.endTime = o.dateRange[1];
}
if(params.shapeType == 3){
params.areaCode = this.areaId;
params.areaString = this.areaStr;
}else if(params.shapeType == 2){
params.lng = form.lng;
params.lat = form.lat;
params.radius = form.fenceRadius;
params.analysisAddress = transferItem.data[0].transferAddress;
}else if(params.shapeType == 5){
params.lnglat = this.polygonPath.join('|')
}
params.status = form.status;
params.snList = [{sn: this.sn}]
params.startTime = moment(this.form.dateRange[0]).format('YYYY-MM-DD');
params.endTime = moment(this.form.dateRange[1]).format('YYYY-MM-DD');
if(form.msgtel){
params.telNumbers = form.msgtel
}
params.timeType = 2
// 圆形围栏
if (o.shapeType == 1) {
oParams.radius = o.radius;
oParams.lnglat = `${device.elng},${device.elat}`;
}
resolve(params)
});
});
},
areaChoose(areaId, areaStr){
this.areaId = areaId;
this.areaStr = areaStr;
if(this.form.shapeType === 3){
this.drawDistrict(areaId)
}
},
updateFenceRadius(radius){
EventBus.$emit('uiMap.fence.updateFenceRadius', radius)
},
drawFenceCircle(){
EventBus.$emit('uiMap.fence.createFenceCircle', {
lng: this.form.lng,
lat: this.form.lat,
radius: this.form.fenceRadius
});
},
drawDistrict(areaCode){
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
// 多边形围栏
if (o.shapeType == 3) {
oParams.lnglat = this.polygonPath;
}
this._drawDistrictTimeoutId = setTimeout(()=>{
EventBus.$emit('uiMap.fence.drawDistrict', areaCode);
}, 500);
},
drawPolygon(){
EventBus.$emit('uiMap.fence.drawPolygon', this.polygonPath)
}
},
created () {
if(window.AMap){
this.initMap();
}else{
remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{
this.initMap();
})
})
}
EventBus.$on('uiMap.fence.loading', (isLoading)=>{
this.mapLoading = isLoading;
});
EventBus.$on('uiMap.fence.onFenceRadiusChange', (radius)=>{
this.form.fenceRadius = radius;
//this.$refs.form.validateField('fenceRadius');
});
EventBus.$on('uiMap.fence.onFenceLngLatChange', (data)=>{
this.form.lng = data.lng;
this.form.lat = data.lat;
});
EventBus.$on('uiMap.fence.polygonChange', (data)=>{
this.polygonPath = data.polygonPath
});
},
beforeDestroy(){
// 行政区域围栏
if (o.shapeType == 4) {
oParams.areaCode = o.areaCode[o.areaCode.length - 1];
oParams.areaText = o.areaText[o.areaText.length - 1];
}
},
components: {
AreaSelect,
MapControll
}
}
// 设备列表
let arr = [];
deviceList.map((k) => {
let cur = {};
let _gps = k.gpsLocation || {};
cur.address = _gps.address;
cur.lat = _gps.elat;
cur.lng = _gps.elng;
cur.name = k.ownerName;
cur.sn = k.sn;
cur.time = _gps.dateTime;
cur.userTel = "";
cur.vin = k.vin;
arr.push(cur);
});
oParams.snList = arr;
},
},
};
</script>
<style scoped>
/*样式写在 scss/monitor.scss*/
.side_auto_h{
max-height: calc(100vh - 100px);
overflow: auto;
}
.shape_tip{
color:#999;
line-height:1.5;
margin-bottom: 10px;
}
<style lang="scss" scoped>
/*样式写在 scss/monitor.scss*/
.side_auto_h {
max-height: calc(100vh - 100px);
overflow: auto;
}
.shape_tip {
color: #999;
line-height: 1.5;
margin-bottom: 10px;
}
.search-box {
height: 100%;
display: block;
.info {
word-break: break-all;
}
.a_select {
width: 100%;
}
}
.map-wrap {
.controll-wrap {
top: 10px;
left: 10px;
bottom: 10px;
}
.el_scrollbar {
height: 100%;
z-index: 999;
/deep/ .el-scrollbar__wrap {
overflow-x: hidden;
}
}
}
.el_radio_group {
display: flex;
flex-direction: column;
.radio_cell {
display: flex;
align-items: center;
margin: 0 0 10px 0;
.el-radio {
margin-bottom: 15px;
}
.shape_tip {
font-size: 12px;
}
}
}
</style>
\ No newline at end of file
<template>
<!-- 围栏调用地图弹框 -->
<!-- <el-dialog id="fenceMapModal1" :visible="fenceMapModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="1200px" top="10vh"> -->
<!-- <div class="dialog-header" slot="title">
<!-- 围栏调用地图弹框 -->
<!-- <el-dialog id="fenceMapModal1" :visible="fenceMapModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="1200px" top="10vh"> -->
<!-- <div class="dialog-header" slot="title">
<h2 class="header-title">地图引用</h2>
</div> -->
<div class="fence-map" :visible="fenceMapModalVisible" v-loading="mapLoading">
<!-- <el-form :model="form" ref="fenceMapForm" :rules="rules" :inline="true" size="mini" >
<div class="fence-map" :visible="fenceMapModalVisible" v-loading="mapLoading">
<!-- <el-form :model="form" ref="fenceMapForm" :rules="rules" :inline="true" size="mini" >
<el-form-item label="经度" prop="lng">
<el-input v-model="form.lng" style="width:100px" @change="transfer"></el-input>
</el-form-item>
......@@ -24,93 +23,90 @@
</el-form-item>
<el-form-item><el-button type="primary" @click="updateFence">更新围栏</el-button></el-form-item>
</el-form>-->
<div id="mapContainer" class="map-container"></div>
<fence-map-controll @onRefreshMap="refreshMap" :isModalMap="true"></fence-map-controll>
<div class="map-seacrh-wrap">
<!-- <input type="text" id="fenceMapSearch"> -->
<el-input placeholder="请输入位置" id="fenceMapSearch" size="small" v-model="fenceMapSearch" :disabled="readonlyStatus">
<template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input>
</div>
</div>
<!-- <div slot="footer" class="dialog-footer">
<div id="mapContainer" class="map-container"></div>
<fence-map-controll @onRefreshMap="refreshMap" :isModalMap="true"></fence-map-controll>
<div class="map-seacrh-wrap">
<!-- <input type="text" id="fenceMapSearch"> -->
<el-input placeholder="请输入位置" id="fenceMapSearch" size="small" v-model="fenceMapSearch" :disabled="readonlyStatus">
<template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input>
</div>
</div>
<!-- <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="sure" size="small">确认</el-button>
<el-button @click="$emit('onFenceMapModalChange', false)" size="small">关闭</el-button>
</div> -->
<!-- </el-dialog> -->
<!-- 围栏调用地图弹框 /-->
<!-- </el-dialog> -->
<!-- 围栏调用地图弹框 /-->
</template>
<script>
import {services} from '../../api'
import remoteLoad from 'utils/remoteLoad.js'
import mapService from 'utils/mapService.js'
import FenceMapControll from './FenceMapControll.vue'
const BUSINESS_SERVICE = services.business;
import {CONSTANT} from '../../constant'
export default{
props: ['fenceMapModalVisible', 'init', 'readonlyStatus'],
data(){
return {
fenceMapSearch: '',
geolocation: null,
circleEditor: null,
areaCodeMap:"",
polygons:[],
polygonEditor:null,
autoCenterMarker:null,
marke:null,
fenceMapModalVisible:false,
polygon:null,
mapDot:true,
circle: null,
tableData:[],
transferTimeoutId: undefined,
geocoder: null,
transferFlag: null,
opts : {
subdistrict: 1, //返回下一级行政区
showbiz:false //最后一级返回街道信息
},
mapObj: null,
fenceType: 'polygon', //'area' 'polygon'
lng: '',
lat: '',
radius: '',
fenceCircle: null,
fenceCenter: null,
areaCode: '',
isFenceInit: false,
mapLoading: false,
polygonPath: [
/* [116.403322, 39.920255],
import { services } from "../../api";
import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
import FenceMapControll from "./FenceMapControll.vue";
const BUSINESS_SERVICE = services.business;
import { CONSTANT } from "../../constant";
export default {
props: ["fenceMapModalVisible", "init", "readonlyStatus"],
data() {
return {
fenceMapSearch: "",
geolocation: null,
circleEditor: null,
areaCodeMap: "",
polygons: [],
polygonEditor: null,
autoCenterMarker: null,
marke: null,
fenceMapModalVisible: false,
polygon: null,
mapDot: true,
circle: null,
tableData: [],
transferTimeoutId: undefined,
geocoder: null,
transferFlag: null,
opts: {
subdistrict: 1, //返回下一级行政区
showbiz: false, //最后一级返回街道信息
},
mapObj: null,
fenceType: "polygon", //'area' 'polygon'
lng: "",
lat: "",
radius: "",
fenceCircle: null,
fenceCenter: null,
areaCode: "",
isFenceInit: false,
mapLoading: false,
polygonPath: [
/* [116.403322, 39.920255],
[116.410703, 39.897555],
[116.402292, 39.892353],
[116.389846, 39.891365] */
]
}
},
mounted(){
},
watch: {
lng(newVal){
//this.transfer()
},
lat(newVal){
//this.transfer()
},
/* mapData(newVal){
],
};
},
mounted() {},
watch: {
lng(newVal) {
//this.transfer()
},
lat(newVal) {
//this.transfer()
},
/* mapData(newVal){
const fenceData = newVal;
this.initMapPromise.then(()=>{console.log(fenceData)
if(fenceData.fenceType === 'circle'){
......@@ -118,507 +114,490 @@ export default{
}
})
} */
},
async created () {
if(window.AMap){
this.initMap()
}else{
await remoteLoad(`${CONSTANT.AMAP_URL}`, true);
this.initMap()
}
},
methods: {
initMap(){
this.initMapPromise = new Promise((resolve, reject)=>{
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(()=>{
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
window.AMap = AMap;
this.mapObj = mapService.init('mapContainer');
this.bindContextMenu();
this.bindSearch();
resolve()
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
})
},
bindSearch(){
const self = this;
this.auto = new AMap.Autocomplete({
input: 'fenceMapSearch'
});
this.autoCenterMarker = new AMap.Marker({
icon: require('images/auto-center-marker.gif'),
map: this.mapObj,
offset: new AMap.Pixel(-12,-12),
visible: false
});
this.autoCenterMarker.on('rightclick', (e)=> {
if(self.mapObj.getAllOverlays('circle').length){
window.mapMenu.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
});
AMap.event.addListener(this.auto, 'select', (e)=>{
if(e.poi && e.poi.location){
this.mapObj.setCenter(e.poi.location);
this.autoCenterMarker.setPosition(e.poi.location);
/*for(var i = 0, l = this.polygons.length; i < l; i++) {
},
async created() {
if (window.AMap) {
this.initMap();
} else {
await remoteLoad(`${CONSTANT.AMAP_URL}`, true);
this.initMap();
}
},
methods: {
initMap() {
this.initMapPromise = new Promise((resolve, reject) => {
let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("mapContainer");
this.bindContextMenu();
this.bindSearch();
resolve();
} else {
this.checkMapLoaded = check();
}
}, 100);
};
this.checkMapLoaded = check();
});
},
bindSearch() {
const self = this;
this.auto = new AMap.Autocomplete({
input: "fenceMapSearch",
});
this.autoCenterMarker = new AMap.Marker({
icon: require("images/auto-center-marker.gif"),
map: this.mapObj,
offset: new AMap.Pixel(-12, -12),
visible: false,
});
this.autoCenterMarker.on("rightclick", (e) => {
if (self.mapObj.getAllOverlays("circle").length) {
window.mapMenu.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
});
AMap.event.addListener(this.auto, "select", (e) => {
if (e.poi && e.poi.location) {
this.mapObj.setCenter(e.poi.location);
this.autoCenterMarker.setPosition(e.poi.location);
/*for(var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null);
}*/
this.autoCenterMarker.show();
this.mapObj.add(this.autoCenterMarker);
//this.form.lng = e.poi.location.lng;
//this.form.lat = e.poi.location.lat;
//this.contextMenuPositon = e.poi.location
//window.mapMenu.contextMenu.open(this.mapObj, mapService.getLngLat(e.poi.location.lng, e.poi.location.lat))
}
this.mapObj.setZoom(14);
});
},
bindContextMenu(){
const self = this;
window.mapMenu = new ContextMenu(this.mapObj);//暴露mapMenu onclick要用
function ContextMenu(map) {
var me = this;
this.contextMenuPositon = null;
this.contextMenu = new AMap.ContextMenu({
isCustom: true,
content: `<div class="context_menu" >
<p onclick="mapMenu.moveCenter()"><span>设置围栏中心</span></p>
</div>`
});
map.on('rightclick', (e)=> {
if(self.mapObj.getAllOverlays('circle').length){
this.contextMenu.open(map, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
});
}
ContextMenu.prototype.moveCenter = function addPOI() {
self.moveCenter()
this.contextMenu.close();
};
},
drawFence(){
if(!this.lng && !this.lat){
this.mapLoading = true;
this.getCurrentPosition().then((pos)=>{
this.lng = pos.lng;
this.lat = pos.lat;
this.radius = 1000;
this.drawFenceCircle(pos)
this.$emit('onUpdateMapData',{
lng: this.lng,
lat: this.lat,
radius: this.radius
});
this.mapLoading = false;
})
}else{
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat))
}
},
drawFenceCircle(fenceCenter){
const mapObj = this.mapObj;
if(this.fenceCircle){
this.fenceCircle.setCenter(mapService.getLngLat(this.lng, this.lat))
}else{
this.fenceCircle = new AMap.Circle({
map: mapObj,
center: fenceCenter,
radius: this.radius*1,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35
});
mapObj.plugin(["AMap.CircleEditor"],()=>{
this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle);
AMap.event.addListener(this.circleEditor, 'adjust', (e)=>{
this.radius = e.radius/1;
this.$emit('onUpdateMapData',{
lng: this.lng,
lat: this.lat,
radius: this.radius
});
});
AMap.event.addListener(this.circleEditor, 'move', (e)=>{
this.lng = e.lnglat.lng;
this.lat = e.lnglat.lat;
this.$emit('onUpdateMapData',{
lng: this.lng,
lat: this.lat,
});
});
this.circleEditor.open();
});
}
mapService.setFitView()
mapObj.setZoom(14);
},
initFence(data){
this._mapPromiseTimeout && clearTimeout(this._mapPromiseTimeout)
if(this.initMapPromise){
if(data){
this.fenceType = data.fenceType
if(this.fenceType === 'circle'){
this.lng = data.lng;
this.lat = data.lat;
this.radius = data.radius;
}else if(this.fenceType === 'area'){
this.areaCode = data.areaCode
}else if(this.fenceType === 'polygon'){
if(data.polygonPath && data.polygonPath.length){
this.polygonPath = data.polygonPath
}
}
}
this.initMapPromise.then(()=>{
if(this.fenceType === 'circle'){
this.drawFence()
}else if(this.fenceType === 'area'){
this.drawArea()
}else if(this.fenceType === 'polygon'){
this.drawPolygon()
}
})
}else{
this._mapPromiseTimeout = setTimeout(() => {console.log('timeout')
this.initFence(data)
}, 100);
}
},
updateFence(data){
this.mapObj.clearMap()
this.fenceType = data.fenceType
this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close()
if(this.fenceType === 'circle'){
this.fenceCircle = null;
if(data.lng){
this.lng = data.lng;
}
if(data.lat){
this.lat = data.lat;
}
if(data.radius){
this.radius = data.radius;
}
this.drawFence()
}else if(this.fenceType === 'area'){
if(data.areaCode){
this.areaCode = data.areaCode
}
if(this.areaCode){
this.drawArea()
}
}else if(this.fenceType === 'polygon'){
this.drawPolygon()
}
},
drawArea(){
let _this = this;
let areaCode = this.areaCode?this.areaCode.toString():'中国'
this.mapObj.clearMap()
for (var i = 0, l =this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null);
}
let district,lng,lat
this.mapLoading = true;
AMap.service('AMap.DistrictSearch', function() {
var opts = {
subdistrict: 1, //返回下一级行政区
extensions: 'all',
showbiz:false //最后一级返回街道信息
};
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;
}
});
});
},
moveCenter(){
this.lng = this.contextMenuPositon.lng;
this.lat = this.contextMenuPositon.lat;
let center = mapService.getLngLat(this.lng, this.lat);
this.fenceCircle.setCenter(center);
this.$emit('onUpdateMapData', {
lng: this.lng,
lat: this.lat
})
},
getCurrentPosition(){
const mapObj = this.mapObj;
const self = this;
return new Promise((resolve, reject)=>{
mapObj.plugin('AMap.Geolocation', function(){
self.geolocation = new AMap.Geolocation();
self.geolocation.getCurrentPosition();
AMap.event.addListener(self.geolocation, 'complete', function(e){//返回定位信息
var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat);
resolve(lnglatXY)
});
AMap.event.addListener(self.geolocation, 'error', function(e){//返回定位出错信息
resolve(mapObj.getCenter())
});
});
})
},
drawPolygon(){
const mapObj = this.mapObj;
const self = this;
if(this.polygonPath.length){
self.polygon = new AMap.Polygon({
path: this.polygonPath,
strokeColor: "#FF33FF",
strokeWeight: 6,
strokeOpacity: 0.2,
fillOpacity: 0.4,
fillColor: '#1791fc',
zIndex: 50,
})
mapObj.add(self.polygon)
mapObj.setFitView([ self.polygon ])
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon)
self.polyEditor.open()
self.bindPolyEvent(self.polyEditor)
}else{
self.mouseTool = new AMap.MouseTool(mapObj)
self.mouseTool.polygon({
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
fillColor: '#1791fc',
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(mapObj, self.polygon)
self.polyEditor.open()
self.bindPolyEvent(self.polyEditor)
self.mouseTool.close()
self.emitPolyEvent()
})
}
},
emitPolyEvent(){
let pathArr = this.polygon.getPath()
let resultArr = pathArr.map((item)=>{
return [item.lng, item.lat]
})
this.autoCenterMarker.show();
this.mapObj.add(this.autoCenterMarker);
this.polygonPath = resultArr
this.$emit('onUpdateMapData',{
polygonPath: this.polygonPath
});
console.log(resultArr.join('|'))
},
bindPolyEvent(polyEditor){
const self = this
polyEditor.on('addnode', function(event) {
console.log('触发事件:addnode')
self.emitPolyEvent()
})
//this.form.lng = e.poi.location.lng;
//this.form.lat = e.poi.location.lat;
//this.contextMenuPositon = e.poi.location
polyEditor.on('adjust', function(event) {
console.log('触发事件:adjust')
self.emitPolyEvent()
})
//window.mapMenu.contextMenu.open(this.mapObj, mapService.getLngLat(e.poi.location.lng, e.poi.location.lat))
}
polyEditor.on('removenode', function(event) {
console.log('触发事件:removenode')
self.emitPolyEvent()
})
this.mapObj.setZoom(14);
});
},
bindContextMenu() {
const self = this;
window.mapMenu = new ContextMenu(this.mapObj); //暴露mapMenu onclick要用
function ContextMenu(map) {
self.contextMenuPositon = null;
self.contextMenu = new AMap.ContextMenu({
isCustom: true,
content: `<div class="context_menu" >
<p onclick="mapMenu.moveCenter()"><span>设置围栏中心</span></p>
</div>`,
});
map.on("rightclick", (e) => {
if (self.mapObj.getAllOverlays("circle").length) {
self.contextMenu.open(map, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置
}
});
}
ContextMenu.prototype.moveCenter = function addPOI() {
self.moveCenter();
self.contextMenu.close();
};
},
drawFence() {
if (!this.lng && !this.lat) {
this.mapLoading = true;
this.getCurrentPosition().then((pos) => {
console.log(pos);
this.lng = pos.lng;
this.lat = pos.lat;
this.radius = 1000;
this.drawFenceCircle(pos);
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
this.mapLoading = false;
}).catch(error => {
console.log(error)
});
} else {
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat));
}
},
drawFenceCircle(fenceCenter) {
const mapObj = this.mapObj;
if (this.fenceCircle) {
this.fenceCircle.setCenter(mapService.getLngLat(this.lng, this.lat));
} else {
this.fenceCircle = new AMap.Circle({
map: mapObj,
center: fenceCenter,
radius: this.radius * 1,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
});
mapObj.plugin(["AMap.CircleEditor"], () => {
this.circleEditor = new AMap.CircleEditor(mapObj, this.fenceCircle);
AMap.event.addListener(this.circleEditor, "adjust", (e) => {
this.radius = e.radius / 1;
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
});
AMap.event.addListener(this.circleEditor, "move", (e) => {
this.lng = e.lnglat.lng;
this.lat = e.lnglat.lat;
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
});
});
this.circleEditor.open();
});
}
polyEditor.on('end', function(event) {
console.log('触发事件: end')
self.emitPolyEvent()
// event.target 即为编辑后的多边形对象
})
},
transfer(){
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(()=>{
const flag = new Date();
this.transferFlag = flag;
if(!this.geocoder){
mapService.getGeocoder().then((gc)=>{
this.geocoder = gc;
this.getAddress(flag);
});
}else{
this.getAddress(flag);
}
}, 500)
},
getAddress(flag){
const lnglatXY = [this.form.lng, this.form.lat];
this.transferAddr = '';
this.geocoder.getAddress(lnglatXY, (status, result)=>{
if(flag == this.transferFlag){
if (status === 'complete' && result.info === 'OK') {//获取地址成功
this.form.transferAddr = result.regeocode.formattedAddress;
this.$emit('onUpdateMapData',{
lng: this.form.lng,
lat: this.form.lat,
address: this.form.transferAddr,
radius: this.form.radius
});
}else{
this.form.transferAddr = '';
}
}
mapService.setFitView();
mapObj.setZoom(14);
},
initFence(data) {
this._mapPromiseTimeout && clearTimeout(this._mapPromiseTimeout);
if (this.initMapPromise) {
if (data) {
this.fenceType = data.fenceType;
if (this.fenceType === "circle") {
this.lng = data.lng;
this.lat = data.lat;
this.radius = data.radius;
} else if (this.fenceType === "area") {
this.areaCode = data.areaCode;
} else if (this.fenceType === "polygon") {
if (data.polygonPath && data.polygonPath.length) {
this.polygonPath = data.polygonPath;
}
}
}
this.initMapPromise.then(() => {
if (this.fenceType === "circle") {
this.drawFence();
} else if (this.fenceType === "area") {
this.drawArea();
} else if (this.fenceType === "polygon") {
this.drawPolygon();
}
});
} else {
this._mapPromiseTimeout = setTimeout(() => {
console.log("timeout");
this.initFence(data);
}, 100);
}
},
updateFence(data) {
let _this = this;
let mapInterval = setInterval(function () {
if (_this.mapObj) {
clearInterval(mapInterval);
_this.mapObj.clearMap();
_this.fenceType = data.fenceType;
_this.polyEditor && _this.polyEditor.close();
_this.mouseTool && _this.mouseTool.close();
if (_this.fenceType === "circle") {
_this.fenceCircle = null;
if (data.lng) {
_this.lng = data.lng;
}
if (data.lat) {
_this.lat = data.lat;
}
if (data.radius) {
_this.radius = data.radius;
}
_this.drawFence();
} else if (_this.fenceType === "area") {
if (data.areaCode) {
_this.areaCode = data.areaCode;
}
if (_this.areaCode) {
_this.drawArea();
}
} else if (_this.fenceType === "polygon") {
_this.drawPolygon();
}
}
}, 100);
},
drawArea() {
let _this = this;
let areaCode = this.areaCode ? this.areaCode.toString() : "中国";
this.mapObj.clearMap();
for (var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null);
}
let district, lng, lat;
this.mapLoading = true;
AMap.service("AMap.DistrictSearch", function () {
var opts = {
subdistrict: 1, //返回下一级行政区
extensions: "all",
showbiz: false, //最后一级返回街道信息
};
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;
}
});
});
},
moveCenter() {
this.lng = this.contextMenuPositon.lng;
this.lat = this.contextMenuPositon.lat;
let center = mapService.getLngLat(this.lng, this.lat);
this.fenceCircle.setCenter(center);
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
});
},
getCurrentPosition() {
const mapObj = this.mapObj;
const self = this;
return new Promise((resolve, reject) => {
mapObj.plugin("AMap.Geolocation", function () {
self.geolocation = new AMap.Geolocation();
self.geolocation.getCurrentPosition();
AMap.event.addListener(self.geolocation, "complete", function (e) {
//返回定位信息
var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat);
resolve(lnglatXY);
});
AMap.event.addListener(self.geolocation, "error", function (e) {
//返回定位出错信息
resolve(mapObj.getCenter());
});
});
});
},
drawPolygon() {
const mapObj = this.mapObj;
const self = this;
if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({
path: this.polygonPath,
strokeColor: "#FF33FF",
strokeWeight: 6,
strokeOpacity: 0.2,
fillOpacity: 0.4,
fillColor: "#1791fc",
zIndex: 50,
});
mapObj.add(self.polygon);
mapObj.setFitView([self.polygon]);
self.polyEditor = new AMap.PolyEditor(mapObj, self.polygon);
self.polyEditor.open();
self.bindPolyEvent(self.polyEditor);
} else {
self.mouseTool = new AMap.MouseTool(mapObj);
self.mouseTool.polygon({
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
fillColor: "#1791fc",
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(mapObj, self.polygon);
self.polyEditor.open();
self.bindPolyEvent(self.polyEditor);
self.mouseTool.close();
self.emitPolyEvent();
});
}
},
emitPolyEvent() {
let pathArr = this.polygon.getPath();
let resultArr = pathArr.map((item) => {
return [item.lng, item.lat];
});
this.polygonPath = resultArr;
this.$emit("onUpdateMapData", {
polygonPath: this.polygonPath,
});
console.log(resultArr.join("|"));
},
bindPolyEvent(polyEditor) {
const self = this;
polyEditor.on("addnode", function (event) {
console.log("触发事件:addnode");
self.emitPolyEvent();
});
polyEditor.on("adjust", function (event) {
console.log("触发事件:adjust");
self.emitPolyEvent();
});
polyEditor.on("removenode", function (event) {
console.log("触发事件:removenode");
self.emitPolyEvent();
});
polyEditor.on("end", function (event) {
console.log("触发事件: end");
self.emitPolyEvent();
// event.target 即为编辑后的多边形对象
});
},
transfer() {
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(() => {
const flag = new Date();
this.transferFlag = flag;
if (!this.geocoder) {
mapService.getGeocoder().then((gc) => {
this.geocoder = gc;
this.getAddress(flag);
});
} else {
this.getAddress(flag);
}
}, 500);
},
getAddress(flag) {
const lnglatXY = [this.form.lng, this.form.lat];
this.transferAddr = "";
this.geocoder.getAddress(lnglatXY, (status, result) => {
if (flag == this.transferFlag) {
if (status === "complete" && result.info === "OK") {
//获取地址成功
this.form.transferAddr = result.regeocode.formattedAddress;
this.$emit("onUpdateMapData", {
lng: this.form.lng,
lat: this.form.lat,
address: this.form.transferAddr,
radius: this.form.radius,
});
},
} else {
this.form.transferAddr = "";
}
}
});
},
components:{
FenceMapControll
}
}
},
components: {
FenceMapControll,
},
};
</script>
<style scoped>
.fence-map{
position: relative;
}
.fence-map .map-container{
width: 100%;
height: 500px;
}
.fence-map .map-seacrh-wrap{
position: absolute;
top: 40px;
left: 10px;
z-index: 1000;
}
.el-form-item{
margin: -20px 0 20px 10px;
}
.fence-map {
position: relative;
}
.fence-map .map-container {
width: 100%;
height: 500px;
}
.fence-map .map-seacrh-wrap {
position: absolute;
top: 40px;
left: 10px;
z-index: 1000;
}
.el-form-item {
margin: -20px 0 20px 10px;
}
</style>
<style lang="scss">
.context_menu{
min-width: 10em;
background-color: #fff;
padding: 10px;
border: 1px solid #efefef;
border-radius: 2px;
cursor: pointer;
&>p{
margin: 0;
i{
font-size: 18px;
color: #094;
margin-right: 5px;
}
i,span{
vertical-align: middle;
}
}
}
.context_menu {
min-width: 10em;
background-color: #fff;
padding: 10px;
border: 1px solid #efefef;
border-radius: 2px;
cursor: pointer;
& > p {
margin: 0;
i {
font-size: 18px;
color: #094;
margin-right: 5px;
}
i,
span {
vertical-align: middle;
}
}
}
</style>
\ No newline at end of file
<template>
<!-- 关联用户弹框 -->
<el-dialog id="userListModal" :visible="userListModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="1040px" top="8vh">
<div class="dialog-header" slot="title">
<h2 class="header-title">关联用户</h2>
</div>
<!-- 搜索区域 开始 -->
<el-form :model="form" :inline="true" size="mini" class="search_form">
<el-form-item label="用户查询" class="pull-left">
<el-input placeholder="请输入对应条件值" v-model="form.term" size="small" class="input-with-select" style="width:340px" maxlength="50" clearable>
<el-select v-model="form.termType" slot="prepend" style="width:100px;" placeholder="请选择" size="small">
<el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option>
<el-option label="工单号" value="4"></el-option>
</el-select>
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="search">查询</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small">高级搜索</el-button>
</el-form-item>
</el-form>
<!-- 搜索区域 end -->
<!-- 批量导入 开始 -->
<div class="links_group">
</div>
<!-- 批量导入 end -->
<el-row>
<el-col :span="12" class="choose-list-wrap">
<p class="right_title">结果列表</p>
<ul class="choose-list">
<li v-for="item in resultList" :key="item.vin">
<el-checkbox v-model="item.checked" @change="checkedChange(item)" class="choose-list-checkbox">
<div class="choose-list-content">
<p>{{item.name}}/{{item.vin}}</p>
<p class="choose-list-group">
<el-tag type="info" size="small" v-for="snItem in item.sns" :key="snItem">{{snItem}}</el-tag>
</p>
</div>
</el-checkbox>
</li>
<infinite-loading v-if="needInfinite" @infinite="infiniteHandler" ref="infiniteLoading">
<span slot="no-more">没有更多数据了</span>
<span slot="no-results">无结果</span>
</infinite-loading>
</ul>
<el-checkbox v-model="checkedAll">全选</el-checkbox>
<span class="pull-right">列表记录总数 {{total}} 条</span>
</el-col>
<el-col :span="12" class="choose-list-wrap">
<p class="right_title">
<span>已选列表</span>
<el-button type="primary" plain size="small" @click="groupImport">批量导入</el-button>
</p>
<ul class="choose-list">
<li v-for="item in chosenList" :key="item.vin">
<el-checkbox v-model="item.checked" @change="checkedChange(item)" class="choose-list-checkbox">
<div class="choose-list-content">
<p>{{item.name}}/{{item.vin}}</p>
<p class="choose-list-group">
<el-tag type="info" size="small" v-for="snItem in item.sns" :key="snItem">{{snItem}}</el-tag>
</p>
</div>
</el-checkbox>
</li>
</ul>
<el-checkbox v-model="checkedCancel">取消</el-checkbox>
<span class="pull-right">列表记录总数 {{chosenList.length}} 条</span>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="sure" size="small">确认</el-button>
<el-button @click="$emit('onUserListModalChange', false)" size="small">取消</el-button>
</div>
<!-- 批量导入弹框 -->
<user-list-import @exportDate="exportDate" v-if="userImportModalVisible" :userImportModalVisible="userImportModalVisible" @onUserImportModalChange="userImportModalChange" @onRefreshList="getData"></user-list-import>
<!-- 批量导入弹框 /-->
</el-dialog>
<!-- 关联用户弹框 /-->
</template>
<script>
import vVechicleSelect from "components/VechicleSelect.vue";
import userListImport from "./userListImport.vue";
import InfiniteLoading from "vue-infinite-loading";
import { GET_VEHICLE_LINKSNS } from "@/api/services/fence";
export default {
name: "UserList",
props: ["userListModalVisible", "userData", "init", "shopId"],
components: {
vVechicleSelect,
InfiniteLoading,
userListImport,
},
data() {
return {
form: {
term: "",
termType: "1",
sTime: "",
eTime: "",
},
dateType: "1",
dateRange: [],
orderStatus: "",
orderStatusOpts: [
{
name: "已提交",
value: 2,
},
{
name: "已派单",
value: 3,
},
{
name: "已激活",
value: 4,
},
{
name: "已退单",
value: 5,
},
{
name: "已拆除",
value: 6,
},
{
name: "已删除",
value: 7,
},
],
resultcheck: false,
gender: "",
resultItem: "",
highSearchVisible: false,
userImportModalVisible: false,
pageNumber: 1,
pageSize: 50,
total: 0,
maxPage: 1,
resultList: [],
chosenTotal: 0,
chosenList: [],
needInfinite: false,
groupId: "",
classIdList: "",
className: "",
tags: [],
checkedAll: false,
checkedCancel: false,
params: {},
};
},
mounted() {
console.log(this.userData);
this.search();
},
watch: {
dateRange(newVal) {
if (newVal && newVal.length) {
this.form.sTime = moment(newVal[0]).format("YYYY-MM-DD HH:mm:ss");
this.form.eTime = moment(newVal[1]).format("YYYY-MM-DD HH:mm:ss");
} else {
this.form.sTime = "";
this.form.eTime = "";
}
},
checkedCancel(newVal) {
if (newVal) {
this.chosenList.forEach((item) => {
item.checked = false;
item.sns = (item.sn && item.sn.split(",")) || [];
});
this.chosenList = [];
this.checkedAll = false;
}
},
init(newVal) {
if (newVal) {
this.reset();
this.$emit("onUserListInit", false);
}
},
checkedAll(newVal) {
if (newVal) {
this.resultList.forEach((item) => {
item.checked = true;
const findItem = this.chosenList.find((o) => o.vin === item.vin);
if (!findItem) {
this.chosenList.push(item);
}
});
this.checkedCancel = false;
} else {
this.resultList.forEach((item) => {
item.checked = false;
const findItem = this.chosenList.find((o) => o.vin === item.vin);
if (findItem) {
this.chosenList.splice(this.chosenList.indexOf(findItem), 1);
}
});
}
},
userData: {
handler: function (n, o) {
this.reset(n);
},
immediate: true,
},
},
methods: {
reset(date) {
this.userData = date;
this.checkedAll = false;
let arr = [];
this.userData.forEach((o) => {
o.checked = true;
o.sns = (o.sn && o.sn.split(",")) || [];
arr.push(o);
});
this.chosenList = arr;
},
sure() {
const userdata = [];
this.chosenList.forEach((obj) => {
if (obj.sns && obj.sns.length > 0) {
obj.sns.forEach((snsItem) => {
userdata.push({
sn: snsItem,
name: obj.name,
vin: obj.vin,
userTel: obj.userTel,
});
});
} else {
userdata.push({
sn: obj.sns,
name: obj.name,
vin: obj.vin,
userTel: obj.userTel,
});
}
});
this.$emit("onUpdateUserData", userdata);
this.$emit("onUserListModalChange", false);
},
search() {
this.resultList = [];
//this.chosenList = [];
this.pageNumber = 1;
this.needInfinite = false;
this.$nextTick(() => {
this.$refs.infiniteLoading &&
this.$refs.infiniteLoading.$emit("$InfiniteLoading:reset");
});
const params = this.params;
delete params.sn;
delete params.vin;
delete params.name;
delete params.workOrderNo;
let { term, termType } = this.form;
term = term.trim();
params.term = term;
params.termType = termType;
this.needInfinite = true;
},
highSearchSure() {
this.highSearchVisible = false;
this.tags = [];
this.params = this.getParams();
//this.needInfinite = true;
},
createTag(key, label, value) {
this.tags.push({
key: key,
name: label + ":" + value,
type: "",
});
},
checkedChange(item) {
if (item.checked) {
this.resultcheck = item.checked;
this.resultItem = item;
const findItem = this.chosenList.find((o) => o.sns === item.sns);
if (findItem) return;
this.chosenList.push(item);
this.checkedCancel = false;
} else {
this.chosenList.splice(this.chosenList.indexOf(item), 1);
}
},
exportDate(returnDate) {
var obj = {};
returnDate.map((obj) => {
if (obj.userTel) {
obj.sns = obj.sn.split(",");
} else {
obj.sns = [];
}
obj.checked = true;
});
console.log(returnDate);
for (var key in returnDate) {
returnDate;
obj = returnDate[key];
this.chosenList.push(obj);
this.resultcheck = true;
}
console.log(this.chosenList);
console.log(obj);
},
handleClose(tag) {
this.tags.splice(this.tags.indexOf(tag), 1);
switch (tag.key) {
case "activation":
delete this.params.activationSTime;
delete this.params.activationETime;
break;
case "expiration":
delete this.params.expirationSTime;
delete this.params.expirationETime;
break;
case "status":
delete this.params.businessStatus;
break;
case "sex":
delete this.params.sex;
break;
case "classIdList":
delete this.params.classIdList;
break;
}
},
getParams() {
const form = this.form;
const params = {};
if (form.sTime && form.eTime) {
if (this.dateType == "1") {
params.activationSTime = form.sTime;
params.activationETime = form.eTime;
this.createTag(
"activation",
"激活时间",
params.activationSTime + "至" + params.activationETime
);
} else if (this.dateType == "2") {
params.expirationSTime = form.sTime;
params.expirationETime = form.eTime;
this.createTag(
"expiration",
"到期时间",
params.expirationSTime + "至" + params.expirationETime
);
}
}
if (this.orderStatus) {
params.businessStatus = this.orderStatus;
const findItem = this.orderStatusOpts.find(
(obj) => obj.value == this.orderStatus
);
if (findItem) {
this.createTag("status", "业务工单状态", findItem.name);
}
}
if (this.gender) {
params.sex = this.gender;
this.createTag("sex", "性别", params.sex == "1" ? "男" : "女");
}
if (this.classIdList) {
params.classIdList = this.classIdList;
this.createTag("classIdList", "客户归属", this.className);
}
return params;
},
infiniteHandler($state) {
if (this.pageNumber > this.maxPage) {
$state.complete();
return;
}
this.params.pageNumber = this.pageNumber;
this.params.pageSize = this.pageSize;
this.params.shopId = this.shopId;
GET_VEHICLE_LINKSNS(this.params).then((res) => {
const { code, data, message } = res;
if (code == 200) {
const { list } = data;
if (list && list.length > 0) {
list.map((obj) => {
if (obj.sns) {
obj.sns = obj.sns.split(",");
} else {
obj.sns = [];
}
});
this.resultList = this.resultList.concat(list);
this.total = data.totalElements;
this.maxPage = data.totalPages;
this.pageNumber++;
$state.loaded();
} else {
$state.complete();
}
} else {
$state.complete();
}
});
},
// 打开批量导入
groupImport() {
this.userImportModalVisible = true;
},
// 关闭批量导入弹框
userImportModalChange() {
this.userImportModalVisible = false;
},
openDialog() {},
closeDialog() {
this.$emit("onUserListModalChange", false);
},
},
};
</script>
<style lang="scss" scoped>
h3 {
margin: 10px 0px;
}
p {
margin: 0px;
}
form.main-form {
height: 540px;
overflow: auto;
margin: -30px -20px;
padding: 20px;
}
form.detail-search-form {
padding: 20px 0px;
}
.popover-footer {
border-top: 1px solid #eee;
overflow: auto;
margin: -12px;
padding: 10px;
}
.popover-footer .el-button.pull-right {
margin-left: 10px;
}
.tab-content {
margin-top: 20px;
}
.tag-list {
width: 100%;
max-height: 90px;
overflow: auto;
margin: -10px 0px 0px -10px;
}
.tag-list .el-tag {
margin-left: 10px;
/* margin-top: 10px; */
}
.choose-list-wrap {
padding: 10px;
}
ul.choose-list {
height: 340px;
overflow: auto;
margin-bottom: 5px;
border: 1px solid #eee;
padding: 10px;
border-radius: 4px;
}
.choose-list-checkbox {
line-height: 30px;
margin: 0 5px;
}
.choose-list-content {
display: inline-block;
vertical-align: middle;
}
.choose-list-content p {
line-height: 30px;
}
.choose-list-group {
font-size: 0px;
}
.choose-list-content .el-tag {
font-size: 12px;
margin-right: 4px;
}
.right_title {
display: flex;
justify-content: space-between;
align-items: center;
height: 32px;
padding: 4px 0;
}
</style>
\ No newline at end of file
......@@ -147,7 +147,18 @@
</div>
<div class="filter-dialog-body">
<div class="monitor-list">
<el-tree ref="tree" :key="treeKey" :data="treeData" :props="treeProps" lazy :load="loadNode" show-checkbox node-key="id" :render-content="renderTreeContent" :default-expanded-keys="expandedKeys" :default-checked-keys="checkedKeys" @check="handleCheck" v-loading="treeLoading" @check-change="handleCheckChange">
<el-tree ref="tree" :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 }">
<div v-if="node.data.leaf">
<div>姓名:{{node.data.label1 || "--"}}</div>
<div>设备号:{{node.data.label||'--'}}</div>
<div>车架号:{{node.data.label2}}</div>
<div v-if="showMore(node,data)" @click="loadNext(node, data)">查看更多</div>
</div>
<span v-else>
{{node.data.label}}
</span>
</span>
</el-tree>
</div>
......@@ -173,6 +184,7 @@ const MONITOR_SERVICE = services.monitor;
import { CONSTANT } from "@/constant";
import MapControll from "./MapControll.vue";
import { exportExcel } from "@/utils";
import AMapLoader from "@amap/amap-jsapi-loader";
export default {
data() {
let checkFilename = (rule, vaule, cb) => {
......@@ -231,6 +243,7 @@ export default {
treeLoading: true,
currentMessage: "", //当前是否有提示语弹框
treeKey: "",
treeDataList: {}, // 缓存车辆
};
},
computed: {
......@@ -507,20 +520,27 @@ export default {
}
MONITOR_SERVICE.getVehicleTreeUserList(oParams).then(({ data }) => {
if (data.length) {
let arr = [];
data.map((item) => {
item.leaf = true;
});
return resolve(data);
}
if (data.length > 100) {
arr = data.slice(0, 100);
this.treeDataList[node.data.id] = { data: data, idx: 1 };
} else {
arr = data;
}
return resolve(arr);
}
return resolve([]);
});
return;
}
}
}
return resolve(nodeData);
let isArray = Array.isArray(nodeData);
return resolve(isArray?nodeData:[]);
if (node.level === 0) {
return resolve([{ name: "region1" }, { name: "region2" }]);
......@@ -1096,6 +1116,33 @@ export default {
this.expandedKeys = [];
this.checkedKeys = [];
},
// 展示更多
showMore(node,data) {
console.log(data)
console.log(node);
console.log(this.treeDataList)
let o = this.treeDataList['u' + data.parentId];
// 不存在
if(!o){
return false;
}
let len = o.data.length;
let curr = o.idx||1;
// 判断是否有下一页
if(len>curr*10){
return true
}else{
return false;
}
},
// 加载下一页
loadNext(node,data){
console.log(data)
}
},
created() {
if (window.AMap) {
......
......@@ -4,7 +4,7 @@
<el-form ref="form" :model="form" :inline="false" size="mini" v-show="!showResult">
<el-upload ref="upload" class="upload-wrap"
action="ecFence/importDeviceManage"
:action="IMPORT_ELECFENCE_LINKEDDEVICES"
:on-change="changeFile"
:before-upload="beforeUpload"
:multiple="false"
......@@ -49,7 +49,7 @@
</template>
<script>
import {exportExcel} from 'utils'
import {IMPORT_ELECFENCE_LINKEDDEVICES} from '@/api/services/fence'
export default{
props: ['userImportModalVisible'],
data(){
......@@ -63,7 +63,8 @@
seqNo: '',
importing: false,
filename: '',
flag:[]
flag:[],
IMPORT_ELECFENCE_LINKEDDEVICES
}
},
methods: {
......@@ -149,19 +150,17 @@
return false
},
downloadTpl(){
exportExcel('ecFence/downTemplates')
exportExcel('/ecFence/downTemplates')
},
openDialog(){
this.$emit('onUserImportModalChange', true)
},
closeDialog(){
this.$emit('onUserImportModalChange', false);
},
errorUpload(err){
window.location.href = '../ots/login';
//window.location.href = '../ots/login';
}
}
}
......
......@@ -34,6 +34,7 @@ const fence = () => import( /*webpackChunkName: "fence"*/ 'pages/monitor/fence.
const fenceManagement = () => import(/* webpackChunkName: "fenceManagement" */ 'pages/monitor/fenceManagement.vue');
const editFence = () => import(/* webpackChunkName: "editFence" */ 'pages/monitor/editFence.vue');
const addFence = () => import(/* webpackChunkName: "addFence" */ 'pages/monitor/addFence.vue');
const compareLocation = () => import(/* webpackChunkName: "compareLocation" */ 'pages/monitor/compareLocation.vue')
const userCarAdmin = () => import(/* webpackChunkName: "userCarAdmin" */ 'pages/business/userCarAdmin.vue');
......@@ -69,12 +70,12 @@ const routes = [
path: '/',
name: 'home',
icon: 'fa-home',
meta: {title:'首页'},
meta: { title: '首页' },
component: home
},
{
path: '/report',
meta: {title:'统计报表'},
meta: { title: '统计报表' },
icon: 'fa-bar-chart',
component: {
template: '<router-view></router-view>'
......@@ -82,115 +83,115 @@ const routes = [
children: [{
path: 'activeList',
name: 'activeList',
meta: {title:'设备激活'},
meta: { title: '设备激活' },
component: activeList
},
{
path: 'alarmList',
name: 'alarmList',
meta: {title:'围栏预警'},
meta: { title: '围栏预警' },
component: alarmList
},
{
path: 'outageAlarm',
name: 'outageAlarm',
meta: {title:'断电报警'},
meta: { title: '断电报警' },
notMenu: true,
component: outageAlarm
},
{
path: 'antiOffAlarm',
name: 'antiOffAlarm',
meta: {title:'防拆报警'},
meta: { title: '防拆报警' },
component: antiOffAlarm
},
{
path: 'lastLocation',
name: 'lastLocation',
meta: {title:'最后定位报表'},
meta: { title: '最后定位报表' },
component: lastLocation
},{
}, {
path: 'offlineReport',
name: 'offlineReport',
meta: {title:'离线报警'},
meta: { title: '离线报警' },
component: offlineReport
},{
}, {
path: 'shutdownReport',
name: 'shutdownReport',
meta: {title:'停驶报警'},
meta: { title: '停驶报警' },
component: shutdownReport
},{
}, {
path: 'speedAlarm',
name: 'speedAlarm',
meta: {title:'超速报警'},
meta: { title: '超速报警' },
component: speedAlarm
},{
}, {
path: 'singleDevice',
name: 'singleDevice',
meta: {title:'单个超速报警'},
meta: { title: '单个超速报警' },
component: singleDevice,
notMenu: true,
},{
}, {
path: 'mileageStatistics',
name: 'mileageStatistics',
meta: {title:'里程统计'},
meta: { title: '里程统计' },
component: mileageStatistics
},{
}, {
path: 'mileageMapModal',
name: 'mileageMapModal',
meta: {title:'单个里程统计'},
meta: { title: '单个里程统计' },
component: mileageMapModal,
notMenu: true,
},{
}, {
path: 'electricityStatistics',
name: 'electricityStatistics',
meta: {title:'电量统计'},
meta: { title: '电量统计' },
component: electricityStatistics
},{
}, {
path: 'alarmCenter',
name: 'alarmCenter',
meta: {title:'警情中心'},
meta: { title: '警情中心' },
component: alarmCenter
},{
}, {
path: 'alarmDispose',
name: 'alarmDispose',
meta: {title:'警情配置(广汽)'},
meta: { title: '警情配置(广汽)' },
component: alarmDispose
},{
}, {
path: 'alarmCore',
name: 'alarmCore',
meta: {title:'警情中心(广汽)'},
meta: { title: '警情中心(广汽)' },
component: alarmCore
},{
}, {
path: 'alarmDetail',
name: 'alarmDetail',
meta: {title:'警情中心/详情'},
meta: { title: '警情中心/详情' },
component: alarmDetail,
notMenu: true,
},{
}, {
path: 'alarmFocus',
name: 'alarmFocus',
meta: {title:'警情中心/我的关注'},
meta: { title: '警情中心/我的关注' },
component: alarmFocus,
notMenu: true,
},{
}, {
path: 'alarmIgnore',
name: 'alarmIgnore',
meta: {title:'警情中心/忽略的车辆'},
meta: { title: '警情中心/忽略的车辆' },
component: alarmIgnore,
notMenu: true,
},{
}, {
path: 'alarmLog',
name: 'alarmLog',
meta: {title:'警情中心/处理日志'},
meta: { title: '警情中心/处理日志' },
component: alarmLog,
notMenu: true,
}]
},
{
path: '/monitor',
meta: {title:'车辆监控'},
meta: { title: '车辆监控' },
icon: 'fa-car',
component: {
template: '<router-view></router-view>'
......@@ -198,68 +199,77 @@ const routes = [
children: [{
path: 'monitor',
name: 'monitor',
meta: {title:'车辆监控'},
meta: { title: '车辆监控' },
component: monitor
},
{
path: 'historyLocation',
name: 'historyLocation',
meta: {title:'历史停留'},
meta: { title: '历史停留' },
component: historyLocation,
notMenu: true,
},
{
path: 'replay',
name: 'replay',
meta: {title:'轨迹回放'},
meta: { title: '轨迹回放' },
component: replay,
notMenu: true,
},
{
path: 'resident',
name: 'resident',
meta: {title:'常驻地'},
meta: { title: '常驻地' },
component: resident,
notMenu: true,
},
{
path: 'fence',
name: 'fence',
meta: {title:'电子围栏'},
meta: { title: '电子围栏' },
component: fence,
notMenu: true,
},
{
path: 'fenceManagement',
name: 'fenceManagement',
meta: {title:'试驶线路管理'},
meta: { title: '试驶线路管理' },
component: fenceManagement
},
{
path: 'editFence',
name: 'editFence',
meta: {
title:'新增线路',
title: '新增线路',
pushState: true
},
component: editFence,
notMenu: true,
},{
path: 'addFence',
name: 'addFence',
meta: {
title: '新增围栏',
pushState: true
},
component: addFence,
notMenu: true,
}, {
path: 'compareLocation',
name: 'compareLocation',
meta: {title:'位置对比'},
meta: { title: '位置对比' },
component: compareLocation
},{
}, {
path: 'activeLocation',
name: 'activeLocation',
meta: {title:'设备激活位置'},
meta: { title: '设备激活位置' },
component: () => import('pages/monitor/activeLocation.vue'),
notMenu: true,
}]
},
{
path: '/business',
meta: {title:'业务管理'},
meta: { title: '业务管理' },
icon: 'fa-briefcase',
component: {
template: '<router-view></router-view>'
......@@ -267,7 +277,7 @@ const routes = [
children: [{
path: 'userCarAdmin',
name: 'userCarAdmin',
meta: {title:'车辆管理'},
meta: { title: '车辆管理' },
component: userCarAdmin
},
/*{
......@@ -279,34 +289,34 @@ const routes = [
{
path: 'workOrderAdmin',
name: 'workOrderAdmin',
meta: {title:'工单管理'},
meta: { title: '工单管理' },
component: workOrderAdmin
}, {
path: 'editOrderPage',
name: 'editOrderPage',
meta: {title: '编辑工单'},
meta: { title: '编辑工单' },
component: editOrderPage,
notMenu: true,
}, {
path: 'gqOrder',
name: 'gqOrder',
meta: {title:'工单管理(广汽)'},
meta: { title: '工单管理(广汽)' },
component: gqOrder
}, {
path: 'anjiAccount',
name: 'anjiAccount',
meta: {title:'对账管理(安吉)'},
meta: { title: '对账管理(安吉)' },
component: anjiAccount
}, {
path: 'gqReport',
name: 'gqReport',
meta: {title:'报表管理(广汽)'},
meta: { title: '报表管理(广汽)' },
component: gqReport
}]
},
{
path: '/device',
meta: {title:'设备管理'},
meta: { title: '设备管理' },
icon: 'fa-microchip',
component: {
template: '<router-view></router-view>'
......@@ -314,33 +324,33 @@ const routes = [
children: [{
path: 'deviceType',
name: 'deviceType',
meta: {title:'设备类型'},
meta: { title: '设备类型' },
component: deviceType
},{
}, {
path: 'deviceList',
name: 'deviceList',
meta: {title:'设备管理'},
meta: { title: '设备管理' },
component: deviceList
},{
}, {
path: 'deviceAdminList',
name: 'deviceAdminList',
meta: {title:'入库管理'},
meta: { title: '入库管理' },
component: deviceAdminList
},{
}, {
path: 'policyDeviceImport',
name: 'policyDeviceImport',
meta: {title:'保单设备导入'},
meta: { title: '保单设备导入' },
component: policyDeviceImport
},{
}, {
path: 'xfDeviceAdminList',
name: 'xfDeviceAdminList',
meta: {title:'先锋太盟设备管理'},
meta: { title: '先锋太盟设备管理' },
component: xfDeviceAdminList
}]
},
{
path: '/accounts',
meta: {title:'汇通分账'},
meta: { title: '汇通分账' },
icon: 'fa-cogs',
component: {
template: '<router-view></router-view>'
......@@ -348,19 +358,19 @@ const routes = [
children: [{
path: 'accountsList',
name: 'accountsList',
meta: {title:'汇通分账'},
meta: { title: '汇通分账' },
component: accountsList
}, {
path: 'accountsDetail',
name: 'accountsDetail',
meta: {title:'汇通分账详情'},
meta: { title: '汇通分账详情' },
component: accountsDetail,
notMenu: true
}]
},
{
path: '/stock',
meta: {title:'库存管理'},
meta: { title: '库存管理' },
icon: 'fa-cubes',
component: {
template: '<router-view></router-view>'
......@@ -368,18 +378,18 @@ const routes = [
children: [{
path: 'stockList',
name: 'stockList',
meta: {title:'库存信息'},
meta: { title: '库存信息' },
component: stockList,
}, {
path: 'stockDeviceList',
name: 'stockDeviceList',
meta: {title:'设备明细'},
meta: { title: '设备明细' },
component: stockDeviceList,
}]
},
{
path: '/system',
meta: {title:'系统管理'},
meta: { title: '系统管理' },
icon: 'fa-cogs',
component: {
template: '<router-view></router-view>'
......@@ -387,30 +397,30 @@ const routes = [
children: [{
path: 'personalInfo',
name: 'personalInfo',
meta: {title:'个人信息'},
meta: { title: '个人信息' },
component: personalInfo
}]
},
{
path: '/notice',
name: 'notice',
meta: {title:'系统公告'},
meta: { title: '系统公告' },
component: notice,
notMenu: true,
},
{
path: '/tool',
name: 'tool',
meta: {title:'工具'},
meta: { title: '工具' },
icon: 'fa-download',
component: tool
},
]
function getFullPath(arr, prefix=''){
return arr.map((item)=>{
function getFullPath(arr, prefix = '') {
return arr.map((item) => {
item.fullPath = `${prefix}${item.path}`
if(item.children && item.children.length){
if (item.children && item.children.length) {
let children = getFullPath([...item.children], `${item.path}/`)
return {
...item,
......@@ -421,7 +431,7 @@ function getFullPath(arr, prefix=''){
return {
...item,
url: item.fullPath,
title: item.meta&&item.meta.title,
title: item.meta && item.meta.title,
}
})
}
......@@ -429,26 +439,26 @@ function getFullPath(arr, prefix=''){
/* const _routes = getFullPath(routes)
console.log(JSON.stringify(_routes)) */
function filterRoutes(arr, path, initArr=[]){
function filterRoutes(arr, path, initArr = []) {
arr.reduce((prevArr, item)=>{
if(item.notMenu) {
arr.reduce((prevArr, item) => {
if (item.notMenu) {
initArr.push({
...item
})
}else{
if(path.indexOf(item.url)>-1){
if(item.children && item.children.length){
} else {
if (path.indexOf(item.url) > -1) {
if (item.children && item.children.length) {
initArr.push({
...item,
children: filterRoutes(item.children, path)
})
}else{
} else {
initArr.push({
...item
})
}
}
}
return initArr
......@@ -456,62 +466,62 @@ function filterRoutes(arr, path, initArr=[]){
return initArr
}
function getPathArr(arr, prevArr=[]){
return arr.reduce((prevArr, item)=>{
function getPathArr(arr, prevArr = []) {
return arr.reduce((prevArr, item) => {
prevArr.push(item.url)
if(item.children && item.children.length){
if (item.children && item.children.length) {
getPathArr(item.children, prevArr)
}
return prevArr
}, prevArr)
}
function filterMenuItems(arr, initArr=[]){
return arr.reduce((prevArr, item)=>{
if(!item.notMenu) {
if(item.children && item.children.length){
function filterMenuItems(arr, initArr = []) {
return arr.reduce((prevArr, item) => {
if (!item.notMenu) {
if (item.children && item.children.length) {
initArr.push({
...item,
children: filterMenuItems(item.children)
})
}else{
} else {
initArr.push({
...item
})
}
}
return initArr
}, initArr)
}
function getMenuItems(arr){
return arr.map((item)=>{
function getMenuItems(arr) {
return arr.map((item) => {
const _url = item.url.split('')
_url.shift()
let index = _url.join('')
if(item.children && item.children.length){
if (item.children && item.children.length) {
let children = getMenuItems([...item.children])
return {
index,
icon: item.icon,
title: item.meta&&item.meta.title,
title: item.meta && item.meta.title,
children,
}
}
return {
index,
icon: item.icon,
title: item.meta&&item.meta.title,
title: item.meta && item.meta.title,
}
})
}
function getFirstPath(arr){
function getFirstPath(arr) {
let _item = arr[0];
if(_item.children && _item.children.length){
if (_item.children && _item.children.length) {
return getFirstPath(_item.children)
}
return _item.url
......@@ -521,52 +531,52 @@ let firstPath = '/'
// router.beforeEach((to, from, next) => {
// document.title = '虎哥e盾|'+to.meta.title;
// if(store.getters.roleType === undefined){
// store.dispatch('getRoleInfo').then((data)=>{
// if(data && data.permission){
// const allPath = getPathArr(data.permission)
// const fullPathRoutes = getFullPath(routes)
// const allRoutes = filterRoutes(fullPathRoutes, allPath)
// const menuItems = getMenuItems(filterMenuItems([...allRoutes]))
// firstPath = getFirstPath(allRoutes)
// store.dispatch('setPermission', menuItems)
// router.addRoutes(allRoutes)
// }
// if(to.path === '/' && to.matched.length === 0){
// next({
// ...to,
// path: firstPath
// })
// return;
// }
// if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'})
// return;
// }
// next({...to})
// });
// }else{
// if(to.path === '/' && to.matched.length === 0){
// next({
// ...to,
// path: firstPath
// })
// return;
// }
// if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'})
// return;
// }
// next()
// }
// next();
// if(store.getters.roleType === undefined){
// store.dispatch('getRoleInfo').then((data)=>{
// if(data && data.permission){
// const allPath = getPathArr(data.permission)
// const fullPathRoutes = getFullPath(routes)
// const allRoutes = filterRoutes(fullPathRoutes, allPath)
// const menuItems = getMenuItems(filterMenuItems([...allRoutes]))
// firstPath = getFirstPath(allRoutes)
// store.dispatch('setPermission', menuItems)
// router.addRoutes(allRoutes)
// }
// if(to.path === '/' && to.matched.length === 0){
// next({
// ...to,
// path: firstPath
// })
// return;
// }
// if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'})
// return;
// }
// next({...to})
// });
// }else{
// if(to.path === '/' && to.matched.length === 0){
// next({
// ...to,
// path: firstPath
// })
// return;
// }
// if(store.getters.zlAccount && to.path === '/'){
// next({path: '/monitor/monitor'})
// return;
// }
// next()
// }
// next();
// })
export default routes
\ No newline at end of file
import EventBus from '../event-bus'
import EventBus from '@/event-bus'
import mapService from './mapService.js'
import MAPGEO from './mapgeo'
......@@ -7,36 +7,36 @@ const fence = {
polygons: [],
circle: null,
isEditMode: true,
bindEvent(){
EventBus.$on('uiMap.fence.drawDistrict', (data)=>{
bindEvent() {
EventBus.$on('uiMap.fence.drawDistrict', (data) => {
this.drawDistrict(data)
});
EventBus.$on('uiMap.fence.createFenceCircle', (data)=>{
if(('isEdit' in data)&&!data.isEdit){
EventBus.$on('uiMap.fence.createFenceCircle', (data) => {
if (('isEdit' in data) && !data.isEdit) {
this.isEditMode = false
}else{
} else {
this.isEditMode = true
}
this.createFenceCircle(data)
});
EventBus.$on('uiMap.fence.updateFenceRadius', (data)=>{
this.circle.setRadius(data*1);
EventBus.$on('uiMap.fence.updateFenceRadius', (data) => {
this.circle.setRadius(data * 1);
mapService.setFitView()
});
EventBus.$on('uiMap.fence.createFenceMarker', (data)=>{
EventBus.$on('uiMap.fence.createFenceMarker', (data) => {
this.createFenceMarker(data)
});
EventBus.$on('uiMap.fence.drawPolygon', (data)=>{
if(data){
if(Array.isArray(data)){
EventBus.$on('uiMap.fence.drawPolygon', (data) => {
if (data) {
if (Array.isArray(data)) {
this.polygonPath = data;
this.isEditMode = true;
}else if(('isEdit' in data)&&!data.isEdit){
} else if (('isEdit' in data) && !data.isEdit) {
this.polygonPath = data.path;
this.isEditMode = false;
}
......@@ -44,43 +44,63 @@ const fence = {
this.drawPolygon()
});
EventBus.$on('uiMap.fence.destroy', (data)=>{
EventBus.$on('uiMap.fence.destroy', (data) => {
this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close()
});
},
destroy(){
destroy() {
const MAP = mapService.map;
this.polygons && MAP.remove(this.polygons);
this.circle && MAP.remove(this.circle);
this.circleEditor && this.circleEditor.close();//MAP.remove(this.circleEditor);
this.polygons = [];
this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close()
this.polygon && MAP.remove(this.polygon)
this.clearTimeoutIds();
if (MAP) {
this.polygons && MAP.remove(this.polygons);
this.circle && MAP.remove(this.circle);
this.circleEditor && this.circleEditor.close();//MAP.remove(this.circleEditor);
this.polygons = [];
this.polyEditor && this.polyEditor.close()
this.mouseTool && this.mouseTool.close()
this.polygon && MAP.remove(this.polygon)
}
//this.clearTimeoutIds();
},
drawDistrict(data){
// 行政区域
drawDistrict(data) {
if (!data || data.length <= 0) {
return false;
}
const MAP = mapService.map;
this.destroy();
var opts = {
subdistrict: 1, //返回下一级行政区
subdistrict: 0, //返回下一级行政区
extensions: 'all',
showbiz:false //最后一级返回街道信息
showbiz: false //最后一级返回街道信息
};
data == "中国"?delete opts.extensions :delete opts.showbiz;
let oParams = data[data.length - 1];
//data == "中国" ? delete opts.extensions : delete opts.showbiz;
let district = new AMap.DistrictSearch(opts);
district.setLevel('district');
EventBus.$emit('uiMap.fence.loading', true);
switch (data.length) {
case 1:
district.setLevel('province');
break;
case 2:
district.setLevel('city');
break;
default:
district.setLevel('district');
break;
}
//EventBus.$emit('uiMap.fence.loading', true);
//行政区查询
district.search(data.toString(), function(status, result) {
district.search(oParams, function (status, result) {
console.log(result)
const dst = result.districtList[0];
var bounds = dst.boundaries;
let lng = dst.center.lng;
let lat = dst.center.lat;
if (bounds) {
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
//生成行政区划polygon
var polygon = new AMap.Polygon({
......@@ -90,98 +110,87 @@ const fence = {
fillOpacity: 0.7,
fillColor: '#CCF3FF',
strokeColor: '#CC66CC',
});
fence.polygons.push(polygon);
}
let center = mapService.getLngLat(lng,lat);
}
let center = mapService.getLngLat(lng, lat);
mapService.setFitView();
EventBus.$emit('uiMap.fence.loading', false);
//EventBus.$emit('uiMap.fence.loading', false);
}
});
},
createFenceCircle(data){
createFenceCircle(data) {
const MAP = mapService.map;
//this.destroy();
this.destroy();
this.circle = new AMap.Circle({
map: MAP,
center: mapService.getLngLat(data.lng, data.lat),
radius: data.radius*1,
radius: data.radius * 1,
strokeColor: "#F33",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "ee2200",
fillOpacity: 0.35,
zIndex: 0,
});
this.circleEditor = new AMap.CircleEditor(MAP, this.circle);
AMap.event.addListener(this.circleEditor, 'adjust', (e)=>{
EventBus.$emit('uiMap.fence.onFenceRadiusChange', e.radius/1)
/*this.form.radius = e.radius/1;
this.$emit('onUpdateMapData',{
lng: this.form.lng,
lat: this.form.lat,
address: this.form.transferAddr,
radius: this.form.radius
});*/
//this.$refs.fenceMapForm.validateField('radius');
});
AMap.event.addListener(this.circleEditor, 'move', (e)=>{
this.circleEditor = new AMap.CircleEditor(MAP, this.circle);
this.circleEditor.on('adjust', function (e) {
//log.info('触发事件:adjust')
EventBus.$emit('uiMap.fence.onFenceRadiusChange', e.radius / 1)
})
this.circleEditor.on('move', function (e) {
EventBus.$emit('uiMap.fence.onFenceLngLatChange', {
lng: e.lnglat.lng,
lat: e.lnglat.lat
});
});
if(this.isEditMode){
this.circleEditor.open();
}else{
this.circleEditor.close();
})
if (this.isEditMode) {
this.circleEditor.open();
} else {
this.circleEditor.close();
}
mapService.setFitView()
MAP.setZoom(14);
},
createFenceMarker(data){
createFenceMarker(data) {
this.data = [{
elng: data.lngGPS,
elat: data.latGPS
}];
if(data.lngBase && data.latBase){
if (data.lngBase && data.latBase) {
this.data.push({
elng: data.lngBase,
elat: data.latBase
});
}
const MAP = mapService.map;
MAPGEO.transferAddressByGroup(this, ()=>{
data.transferAddressGPS = this.data[0].transferAddress;
if(this.data.length > 1){
data.transferAddressBase = this.data[1].transferAddress;
}
let marker = mapService.createCarMarker([data.lngGPS, data.latGPS], MAP);
let infoWindow = mapService.bindFenceInfoWindow(marker, MAP, data);
});
//MAPGEO.transferAddressByGroup(this, ()=>{
//data.transferAddressGPS = this.data[0].transferAddress;
// if(this.data.length > 1){
// 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;
//this.destroy();
this.destroy();
if(this.polygonPath.length){
if (this.polygonPath.length) {
self.polygon = new AMap.Polygon({
path: this.polygonPath,
strokeColor: "#FF33FF",
strokeColor: "#FF33FF",
strokeWeight: 6,
strokeOpacity: 0.2,
fillOpacity: 0.4,
......@@ -190,21 +199,21 @@ const fence = {
})
MAP.add(self.polygon)
MAP.setFitView([ self.polygon ])
MAP.setFitView([self.polygon])
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
if(self.isEditMode){
if (self.isEditMode) {
self.polyEditor.open()
}else{
} else {
self.polyEditor.close()
}
self.bindPolyEvent(self.polyEditor)
}else if(self.isEditMode){
} else if (self.isEditMode) {
self.mouseTool = new AMap.MouseTool(MAP)
self.mouseTool.polygon({
strokeColor: "#FF33FF",
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
......@@ -216,7 +225,7 @@ const fence = {
// strokeDasharray: [30,10],
})
self.mouseTool.on('draw', function(event) {
self.mouseTool.on('draw', function (event) {
// event.obj 为绘制出来的覆盖物对象
self.polygon = event.obj;
self.polyEditor = new AMap.PolyEditor(MAP, self.polygon)
......@@ -227,46 +236,46 @@ const fence = {
})
}
},
bindPolyEvent(polyEditor){
bindPolyEvent(polyEditor) {
const self = this
polyEditor.on('addnode', function(event) {
polyEditor.on('addnode', function (event) {
console.log('触发事件:addnode')
self.emitPolyEvent()
})
polyEditor.on('adjust', function(event) {
polyEditor.on('adjust', function (event) {
console.log('触发事件:adjust')
self.emitPolyEvent()
})
polyEditor.on('removenode', function(event) {
polyEditor.on('removenode', function (event) {
console.log('触发事件:removenode')
self.emitPolyEvent()
})
polyEditor.on('end', function(event) {
polyEditor.on('end', function (event) {
console.log('触发事件: end')
self.emitPolyEvent()
// event.target 即为编辑后的多边形对象
})
},
emitPolyEvent(){
emitPolyEvent() {
let pathArr = this.polygon.getPath()
let resultArr = pathArr.map((item)=>{
let resultArr = pathArr.map((item) => {
return [item.lng, item.lat]
})
this.polygonPath = resultArr
EventBus.$emit('uiMap.fence.polygonChange',{
EventBus.$emit('uiMap.fence.polygonChange', {
polygonPath: this.polygonPath
});
console.log(resultArr.join('|'))
},
clearTimeoutIds(){
this.timeoutIds && this.timeoutIds.forEach((item)=>{
clearTimeoutIds() {
this.timeoutIds && this.timeoutIds.forEach((item) => {
item && window.clearTimeout(item);
});
this.timeoutIds = []
......
......@@ -3,48 +3,50 @@ window.ClipboardJS = ClipboardJS
import EventBus from '../event-bus'
import { Message } from "element-ui";
import store from '../vuex/store.js'
EventBus.$on('uiMap.copySuccess', (data)=>{
import vue from 'vue'
EventBus.$on('uiMap.copySuccess', (data) => {
Message({
type: 'success',
message: '已复制内容至粘贴板'
type: 'success',
message: '已复制内容至粘贴板'
});
});
function MapService(){
function MapService() {
this.map = null;
this.restainLayer = null;
}
var zhongliType = sessionStorage.getItem('zhongliType');//获取是否仲利账号状态,从本地内存中拿取数据
MapService.prototype = {
init: function(id){
init: function (id) {
var self = this;
self.map = new AMap.Map(id, {
resizeEnable: true,
zoom: 11
});
//距离测量
self.map.plugin(["AMap.RangingTool"],function(){
self.ruler = new AMap.RangingTool(self.map);
self.map.plugin(["AMap.RangingTool"], function () {
self.ruler = new AMap.RangingTool(self.map);
});
//定位
self.map.plugin('AMap.Geolocation', function(){
self.map.plugin('AMap.Geolocation', function () {
self.geolocation = new AMap.Geolocation();
});
return self.map;
},
toggleMapType: function(){
toggleMapType: function () {
var self = this;
self.type = self.type?0:1; //0:使用2D地图,1:混合图
self.type = self.type ? 0 : 1; //0:使用2D地图,1:混合图
if(self.type === 1){
if (self.type === 1) {
// 构造官方卫星、路网图层
self.mixLayers = [
self.mixLayers = [
new AMap.TileLayer.Satellite(),
new AMap.TileLayer.RoadNet()
];
......@@ -52,7 +54,7 @@ MapService.prototype = {
let layers = self.mixLayers.concat(self.map.getLayers());
// 地图上设置图层
self.map.setLayers(layers);
}else{
} else {
// 地图上设置图层
self.map.remove(self.mixLayers);
/*self.map.plugin(["AMap.MapType"],function(){
......@@ -64,69 +66,69 @@ MapService.prototype = {
});*/
}
},
rulerTurnOn: function(){
rulerTurnOn: function () {
this.ruler.turnOn();
},
rulerTurnOff: function(){
rulerTurnOff: function () {
this.ruler.turnOff();
},
getCurrentLocation: function(){
getCurrentLocation: function () {
var self = this;
self.geolocation.getCurrentPosition();
self.currentMarker && self.map.remove(self.currentMarker);
AMap.event.addListener(self.geolocation, 'complete', function(e){//返回定位信息
AMap.event.addListener(self.geolocation, 'complete', function (e) {//返回定位信息
var lnglatXY = self.getLngLat(e.position.lng, e.position.lat);
self.currentMarker = self.createMarker(lnglatXY);
//self.map.setCenter(lnglatXY);
self.setFitView()
});
AMap.event.addListener(self.geolocation, 'error', function(e){//返回定位出错信息
AMap.event.addListener(self.geolocation, 'error', function (e) {//返回定位出错信息
});
});
},
createMarker: function (lnglatXY){
createMarker: function (lnglatXY) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/mapLocation.gif'),
map: this.map,
offset: new AMap.Pixel(-12,-12)
offset: new AMap.Pixel(-12, -12)
});
return marker;
},
createPointMarker: function (lnglatXY){
createPointMarker: function (lnglatXY) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/point.png'),
map: this.map,
offset: new AMap.Pixel(-9,-9)
offset: new AMap.Pixel(-9, -9)
});
return marker;
},
createConstantMarker: function (lnglatXY, map){
createConstantMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_constant.png'),
map: map,
offset: new AMap.Pixel(-12,-17)
offset: new AMap.Pixel(-12, -17)
});
return marker;
},
createCarMarker: function (lnglatXY, map){
createCarMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_car.png'),
map: map,
autoRotation: true,
offset: new AMap.Pixel(-18,-11),
offset: new AMap.Pixel(-18, -11),
zIndex: 1020,
animation: 'AMAP_ANIMATION_DROP'
});
return marker;
},
createPOIMarker(lnglatXY, map){
createPOIMarker(lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
content:`<span class="poi_marker"></span>`,
content: `<span class="poi_marker"></span>`,
//icon: require('images/poi-marker-default.png'),
map: map,
autoRotation: true,
......@@ -136,8 +138,8 @@ MapService.prototype = {
});
return marker;
},
createPOIInfo(info){
return `<div class="poi_infowin">
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>
......@@ -146,10 +148,10 @@ MapService.prototype = {
<p class="poi_item"><label>解析地址:</label><span>${info.address}</span>
</div></div>`
},
bindPOIInfoWindow(marker, map, info){
bindPOIInfoWindow(marker, map, info) {
var infoDiv = document.createElement('div');
infoDiv.innerHTML = this.createPOIInfo(info);
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, -48),
content: infoDiv,
......@@ -157,59 +159,59 @@ MapService.prototype = {
});
marker.infoWindow = infoWindow;
marker.on('click', markerClick);
function markerClick(e){
function markerClick(e) {
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition());
}
return infoWindow;
},
setAlarmIcon(marker){
setAlarmIcon(marker) {
marker.setIcon(require('images/icon_car_alarm.png'))
},
setDefaultIcon(marker){
setDefaultIcon(marker) {
marker.setIcon(require('images/icon_car.png'))
},
createHistoryLocationMarker(lnglatXY, map){
createHistoryLocationMarker(lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_location.png'),
map: map,
autoRotation: true,
offset: new AMap.Pixel(-12,-17),
offset: new AMap.Pixel(-12, -17),
zIndex: 1020,
animation: 'AMAP_ANIMATION_DROP'
});
return marker;
},
createStartMarker: function(lnglatXY, map){
createStartMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_start.png'),
map: map,
offset: new AMap.Pixel(-12,-34),
offset: new AMap.Pixel(-12, -34),
zIndex: 100
});
return marker;
},
createEndMarker: function(lnglatXY, map){
createEndMarker: function (lnglatXY, map) {
var marker = new AMap.Marker({
position: lnglatXY,
icon: require('images/icon_end.png'),
map: map,
offset: new AMap.Pixel(-12,-34),
offset: new AMap.Pixel(-12, -34),
zIndex: 101
});
return marker;
},
createPolyline: function(map){
createPolyline: function (map) {
return new AMap.Polyline({
map: map,
strokeWeight: 2,
strokeColor: '#009944'
});
},
createCircle: function(lnglatXY, map, radius){
createCircle: function (lnglatXY, map, radius) {
return new AMap.Circle({
map: map,
center: lnglatXY,
......@@ -221,7 +223,7 @@ MapService.prototype = {
fillOpacity: 0.1
});
},
createPoint: function(lnglatXY, map){
createPoint: function (lnglatXY, map) {
return new AMap.Circle({
map: map,
center: lnglatXY,
......@@ -233,7 +235,7 @@ MapService.prototype = {
fillOpacity: 1
});
},
createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove){
createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, 0),
content: div,
......@@ -241,29 +243,31 @@ MapService.prototype = {
});
marker.infoWindow = infoWindow;
var clipboard = new ClipboardJS(div.querySelector('.copy-btn'));
clipboard.on('success', function(e) {
clipboard.on('success', function (e) {
e.clearSelection();
EventBus.$emit('uiMap.copySuccess');
});
clipboard.on('error', function(e) {
clipboard.on('error', function (e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
if(isInfoOpen){
if (isInfoOpen) {
infoWindow.open(map, marker.getPosition());
}
//给Marker绑定单击事件
marker.on('click', markerClick);
function markerClick(e){
function markerClick(e) {
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition());
}
return infoWindow;
},
bindMonitorInfoWindow: function(marker, map, info, isInfoOpen, isInfoAutoMove){
// 车辆监控-查看位置点
bindMonitorInfoWindow: function (marker, map, info, isInfoOpen, isInfoAutoMove) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createMonitorInfo(info);
......@@ -271,41 +275,43 @@ MapService.prototype = {
let eLocation = info[info.eLocateType];
var statusArr = ['行驶中', '静止', '离线', '在线']
if(info.status === 2){
if (info.status === 2) {
infoDiv.querySelector('[data-status]').textContent = `${statusArr[info.status]} | 已离线${info.statusTime}`;
}else{
} else {
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
}
infoDiv.querySelector('[data-time]').textContent = eLocation.dateTime;
infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
infoDiv.querySelector('[data-clipboard-text').setAttribute('data-clipboard-text', eLocation.transferAddress);
if(info.battery){
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{
} 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');
//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');
} else {
gpsBtn && gpsBtn.classList.add('el-button--primary');
baseBtn && baseBtn.classList.remove('el-button--primary');
}
baseBtn&&(baseBtn.onclick = function(e){console.log(info)
if(info.eLocateType === 'bsLocation') return;
baseBtn && (baseBtn.onclick = function (e) {
console.log(info)
if (info.eLocateType === 'bsLocation') return;
info.eLocateType = 'bsLocation'
eLocation = info[info.eLocateType];
if(!eLocation.elng || !eLocation.elat) {
if (!eLocation.elng || !eLocation.elat) {
Message({
type: 'info',
message: '暂无基站数据'
......@@ -321,11 +327,11 @@ MapService.prototype = {
EventBus.$emit('uiMap.monitor.drawDone');
})
gpsBtn&&(gpsBtn.onclick = function(e){
if(info.eLocateType === 'gpsLocation') return;
gpsBtn && (gpsBtn.onclick = function (e) {
if (info.eLocateType === 'gpsLocation') return;
info.eLocateType = 'gpsLocation'
eLocation = info[info.eLocateType];
if(!eLocation.elng || !eLocation.elat) {
if (!eLocation.elng || !eLocation.elat) {
Message({
type: 'info',
message: '暂无GPS数据'
......@@ -341,20 +347,20 @@ MapService.prototype = {
EventBus.$emit('uiMap.monitor.drawDone');
})
wifiBtn&&(wifiBtn.onclick = function(e){
wifiBtn && (wifiBtn.onclick = function (e) {
//infoDiv.querySelector('[data-transferAddress]').textContent = eLocation.transferAddress;
//infoDiv.querySelector('[data-time]').textContent = eLocation.time;
EventBus.$emit('uiMap.monitor.wifiLocate', {info, infoDiv, gpsBtn, baseBtn, wifiBtn})
EventBus.$emit('uiMap.monitor.wifiLocate', { info, infoDiv, gpsBtn, baseBtn, wifiBtn })
})
if(info.alarmTypeSet && info.alarmTypeSet.length){
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>`
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;
......@@ -370,12 +376,48 @@ MapService.prototype = {
window.open(`#/report/antiOffAlarm?type=99&time=${e.target.dataset.alarmtime}&sn=${info.sn}`)
}
} */
infoDiv.querySelector('[data-alarm]').style.display = 'block';
}else{
} else {
infoDiv.querySelector('[data-alarm]').style.display = 'none';
}
// 通用参数
let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`;
// 跳转到历史停留页面
let historyBtn = infoDiv.querySelector('[data-history]');
if (historyBtn) {
historyBtn.onclick = function () {
mapService.openPage(`#/monitor/historyLocation?${queryCode}`)
}
}
// 跳转到常住地
let residentBtn = infoDiv.querySelector('[data-resident]');
if (residentBtn) {
residentBtn.onclick = function () {
mapService.openPage(`#/monitor/resident?${queryCode}`)
}
}
// 跳转到轨迹回放页面
let replayBtn = infoDiv.querySelector('[data-replay]');
if (replayBtn) {
replayBtn.onclick = function () {
mapService.openPage(`#/monitor/replay?${queryCode}`)
}
}
// 跳转到轨迹回放页面
let fenceBtn = infoDiv.querySelector('[data-fence]');
if (fenceBtn) {
fenceBtn.onclick = function () {
mapService.openPage(`#/monitor/fence?${queryCode}`)
}
}
console.log(historyBtn)
const snSourceType = `${info.sn}:${info.isSource}`
/* EventBus.$on(`uiMap.monitor.changeStatus.${snSourceType}`, (status)=>{
if(status === 2){
......@@ -387,28 +429,28 @@ MapService.prototype = {
return this.createInfoWindow(marker, map, infoDiv, isInfoOpen, isInfoAutoMove);
},
bindLocationInfoWindow(marker, map, info){
bindLocationInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createLocationInfo(info);
return this.createInfoWindow(marker, map, infoDiv);
},
bindResidentInfoWindow(marker, map, info){
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){
bindFenceInfoWindow(marker, map, info) {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createFenceInfo(info);
var statusArr = ['行驶中', '静止', '离线', '在线'];
function fillGPS(){
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);
......@@ -418,7 +460,7 @@ MapService.prototype = {
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
function fillBase(){
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);
......@@ -427,34 +469,34 @@ MapService.prototype = {
marker.setPosition(self.getLngLat(info.lngBase, info.latBase));
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
infoDiv.querySelector('[data-status]').textContent = statusArr[info.status];
if(info.battery){
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{
} else {
infoDiv.querySelector('[data-battery]').classList.add('hide');
}
infoDiv.querySelector('#locateTypeGps').onclick = function(e){
infoDiv.querySelector('#locateTypeGps').onclick = function (e) {
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function(e){
infoDiv.querySelector('#locateTypeBase').onclick = function (e) {
fillBase()
}
fillGPS();
return this.createInfoWindow(marker, map, infoDiv);
},
getLngLat: function(lng, lat){
getLngLat: function (lng, lat) {
return new AMap.LngLat(lng, lat);
},
getGeocoder: function(){
return new Promise((resolve)=>{
AMap.service('AMap.Geocoder',function(){//回调函数
getGeocoder: function () {
return new Promise((resolve) => {
AMap.service('AMap.Geocoder', function () {//回调函数
var geocoder = new AMap.Geocoder({
batch: true
});
......@@ -462,23 +504,23 @@ MapService.prototype = {
});
})
},
getAddress: function(geocoder, lnglatXY){
geocoder.getAddress(lnglatXY, function(status, result) {
getAddress: function (geocoder, lnglatXY) {
geocoder.getAddress(lnglatXY, function (status, result) {
if (status === 'complete' && result.info === 'OK') {
//获得了有效的地址信息:
//即,result.regeocode.formattedAddress
}else{
//获取地址失败
//获得了有效的地址信息:
//即,result.regeocode.formattedAddress
} else {
//获取地址失败
}
});
},
zoomIn: function(){
zoomIn: function () {
this.map.zoomIn();
},
zoomOut: function(){
zoomOut: function () {
this.map.zoomOut();
},
createMonitorInfo: function(info){
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>';
......@@ -486,27 +528,43 @@ MapService.prototype = {
_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 = `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>`;
_html += `<div class="map-infowindow-ct">`;
var _html = `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>`;
_html += `<div class="map-infowindow-ct map_info_window">`;
console.log(zhongliType);
if(zhongliType == 'yes'){
if (zhongliType == 'yes') {
_html += `<div>`;
if(info.shopName){
if (info.shopName) {
_html += `<p><i class="icon icon-icon_store"></i> 店面名称: <span class="des">${info.shopName}</span></p>`;
}
if(info.shopContacts){
if (info.shopContacts) {
_html += `<p style="margin-left:29px;"> 店面联系人: <span class="des">${info.shopContacts}</span></p>`;
}
if(info.contactsPhone){
if (info.contactsPhone) {
_html += `<p style="margin-left:29px;"> 联系方式: <span class="des">${info.contactsPhone}</span></p>`;
}
if(info.idnum) {
if (info.idnum) {
_html += `<p style="margin-left:29px;"> 车牌号: <span class="des">${info.idnum}</span></p>`;
}
_html += `</div>`;
}
_html += `<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${info.sn} (${info.isSource==='1'?'有线':'无线'})</span>
// 根据权限-显示店面名称、车牌号
let list = vue.prototype.$parentCommon.getAuthData();
let o = list.find(k => k.origin.permissionTag == 'oEshield_monitor_store_name');
let n = list.find(k => k.origin.permissionTag == 'oEshield_monitor_plate_number');
console.log(list)
if (o && info.shopName) {
_html += `<p><i class="icon-info_shop"></i> 店面名称: <span class="des">${info.shopName || '--'}</span></p>`;
}
if (n && info.licensePlate) {
_html += `<p><i class="icon-info_plate"></i>车牌号: <span class="des">${info.licensePlate || '--'}</span></p>`;
}
_html += `<p><i class="icon icon-info_device"></i> 设备号:<span class="des"> ${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>
......@@ -523,42 +581,42 @@ MapService.prototype = {
<a class="copy-btn" data-clipboard-text=""><i class="icon icon-info_copy"></i></a>
</p>
<p><i class="icon icon-info_type"></i> 定位类型:
${info.wifiLocation?
(info.eLocateSingle?
(info.eLocateType==='gpsLocation'?
`<span class="el-button-group">
${info.wifiLocation ?
(info.eLocateSingle ?
(info.eLocateType === 'gpsLocation' ?
`<span class="el-button-group">
<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button>
<button type="button" class="el-button el-button--mini" data-wifi>wifi</button>
</span>`:
`<span class="el-button-group">
`<span class="el-button-group">
<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button>
<button type="button" class="el-button el-button--mini" data-wifi>wifi</button>
</span>`
):
`<span class="el-button-group">
) :
`<span class="el-button-group">
<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button>
<button type="button" class="el-button el-button--mini" data-base>基站</button>
<button type="button" class="el-button el-button--mini" data-wifi>wifi</button>
</span>`
):
info.eLocateSingle?
(info.eLocateType==='gpsLocation'?`<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button> `:
`<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button>`):
`<span class="el-button-group">
) :
info.eLocateSingle ?
(info.eLocateType === 'gpsLocation' ? `<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button> ` :
`<button type="button" class="el-button el-button--mini el-button--primary" data-base>基站</button>`) :
`<span class="el-button-group">
<button type="button" class="el-button el-button--mini el-button--primary" data-gps>GPS</button>
<button type="button" class="el-button el-button--mini" data-base>基站</button>
</span>`
}
}
</p>
<p class="redirect-row">
<a class="redirect-btn" onclick="window.open('#/monitor/historyLocation?${queryCode}')" style="display:none;">历史停留</a>
<a class="redirect-btn" onclick="window.open('#/monitor/resident?${queryCode}')" style="display:none;">常驻地</a>
<a class="redirect-btn" onclick="location.href='oEshield#/monitor/replay?${queryCode}'">轨迹回放</a>
<a class="redirect-btn" onclick="window.open('#/monitor/fence?${queryCode}')" style="display:none;">电子围栏</a>
<a class="redirect-btn" id="monitor_btn_history" data-history>历史停留</a>
<a class="redirect-btn" id="btn_resident" data-resident>常驻地</a>
<a class="redirect-btn" id="btn_replay" data-replay>轨迹回放</a>
<a class="redirect-btn" id="btn_fence" data-fence>电子围栏</a>
</p>
</div>`;
// return `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>
// <div class="map-infowindow-ct">
// <div v-show="zhongliType">
......@@ -574,7 +632,7 @@ MapService.prototype = {
// </span></p>
// <p><i class="icon icon-info_device_status"></i> 设备状态: <span class="des" data-status></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>
......@@ -619,7 +677,7 @@ MapService.prototype = {
// </div>`;
return _html;
},
createFenceInfo(info){
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>
......@@ -641,7 +699,7 @@ MapService.prototype = {
</p>
</div>`;
},
createLocationInfo(info){
createLocationInfo(info) {
return `<h3 class="map-infowindow-title">${info.name}/${info.standno}</h3>
<div class="map-infowindow-ct">
<p><i class="icon icon-info_time"></i> 停留时间: <span class="des">${info.begintime}</span></p>
......@@ -651,7 +709,7 @@ MapService.prototype = {
<p><i class="icon icon-info_stop"></i> 停留时长: <span class="des">${info.duration}</span></p>
</div>`;
},
createResidentInfo(info){
createResidentInfo(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}</span></p>
......@@ -662,107 +720,115 @@ MapService.prototype = {
<p><i class="icon icon-info_stop"></i> 驻留时长: <span class="des">${info.totalDurationString}</span></p>
</div>`;
},
clearMap: function(map){
clearMap: function (map) {
this.map.clearMap();
},
setFitView: function(map){
setFitView: function (map) {
this.map.setFitView();
},
bindClickEvent(){
bindClickEvent() {
},
// 创建位置点弹框
createActiveInfo(info) {
let msg = '报警'
// 激活
if(info.type == 1){
msg = '激活'
}
createActiveInfo(info) {
let msg = '报警'
// 激活
if (info.type == 1) {
msg = '激活'
}
// 定位
if(info.type == 2){
msg = '定位'
}
// 定位
if (info.type == 2) {
msg = '定位'
}
return `<h3 class="map-infowindow-title">${info.name||'--'}/${info.standNo||'--'}</h3>
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.source == 1?'有线':'无线'})</span></p>
<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>
<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());
}
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());
}
// 基站位置信息
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));
self.setFitView()
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
// 基站位置信息
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));
self.setFitView()
marker.infoWindow && marker.infoWindow.open(map, marker.getPosition());
}
infoDiv.querySelector('#locateTypeGps').onclick = function(e){
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function(e){
fillBase()
}
infoDiv.querySelector('#locateTypeGps').onclick = function (e) {
fillGPS()
}
infoDiv.querySelector('#locateTypeBase').onclick = function (e) {
fillBase()
}
if(info.lng){
fillGPS()
}
if (info.lng) {
fillGPS()
}
if(!info.lng && info.bsLng){
fillBase()
}
if (!info.lng && info.bsLng) {
fillBase()
}
return this.createActiveInfoWindow(marker, map, infoDiv)
},
// 创建位置点弹框
createActiveInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, 0),
content: div,
autoMove: !!isInfoAutoMove,
})
console.log(infoWindow)
marker.infoWindow = infoWindow
if (isInfoOpen) {
infoWindow.open(map, marker.getPosition())
}
return this.createActiveInfoWindow(marker, map, infoDiv)
},
// 创建位置点弹框
createActiveInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, 0),
content: div,
autoMove: !!isInfoAutoMove,
})
console.log(infoWindow)
marker.infoWindow = infoWindow
if (isInfoOpen) {
infoWindow.open(map, marker.getPosition())
}
//给Marker绑定单击事件
marker.on('click', markerClick)
//给Marker绑定单击事件
marker.on('click', markerClick)
function markerClick(e) {
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition())
function markerClick(e) {
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition())
}
return infoWindow
},
// 页面跳转,打开新窗口
openPage(path) {
vue.prototype.$parentCommon.setBreadCrumbs(path);
window.open(path)
}
return infoWindow
},
}
const mapService = new MapService();
......
import Vue from 'vue'
const EventBus = new Vue()
import { Message, MessageBox, Loading } from 'element-ui'
import moment from 'moment'
let loadingInstance = ''
export const Util = {
/**
* 简单alert
* title 标题
* message 内容
* className 自定义class
* showCancelButton 是否展示取消按钮
* confirmButtonText 确认按钮文案
* cancelButtonText 取消按钮文案
* confirmButtonColor 确认按钮颜色
* cancelButtonColor 取消按钮颜色
* type: success / info / warning / error
*/
msg: function (options) {
MessageBox({
title: options.title || '',
type: options.type || 'error',
message: options.message || '',
className: options.className || '',
showCancelButton: options.showCancelButton || false,
confirmButtonText: options.confirmButtonText || '确认',
cancelButtonText: options.cancelButtonText || '取消',
confirmButtonColor: options.confirmButtonColor || '#1989fa',
cancelButtonColor: options.cancelButtonColor || '#000',
dangerouslyUseHTMLString: true,
center: options.center || false,
callback: function (action, done) {
if (action == 'confirm') {
if (options.success) {
options.success(done)
}
} else {
console.log(done)
//done.close()
}
},
})
/* Vue.$vux.alert.show({
title: options.title||'',
content: options.message||'',
onShow() {
options.onShow?(options.onShow)():'';
},
onHide() {
options.onHide?(options.onHide)():'';
}
}) */
},
/**
* 提示框
*/
Info: function (options) {
Message({
message: options.message || '提示',
type: options.type || 'error',
duration: options.time || 2000,
onClose: options.onClose || '',
})
},
/**
* 轻提示
*/
Tips: function (options) {
Message({
message: options.message || '提示',
duration: options.duration || 3000,
type: options.type || 'text',
icon: options.icon || '',
})
},
/**
* loading
*/
loading: function (message) {
loadingInstance = Loading.service({
text: message || '加载中...',
})
},
/**
* 关闭loading
*/
closeLoading: function () {
loadingInstance.close()
},
/**
* 校验手机号码格式
*/
checkPhone: function (mobile) {
let myreg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
return myreg.test(mobile)
},
/**
* 校验固定电话
*/
validationTel: function (tel) {
let reg = /^0[\d]{2,3}-[\d]{7,8}$/
return reg.test(tel)
},
/**
* 是否特殊字符
*/
isSpecialLetter: function (str) {
let reg = new RegExp(
"[`~!@#$^&*=|{}':;',\\[\\]<>?~!@#¥……&*——|{}【】‘;:”“'。,、? ]"
)
return reg.test(str)
},
/**
* 获取当前时间
*/
getCurrentDate: function () {
let time = new Date()
let y = time.getFullYear()
let m = time.getMonth() + 1
let d = time.getDate()
return {
date: y + '/' + m + '/' + d,
}
},
/**
* 获取浏览器参数
*/
getUrlParams: function (name) {
let vars = [],
hash
let oParams = {}
let hashes = window.location.href
.slice(window.location.href.indexOf('?') + 1)
.split('&')
for (let i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=')
vars.push(hash[0])
oParams[hash[0]] = hash[1]
}
console.log(vars)
if (name) {
return oParams[name]
} else {
return oParams
}
},
/**
* 根据当前时间,计算往后30天的日期
*/
getAfterDate: function (day) {
let date1 = new Date()
let date2 = new Date(date1)
let time = 30
if (day) {
time = day
}
date2.setDate(date1.getDate() + time)
let _date =
date2.getFullYear() + '-' + (date2.getMonth() + 1) + '-' + date2.getDate()
return {
date: _date,
year: date2.getFullYear(),
month: date2.getMonth() + 1,
day: date2.getDate(),
}
},
/**
* 日期格式转换
*/
dateFormate: function (str, type) {
let txt = 'YYYY-MM-DD'
if (!str) {
return ''
}
if (type) {
txt = type
}
const m = moment(str).format(txt)
return m
},
/**
* 字段截取
*/
cutStr: function (str, num) {
if (!str) {
return ''
}
let m = 10
let n = str
if (num) {
m = num
}
if (str.length > m) {
n = str.slice(0, m) + '...'
}
return n
},
/**
* 深克隆 所有原型链上的对象和属性
* 例: const bar=deepClone(foo)
* console.log(bar===foo) false
* @param {*} obj
*/
deepClone: function (obj) {
// Handle the 3 simple types, and null or undefined or function
if (obj == null || typeof obj !== 'object') return obj
// Handle Date
if (obj instanceof Date) {
const copy = new Date()
copy.setTime(obj.getTime())
return copy
}
// Handle Array or Object
if ((obj instanceof Array) | (obj instanceof Object)) {
const copy = obj instanceof Array ? [] : {}
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) {
copy[attr] = Util.deepClone(obj[attr])
}
}
return copy
}
throw new Error("Unable to clone obj! Its type isn't supported.")
},
// 传递消息
broadcast: function (msg, data) {
EventBus.$emit(msg, data)
},
// 接收消息
received: function (msg, callBack) {
EventBus.$off(msg)
EventBus.$on(msg, function (row) {
callBack(row)
})
},
}
export const showModal = Util.msg
export const showToast = Util.Info
export const showLoading = Util.loading
export const hideLoading = Util.closeLoading
export const deepClone = Util.deepClone
// export const broadcast = Util.broadcast
// export const received = Util.received
......@@ -84,6 +84,7 @@ const mutations = {
[types.vehicleGenerate](state, data) {
state.vehicleGenerate = data
},
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!