lineView.vue
7.7 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<template>
<div id="lineOutput" class="main-customer"></div>
</template>
<script>
import util from "@/utils/util";
import * as echarts from "echarts";
export default {
name: "lineView",
data() {
return {
selectIndex: 0,
customerCount: 0,
newCustomerCount: 0,
addEntmicroCount: 0,
notAddEntmicroCount: 0,
newEntmicroCount: 0,
entmicroLoseCount: 0,
todayEntmicroLoseCount: 0,
packmenberCount: 0,
todayAddPackmenberCount: 0,
currentDayTotalOutputValue: 0,
totalOutputValue: 0,
summaryTime: util.getBeforeDate(),
pickerOptions: {
disabledDate: (time) => {
return time.getTime() > Date.now();
},
},
expandStatus: true,
chartStatus: false,
echartId1: "customerEchartId1",
echartId2: "customerEchartId2",
echartId3: "customerEchartId3",
echartId4: "customerEchartId4",
custAddList: [],
custEntmicroAdds: [],
custLoseList: [],
outputList: [],
custAddListEmpty: false,
custEntmicroAddsEmpty: false,
custLoseListEmpty: false,
totalOutputValueEmpty: false,
};
},
props: {
outputEchartData: {
type: Object,
},
},
watch: {
outputEchartData: {
handler: function () {
this.getChart();
},
},
},
methods: {
getChart() {
const {
totalOutputValueTrends,
equityOutputValueTrends,
shopmallOutputValueTrends,
boutiqueUpgradeOutputValueTrends,
} = this.outputEchartData;
let dateTime = totalOutputValueTrends.map((item) => {
return item.dateTime;
});
let totalOutputValueTrendsValue = totalOutputValueTrends.map((item) => {
return item.outputValue;
});
// let totalOutputValueTrendsAverg = totalOutputValueTrends.map((item) => {
// return item.monthAverg;
// });
// let totalOutputValueTrendsRadio = totalOutputValueTrends.map((item) => {
// return item.radio;
// });
let equityOutputValueTrendsValue = equityOutputValueTrends.map((item) => {
return item.outputValue;
});
// let equityOutputValueTrendsAverg = equityOutputValueTrends.map((item) => {
// return item.monthAverg;
// });
// let equityOutputValueTrendsRadio = equityOutputValueTrends.map((item) => {
// return item.radio;
// });
let shopmallOutputValueTrendsValue = shopmallOutputValueTrends.map((item) => {
return item.outputValue;
});
// let shopmallOutputValueTrendsAverg = shopmallOutputValueTrends.map((item) => {
// return item.monthAverg;
// });
// let shopmallOutputValueTrendsRadio = shopmallOutputValueTrends.map((item) => {
// return item.radio;
// });
let boutiqueUpgradeOutputValueTrendsValue = boutiqueUpgradeOutputValueTrends.map(
(item) => {
return item.outputValue;
}
);
// let boutiqueUpgradeOutputValueTrendsAverg = boutiqueUpgradeOutputValueTrends.map(
// (item) => {
// return item.monthAverg;
// }
// );
// let boutiqueUpgradeOutputValueTrendsRadio = boutiqueUpgradeOutputValueTrends.map(
// (item) => {
// return item.radio;
// }
// );
let chartDom = document.getElementById("lineOutput");
let myChart = echarts.init(chartDom);
let option;
option = {
tooltip: {
trigger: "item",
formatter(params) {
let circleColor;
// let Averg;
// let i_name;
if (params.seriesName == "总产值") {
circleColor = "#5850FF";
// Averg = totalOutputValueTrendsAverg[params.dataIndex];
// i_name =
// totalOutputValueTrendsRadio[params.dataIndex] == 1
// ? "el-icon-top"
// : totalOutputValueTrendsRadio[params.dataIndex] == -1
// ? "el-icon-bottom"
// : "";
}
if (params.seriesName == "商城") {
circleColor = "#2CCA74";
// Averg = shopmallOutputValueTrendsAverg[params.dataIndex];
// i_name =
// shopmallOutputValueTrendsRadio[params.dataIndex] == 1
// ? "el-icon-top"
// : shopmallOutputValueTrendsRadio[params.dataIndex] == -1
// ? "el-icon-bottom"
// : "";
}
if (params.seriesName == "门店服务套餐") {
circleColor = "#FF6D00";
// Averg = equityOutputValueTrendsAverg[params.dataIndex];
// i_name =
// equityOutputValueTrendsRadio[params.dataIndex] == 1
// ? "el-icon-top"
// : equityOutputValueTrendsRadio[params.dataIndex] == -1
// ? "el-icon-bottom"
// : "";
}
if (params.seriesName == "精品升级") {
circleColor = "#FACD67";
// Averg = boutiqueUpgradeOutputValueTrendsAverg[params.dataIndex];
// i_name =
// boutiqueUpgradeOutputValueTrendsRadio[params.dataIndex] == 1
// ? "el-icon-top"
// : boutiqueUpgradeOutputValueTrendsRadio[params.dataIndex] == -1
// ? "el-icon-bottom"
// : "";
}
return (
params.name +
"<br>" +
`<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${circleColor};"></span>` +
params.seriesName +
":" +
params.value
// `<i class="${i_name}" style="color: ${circleColor}"></i>` +
// "<br>" +
// `<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${circleColor};"></span>` +
// (new Date(params.name).getMonth() + 1)
// "月均值:" +
// Averg
);
},
},
legend: {
data: ["总产值", "商城", "门店服务套餐", "精品升级"],
x: "center",
icon: "stack",
itemHeight: 2,
itemWidth: 12,
},
grid: {
left: "3%",
right: "4%",
bottom: 0,
containLabel: true,
},
xAxis: {
type: "category",
boundaryGap: false,
color: "#A3A3A3",
data: dateTime,
},
yAxis: {
type: "value",
show: true,
name: "单位:元",
},
series: [
{
name: "总产值",
type: "line",
lineStyle: { color: "#5850FF " },
data: totalOutputValueTrendsValue,
smooth: true,
},
{
name: "商城",
type: "line",
lineStyle: { color: "#2CCA74 " },
data: shopmallOutputValueTrendsValue,
smooth: true,
},
{
name: "门店服务套餐",
type: "line",
lineStyle: { color: "#FF6D00 " },
data: equityOutputValueTrendsValue,
smooth: true,
},
{
name: "精品升级",
type: "line",
lineStyle: { color: "#FACD67 " },
data: boutiqueUpgradeOutputValueTrendsValue,
smooth: true,
},
],
};
myChart.clear()
option && myChart.setOption(option);
window.addEventListener('resize', myChart.resize)
},
},
};
</script>
<style scoped lang="scss">
.main-customer {
margin-top: 15px;
height: 260px;
}
</style>