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
......@@ -180,7 +180,7 @@ export default {
isSubmitting: false,
form: {
locationType: 1,
triggerType: 3,
triggerType: 1,
shapeType: 1,
radius: 1000,
enableStatus: 1,
......@@ -459,9 +459,9 @@ export default {
// 监听圆形半径更改
changeRadius(e) {
let reg = /^\d+$/;
if (!reg.test(e) || e < 1000) {
if (!reg.test(e) || e > 10000) {
showToast({
message: "请输入整数且不小于1000",
message: "请输入1-10000间的整数",
});
return false;
}
......
......@@ -30,7 +30,7 @@
<div class="map-seacrh-wrap">
<!-- <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>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input>
......@@ -51,6 +51,7 @@ import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
import FenceMapControll from "./FenceMapControll.vue";
import { CONSTANT } from "../../constant";
import AMapLoader from "@amap/amap-jsapi-loader";
export default {
props: ["fenceMapModalVisible", "init", "readonlyStatus"],
data() {
......@@ -87,21 +88,21 @@ export default {
areaCode: "",
isFenceInit: false,
mapLoading: false,
polygonPath: [
/* [116.403322, 39.920255],
[116.410703, 39.897555],
[116.402292, 39.892353],
[116.389846, 39.891365] */
],
polygonPath: [],
};
},
async mounted() {
if (window.AMap) {
this.initMap();
} else {
await remoteLoad(`${CONSTANT.AMAP_URL}`, true);
this.initMap();
}
mounted() {
let _this = this;
AMapLoader.load({
key: CONSTANT.MAP_KEY,
version: "1.4.2",
plugins: CONSTANT.MAP_PLUGINS,
}).then((AMap) => {
window.AMap = AMap;
_this.mapObj = mapService.init("mapContainer");
_this.bindContextMenu();
_this.bindSearch();
});
},
watch: {
lng(newVal) {
......@@ -119,9 +120,7 @@ export default {
})
} */
},
async created() {
},
async created() {},
methods: {
initMap() {
this.initMapPromise = new Promise((resolve, reject) => {
......@@ -196,7 +195,6 @@ export default {
);
//地图绑定鼠标右击事件——弹出右键菜单
self.mapObj.on("rightclick", function (e) {
console.log(e)
contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat;
});
......@@ -273,38 +271,34 @@ export default {
mapObj.setZoom(14);
},
initFence(data) {
this._mapPromiseTimeout && clearTimeout(this._mapPromiseTimeout);
if (this.initMapPromise) {
if (data) {
let _this = this;
this._mapPromiseTimeout = setInterval(function () {
if (_this.mapObj) {
clearInterval(_this._mapPromiseTimeout);
if (!data) {
return false;
}
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;
}
switch (data.fenceType) {
case "area":
_this.areaCode = data.areaCode;
_this.drawArea();
break;
case "polygon":
if (data.polygonPath && data.polygonPath.length) {
_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) {
let _this = this;
......
......@@ -2,7 +2,7 @@
<!-- 关联用户弹框 -->
<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>
<h2 class="header-title">关联设备</h2>
</div>
<!-- 搜索区域 开始 -->
<el-form :model="form" :inline="true" size="mini" class="search_form">
......@@ -57,7 +57,7 @@
<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>
<el-tag type="info" size="small">{{item.sns}}</el-tag>
</p>
</div>
</el-checkbox>
......@@ -95,7 +95,7 @@
<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>
<el-tag type="info" size="small">{{item.sns}}</el-tag>
</p>
</div>
</el-checkbox>
......@@ -173,7 +173,7 @@ export default {
if (newVal) {
this.chosenList.forEach((item) => {
item.checked = false;
item.sns = (item.sn && item.sn.split(",")) || [];
//item.sns = (item.sn && item.sn.split(",")) || [];
});
this.chosenList = [];
......@@ -190,6 +190,7 @@ export default {
if (newVal) {
this.resultList.forEach((item) => {
item.checked = true;
item.sn = item.sns;
const findItem = this.chosenList.find((o) => o.vin === item.vin);
if (!findItem) {
this.chosenList.push(item);
......@@ -221,7 +222,8 @@ export default {
let arr = [];
this.userData.forEach((o) => {
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);
});
this.chosenList = arr;
......@@ -229,29 +231,18 @@ export default {
// 保存数据
sure() {
let list = deepClone(this.chosenList);
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,
address: obj.address,
time: obj.time,
});
});
} else {
userdata.push({
sn: obj.sns,
name: obj.name,
vin: obj.vin,
userTel: obj.userTel,
address: obj.address,
time: obj.time,
});
}
list.map((k) => {
let o = {
sn: k.sns,
name: k.name,
vin: k.vin,
userTel: k.userTel,
address: k.address,
time: k.time,
};
userdata.push(o);
});
this.$emit("onUpdateUserData", userdata);
this.$emit("onUserListModalChange", false);
......@@ -270,17 +261,23 @@ export default {
this.needInfinite = true;
},
// 监听设备勾选操作
checkedChange(item) {
console.log(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);
const findItem = this.chosenList.find((o) => o.sn == item.sns);
if (!findItem) {
this.chosenList.push(item);
this.checkedCancel = false;
}
return false;
}
// 取消勾选
this.chosenList = this.chosenList.filter((k) => k.sns != item.sns);
},
exportDate(returnDate) {
var obj = {};
......@@ -333,13 +330,13 @@ export default {
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 = [];
}
});
// 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;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!