Explorar o código

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

1. 统一多个页面的通道过检率标题为"通道高峰过检率"
2. 重构自定义时间范围选择逻辑,替换为beginTime/endTime变量
3. 优化标签得分展示逻辑,改为统计用户标签数量
4. 新增自动计算默认时间范围功能
5. 调整分数详情获取逻辑,仅取最后一条数据
6. 优化日期选择器展示格式与交互
huoyi hai 1 semana
pai
achega
c7aa083e4e

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

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

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

@@ -18,15 +18,15 @@
18
                     </view>
18
                     </view>
19
                 </scroll-view>
19
                 </scroll-view>
20
                 <view v-if="selectedTimeTag === 4" class="date-range-picker">
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
                         </view>
24
                         </view>
25
                     </picker>
25
                     </picker>
26
                     <text class="date-separator">至</text>
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
                         </view>
30
                         </view>
31
                     </picker>
31
                     </picker>
32
                 </view>
32
                 </view>
@@ -106,13 +106,13 @@
106
                         <view class="score-section">
106
                         <view class="score-section">
107
                             <div class="score-circle" ref="scoreCircle"></div>
107
                             <div class="score-circle" ref="scoreCircle"></div>
108
                             <view class="score-box">
108
                             <view class="score-box">
109
-                                <view class="score-row">
109
+                                <!-- <view class="score-row">
110
                                     <text class="score-label">评分:</text>
110
                                     <text class="score-label">评分:</text>
111
                                     <text class="score-val">{{ portrait.totalScore || 0 }}</text>
111
                                     <text class="score-val">{{ portrait.totalScore || 0 }}</text>
112
-                                </view>
112
+                                </view> -->
113
                                 <view class="score-row">
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
                                 </view>
116
                                 </view>
117
                             </view>
117
                             </view>
118
                         </view>
118
                         </view>
@@ -309,8 +309,8 @@ export default {
309
             timeTags: ['近一周', '近一月', '近三月', '近一年', '自定义时间范围'],
309
             timeTags: ['近一周', '近一月', '近三月', '近一年', '自定义时间范围'],
310
             currentTime: '',
310
             currentTime: '',
311
             timer: null,
311
             timer: null,
312
-            startDate: '',
313
-            endDate: '',
312
+            beginTime: '',
313
+            endTime: '',
314
             searchKeyword: '',
314
             searchKeyword: '',
315
             portrait: { dimensions: [], awards: [] },
315
             portrait: { dimensions: [], awards: [] },
316
             tagScoreData: null,
316
             tagScoreData: null,
@@ -350,11 +350,12 @@ export default {
350
             return age + '岁'
350
             return age + '岁'
351
         },
351
         },
352
         tagScoreDisplay() {
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
         scoreLevelClass() {
360
         scoreLevelClass() {
360
             if ((this.portrait.totalScore || 0) < 75) return 'score-danger'
361
             if ((this.portrait.totalScore || 0) < 75) return 'score-danger'
@@ -383,6 +384,8 @@ export default {
383
         this.timer = setInterval(() => {
384
         this.timer = setInterval(() => {
384
             this.updateTime()
385
             this.updateTime()
385
         }, 1000)
386
         }, 1000)
387
+        // 默认计算时间范围(近一年)
388
+        this.onTimeTagClick(this.selectedTimeTag)
386
         this.fetchEmployeeList()
389
         this.fetchEmployeeList()
387
     },
390
     },
388
     beforeDestroy() {
391
     beforeDestroy() {
@@ -562,16 +565,64 @@ export default {
562
         onTimeTagClick(index) {
565
         onTimeTagClick(index) {
563
             this.selectedTimeTag = index
566
             this.selectedTimeTag = index
564
             if (index === 4) {
567
             if (index === 4) {
565
-                this.startDate = ''
566
-                this.endDate = ''
568
+                this.beginTime = ''
569
+                this.endTime = ''
567
                 return
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
         formatWorkDate(d) {
627
         formatWorkDate(d) {
577
             if (!d) return '-'
628
             if (!d) return '-'
@@ -589,6 +640,13 @@ export default {
589
             if (this.searchKeyword.trim()) {
640
             if (this.searchKeyword.trim()) {
590
                 params.personName = this.searchKeyword.trim()
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
             const portraitPromise = getEmployeePortrait(params).then(res => {
651
             const portraitPromise = getEmployeePortrait(params).then(res => {
594
                 if (res.code === 200 && res.data) {
652
                 if (res.code === 200 && res.data) {
@@ -596,7 +654,9 @@ export default {
596
                     this.portrait.awards.forEach(item => {
654
                     this.portrait.awards.forEach(item => {
597
                         item.color = getRandomHexColor()
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
             }).catch(() => { })
661
             }).catch(() => { })
602
 
662
 

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

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

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

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