tech-billing-stat.vue
2.39 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
<template>
<workbench-card title="科技部开单业绩" subtitle="科技部当月开单" icon="el-icon-s-promotion" tone="green" :loading="loading">
<div class="stat">
<div class="stat__icon"><i class="el-icon-s-promotion" /></div>
<div class="stat__amount">¥{{ formatMoney(totalAmount) }}</div>
<div class="stat__sub">本月科技部开单合计</div>
<div class="stat__hint">{{ rowCount ? `共 ${rowCount} 条记录` : '本月暂无数据' }}</div>
</div>
</workbench-card>
</template>
<script>
import { mapGetters } from 'vuex'
import { getTechPerformanceStatisticsList } from '@/api/extend/statistics'
import WorkbenchCard from '../workbench-card.vue'
import { formatMoney, getCurrentMonthYm } from '../utils'
export default {
name: 'WidgetTechBillingStat',
components: { WorkbenchCard },
data() {
return { loading: false, totalAmount: 0, rowCount: 0 }
},
computed: {
...mapGetters(['userInfo']),
teacherName() {
return (this.userInfo && (this.userInfo.realName || this.userInfo.userName)) || ''
}
},
mounted() {
this.load()
},
methods: {
formatMoney,
async load() {
this.loading = true
try {
const res = await getTechPerformanceStatisticsList({
pageIndex: 1,
pageSize: 500,
statisticsMonth: getCurrentMonthYm(),
teacherName: this.teacherName || undefined
})
const list = (res.data && res.data.list) || []
this.rowCount = list.length
this.totalAmount = list.reduce((s, r) => s + (Number(r.BillingPerformance || r.TotalPerformance || r.Performance || 0)), 0)
} catch (e) {
this.totalAmount = 0
this.rowCount = 0
} finally {
this.loading = false
}
}
}
}
</script>
<style lang="scss" scoped>
.stat {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 8px 0;
}
.stat__icon {
width: 44px;
height: 44px;
border-radius: 12px;
background: #ecfdf5;
color: #10b981;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
margin-bottom: 10px;
}
.stat__amount {
font-size: 26px;
font-weight: 700;
color: #1e293b;
letter-spacing: -0.02em;
}
.stat__sub { margin-top: 6px; font-size: 13px; color: #64748b; }
.stat__hint { margin-top: 8px; font-size: 12px; color: #94a3b8; }
</style>