efficient.vue
3.21 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!--
* @Description: 有效客户
* @Author: huyue
* @Date: 2022-06-23 15:05:21
* @LastEditors: huyue
* @LastEditTime: 2022-06-23 17:21:17
-->
<template>
<div>
<div class="title title-icon">
<span class="icon"></span>
<span>有效客户</span>
</div>
<div v-if="!dataList.length" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<div v-else>
<div v-if="isEmpty" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<LineChart v-else ref="lineChartRef" domId="efficientChart" :dataList.sync="dataList" :storeOrBrandTxt="storeOrBrandTxt" :queryType="queryType"></LineChart>
</div>
</div>
</template>
<script>
import { changeMixin } from '@/mixins'
export default {
name: 'Efficient',
mixins: [changeMixin],
props: {
height: {
type: String,
default: '19.8vh'
}
},
data() {
return {
isEmpty: true,
storeOrBrandTxt: '品牌',
queryType: 0,
dataList: []
}
},
mounted() { },
methods: {
init(val) {
this.isEmpty = true
this.queryType = +this.watchReportParams.reportType
var params = {
req: {
queryItem: 'valid',
querystartTime: +this.watchReportParams.reportType === 1 ? this.getNDate(-30) : this.getNMonth(-12),
queryendTime: +this.watchReportParams.reportType === 1 ? this.getNDate(-1) : this.getNMonth(-1),
queryType: this.watchReportParams.reportType || 0
}
}
var brandName = val.brand ? val.brand.name : ''
this.storeOrBrandTxt = brandName ? '门店' : '品牌'
if (brandName) {
params.req.brandName = brandName
}
this.api.afterSales[brandName ? 'getMerchantAfterSale' : 'getAfterSale'](params).then(res => {
var { code, data } = res
switch (+code) {
case 0:
this.dataList = []
if (!data.dataList.map(item => item.num).every(item => item === 0)) {
this.isEmpty = false
this.dealList(data.dataList)
this.$nextTick(() => {
this.$refs.lineChartRef.drawLine()
})
}
break
}
})
},
dealList(list) {
var topList = []
var lastList = []
list.forEach(item => {
const topTempList = item.topList === 'null' ? [] : JSON.parse(item.topList)
const lastTempList = item.lastList === 'null' ? [] : JSON.parse(item.lastList)
topList = []
lastList = []
Object.keys(topTempList).forEach(item => {
topList.push({
label: item,
value: topTempList[item].num ? this.numAddSymbol(topTempList[item].num) : '- -'
})
})
Object.keys(lastTempList).forEach(item => {
lastList.push({
label: item,
value: lastTempList[item].num ? this.numAddSymbol(lastTempList[item].num) : '- -'
})
})
this.dataList.push({
num: item.num || 0,
hrate: item.hrate.toFixed(4) || 0,
trate: item.trate.toFixed(4) || 0,
statDate: item.statDate,
topList: topList,
lastList: lastList
})
})
}
}
}
</script>