mileage.vue
4.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!--
* @Description: 售后车辆里程
* @Author: huyue
* @Date: 2022-06-23 15:05:21
* @LastEditors: huyue
* @LastEditTime: 2022-07-11 11:00:49
-->
<template>
<div>
<div class="title title-icon">
<span class="icon"></span>
<span>售后车辆里程</span>
</div>
<template v-if="mileageData.length > 0">
<div class="flex container">
<pie-chart :id="chart.id" :list="mileageData" :height="height - 5 + 'vh'" :radius="chart.radius" @pieAction="pieAction" :size="chart.size"></pie-chart>
<div class="ranking-container">
<div class="ranking-title">
<div class="ranking-title-brand">{{ this.$store.state.app.reportParams.brand ? '门店' : '品牌' }}</div>
<div>客户数</div>
</div>
<div class="ranking">
<div class="brand flex" v-for="(item, index) in rankingData.slice(0, 5)" :key="index">
<span class="brand-num">{{ index + 1 }}</span>
<marquee class="marquee" :direction="directionTimer" :delay="delayTimer" :text="item.brand" />
<span>{{ item.value }}</span>
</div>
</div>
</div>
</div>
</template>
<div class="empty" :style="{ height: height - 4.9 + 'vh' }" v-else>
<img src="../../assets/images/empty.png" alt="" />
</div>
</div>
</template>
<script>
import { changeMixin } from '../../mixins/index'
export default {
name: 'Mileage',
props: ['height'],
mixins: [changeMixin],
data() {
return {
mileageData: [],
distributionRank: '',
rankingData: [],
chart: {
id: 'mileagePie',
radius: ['60%', '78%'],
size: '0.8vw'
},
delayTimer: 3000,
directionTimer: 3000,
brandList: this.list,
isBrand: false,
brandName: ''
}
},
mounted() {
this.getValueType()
},
methods: {
getValueType() {
let mileageApi = !this.isBrand ? 'aftersaleother' : 'afterMerchantSaleother'
const params = {
req: {
queryItem: 'mileage',
queryTime: this.getCurrentDate(),
queryType: this.watchReportParams.reportType
}
}
if (this.isBrand) params.req.brandName = this.brandName
this.api.afterSales[mileageApi](params).then(res => {
this.mileageData = []
this.rankingData = []
if (res.data.dataList.length > 0) {
let distribution = JSON.parse(res.data.dataList[0].distribution)
// console.log()
const keys = Object.keys(distribution)
keys.forEach((item, index) => {
this.mileageData.push({
name: item,
value: distribution[item]
})
})
this.distributionRank = JSON.parse(res.data.dataList[0].distributionRank)
}
})
},
pieAction(data) {
let distributionRank = this.distributionRank[data.name]
this.rankingData = []
for (const key in distributionRank) {
this.rankingData.push({
brand: key,
value: distributionRank[key]
})
}
this.rankingData.sort(function (a, b) {
return b.value - a.value //倒序
})
},
init(newVal) {
this.isBrand = false
if (newVal && newVal.brand) {
this.isBrand = true
this.brandName = newVal.brand.name
}
this.getValueType()
}
}
}
</script>
<style lang="scss" scoped>
.title {
padding: 1vh 8px;
height: 4vh;
}
.ranking-container {
flex: 1;
margin-left: 0.6vw;
box-sizing: border-box;
height: 21.5vh;
width: 10.8vw;
background: #262525;
.ranking-title {
padding: 0.5vh 1.5vw 0.4vh 1.5vw;
font-size: 0.833vw;
color: #eb6001;
letter-spacing: 0;
font-weight: 400;
background: rgba(53, 53, 53, 0.6);
display: flex;
align-items: center;
div {
white-space: nowrap;
}
.ranking-title-brand {
width: 4.9vw;
margin-right: 0.6vw;
}
}
.ranking {
font-size: 0.694vw;
color: #ffffff;
letter-spacing: 0;
font-weight: 400;
padding: 0.1vh 0 0.4vh 8px;
height: 18.5vh;
box-sizing: border-box;
.brand {
line-height: 3.6vh;
.brand-num {
color: #606266;
margin-right: 8px;
display: inline-block;
width: 0.3vw;
text-align: center;
}
.marquee {
width: 4.9vw;
height: 3.6vh;
margin-right: 0.6vw;
}
}
}
}
</style>