store-kpi.vue
2.78 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
<template>
<workbench-card title="本店核心指标" subtitle="当前门店当月" icon="el-icon-office-building" tone="cyan" :loading="loading">
<div v-if="!storeId" class="wb-empty">
<div class="wb-empty__circle" style="background:#ecfeff;color:#06b6d4">
<i class="el-icon-office-building" />
</div>
<div class="wb-empty__title">未绑定门店</div>
<div class="wb-empty__desc">当前账号未绑定门店,无法展示本店指标</div>
</div>
<div v-else class="wb-kpi-grid kpi-4">
<div class="wb-kpi-cell wb-kpi-cell--primary">
<div class="wb-kpi-cell__label">开单业绩</div>
<div class="wb-kpi-cell__value">¥{{ formatMoney(perf.BillingPerformance) }}</div>
</div>
<div class="wb-kpi-cell wb-kpi-cell--success">
<div class="wb-kpi-cell__label">消耗业绩</div>
<div class="wb-kpi-cell__value">¥{{ formatMoney(perf.ConsumePerformance) }}</div>
</div>
<div class="wb-kpi-cell wb-kpi-cell--warning">
<div class="wb-kpi-cell__label">完成率</div>
<div class="wb-kpi-cell__value">{{ rateText }}%</div>
</div>
<div class="wb-kpi-cell wb-kpi-cell--info">
<div class="wb-kpi-cell__label">净业绩</div>
<div class="wb-kpi-cell__value">¥{{ formatMoney(perf.NetPerformance) }}</div>
</div>
</div>
</workbench-card>
</template>
<script>
import { mapGetters } from 'vuex'
import { getStoreDashboardStatistics } from '@/api/report'
import WorkbenchCard from '../workbench-card.vue'
import { formatMoney } from '../utils'
export default {
name: 'WidgetStoreKpi',
components: { WorkbenchCard },
data() {
return { loading: false, perf: {} }
},
computed: {
...mapGetters(['userInfo']),
storeId() {
return (this.userInfo && (this.userInfo.mdid || this.userInfo.organizeId)) || ''
},
month() {
const d = new Date()
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}`
},
rateText() {
return Number(this.perf.CompletionRate || 0).toFixed(2)
}
},
mounted() {
this.load()
},
methods: {
formatMoney,
async load() {
if (!this.storeId) return
this.loading = true
try {
const res = await getStoreDashboardStatistics({
storeId: this.storeId,
month: this.month
})
const data = (res.data && res.data.Data) || res.data || {}
this.perf = (data.Performance || data.performance || data) || {}
} catch (e) {
this.perf = {}
} finally {
this.loading = false
}
}
}
}
</script>
<style lang="scss" scoped>
@import '../widget-common.scss';
.kpi-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) {
.kpi-4 { grid-template-columns: repeat(2, 1fr); }
}
</style>