浏览代码

单元楼栋问题

Shannon_mu 3 年之前
父节点
当前提交
0cac4a8cf3

+ 5 - 3
operationSupport/src/views/facilityInspections/popups/add.vue

@@ -21,7 +21,7 @@
             <el-cascader
                 :key="typeValueKey"
                 ref="typeValue"
-                v-model="formData.typeValue"
+                v-model="typeValueW"
                 :props="defaultProps"
                 :options="deviceArr"
                 @change="deviceArrToggle"
@@ -166,10 +166,10 @@ export default {
             defaultProps: {
                 value: 'id', // 唯一标识
                 label: 'label', // 标签显示
-                children: 'children',
-                emitPath: false
+                children: 'children'
             },
             typeValueKey: 0,
+            typeValueW: [],
             effectiveDate: []
         };
     },
@@ -206,6 +206,7 @@ export default {
             this.formData.peopleName = this.$refs.userName.getCheckedNodes()[0].label;
         },
         deviceArrToggle() {
+            this.formData.typeValue = this.typeValueW[this.typeValueW.length - 1];
             if (!!this.formData.typeValue) {
                 this.formData.type = this.$refs.typeValue.getCheckedNodes()[0].data.type;
             }
@@ -268,6 +269,7 @@ export default {
                     remark: remark,
                     id: id
                 };
+                this.typeValueW = typeValue;
                 this.effectiveDate = [data.startDate, data.endDate];
                 resolve && resolve(true);
             });

+ 45 - 40
operationSupport/src/views/patrolManagement/popups/addPoint.vue

@@ -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}`;
         }
     }
 };