|
@@ -32,7 +32,7 @@
|
32
|
32
|
</div>
|
33
|
33
|
<div class="trendBox" v-loading="trends_loading">
|
34
|
34
|
<div class="legendBox">
|
35
|
|
- <div class="legendItem" v-for="(item,index) in legendList" :key="index" @click="changeLegend(item,index)">{{item.name}}
|
|
35
|
+ <div class="legendItem" v-for="(item,index) in legendList" :key="index" @click="changeLegend('legendList',item,index)">{{item.name}}
|
36
|
36
|
<div :class="['checkbox',item.selectFlag?'checkbox_active':'']" :style="item.selectFlag?`background: ${item.color};
|
37
|
37
|
border-color: ${item.color};`:''"><i class="el-icon-check"></i></div>
|
38
|
38
|
</div>
|
|
@@ -47,6 +47,18 @@
|
47
|
47
|
<div id="trend" style="width:100%;height:250px"></div>
|
48
|
48
|
<noData class="noData" v-if="custTrends&&custTrends.length<=0&&!trends_loading"></noData>
|
49
|
49
|
</div>
|
|
50
|
+ <!-- S 新增"总消耗"、"总回收"图表 -->
|
|
51
|
+ <div class="trendBox mt-10" v-loading="trends_loading">
|
|
52
|
+ <div class="legendBox">
|
|
53
|
+ <div class="legendItem" v-for="(item,index) in legendListNew" :key="index" @click="changeLegend('legendListNew',item,index)">{{item.name}}
|
|
54
|
+ <div :class="['checkbox',item.selectFlag?'checkbox_active':'']" :style="item.selectFlag?`background: ${item.color};
|
|
55
|
+ border-color: ${item.color};`:''"><i class="el-icon-check"></i></div>
|
|
56
|
+ </div>
|
|
57
|
+ </div>
|
|
58
|
+ <div id="trendNew" style="width:100%;height:250px"></div>
|
|
59
|
+ <noData class="noData" v-if="custTrendsNew&&custTrendsNew.length<=0&&!trends_loading"></noData>
|
|
60
|
+ </div>
|
|
61
|
+ <!-- E 新增"总消耗"、"总回收"图表 -->
|
50
|
62
|
<div class="listBox" v-loading="custDataListLoading">
|
51
|
63
|
<h3>企微列表</h3>
|
52
|
64
|
<ux-grid ref="plxTable" :border="false" @row-click="()=>{return}" :header-cell-style="()=>{return { backgroundColor: '#FFFFFF !important', border: 'none!important' }}" :height="height" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini">
|
|
@@ -70,6 +82,7 @@
|
70
|
82
|
<script>
|
71
|
83
|
import datePicker from '@/components/assembly/screen/datePicker.vue'
|
72
|
84
|
import noData from "@/components/assembly/noData";
|
|
85
|
+import _lodash from 'lodash'
|
73
|
86
|
export default {
|
74
|
87
|
components: { datePicker, noData },
|
75
|
88
|
data () {
|
|
@@ -89,6 +102,10 @@ export default {
|
89
|
102
|
{ name: '付费金额', key: 'cust_pay_amount', color: '#F28544', selectFlag: true },
|
90
|
103
|
{ name: '付费用户客单价', key: 'charge_user_cost', color: '#E360C8', selectFlag: true },
|
91
|
104
|
],
|
|
105
|
+ legendListNew: [
|
|
106
|
+ { name: '总消耗', key: 'total_cost', color: '#2983DF', selectFlag: true },
|
|
107
|
+ { name: '总回收', key: 'total_cust_pay_amount', color: '#EB4315', selectFlag: true },
|
|
108
|
+ ],
|
92
|
109
|
data_loading: false,
|
93
|
110
|
custTotal: [
|
94
|
111
|
{
|
|
@@ -184,7 +201,9 @@ export default {
|
184
|
201
|
default_time: [this.$getDay(-8, false), this.$getDay(-1, false)],
|
185
|
202
|
time: [],
|
186
|
203
|
myChart: null,
|
|
204
|
+ myChartNew: null,
|
187
|
205
|
custTrends: [],
|
|
206
|
+ custTrendsNew: [],
|
188
|
207
|
trends_loading: false,
|
189
|
208
|
lastName: '',
|
190
|
209
|
enterpriseList: [],
|
|
@@ -328,13 +347,24 @@ export default {
|
328
|
347
|
start: this.time[0],
|
329
|
348
|
end: this.time[1],
|
330
|
349
|
}
|
331
|
|
- }).then((res) => {
|
332
|
|
- var res = res.data
|
|
350
|
+ }).then((_res) => {
|
|
351
|
+ const res = _res.data
|
333
|
352
|
this.trends_loading = false
|
334
|
353
|
if (res && res.errno == 0) {
|
335
|
|
- this.custTrends = res.rst;
|
|
354
|
+ // 处理后端返回的数据 => 分离&提取新图表数据
|
|
355
|
+ this.custTrends = _lodash.cloneDeep(res.rst)
|
|
356
|
+ this.custTrends.forEach(item => {
|
|
357
|
+ delete item['total_cost']
|
|
358
|
+ delete item['total_cust_pay_amount']
|
|
359
|
+ })
|
|
360
|
+ this.custTrendsNew = _lodash.cloneDeep(res.rst).map(item => ({
|
|
361
|
+ idate: item['idate'],
|
|
362
|
+ total_cost: item['total_cost'],
|
|
363
|
+ total_cust_pay_amount: item['total_cust_pay_amount']
|
|
364
|
+ }))
|
336
|
365
|
this.$nextTick(() => {
|
337
|
|
- this.trendEvent()
|
|
366
|
+ this.trendEvent('custTrends') // 绘制图表
|
|
367
|
+ this.trendEvent('custTrendsNew') // 绘制新图表
|
338
|
368
|
})
|
339
|
369
|
} else if (res.errno != 4002) {
|
340
|
370
|
this.$message({
|
|
@@ -346,14 +376,21 @@ export default {
|
346
|
376
|
this.trends_loading = false
|
347
|
377
|
});
|
348
|
378
|
},
|
349
|
|
- trendEvent () {
|
350
|
|
- this.myChart && this.myChart.clear()
|
351
|
|
- var _this = this;
|
352
|
|
- var series = [], yAxis = []
|
353
|
|
- let xArr = this.custTrends.map((v) => {
|
|
379
|
+ /**
|
|
380
|
+ * chartDataName 图表数据名称
|
|
381
|
+ */
|
|
382
|
+ trendEvent (chartDataName) {
|
|
383
|
+ // 旧图表
|
|
384
|
+ chartDataName === 'custTrends' && this.myChart && this.myChart.clear()
|
|
385
|
+ // 新图表
|
|
386
|
+ chartDataName === 'custTrendsNew' && this.myChartNew && this.myChartNew.clear()
|
|
387
|
+
|
|
388
|
+ const _this = this;
|
|
389
|
+ let series = [], yAxis = []
|
|
390
|
+ let xArr = this[chartDataName].map((v) => {
|
354
|
391
|
return v.idate
|
355
|
392
|
});
|
356
|
|
- this.legendList.forEach((item, index) => {
|
|
393
|
+ this[chartDataName === 'custTrends' ? 'legendList' : 'legendListNew'].forEach((item, index) => {
|
357
|
394
|
if (item.selectFlag) {
|
358
|
395
|
yAxis.push(
|
359
|
396
|
{
|
|
@@ -385,8 +422,8 @@ export default {
|
385
|
422
|
fontSize: 12,
|
386
|
423
|
show: true,
|
387
|
424
|
formatter: function (params) {
|
388
|
|
- var result = params;
|
389
|
|
- var resultData;
|
|
425
|
+ let result = params;
|
|
426
|
+ let resultData;
|
390
|
427
|
resultData = _this.$NumberHandle(result)
|
391
|
428
|
return resultData;
|
392
|
429
|
}
|
|
@@ -394,7 +431,7 @@ export default {
|
394
|
431
|
})
|
395
|
432
|
|
396
|
433
|
// series
|
397
|
|
- let data = this.custTrends.map((v) => {
|
|
434
|
+ let data = this[chartDataName].map((v) => {
|
398
|
435
|
return v[item.key] || v[item.key] == 0 ? v[item.key] : '-'
|
399
|
436
|
});
|
400
|
437
|
series.push({
|
|
@@ -420,13 +457,13 @@ export default {
|
420
|
457
|
series.forEach((item, index) => {
|
421
|
458
|
item.yAxisIndex = index
|
422
|
459
|
})
|
423
|
|
- var option = {
|
|
460
|
+ let option = {
|
424
|
461
|
title: '',
|
425
|
462
|
tooltip: {
|
426
|
463
|
trigger: 'axis',
|
427
|
464
|
show: true,
|
428
|
465
|
formatter: function (params) {
|
429
|
|
- var result = params[0].name;
|
|
466
|
+ let result = params[0].name;
|
430
|
467
|
result += '<br/>'
|
431
|
468
|
params.forEach((item, index) => {
|
432
|
469
|
result +=
|
|
@@ -484,11 +521,16 @@ export default {
|
484
|
521
|
series: series
|
485
|
522
|
};
|
486
|
523
|
//初始化echarts实例
|
487
|
|
- this.myChart = this.myChart ? this.myChart : this.$echarts.init(document.getElementById('trend'));
|
488
|
|
- this.myChart.setOption(option);
|
|
524
|
+ if (chartDataName === 'custTrends') {
|
|
525
|
+ this.myChart = this.myChart ? this.myChart : this.$echarts.init(document.getElementById('trend'));
|
|
526
|
+ this.myChart.setOption(option);
|
|
527
|
+ } else if (chartDataName === 'custTrendsNew') {
|
|
528
|
+ this.myChartNew = this.myChartNew ? this.myChartNew : this.$echarts.init(document.getElementById('trendNew'));
|
|
529
|
+ this.myChartNew.setOption(option);
|
|
530
|
+ }
|
489
|
531
|
},
|
490
|
|
- changeLegend (data, index) {
|
491
|
|
- let arr = this.legendList.filter((v) => {
|
|
532
|
+ changeLegend (legendListName, data, index) {
|
|
533
|
+ let arr = this[legendListName].filter((v) => {
|
492
|
534
|
return v.selectFlag
|
493
|
535
|
})
|
494
|
536
|
if (arr.length == 1 && arr[0].key == data.key) {
|
|
@@ -500,9 +542,10 @@ export default {
|
500
|
542
|
}
|
501
|
543
|
let item = data;
|
502
|
544
|
item.selectFlag = !item.selectFlag;
|
503
|
|
- this.$set(this.legendList, index, item)
|
|
545
|
+ this.$set(this[legendListName], index, item)
|
504
|
546
|
this.$nextTick(() => {
|
505
|
|
- this.trendEvent()
|
|
547
|
+ legendListName === 'legendList' && this.trendEvent('custTrends')
|
|
548
|
+ legendListName === 'legendListNew' && this.trendEvent('custTrendsNew')
|
506
|
549
|
})
|
507
|
550
|
},
|
508
|
551
|
changeTime (time) {//筛选时间变化
|
|
@@ -516,6 +559,7 @@ export default {
|
516
|
559
|
},
|
517
|
560
|
beforeDestroy () {
|
518
|
561
|
this.myChart && this.myChart.clear()
|
|
562
|
+ this.myChartNew && this.myChartNew.clear()
|
519
|
563
|
},
|
520
|
564
|
beforeRouteEnter (to, from, next) {
|
521
|
565
|
next(vm => { // 这里的vm指的就是vue实例,可以用来当做this使用
|
|
@@ -525,6 +569,9 @@ export default {
|
525
|
569
|
}
|
526
|
570
|
</script>
|
527
|
571
|
<style lang="scss" scoped>
|
|
572
|
+.mt-10 {
|
|
573
|
+ margin-top: 10px;
|
|
574
|
+}
|
528
|
575
|
.dataInfoBox {
|
529
|
576
|
display: flex;
|
530
|
577
|
flex-wrap: wrap;
|