ソースを参照

refactor(employeeProfile): 优化员工档案页面功能与文案

1. 统一多个页面的通道过检率标题为"通道高峰过检率"
2. 重构自定义时间范围选择逻辑,替换为beginTime/endTime变量
3. 优化标签得分展示逻辑,改为统计用户标签数量
4. 新增自动计算默认时间范围功能
5. 调整分数详情获取逻辑,仅取最后一条数据
6. 优化日期选择器展示格式与交互
huoyi 1 週間 前
コミット
c7aa083e4e
共有4 個のファイルを変更した87 個の追加27 個の削除を含む
  1. 1 1
      src/pages/deptProfile/index.vue
  2. 84 24
      src/pages/employeeProfile/index.vue
  3. 1 1
      src/pages/groupProfile/index.vue
  4. 1 1
      src/pages/teamProfile/index.vue

+ 1 - 1
src/pages/deptProfile/index.vue

@@ -77,7 +77,7 @@
77 77
             </view>
78 78
 
79 79
             <view v-if="activeTab === 'data'">
80
-                <SectionTitle title="每日通道过检率">
80
+                <SectionTitle title="通道高峰过检率">
81 81
                     <PassengerChart :chartsData="passengerData" />
82 82
                 </SectionTitle>
83 83
 

+ 84 - 24
src/pages/employeeProfile/index.vue

@@ -18,15 +18,15 @@
18 18
                     </view>
19 19
                 </scroll-view>
20 20
                 <view v-if="selectedTimeTag === 4" class="date-range-picker">
21
-                    <picker mode="date" :value="startDate" @change="onStartDateChange">
22
-                        <view class="date-input" :class="{ filled: startDate }">
23
-                            {{ startDate || '开始日期' }}
21
+                    <picker mode="date" :value="beginTime" @change="onBeginTimeChange">
22
+                        <view class="date-input" :class="{ filled: beginTime }">
23
+                            {{ (beginTime || '').substring(0, 10) || '开始日期' }}
24 24
                         </view>
25 25
                     </picker>
26 26
                     <text class="date-separator">至</text>
27
-                    <picker mode="date" :value="endDate" @change="onEndDateChange">
28
-                        <view class="date-input" :class="{ filled: endDate }">
29
-                            {{ endDate || '结束日期' }}
27
+                    <picker mode="date" :value="endTime" @change="onEndTimeChange">
28
+                        <view class="date-input" :class="{ filled: endTime }">
29
+                            {{ (endTime || '').substring(0, 10) || '结束日期' }}
30 30
                         </view>
31 31
                     </picker>
32 32
                 </view>
@@ -106,13 +106,13 @@
106 106
                         <view class="score-section">
107 107
                             <div class="score-circle" ref="scoreCircle"></div>
108 108
                             <view class="score-box">
109
-                                <view class="score-row">
109
+                                <!-- <view class="score-row">
110 110
                                     <text class="score-label">评分:</text>
111 111
                                     <text class="score-val">{{ portrait.totalScore || 0 }}</text>
112
-                                </view>
112
+                                </view> -->
113 113
                                 <view class="score-row">
114
-                                    <text class="score-label">标签得分:</text>
115
-                                    <text class="score-val">{{ tagScoreDisplay }}</text>
114
+                                    <text class="score-label">附加分:</text>
115
+                                    <text class="score-val">{{ tagScoreDisplay }}</text>
116 116
                                 </view>
117 117
                             </view>
118 118
                         </view>
@@ -309,8 +309,8 @@ export default {
309 309
             timeTags: ['近一周', '近一月', '近三月', '近一年', '自定义时间范围'],
310 310
             currentTime: '',
311 311
             timer: null,
312
-            startDate: '',
313
-            endDate: '',
312
+            beginTime: '',
313
+            endTime: '',
314 314
             searchKeyword: '',
315 315
             portrait: { dimensions: [], awards: [] },
316 316
             tagScoreData: null,
@@ -350,11 +350,12 @@ export default {
350 350
             return age + '岁'
351 351
         },
352 352
         tagScoreDisplay() {
353
-            if (this.tagScoreData == null) return '0'
354
-            if (typeof this.tagScoreData === 'object') {
355
-                return this.tagScoreData.totalScore ?? this.tagScoreData.score ?? this.tagScoreData ?? '0'
356
-            }
357
-            return this.tagScoreData
353
+            
354
+            // if (this.tagScoreData == null) return '0'
355
+            // if (typeof this.tagScoreData === 'object') {
356
+            //     return this.tagScoreData.totalScore ?? this.tagScoreData.score ?? this.tagScoreData ?? '0'
357
+            // }
358
+            return this.portrait?.userTags?.split(',').length || 0
358 359
         },
359 360
         scoreLevelClass() {
360 361
             if ((this.portrait.totalScore || 0) < 75) return 'score-danger'
@@ -383,6 +384,8 @@ export default {
383 384
         this.timer = setInterval(() => {
384 385
             this.updateTime()
385 386
         }, 1000)
387
+        // 默认计算时间范围(近一年)
388
+        this.onTimeTagClick(this.selectedTimeTag)
386 389
         this.fetchEmployeeList()
387 390
     },
388 391
     beforeDestroy() {
@@ -562,16 +565,64 @@ export default {
562 565
         onTimeTagClick(index) {
563 566
             this.selectedTimeTag = index
564 567
             if (index === 4) {
565
-                this.startDate = ''
566
-                this.endDate = ''
568
+                this.beginTime = ''
569
+                this.endTime = ''
567 570
                 return
568 571
             }
572
+            // 自动计算时间范围
573
+            const now = new Date()
574
+            // 设置结束时间为今天的 23:59:59
575
+            const endTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59)
576
+            // 设置开始时间
577
+            let beginTime
578
+            switch(index) {
579
+                case 0: // 近一周
580
+                    beginTime = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000)
581
+                    break
582
+                case 1: // 近一月
583
+                    beginTime = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate())
584
+                    break
585
+                case 2: // 近三月
586
+                    beginTime = new Date(now.getFullYear(), now.getMonth() - 3, now.getDate())
587
+                    break
588
+                case 3: // 近一年
589
+                    beginTime = new Date(now.getFullYear() - 1, now.getMonth(), now.getDate())
590
+                    break
591
+                default:
592
+                    beginTime = now
593
+            }
594
+            // 格式化日期为 YYYY-MM-DD HH:mm:ss
595
+            this.beginTime = this.formatFullDate(beginTime)
596
+            this.endTime = this.formatFullDate(endTime)
597
+            // 选择时间标签后立即查询
598
+            if (this.selectedEmployeeId) {
599
+                this.fetchEmployeePortrait()
600
+            }
569 601
         },
570
-        onStartDateChange(e) {
571
-            this.startDate = e.detail.value
602
+        formatFullDate(d) {
603
+            const y = d.getFullYear()
604
+            const m = String(d.getMonth() + 1).padStart(2, '0')
605
+            const day = String(d.getDate()).padStart(2, '0')
606
+            const h = String(d.getHours()).padStart(2, '0')
607
+            const min = String(d.getMinutes()).padStart(2, '0')
608
+            const s = String(d.getSeconds()).padStart(2, '0')
609
+            return `${y}-${m}-${day} ${h}:${min}:${s}`
610
+        },
611
+        onBeginTimeChange(e) {
612
+            const dateStr = e.detail.value
613
+            this.beginTime = dateStr + ' 00:00:00'
614
+            // 自定义时间选择后立即查询
615
+            if (this.selectedEmployeeId && this.endTime) {
616
+                this.fetchEmployeePortrait()
617
+            }
572 618
         },
573
-        onEndDateChange(e) {
574
-            this.endDate = e.detail.value
619
+        onEndTimeChange(e) {
620
+            const dateStr = e.detail.value
621
+            this.endTime = dateStr + ' 23:59:59'
622
+            // 自定义时间选择后立即查询
623
+            if (this.selectedEmployeeId && this.beginTime) {
624
+                this.fetchEmployeePortrait()
625
+            }
575 626
         },
576 627
         formatWorkDate(d) {
577 628
             if (!d) return '-'
@@ -589,6 +640,13 @@ export default {
589 640
             if (this.searchKeyword.trim()) {
590 641
                 params.personName = this.searchKeyword.trim()
591 642
             }
643
+            // 添加时间参数
644
+            if (this.beginTime) {
645
+                params.beginTime = this.beginTime
646
+            }
647
+            if (this.endTime) {
648
+                params.endTime = this.endTime
649
+            }
592 650
 
593 651
             const portraitPromise = getEmployeePortrait(params).then(res => {
594 652
                 if (res.code === 200 && res.data) {
@@ -596,7 +654,9 @@ export default {
596 654
                     this.portrait.awards.forEach(item => {
597 655
                         item.color = getRandomHexColor()
598 656
                     })
599
-                    this.scoreDetails = res.data.scoreDetails || []
657
+                    // 只取数组中最后一个元素的 scoreDetails
658
+                    const allScoreDetails = res.data.scoreDetails || []
659
+                    this.scoreDetails = allScoreDetails.length > 0 ? allScoreDetails[allScoreDetails.length - 1] : []
600 660
                 }
601 661
             }).catch(() => { })
602 662
 

+ 1 - 1
src/pages/groupProfile/index.vue

@@ -77,7 +77,7 @@
77 77
             </view>
78 78
 
79 79
             <view v-if="activeTab === 'data'">
80
-                <SectionTitle title="当日开航每小时通道过检率">
80
+                <SectionTitle title="通道高峰过检率">
81 81
                     <PassengerChart :chartsData="passengerData" />
82 82
                 </SectionTitle>
83 83
 

+ 1 - 1
src/pages/teamProfile/index.vue

@@ -77,7 +77,7 @@
77 77
             </view>
78 78
 
79 79
             <view v-if="activeTab === 'data'">
80
-                <SectionTitle title="当日开航每小时通道过检率">
80
+                <SectionTitle title="通道高峰过检率">
81 81
                     <PassengerChart :chartsData="passengerData" />
82 82
                 </SectionTitle>
83 83