tech-teacher-ranking.vue
3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
<workbench-card title="科技部老师排行" :subtitle="deptName || 'Top5 总业绩'" icon="el-icon-medal" tone="cyan" :loading="loading">
<template #extra>
<el-button type="text" size="mini" @click="goMore">更多</el-button>
</template>
<div v-if="list.length" class="wb-list">
<div
v-for="(item, idx) in list"
:key="item.EmployeeId || item.employeeId || idx"
class="wb-list-item"
@click="goMore"
>
<div class="wb-list-item__left">
<span class="wb-list-item__dot" :style="{ background: rankColor(idx) }" />
<span class="wb-list-item__title">{{ idx + 1 }}. {{ item.EmployeeName || item.employeeName || '无' }}</span>
</div>
<span class="wb-list-item__meta">¥{{ formatMoney(item.TotalPerformance != null ? item.TotalPerformance : item.totalPerformance) }}</span>
</div>
</div>
<div v-else class="wb-empty">
<div class="wb-empty__circle" style="background:#ecfeff;color:#06b6d4"><i class="el-icon-medal" /></div>
<div class="wb-empty__title">暂无排行数据</div>
<div class="wb-empty__desc">本月科技部老师排行将显示在这里</div>
</div>
</workbench-card>
</template>
<script>
import request from '@/utils/request'
import WorkbenchCard from '../workbench-card.vue'
import { formatMoney, getCurrentMonthYm } from '../utils'
export default {
name: 'WidgetTechTeacherRanking',
components: { WorkbenchCard },
data() {
return {
loading: false,
techDepartmentId: '',
deptName: '',
list: []
}
},
mounted() {
this.load()
},
methods: {
formatMoney,
rankColor(idx) {
return ['#f59e0b', '#94a3b8', '#cd7f32', '#06b6d4', '#06b6d4'][idx] || '#06b6d4'
},
async resolveDept() {
const res = await request({
url: '/api/Extend/Organize/GetByName',
method: 'get',
data: { organizeName: '科技部' }
})
const list = res.data || []
const first = list[0]
if (!first) return
this.techDepartmentId = first.Id || first.id || ''
this.deptName = first.FullName || first.fullName || '科技部'
},
async load() {
this.loading = true
try {
await this.resolveDept()
if (!this.techDepartmentId) {
this.list = []
return
}
const res = await request({
url: '/api/Extend/LqTechDepartmentDashboard/GetTeacherRanking',
method: 'post',
data: {
statisticsMonth: getCurrentMonthYm(),
techDepartmentId: this.techDepartmentId,
storeIds: []
}
})
const rows = (res.data && (res.data.RankingData || res.data.rankingData)) || []
this.list = (Array.isArray(rows) ? rows : []).slice(0, 5)
} catch (e) {
this.list = []
} finally {
this.loading = false
}
},
goMore() {
this.$router.push('/extend/techDepartmentDashboard').catch(() => {})
}
}
}
</script>
<style lang="scss" scoped>
@import '../widget-common.scss';
</style>