Commit ffbe18c8 by zhangxw
2 parents fd33c9ed 98a54dcd
<template>
<el-popover trigger="click" popper-class="city_select_popover">
<div class="city_list">
<div class="cell_box">
<el-scrollbar class="el_scrollbar">
<div class="cell" :class="showClassName(item)" v-for="(item,index) in provinceList" :key="`province_${index}`" @click="showChildren(item,'city')">
<span>{{item.fullname}}</span>
<i class="el-icon-arrow-right"></i>
</div>
</el-scrollbar>
</div>
<div class="cell_box" v-show="cityList && cityList.length>0">
<el-scrollbar class="el_scrollbar">
<div class="cell" :class="showClassName(item)" v-for="(item,index) in cityList" :key="`city_${index}`" @click="showChildren(item,'area')">
<span>{{item.fullname}}</span>
<i class="el-icon-arrow-right"></i>
</div>
</el-scrollbar>
</div>
<div class="cell_box" v-show="areaList && areaList.length>0">
<el-scrollbar class="el_scrollbar">
<div class="cell" :class="showClassName(item)" v-for="(item,index) in areaList" :key="`area_${index}`" @click="showChildren(item)">{{item.fullname}}</div>
</el-scrollbar>
</div>
</div>
<el-input slot="reference" v-model="selectText"></el-input>
</el-popover>
</template>
<script>
import cityJson from "@/assets/json/city.json";
export default {
name: "CitySelect",
props: {
value: "",
},
data() {
return {
provinceList: cityJson,
cityList: [],
areaList: [],
selectText: "",
areaCode: [],
areaName: [],
};
},
mounted() {
console.log(cityJson);
},
methods: {
// 获取省市区
showChildren(row, id) {
let typeList = {
city: 0,
area: 1,
};
if (id) {
this.areaList = [];
}
let idx = id ? typeList[id] : 2;
this.$set(this.areaCode, idx, row.code);
this.$set(this.areaName, idx, row.fullName);
this[id + "List"] = row.children || [];
},
// 是否选中
showClassName(row) {
let list = this.areaCode;
let idx = list.findIndex((k) => k == row.code);
if (idx >= 0) {
return "active";
} else {
return "";
}
},
},
};
</script>
<style lang="scss" scoped>
.city_list {
display: flex;
.cell_box {
width: 184px;
height: 300px;
position: relative;
.cell {
padding: 8px 10px;
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
}
.active {
color: #409eff;
background: #f5f7fa;
}
}
.cell_box:after {
position: absolute;
display: block;
content: "";
width: 1px;
background: #f2f2f2;
top: 0;
bottom: 0;
right: 0;
}
.cell_box:last-child:after {
display: none;
}
.el_scrollbar {
/deep/ .el-scrollbar__wrap {
overflow-x: hidden;
}
}
}
</style>
<style lang="scss">
.city_select_popover {
padding: 12px 0 !important;
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -180,7 +180,7 @@ export default { ...@@ -180,7 +180,7 @@ export default {
isSubmitting: false, isSubmitting: false,
form: { form: {
locationType: 1, locationType: 1,
triggerType: 3, triggerType: 1,
shapeType: 1, shapeType: 1,
radius: 1000, radius: 1000,
enableStatus: 1, enableStatus: 1,
...@@ -459,9 +459,9 @@ export default { ...@@ -459,9 +459,9 @@ export default {
// 监听圆形半径更改 // 监听圆形半径更改
changeRadius(e) { changeRadius(e) {
let reg = /^\d+$/; let reg = /^\d+$/;
if (!reg.test(e) || e < 1000) { if (!reg.test(e) || e > 10000) {
showToast({ showToast({
message: "请输入整数且不小于1000", message: "请输入1-10000间的整数",
}); });
return false; return false;
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<div class="map-seacrh-wrap"> <div class="map-seacrh-wrap">
<!-- <input type="text" id="fenceMapSearch"> --> <!-- <input type="text" id="fenceMapSearch"> -->
<el-input placeholder="请输入位置" id="fenceMapSearch" size="small" v-model="fenceMapSearch" :disabled="readonlyStatus"> <el-input placeholder="请输入搜索地址" id="fenceMapSearch" size="small" maxlength="200" v-model="fenceMapSearch" :disabled="readonlyStatus">
<template slot="prepend">搜索</template> <template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> --> <!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input> </el-input>
...@@ -51,6 +51,7 @@ import remoteLoad from "utils/remoteLoad.js"; ...@@ -51,6 +51,7 @@ import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js"; import mapService from "utils/mapService.js";
import FenceMapControll from "./FenceMapControll.vue"; import FenceMapControll from "./FenceMapControll.vue";
import { CONSTANT } from "../../constant"; import { CONSTANT } from "../../constant";
import AMapLoader from "@amap/amap-jsapi-loader";
export default { export default {
props: ["fenceMapModalVisible", "init", "readonlyStatus"], props: ["fenceMapModalVisible", "init", "readonlyStatus"],
data() { data() {
...@@ -87,21 +88,21 @@ export default { ...@@ -87,21 +88,21 @@ export default {
areaCode: "", areaCode: "",
isFenceInit: false, isFenceInit: false,
mapLoading: false, mapLoading: false,
polygonPath: [ polygonPath: [],
/* [116.403322, 39.920255],
[116.410703, 39.897555],
[116.402292, 39.892353],
[116.389846, 39.891365] */
],
}; };
}, },
async mounted() { mounted() {
if (window.AMap) { let _this = this;
this.initMap(); AMapLoader.load({
} else { key: CONSTANT.MAP_KEY,
await remoteLoad(`${CONSTANT.AMAP_URL}`, true); version: "1.4.2",
this.initMap(); plugins: CONSTANT.MAP_PLUGINS,
} }).then((AMap) => {
window.AMap = AMap;
_this.mapObj = mapService.init("mapContainer");
_this.bindContextMenu();
_this.bindSearch();
});
}, },
watch: { watch: {
lng(newVal) { lng(newVal) {
...@@ -119,9 +120,7 @@ export default { ...@@ -119,9 +120,7 @@ export default {
}) })
} */ } */
}, },
async created() { async created() {},
},
methods: { methods: {
initMap() { initMap() {
this.initMapPromise = new Promise((resolve, reject) => { this.initMapPromise = new Promise((resolve, reject) => {
...@@ -196,7 +195,6 @@ export default { ...@@ -196,7 +195,6 @@ export default {
); );
//地图绑定鼠标右击事件——弹出右键菜单 //地图绑定鼠标右击事件——弹出右键菜单
self.mapObj.on("rightclick", function (e) { self.mapObj.on("rightclick", function (e) {
console.log(e)
contextMenu.open(self.mapObj, e.lnglat); contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; self.contextMenuPositon = e.lnglat;
}); });
...@@ -273,38 +271,34 @@ export default { ...@@ -273,38 +271,34 @@ export default {
mapObj.setZoom(14); mapObj.setZoom(14);
}, },
initFence(data) { initFence(data) {
this._mapPromiseTimeout && clearTimeout(this._mapPromiseTimeout); let _this = this;
if (this.initMapPromise) { this._mapPromiseTimeout = setInterval(function () {
if (data) { if (_this.mapObj) {
clearInterval(_this._mapPromiseTimeout);
if (!data) {
return false;
}
this.fenceType = data.fenceType; this.fenceType = data.fenceType;
if (this.fenceType === "circle") { switch (data.fenceType) {
this.lng = data.lng; case "area":
this.lat = data.lat; _this.areaCode = data.areaCode;
this.radius = data.radius; _this.drawArea();
} else if (this.fenceType === "area") { break;
this.areaCode = data.areaCode; case "polygon":
} else if (this.fenceType === "polygon") {
if (data.polygonPath && data.polygonPath.length) { if (data.polygonPath && data.polygonPath.length) {
this.polygonPath = data.polygonPath; _this.polygonPath = data.polygonPath;
}
} }
_this.drawPolygon();
break;
default:
_this.lng = data.lng;
_this.lat = data.lat;
_this.radius = data.radius;
_this.drawFence();
break;
} }
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); }, 100);
}
}, },
updateFence(data) { updateFence(data) {
let _this = this; let _this = this;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!-- 关联用户弹框 --> <!-- 关联用户弹框 -->
<el-dialog id="userListModal" :visible="userListModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="1040px" top="8vh"> <el-dialog id="userListModal" :visible="userListModalVisible" @open="openDialog" @close="closeDialog" append-to-body width="1040px" top="8vh">
<div class="dialog-header" slot="title"> <div class="dialog-header" slot="title">
<h2 class="header-title">关联用户</h2> <h2 class="header-title">关联设备</h2>
</div> </div>
<!-- 搜索区域 开始 --> <!-- 搜索区域 开始 -->
<el-form :model="form" :inline="true" size="mini" class="search_form"> <el-form :model="form" :inline="true" size="mini" class="search_form">
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<div class="choose-list-content"> <div class="choose-list-content">
<p>{{item.name}}/{{item.vin}}</p> <p>{{item.name}}/{{item.vin}}</p>
<p class="choose-list-group"> <p class="choose-list-group">
<el-tag type="info" size="small" v-for="snItem in item.sns" :key="snItem">{{snItem}}</el-tag> <el-tag type="info" size="small">{{item.sns}}</el-tag>
</p> </p>
</div> </div>
</el-checkbox> </el-checkbox>
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
<div class="choose-list-content"> <div class="choose-list-content">
<p>{{item.name}}/{{item.vin}}</p> <p>{{item.name}}/{{item.vin}}</p>
<p class="choose-list-group"> <p class="choose-list-group">
<el-tag type="info" size="small" v-for="snItem in item.sns" :key="snItem">{{snItem}}</el-tag> <el-tag type="info" size="small">{{item.sns}}</el-tag>
</p> </p>
</div> </div>
</el-checkbox> </el-checkbox>
...@@ -173,7 +173,7 @@ export default { ...@@ -173,7 +173,7 @@ export default {
if (newVal) { if (newVal) {
this.chosenList.forEach((item) => { this.chosenList.forEach((item) => {
item.checked = false; item.checked = false;
item.sns = (item.sn && item.sn.split(",")) || []; //item.sns = (item.sn && item.sn.split(",")) || [];
}); });
this.chosenList = []; this.chosenList = [];
...@@ -190,6 +190,7 @@ export default { ...@@ -190,6 +190,7 @@ export default {
if (newVal) { if (newVal) {
this.resultList.forEach((item) => { this.resultList.forEach((item) => {
item.checked = true; item.checked = true;
item.sn = item.sns;
const findItem = this.chosenList.find((o) => o.vin === item.vin); const findItem = this.chosenList.find((o) => o.vin === item.vin);
if (!findItem) { if (!findItem) {
this.chosenList.push(item); this.chosenList.push(item);
...@@ -221,7 +222,8 @@ export default { ...@@ -221,7 +222,8 @@ export default {
let arr = []; let arr = [];
this.userData.forEach((o) => { this.userData.forEach((o) => {
o.checked = true; o.checked = true;
o.sns = (o.sn && o.sn.split(",")) || []; o.sns = o.sn || o.sns;
//o.sns = (o.sn && o.sn.split(",")) || [];
arr.push(o); arr.push(o);
}); });
this.chosenList = arr; this.chosenList = arr;
...@@ -229,29 +231,18 @@ export default { ...@@ -229,29 +231,18 @@ export default {
// 保存数据 // 保存数据
sure() { sure() {
let list = deepClone(this.chosenList);
const userdata = []; const userdata = [];
this.chosenList.forEach((obj) => { list.map((k) => {
if (obj.sns && obj.sns.length > 0) { let o = {
obj.sns.forEach((snsItem) => { sn: k.sns,
userdata.push({ name: k.name,
sn: snsItem, vin: k.vin,
name: obj.name, userTel: k.userTel,
vin: obj.vin, address: k.address,
userTel: obj.userTel, time: k.time,
address: obj.address, };
time: obj.time, userdata.push(o);
});
});
} else {
userdata.push({
sn: obj.sns,
name: obj.name,
vin: obj.vin,
userTel: obj.userTel,
address: obj.address,
time: obj.time,
});
}
}); });
this.$emit("onUpdateUserData", userdata); this.$emit("onUpdateUserData", userdata);
this.$emit("onUserListModalChange", false); this.$emit("onUserListModalChange", false);
...@@ -270,17 +261,23 @@ export default { ...@@ -270,17 +261,23 @@ export default {
this.needInfinite = true; this.needInfinite = true;
}, },
// 监听设备勾选操作
checkedChange(item) { checkedChange(item) {
console.log(item);
// 勾选
if (item.checked) { if (item.checked) {
this.resultcheck = item.checked; this.resultcheck = item.checked;
this.resultItem = item; this.resultItem = item;
const findItem = this.chosenList.find((o) => o.sns === item.sns); const findItem = this.chosenList.find((o) => o.sn == item.sns);
if (findItem) return; if (!findItem) {
this.chosenList.push(item); this.chosenList.push(item);
this.checkedCancel = false; this.checkedCancel = false;
} else {
this.chosenList.splice(this.chosenList.indexOf(item), 1);
} }
return false;
}
// 取消勾选
this.chosenList = this.chosenList.filter((k) => k.sns != item.sns);
}, },
exportDate(returnDate) { exportDate(returnDate) {
var obj = {}; var obj = {};
...@@ -333,13 +330,13 @@ export default { ...@@ -333,13 +330,13 @@ export default {
if (code == 200) { if (code == 200) {
const { list } = data; const { list } = data;
if (list && list.length > 0) { if (list && list.length > 0) {
list.map((obj) => { // list.map((obj) => {
if (obj.sns) { // if (obj.sns) {
obj.sns = obj.sns.split(","); // obj.sns = obj.sns.split(",");
} else { // } else {
obj.sns = []; // obj.sns = [];
} // }
}); // });
this.resultList = this.resultList.concat(list); this.resultList = this.resultList.concat(list);
this.total = data.totalElements; this.total = data.totalElements;
this.maxPage = data.totalPages; this.maxPage = data.totalPages;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!