vline.vue
4.49 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
<!-- 近期客流趋势 -->
<template>
<div>
<!-- 顶部区域 S-->
<div class="ipage_top">
<div class="tit"><img v-if="icon!='empty'" :src="bindIcon()"/>{{title||chartData.title}}</div>
<div class="acts">
<el-tabs v-model="timeLevel" @tab-click="handleTimeChange" v-if="level.length">
<el-tab-pane v-if="level.includes('MONTH')" :label="$t('iPage.monthOver')" name="MONTH"></el-tab-pane>
<el-tab-pane v-if="level.includes('WEEK')" :label="$t('iPage.weekOver')" name="WEEK"></el-tab-pane>
<el-tab-pane v-if="level.includes('DAY')" :label="$t('iPage.dayOver')" name="DAY"></el-tab-pane>
<el-tab-pane v-if="level.includes('HOUR')" :label="$t('iPage.hourOver')" name="HOUR"></el-tab-pane>
<el-tab-pane v-if="level.includes('MINUTE')" :label="$t('iPage.minuteOver')" name="MINUTE"></el-tab-pane>
</el-tabs>
<slot name="action"></slot>
</div>
</div>
<div class="ichart">
<line-chart ref="chart" :cdata="chartData"></line-chart>
</div>
</div>
</template>
<script>
import _ from 'underscore';
import mixin from './mixin';
import mallData from '@/components/Echarts/data';
/**********************************************************/
let chartsConfig;
/*******************************************************/
export default {
mixins: [mixin],
props: {
level: {
type: Array,
default: () => []
},
selected:{
type:Object,
default: () => {}
}
},
watch:{
level:{
handler(newVal) {
this.timeLevel = newVal[0]||'';
this.loadChartData();
},
deep: true
},
selected: {
handler(newVal) {
this.filterSeries(newVal)
},
deep: true
}
},
data() {
return {
timeLevel:'',
configObj:{},
}
},
created() {
chartsConfig = {
mall_gate_passenger_flow_trends:{ //客流走势
otherConf:{
usePercent:true,
yAxisLineHide:true,
grid:{left:60,top:20,right:20,bottom:20},
}
},
recent_passenger_flow_trends:{ //近期客流趋势
otherConf:{
_color:['#ffb4cc','#4992FF','#FF6D43','#F5D090','#63DAAB'],
barWidth:26,
yAxisLineHide:true,
grid:{left:70,top:40,right:0,bottom:20},
yAxisName:painter.$t('format.perTime')
}
},
detention_comparison:{
otherConf:{
yAxisLineHide:true,
legendShow:true,
yAxisName:painter.$t('format.perNum'),
grid:{left:70,top:40,right:0,bottom:60}
}
},
default:{ //默认
otherConf:{
yAxisLineHide:true,
//usePercent:true,
//_color:['#FFA2C0','#FF6D43','#F5D090','#63DAAB','#4992FF']
}
}
}
},
methods: {
getChartsConfig(){
return chartsConfig;
},
filterSeries(seriList){
if(!this.chartData.series)return;
this.configObj.otherConf.legendSelected = seriList;
this.chartData = Object.assign({},this.chartData,{
otherConf:this.configObj.otherConf||{}
});
},
handleTimeChange(){
this.loadChartData();
},
loadChartData(params){
if(this.ckey=='mall_gate_passenger_flow_trends'){
if(!this.timeLevel)return false;
this.params.timeLevel = this.timeLevel;
}
this.chartId = this.getChartId(this.ckey);
if(this.chartId){
this.ajaxModuleData().then(data=>{
this.setChartData(data);
});
}else{
this.setChartData();
}
},
setChartData(data){
this.configObj.otherConf._color = this.configObj.otherConf._color||this.getSeriesColor();
this.chartData = Object.assign({},data,{
otherConf:this.configObj.otherConf||{}
});
}
}
}
</script>
<style lang="less">
</style>