huoyi 5 dienas atpakaļ
vecāks
revīzija
09c6d89b38

+ 26 - 4
src/pages/employeeProfile/index.vue

@@ -33,11 +33,11 @@
33 33
             </view>
34 34
 
35 35
             <view class="search-selector">
36
-                <view class="search-select-trigger" :class="{ 'search-select-trigger-disabled': isSecurityCheck }"
37
-                    @click="!isSecurityCheck && (showEmployeePicker = true)">
36
+                <view class="search-select-trigger" :class="{ 'search-select-trigger-disabled': isSecurityCheck || routeUserId }"
37
+                    @click="!isSecurityCheck && !routeUserId && (showEmployeePicker = true)">
38 38
                     <u-icon name="list" color="#A78BFA" size="16"></u-icon>
39 39
                     <text class="search-name-text">{{ selectedEmployeeName || '请选择员工' }}</text>
40
-                    <u-icon v-if="!isSecurityCheck" name="arrow-down" color="#A78BFA" size="14"></u-icon>
40
+                    <u-icon v-if="!isSecurityCheck && !routeUserId" name="arrow-down" color="#A78BFA" size="14"></u-icon>
41 41
                 </view>
42 42
             </view>
43 43
 
@@ -379,6 +379,9 @@ export default {
379 379
             expandedDeptIds: [],
380 380
             isSecurityCheck: false,
381 381
             userInfo: null,
382
+            // 路由跳转参数
383
+            routeUserId: null,
384
+            routeUserName: '',
382 385
             // 雷达图tooltip相关
383 386
             activeDimName: null,
384 387
             radarTooltipPosition: { x: 0, y: 0 },
@@ -463,6 +466,13 @@ export default {
463 466
             return s.toFixed(2)
464 467
         }
465 468
     },
469
+    // uni-app 页面生命周期:接收路由参数
470
+    onLoad(options) {
471
+        if (options.userId) {
472
+            this.routeUserId = options.userId
473
+            this.routeUserName = decodeURIComponent(options.userName || '')
474
+        }
475
+    },
466 476
     mounted() {
467 477
         this.updateTime()
468 478
         this.timer = setInterval(() => {
@@ -470,7 +480,19 @@ export default {
470 480
         }, 1000)
471 481
         // 默认计算时间范围(近一年)
472 482
         this.onTimeTagClick(this.selectedTimeTag)
473
-        this.fetchEmployeeList()
483
+
484
+        if (this.routeUserId) {
485
+            // 来自组织架构跳转,直接加载指定人员
486
+            this.selectedEmployeeId = this.routeUserId
487
+            this.selectedEmployeeName = this.routeUserName
488
+            this.searchKeyword = this.routeUserName
489
+            this.employeeLoading = false
490
+            this.$nextTick(() => {
491
+                this.fetchEmployeePortrait()
492
+            })
493
+        } else {
494
+            this.fetchEmployeeList()
495
+        }
474 496
     },
475 497
     beforeDestroy() {
476 498
         if (this.timer) {

+ 9 - 0
src/pages/organizationStruct/index.vue

@@ -82,6 +82,7 @@
82 82
                     v-for="item in displayUsers" 
83 83
                     :key="item.userId"
84 84
                     class="user-item"
85
+                    @click="navigateToEmployee(item)"
85 86
                 >
86 87
                     <view class="user-avatar">
87 88
                         <image v-if="item.avatar" :src="item.avatar" mode="aspectFill" class="avatar-img" />
@@ -247,6 +248,9 @@ export default {
247 248
                 if (targetNode) {
248 249
                     this.navigateToNodeFromRoot(targetNode)
249 250
                 }
251
+            } else {
252
+                // 搜索结果是人员,跳转到员工画像
253
+                this.navigateToEmployee(item)
250 254
             }
251 255
         },
252 256
         navigateToNodeFromRoot(targetNode) {
@@ -277,6 +281,11 @@ export default {
277 281
         clearSearch() {
278 282
             this.searchKeyword = ''
279 283
             this.searchResults = []
284
+        },
285
+        navigateToEmployee(item) {
286
+            const userId = item.userId
287
+            const userName = encodeURIComponent(item.label || item.nickName || item.userName || '')
288
+            this.$tab.navigateTo(`/pages/employeeProfile/index?userId=${userId}&userName=${userName}`)
280 289
         }
281 290
     }
282 291
 }