performanceStatus.vue
5.13 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!-- 业绩状况 -->
<template>
<div class="performance-status">
<div class="header">
业绩状况({{
queryData.scene == 1 ? "延保" : queryData.scene == 2 ? "轻改" : "权益"
}})
</div>
<div class="tabs">
<div
:class="{
'tabs-item': true,
'tabs-item-active': index === activeIndex
}"
v-for="(item, index) in timeData"
:key="index"
@click="handleClick(index)"
>
{{ item.text }}
</div>
</div>
<div class="content">
<!-- 产值 -->
<div class="content-item">
<div class="title">个人产值(元)</div>
<echart-bar
title="个人产值"
class="echart"
id="Output"
:rate="'outputChangeRatio'"
:dataRate="performanceItemInfo"
:xData="xData"
:yData="yOutputData"
></echart-bar>
</div>
<div class="content-item">
<div class="title">转化率(%)</div>
<echart-line
title="转化率"
class="echart"
id="Conversion"
:rate="'conversionChangeRatio'"
:dataRate="performanceItemInfo"
:xData="xData"
:yData="yConversionData"
></echart-line>
</div>
<div class="content-item">
<div class="title">客单价(元)</div>
<echart-bar
title="客单价"
class="echart"
id="AverageOrderValue"
:rate="'aovChangeRatio'"
:dataRate="performanceItemInfo"
:xData="xData"
:yData="yAverageOrderValueData"
></echart-bar>
</div>
</div>
</div>
</template>
<script>
import EchartLine from "./echartLine"
import EchartBar from "./echartBar"
export default {
components: {
EchartLine,
EchartBar
},
name: "performanceStatus",
data() {
return {
xData: [],
yOutputData: [], //产值
yConversionData: [], //转化率
yAverageOrderValueData: [], //客单价
activeIndex: 0,
activeType: "week",
timeData: [
{
text: "近4周",
value: "week"
},
{
text: "近4月",
value: "month"
}
],
performanceItemInfo: [],
queryData: {}
}
},
watch: {
performanceInfo: {
handler(val) {
console.log(val, "业绩状况")
this.initData()
},
deep: true,
immediate: true
}
},
props: {
performanceInfo: {
type: Array,
default: () => []
}
},
created() {
this.queryData = this.$route.query
},
methods: {
initData() {
this.performanceInfo.forEach((item) => {
if (item.timeUnit == this.activeType) {
this.performanceItemInfo = item.data
this.handleData(item.data)
}
})
},
handleData(data) {
let xData = [],
yOutputData = [],
yConversionData = [],
yAverageOrderValueData = []
//近四周
if (this.activeIndex == 0) {
data.forEach((item) => {
// let timeStr = item.startTime + "-" + item.endTime
xData.push(item.endTime)
yOutputData.push(item.personalOutput ? item.personalOutput : 0)
// yOutputDataRate
yConversionData.push(item.conversionRate ? item.conversionRate : 0)
yAverageOrderValueData.push(
item.averageOrderValue ? item.averageOrderValue : 0
)
})
} else {
//近四月
data.forEach((item) => {
// let timeStr = item.startTime + "-" + item.endTime
xData.unshift(item.endTime.substring(0, 7))
yOutputData.unshift(item.personalOutput ? item.personalOutput : 0)
// yOutputDataRate
yConversionData.unshift(item.conversionRate ? item.conversionRate : 0)
yAverageOrderValueData.unshift(
item.averageOrderValue ? item.averageOrderValue : 0
)
})
}
this.xData = xData
this.yOutputData = yOutputData
this.yConversionData = yConversionData
this.yAverageOrderValueData = yAverageOrderValueData
},
handleClick(index) {
this.activeIndex = index
this.activeType = this.timeData[index].value
this.initData()
}
}
}
</script>
<style scoped lang="scss">
.performance-status {
.header {
color: #111111;
font-size: 16px;
font-weight: 500;
padding: 8px 20px;
border-bottom: 1px solid #e5e5e5;
}
.tabs {
margin: 12px 0 16px 20px;
display: flex;
align-items: center;
background: #fff;
border-radius: 2px;
.tabs-item {
padding: 6px 20px;
cursor: pointer;
font-size: 12px;
font-weight: 400;
color: #1d1d1d;
border: 1px solid #dbdbdb;
}
.tabs-item-active {
color: #ffffff;
background: #2a58ad;
}
}
.content {
margin: 20px;
display: flex;
height: 238px;
width: 100%;
.content-item {
flex: 1;
.echart {
width: 100%;
height: 100%;;
}
.title {
color: #333333;
font-size: 14px;
font-weight: 400;
margin-bottom: 12px;
}
}
}
}
</style>