tk-overview.vue
2.95 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
<template>
<workbench-card title="拓客活动概览" subtitle="当月拓客转化" icon="el-icon-s-custom" tone="green" :loading="loading">
<template #extra>
<el-button type="text" size="mini" @click="goMore">更多</el-button>
</template>
<div class="wb-kpi-grid kpi-4">
<div class="wb-kpi-cell wb-kpi-cell--primary" @click="goMore">
<div class="wb-kpi-cell__label">拓客数</div>
<div class="wb-kpi-cell__value">{{ formatNumber(overview.tkCount) }}</div>
</div>
<div class="wb-kpi-cell wb-kpi-cell--success" @click="goMore">
<div class="wb-kpi-cell__label">到店数</div>
<div class="wb-kpi-cell__value">{{ formatNumber(overview.visitCount) }}</div>
</div>
<div class="wb-kpi-cell wb-kpi-cell--warning" @click="goMore">
<div class="wb-kpi-cell__label">开单数</div>
<div class="wb-kpi-cell__value">{{ formatNumber(overview.billingCount) }}</div>
</div>
<div class="wb-kpi-cell wb-kpi-cell--info" @click="goMore">
<div class="wb-kpi-cell__label">到店率</div>
<div class="wb-kpi-cell__value">{{ overview.visitRate }}%</div>
</div>
</div>
</workbench-card>
</template>
<script>
import { getDashboardOverview } from '@/api/lqTkDashboard'
import WorkbenchCard from '../workbench-card.vue'
import { formatNumber, getCurrentMonthRange } from '../utils'
export default {
name: 'WidgetTkOverview',
components: { WorkbenchCard },
data() {
return {
loading: false,
overview: { tkCount: 0, visitCount: 0, billingCount: 0, visitRate: '0.00' }
}
},
mounted() {
this.load()
},
methods: {
formatNumber,
async load() {
this.loading = true
try {
const range = getCurrentMonthRange()
const res = await getDashboardOverview({
startTime: range.startTime,
endTime: range.endTime
})
const d = res.data || {}
const tkCount = Number(d.TotalExpansionCount || d.totalExpansionCount || d.TotalTkCount || d.totalTkCount || 0)
const visitCount = Number(d.TotalVisitCount || d.totalVisitCount || 0)
const billingCount = Number(d.TotalBillingCount || d.totalBillingCount || d.BillingCount || d.billingCount || 0)
const visitRate = Number(d.OverallVisitRate || d.overallVisitRate || d.VisitRate || d.visitRate || 0)
this.overview = {
tkCount,
visitCount,
billingCount,
visitRate: visitRate.toFixed(2)
}
} catch (e) {
this.overview = { tkCount: 0, visitCount: 0, billingCount: 0, visitRate: '0.00' }
} finally {
this.loading = false
}
},
goMore() {
this.$router.push('/lqTkjlb').catch(() => {})
}
}
}
</script>
<style lang="scss" scoped>
@import '../widget-common.scss';
.kpi-4 { grid-template-columns: repeat(4, 1fr); }
.wb-kpi-cell { cursor: pointer; }
@media (max-width: 1200px) {
.kpi-4 { grid-template-columns: repeat(2, 1fr); }
}
</style>