kpi-overview.vue
2.71 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
<template>
<workbench-card title="经营核心KPI" subtitle="全公司当月概览" icon="el-icon-wallet" tone="blue" :loading="loading">
<div class="wb-kpi-grid kpi-6">
<div v-for="item in items" :key="item.key" class="wb-kpi-cell" :class="'wb-kpi-cell--' + item.type">
<div class="wb-kpi-cell__label">{{ item.label }}</div>
<div class="wb-kpi-cell__value">{{ item.value }}</div>
</div>
</div>
</workbench-card>
</template>
<script>
import request from '@/utils/request'
import WorkbenchCard from '../workbench-card.vue'
import { formatMoney, getCurrentMonthRange } from '../utils'
export default {
name: 'WidgetKpiOverview',
components: { WorkbenchCard },
data() {
return { loading: false, kpiData: {} }
},
computed: {
items() {
const d = this.kpiData || {}
const tk = d.TkCount || d.tkCount || 0
return [
{ key: 'billing', label: '营收核心', value: '¥' + formatMoney(d.TotalBillingAmount), type: 'primary' },
{ key: 'consume', label: '服务产出', value: '¥' + formatMoney(d.TotalConsumeAmount), type: 'success' },
{ key: 'net', label: '净收益', value: '¥' + formatMoney(d.CompletedBillingAmount), type: 'warning' },
{ key: 'target', label: '目标完成', value: (d.BillingCompletionRate || 0) + '%', type: 'info' },
{ key: 'tk', label: '新客增长', value: tk, type: 'danger' },
{ key: 'refund', label: '退卡风险', value: '¥' + formatMoney(d.TotalRefundAmount), type: 'danger' }
]
}
},
mounted() {
this.load()
},
methods: {
async load() {
this.loading = true
const p = getCurrentMonthRange()
try {
const res = await request({
url: '/api/Extend/LqReport/get-business-statistics',
method: 'POST',
data: { startTime: p.startTime, endTime: p.endTime, storeIds: [] }
})
const data = res.data || {}
this.kpiData = {
TotalBillingAmount: data.TotalBillingAmount || data.billing_amount || 0,
TotalConsumeAmount: data.TotalConsumeAmount || data.consume_amount || 0,
TotalRefundAmount: data.TotalRefundAmount || data.refund_amount || 0,
CompletedBillingAmount: (data.TotalBillingAmount || 0) - (data.TotalRefundAmount || 0),
BillingCompletionRate: data.BillingCompletionRate || 0,
TkCount: data.TkCount || data.NewCustomerCount || 0
}
} catch (e) {
this.kpiData = {}
} finally {
this.loading = false
}
}
}
}
</script>
<style lang="scss" scoped>
@import '../widget-common.scss';
.kpi-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1400px) {
.kpi-6 { grid-template-columns: repeat(3, 1fr); }
}
</style>