Commit 98a54dcd by 张杰

修复bug

1 parent 76139a6c
<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
......@@ -21,7 +21,7 @@
<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 ref="fenceForm" :model="form" :rules="rules" :inline="false" size="mini" label-width="100px" class="fence_form" align="left">
<el-form-item label="围栏名称" prop="fenceName">
<el-input v-model.trim="form.fenceName" placeholder="请输入围栏名称" maxlength="200" show-word-limit :disabled="readonlyStatus"></el-input>
</el-form-item>
......@@ -41,7 +41,7 @@
<el-radio :label="2">指定区间</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="指定区间" prop="dateRange" v-if="form.timeType == 2">
<el-form-item label="指定区间" class="is-required" prop="dateRange" v-if="form.timeType == 2">
<el-date-picker v-model="form.dateRange" type="daterange" size="small" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
......@@ -146,7 +146,7 @@ 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";
import CitySelect from "@/components/area/index";
import { deepClone, showToast, showModal } from "@/utils/utils";
import {
GET_ELECFENCE_LINKEDDEVICES,
......@@ -179,24 +179,27 @@ export default {
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);
}
let checkDaterange = (rule, value, cb) => {
if (this.form.timeType == 1) {
cb();
return false;
}
if (!value || value.length <= 0) {
cb(new Error("请选择指定区间"));
return false;
}
let min = value[0];
let max = value[1];
if (min.isBefore(moment(max).subtract(30 * 6, "days"), "minute")) {
cb(new Error("日期范围不能超过180天"));
}
if (!moment.isMoment(min)) {
min = moment(min);
}
if (!moment.isMoment(max)) {
max = moment(max);
}
if (min.isBefore(moment(max).subtract(50, "years"), "minute")) {
cb(new Error("日期范围不能超过50年"));
return false;
}
cb();
};
......@@ -226,13 +229,16 @@ export default {
};
// 校验半径
let checkRadius = (rule, vaule, cb) => {
if (this.form.shapeType == 1 && !/^\d+$/.test(this.form.radius)) {
console.log(this.form.radius);
let checkRadius = (rule, value, cb) => {
if (this.form.shapeType == 1 && !/^\d+$/.test(value)) {
cb(new Error("请输入正确的格式,不能输入小数点"));
} else {
cb();
return false;
}
if (value > 10000) {
cb(new Error("请输入1-10000间的整数"));
return false;
}
cb();
};
// 校验经度
......@@ -301,9 +307,7 @@ export default {
{ required: true, message: "请选择状态", trigger: "change" },
],
telNumbers: [{ validator: checkMsgtel, trigger: "blur" }],
dateRange: [
{ required: true, message: "请选择指定区间", trigger: "change" },
],
dateRange: [{ validator: checkDaterange, trigger: "change" }],
lng: [{ validator: checkLng, trigger: "blur" }],
lat: [{ validator: checkLat, trigger: "blur" }],
},
......@@ -530,7 +534,7 @@ export default {
// 行政区域围栏
if (form.shapeType == 4) {
oParams.areaCode = form.areaCode[form.areaCode.length - 1];
oParams.areaText = form.areaText.toString().replace(/,/g,'');
oParams.areaText = form.areaText.toString().replace(/,/g, "");
}
// 监控周期 1:永久有效,2:指定区间
......@@ -638,15 +642,14 @@ export default {
// 监听监控周期
changeTimeType(e) {
if (e == 1) {
delete this.rules.dateRange;
return false;
}
let oParams = [
{ required: true, message: "请选择指定区间", trigger: "change" },
];
this.$set(this.rules, "dateRange", oParams);
// if (e == 1) {
// delete this.rules.dateRange;
// return false;
// }
// let oParams = [
// { required: true, message: "请选择指定区间", trigger: "change" },
// ];
// this.$set(this.rules, "dateRange", oParams);
},
// 获取关联设备列表
......@@ -769,10 +772,10 @@ export default {
changeRadius() {
let e = this.form.radius;
let reg = /^\d+$/;
if (!reg.test(e) || e < 1000) {
showToast({
message: "请输入整数且不小于1000",
});
if (!reg.test(e) || e > 10000) {
// showToast({
// message: "请输入1-10000间的整数",
// });
return false;
}
this.$refs.fenceMap.updateFence({
......
......@@ -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>
......@@ -88,8 +88,7 @@ export default {
areaCode: "",
isFenceInit: false,
mapLoading: false,
polygonPath: [
],
polygonPath: [],
};
},
mounted() {
......@@ -150,7 +149,6 @@ export default {
},
bindSearch() {
const self = this;
console.log(AMap);
AMap.plugin("AMap.Autocomplete", function () {
self.auto = new AMap.Autocomplete({
input: "fenceMapSearch",
......@@ -197,7 +195,6 @@ export default {
);
//地图绑定鼠标右击事件——弹出右键菜单
self.mapObj.on("rightclick", function (e) {
console.log(e);
contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat;
});
......@@ -274,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;
......
......@@ -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!