Переглянути джерело

社区通知公告树过滤

Shannon_mu 3 роки тому
батько
коміт
156a898b79

+ 4 - 4
operationSupport/src/views/propertyManagement/common/previeInform.vue

@@ -18,7 +18,7 @@
                         </div>
                         <div class="prev-obj-right">
                             <div class="prev-obj-text">
-                                社区员工/{{ '指定员工' }}/{{ peopleData[0].value }}/
+                                社区员工/{{ '指定员工' }}/{{!!peopleData[0]?peopleData[0].value:'' }}/
                                 {{ houseDataNamesPeople }}
                             </div>
                             <div @click="clickDetailPeople()" class="click-prev">{{ showTreePeople ? '关闭详情' : '查看详情' }}</div>
@@ -46,10 +46,10 @@
                                     @node-collapse="closeTree"
                                 >
                                     <span class="custom-tree-node" slot-scope="{ node, data }">
-                                        <span v-if="data.children == null && data.children.length > 0">
+                                        <span v-if="data.children == null || data.children.length > 0">
                                             <span class="circle"></span>
-                                            {{ data.name }}</span
-                                        >
+                                            {{ data.name }}
+                                        </span>
                                     </span>
                                 </el-tree>
                             </GeminiScrollbar>

+ 70 - 18
operationSupport/src/views/propertyManagement/inform.vue

@@ -688,7 +688,10 @@ export default {
             this.showDetail = true;
             this.centerDialogVisible = true;
             this.$refs.upImages.clearImageList('');
-            this.$refs.endit.setContent('');
+            if (!!this.$refs.endit) {
+                this.$refs.endit.setContent('');
+            }
+
             console.log('发布活动类型', val);
         },
         // 清空
@@ -704,9 +707,15 @@ export default {
             this.ruleForm.exigencyText = true;
             this.contentHtml = '';
             this.setContent = '';
-            this.$refs.endit.setContent('');
-            this.$refs.selectTreeHouse.endBtn();
-            this.$refs['ruleForm'].resetFields();
+            if (!!this.$refs.endit) {
+                this.$refs.endit.setContent('');
+            }
+            if (!!this.$refs.selectTreeHouse) {
+                this.$refs.selectTreeHouse.endBtn();
+            }
+            if (!!this.$refs['ruleForm']) {
+                this.$refs['ruleForm'].resetFields();
+            }
         },
         /**添加按钮 */
         add() {
@@ -862,7 +871,10 @@ export default {
                 }
                 this.centerDialogVisible = false;
                 this.clear();
-                this.$refs['ruleForm'].resetFields();
+                if (!!this.$refs['ruleForm']) {
+                    this.$refs['ruleForm'].resetFields();
+                }
+
                 if (this.showUploadImage) {
                     this.$refs.upImages.clearImageList('');
                 }
@@ -923,9 +935,10 @@ export default {
             this.PeopleNames = [];
             this.$http.get('/sc-user-center/user/findUserList').then(({ status, data, msg }) => {
                 if (status === 0) {
+                    this.filterPeople(data);
+                    this.filterPeopleName(data);
+                    this.clearTreeChildrenPeople(data);
                     this.peopleData = data;
-                    this.filterPeople(this.peopleData);
-                    this.filterPeopleName(this.peopleData);
                     this.houseDataNamesPeople = this.PeopleNames.toString();
                 } else {
                     this.$message(error, res.msg);
@@ -935,12 +948,44 @@ export default {
         dimension(arr) {
             arr.map((item, index) => {
                 if (item.children) {
-                    this.dimension(item.children);
+                    if (item.children.length > 0) {
+                        this.dimension(item.children);
+                    }
                 } else if (item.type == 'room') {
                     this.filterArr(arr, item, index);
                 }
             });
         },
+        clearTreeChildren(arr) {
+            arr.map((item, index) => {
+                if (!!item.children && item.children.length > 0) {
+                    this.clearTreeChildren(item.children);
+                } else {
+                    if (!!item.children) {
+                        arr.splice(index, 1);
+                    }
+                }
+            });
+        },
+        clearTreeChildrenPeople(arr) {
+            arr.map((item, index) => {
+                if (!!item.children && item.children.length > 0) {
+                    this.clearTreeChildrenPeople(item.children);
+                } else {
+                    if (!!item.children && item.children.length == 0) {
+                        this.clearTreeChildrenPeopleArr(arr, index);
+                    }
+                }
+            });
+        },
+        clearTreeChildrenPeopleArr(arr, index) {
+            arr.splice(index, 1);
+            arr.map((item, indexs) => {
+                if (!!item.children && item.children.length == 0) {
+                    this.clearTreeChildrenPeopleArr(arr, indexs);
+                }
+            });
+        },
         filterArr(arr, item, index) {
             if (!this.rowDetail.treeData.includes(Number(item.value))) {
                 arr.splice(index, 1);
@@ -971,15 +1016,20 @@ export default {
                         var arr = data.filter((item) => {
                             return item.id == this.rowDetail.communityId;
                         });
-                        console.log('选中的社区', arr);
-                        this.houseData = arr;
-                        this.dimension(this.houseData);
-                        console.log('====================================');
-                        console.log('houseData', this.houseData);
-                        console.log('====================================');
-                        this.filterName(this.houseData);
-                        let h = [...new Set(this.houseNames)];
-                        this.houseDataNames = this.houseNames.toString();
+
+                        if (arr.length > 0) {
+                            // this.houseData = arr;
+                            this.dimension(arr);
+                            this.clearTreeChildren(arr);
+                            this.houseData = arr;
+                            // this.dimension(this.houseData);
+                            // console.log(arr);
+                            // console.log(this.houseData);
+
+                            this.filterName(this.houseData);
+                            let h = [...new Set(this.houseNames)];
+                            this.houseDataNames = this.houseNames.toString();
+                        }
                     }
                 });
         },
@@ -1025,7 +1075,9 @@ export default {
                     this.contentHtml = res.data.content;
                     this.centerDialogVisible = true;
                     this.showDetail = false;
-                    this.$refs.previeInform.closeDialog();
+                    if (!!this.$refs.previeInform) {
+                        this.$refs.previeInform.closeDialog();
+                    }
                 } else {
                     return this.$message.error('获取详情失败!请稍后重试');
                 }