inout.vue
4.6 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
<!-- 出入口客流分布 -->
<template>
<div>
<!-- 顶部区域 S-->
<div class="ipage_top">
<div class="tit"><img :src="bindIcon('zhuancang')"/>{{title||chartData.title}}</div>
<div class="acts">
<slot name="action"></slot>
<!-- <el-tabs v-model="numPerVal" @tab-click="handlePerClick" class="no_bar">
<el-tab-pane label="人次" name="percent"></el-tab-pane>
<el-tab-pane label="人数" name="count"></el-tab-pane>
</el-tabs> -->
</div>
</div>
<div class="ichart">
<div class="legend">
<ul class="acea-row row-start">
<li v-for="(item,idx) in legendList" :class="item[1]?'':'hidden'" @click="legendBtn(item)" :key="idx">
<em :style="{backgroundColor:_color[idx]}"></em>
<span>{{item[0]}}</span>
</li>
</ul>
</div>
<el-row>
<el-col :span="10">
<pie-chart ref="chart" :cdata="chartData"></pie-chart>
</el-col>
<el-col :span="14" class="split">
<vline ref="vline" icon="empty" :selected="selected" :ckey="vlineKey" :title="$t('iPage.coustomertrend')" :level="levels"></vline>
</el-col>
</el-row>
</div>
</div>
</template>
<script>
import mixin from './mixin';
import vline from './vline';
import _ from 'underscore';
/**********************************************************/
const chartsConfig = {
default:{ //默认
otherConf:{
yAxisLineHide:true,
isGraphic:true,
labelName:true,
radius:['50%','78%'],
legendObj:{
show:false,
selected:{}
},
//_color:this._color
}
}
};
/*******************************************************/
export default {
mixins: [mixin],
data() {
return {
numPerVal:'percent',
isEmpty:true,
selected:{},
configObj:{},
legendList:[],
_color:[],
levels:[],
vlineKey:''
}
},
components:{
vline
},
created() {
if(this.ckey=='mall_gate_passenger_distribution'){
this.vlineKey = 'mall_gate_passenger_flow_trends';
}else if(this.ckey=='floor_gate_passenger_distribution'){
this.vlineKey = 'floor_gate_passenger_flow_trends'
}
},
methods: {
setCurLevel(){
let dateType = this.params.dateType;
if(dateType=='day'){
this.levels=['HOUR','MINUTE'];
}else if(dateType=='month'){
this.levels=['DAY','HOUR','MINUTE'];
}else if(dateType=='year'){
this.levels=['MONTH','DAY','HOUR','MINUTE'];
}
},
getChartsConfig(params){
this.setCurLevel();
return chartsConfig;
},
handlePerClick(){
},
handleTimeChange(){
},
legendBtn(item){
let name = item[0];
let selected = this.configObj.otherConf.legendObj.selected;
let isShow = item[1];
selected[item[0]] = !isShow;
this.selected = selected;
item[1] = !isShow;
this.$forceUpdate();
},
loadChartData(params){
this.chartId = this.getChartId(this.ckey);
if(this.chartId){
this.ajaxModuleData().then(data=>{
this.setChartData(data);
});
}
this.$refs.vline.loadModuleData(params,true);
},
setChartData(data){
try{
this._color = this.getSeriesColor();
let legendSelect = {}
data.series[0].data.forEach((item,index)=>{
legendSelect[item.name] = index<100?true:false;
})
this.selected = legendSelect;
this.configObj.otherConf.legendObj.selected = legendSelect;
this.configObj.otherConf._color = this._color;
this.chartData = Object.assign({},data,this.configObj);
this.legendList = _.pairs(legendSelect);
this.isEmpty = false;
}catch(err){
this.chartData = {otherConf:{}};
this.isEmpty = true;
this.hideLoading();
}
}
}
}
</script>
<style scoped lang="less">
</style>