From 9903954c85f651dd5cc6d4b538cfe66b17fc5baa Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 28 十月 2026 18:23:45 +0800
Subject: [PATCH] 提交

---
 src/views/system/user/profile/index.vue |   48 ++++++++++++++++++++++++++++++++++--------------
 1 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/src/views/system/user/profile/index.vue b/src/views/system/user/profile/index.vue
index 2533e08..63e63de 100644
--- a/src/views/system/user/profile/index.vue
+++ b/src/views/system/user/profile/index.vue
@@ -25,7 +25,7 @@
               </li>
 
               <!-- ===== 鎵�灞炵梾鍖� ===== -->
-              <li class="list-group-item" v-if="user.belongWards && user.belongWards.length">
+              <li class="list-group-item" v-if="uniqueWards && uniqueWards.length">
                 <svg-icon icon-class="tree" />鎵�灞炵梾鍖�
                 <div class="pull-right">
                   <!-- 鍗楀崕闄勪竴锛氬彲缂栬緫妯″紡 -->
@@ -44,7 +44,7 @@
                   <!-- 鍗楀崕闄勪竴锛氬彧璇绘ā寮� -->
                   <template v-else-if="isNanhua">
                     <el-tag
-                      v-for="ward in user.belongWards"
+                      v-for="ward in uniqueWards"
                       :key="ward.districtId"
                       size="small"
                       class="ward-tag"
@@ -60,7 +60,7 @@
                       popper-class="ward-popover"
                     >
                       <div class="popover-content">
-                        <p v-for="ward in user.belongWards" :key="ward.districtId" class="popover-item">
+                        <p v-for="ward in uniqueWards" :key="ward.districtId" class="popover-item">
                           {{ ward.districtName }}
                         </p>
                       </div>
@@ -72,11 +72,11 @@
                           class="ward-tag"
                         >{{ ward.districtName }}</el-tag>
                         <el-tag
-                          v-if="user.belongWards.length > maxTagCount"
+                          v-if="uniqueWards.length > maxTagCount"
                           size="small"
                           class="more-tag"
                           @click="showAllWardsPopover = !showAllWardsPopover"
-                        >+{{ user.belongWards.length - maxTagCount }}</el-tag>
+                        >+{{ uniqueWards.length - maxTagCount }}</el-tag>
                       </div>
                     </el-popover>
                   </template>
@@ -88,7 +88,7 @@
               </li>
 
               <!-- ===== 鎵�灞炵瀹� ===== -->
-              <li class="list-group-item" v-if="user.belongDepts && user.belongDepts.length">
+              <li class="list-group-item" v-if="uniqueDepts && uniqueDepts.length">
                 <svg-icon icon-class="tree" />鎵�灞炵瀹�
                 <div class="pull-right">
                   <!-- 鍗楀崕闄勪竴锛氬彲缂栬緫妯″紡 -->
@@ -107,7 +107,7 @@
                   <!-- 鍗楀崕闄勪竴锛氬彧璇绘ā寮� -->
                   <template v-else-if="isNanhua">
                     <el-tag
-                      v-for="dept in user.belongDepts"
+                      v-for="dept in uniqueDepts"
                       :key="dept.deptId"
                       size="small"
                       class="dept-tag"
@@ -123,7 +123,7 @@
                       popper-class="dept-popover"
                     >
                       <div class="popover-content">
-                        <p v-for="dept in user.belongDepts" :key="dept.deptId" class="popover-item">
+                        <p v-for="dept in uniqueDepts" :key="dept.deptId" class="popover-item">
                           {{ dept.deptName }}
                         </p>
                       </div>
@@ -135,11 +135,11 @@
                           class="dept-tag"
                         >{{ dept.deptName }}</el-tag>
                         <el-tag
-                          v-if="user.belongDepts.length > maxTagCount"
+                          v-if="uniqueDepts.length > maxTagCount"
                           size="small"
                           class="more-tag"
                           @click="showAllDeptsPopover = !showAllDeptsPopover"
-                        >+{{ user.belongDepts.length - maxTagCount }}</el-tag>
+                        >+{{ uniqueDepts.length - maxTagCount }}</el-tag>
                       </div>
                     </el-popover>
                   </template>
@@ -223,15 +223,22 @@
     };
   },
   computed: {
+    // sys_user_dept 閲屽悓涓�鐥呭尯鍙兘鏈夊嚑鍗佹潯閲嶅琛岋紝鎺ュ彛鍘熸牱杩斿洖锛岃繖閲屾寜缂栫爜鍘婚噸
+    uniqueWards() {
+      return this.uniqueByCode(this.user.belongWards);
+    },
+    uniqueDepts() {
+      return this.uniqueByCode(this.user.belongDepts);
+    },
     // 璁$畻瑕佹樉绀虹殑鐥呭尯鏍囩锛堝墠maxTagCount涓級
     displayWards() {
-      if (!this.user.belongWards) return [];
-      return this.user.belongWards.slice(0, this.maxTagCount);
+      if (!this.uniqueWards) return [];
+      return this.uniqueWards.slice(0, this.maxTagCount);
     },
     // 璁$畻瑕佹樉绀虹殑绉戝鏍囩锛堝墠maxTagCount涓級
     displayDepts() {
-      if (!this.user.belongDepts) return [];
-      return this.user.belongDepts.slice(0, this.maxTagCount);
+      if (!this.uniqueDepts) return [];
+      return this.uniqueDepts.slice(0, this.maxTagCount);
     },
     // 鍗楀崕澶у闄勫睘绗竴鍖婚櫌 鍏佽缂栬緫绉戝/鐥呭尯
     isNanhua() {
@@ -245,6 +252,19 @@
     }
   },
   methods: {
+    // 鎸夌瀹�/鐥呭尯缂栫爜鍘婚噸锛坰ys_user_dept 瀛樺湪閲嶅琛岋級
+    uniqueByCode(list) {
+      const seen = {};
+      return (list || []).filter((item) => {
+        if (!item) return false;
+        const code =
+          item.districtCode || item.deptCode || item.districtId || item.deptId;
+        const key = String(code === undefined || code === null ? "" : code);
+        if (!key || seen[key]) return false;
+        seen[key] = true;
+        return true;
+      });
+    },
     getUser() {
       getUserProfile().then((response) => {
         this.user = response.data;

--
Gitblit v1.9.3