|
@@ -1,10 +1,10 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<zz-form :cols="formCols" :data="formData" :rules="formRules" labelWidth="100" ref="form">
|
|
|
- <el-select v-model="formData.communityId" placeholder="请选择所属社区" clearable slot="communityId">
|
|
|
+ <el-select v-model="formData.communityId" placeholder="请选择所属社区" clearable slot="communityId" @change="communityChange">
|
|
|
<el-option v-for="(item, index) in communityArr" :key="index" :label="item.communityName" :value="item.id"></el-option>
|
|
|
</el-select>
|
|
|
- <el-select v-model="formData.buildingId" placeholder="请选择楼栋" clearable slot="buildingId">
|
|
|
+ <el-select v-model="formData.buildingId" placeholder="请选择楼栋" clearable slot="buildingId" @change="buildingChange">
|
|
|
<el-option v-for="(item, index) in buildingArr" :key="index" :label="item.label" :value="item.id"></el-option>
|
|
|
</el-select>
|
|
|
<el-select v-model="formData.unit" placeholder="请选择单元" clearable slot="unit">
|
|
@@ -81,44 +81,11 @@ export default {
|
|
|
communityArr: [],
|
|
|
buildingArr: [],
|
|
|
unitArr: [],
|
|
|
+ backfill: false,
|
|
|
mapPopUpStatus: false //地图弹出框
|
|
|
};
|
|
|
},
|
|
|
- watch: {
|
|
|
- 'formData.communityId'(e) {
|
|
|
- this.communityTre.map((item) => {
|
|
|
- this.buildingArr = [];
|
|
|
- if (item.value == e && !!item.children) {
|
|
|
- item.children.map((itemBuilding) => {
|
|
|
- this.buildingArr.push({
|
|
|
- label: itemBuilding.name,
|
|
|
- id: itemBuilding.value,
|
|
|
- children: itemBuilding.children,
|
|
|
- type: itemBuilding.type
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- 'formData.buildingId'(e) {
|
|
|
- this.buildingArr.map((item) => {
|
|
|
- this.unitArr = [];
|
|
|
- if (item.id == e && !!item.children) {
|
|
|
- item.children.map((itemUnit) => {
|
|
|
- if (itemUnit.type == 'unit') {
|
|
|
- this.$nextTick(() => {
|
|
|
- this.unitArr.push({
|
|
|
- label: itemUnit.name,
|
|
|
- id: itemUnit.value,
|
|
|
- type: itemUnit.type
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
+ watch: {},
|
|
|
methods: {
|
|
|
QueryClick() {
|
|
|
new Promise((resolve) => {
|
|
@@ -138,6 +105,32 @@ export default {
|
|
|
this.formData.longitude = e.lng;
|
|
|
});
|
|
|
},
|
|
|
+ CheckChinese(val, name) {
|
|
|
+ var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
|
|
|
+ let newVal = val;
|
|
|
+ if (!reg.test(val)) {
|
|
|
+ newVal = val + name;
|
|
|
+ }
|
|
|
+ return newVal;
|
|
|
+ },
|
|
|
+ nestedLoop(arr, type, thisArr, e, resolve) {
|
|
|
+ let newArr = [];
|
|
|
+ arr.map((item) => {
|
|
|
+ if (item.id == e && !!item.children) {
|
|
|
+ item.children.map((itemUnit) => {
|
|
|
+ if (itemUnit.type == type) {
|
|
|
+ newArr.push({
|
|
|
+ label: this.CheckChinese(itemUnit.name, type == 'unit' ? '单元' : '楼栋'),
|
|
|
+ id: type == 'unit' ? itemUnit.value : Number(itemUnit.value),
|
|
|
+ type: itemUnit.type,
|
|
|
+ children: itemUnit.children
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this[thisArr] = newArr;
|
|
|
+ },
|
|
|
submit() {
|
|
|
new Promise((resolve) => {
|
|
|
this.$refs.form.validate(resolve);
|
|
@@ -173,15 +166,27 @@ export default {
|
|
|
loading.close();
|
|
|
});
|
|
|
});
|
|
|
+ },
|
|
|
+ communityChange(e) {
|
|
|
+ this.formData.buildingId = '';
|
|
|
+ this.formData.unit = '';
|
|
|
+ this.nestedLoop(this.communityTre, 'building', 'buildingArr', e);
|
|
|
+ },
|
|
|
+ buildingChange(e) {
|
|
|
+ this.formData.unit = '';
|
|
|
+ this.nestedLoop(this.buildingArr, 'unit', 'unitArr', e);
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.communityTre = this.params.communityTre;
|
|
|
this.communityArr = this.params.communityArr;
|
|
|
if (this.params.todo == 'edit') {
|
|
|
- this.formData = JSON.parse(JSON.stringify(this.params.data));
|
|
|
- this.initDot = [this.params.data.latitude, this.params.data.longitude];
|
|
|
- this.formData.latitude = `${this.params.data.latitude},${this.params.data.longitude}`;
|
|
|
+ let newData = this.params.data;
|
|
|
+ this.formData = newData;
|
|
|
+ this.nestedLoop(this.communityTre, 'building', 'buildingArr', newData.communityId);
|
|
|
+ this.nestedLoop(this.buildingArr, 'unit', 'unitArr', newData.buildingId);
|
|
|
+ this.initDot = [newData.latitude, newData.longitude];
|
|
|
+ this.formData.latitude = `${newData.latitude},${newData.longitude}`;
|
|
|
}
|
|
|
}
|
|
|
};
|