From 6e88bdd3848904ef55ec03714c9b2770b5195b50 Mon Sep 17 00:00:00 2001
From: luobisheng <727299681@qq.com>
Date: 星期二, 29 十一月 2022 13:47:24 +0800
Subject: [PATCH] 消息修改

---
 src/views/operate/message/myIndex/update/index.vue |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/views/operate/message/myIndex/update/index.vue b/src/views/operate/message/myIndex/update/index.vue
index 9ebf470..9b7265b 100644
--- a/src/views/operate/message/myIndex/update/index.vue
+++ b/src/views/operate/message/myIndex/update/index.vue
@@ -40,7 +40,7 @@
                   </el-option>
                 </el-select>
               </div>
-              <span class="message-add button-addition" @click="dialogCreate = true">
+              <span class="message-add" @click="dialogCreate = true">
                 娣诲姞鏍忕洰</span
               >
             </div>
@@ -66,6 +66,7 @@
                     show-checkbox
                     @check="handleCheck"
                     default-expand-all
+                    :default-checked-keys="checkedList"
                     node-key="id"
                   >
                   </el-tree>
@@ -196,7 +197,10 @@
       getMessageById(this.myDataRow.id)
           .then(res => {
             this.role = res;
-            this.role.targetTo = `${this.role.targetTo.split(',').length}浜篳;
+            if (res.targetTo) {
+              this.checkedList = res.targetTo.split(',');
+              this.role.targetTo = `${this.checkedList}浜篳;
+            }
           })
           .catch(err => this.$message.error(`${err}`))
     }
@@ -265,13 +269,10 @@
 
     // 閫変腑id
     handleCheck(data, node) {
-      node.checkedNodes.forEach((item) => {
-        if (!item.hasOwnProperty("departType")) {
-          this.checkedList.push(item.id);
-          this.tempNameArr.push(item.departName);
-        }
-      });
-      this.role.targetTo = this.checkedList.length + "浜�";
+      const checkedNodes = node.checkedNodes.filter(item => !item.children);
+      this.checkedList = checkedNodes.map(item => item.id);
+      this.tempNameArr = checkedNodes.map(item => item.departName);
+      this.role.targetTo = this.checkedList.length ? this.checkedList.length + "浜�" : null;
     },
 
     // 鏂板缓/淇濆瓨娑堟伅(1:鏂板缓,0淇濆瓨娑堟伅)

--
Gitblit v1.8.0