trendAccount.vue
4.68 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
<!-- 客流总览 -->
<template>
<div>
<div class="iwraper">
<div class="ipage_top" v-show="levels.length">
<div class="tit"></div>
<div class="wact">
<div class="acts" v-if="levels && levels.length > 1">
<el-tabs v-model="timeLevel" @tab-click="handleTimeChange">
<el-tab-pane v-if="levels.includes('MONTH')" :label="$t('iPage.monthOver')" name="MONTH">
</el-tab-pane>
<el-tab-pane v-if="levels.includes('WEEK')" :label="$t('iPage.weekOver')" name="WEEK">
</el-tab-pane>
<el-tab-pane v-if="levels.includes('DAY')" :label="$t('iPage.dayOver')" name="DAY">
</el-tab-pane>
<el-tab-pane v-if="levels.includes('HOUR')" :label="$t('iPage.hourOver')" name="HOUR">
</el-tab-pane>
<el-tab-pane v-if="levels.includes('MINUTE')" :label="$t('iPage.minuteOver')" name="MINUTE">
</el-tab-pane>
</el-tabs>
</div>
<span @click="exportBtn" class="asis-table-download">{{ $t('allPages.load') }}</span>
</div>
</div>
<div class="ichart">
<trent-chart ref="chart" chartId="trendChart1" :cdata="chartData"></trent-chart>
</div>
</div>
<export-data-dialog ref="exportDialog"></export-data-dialog>
</div>
</template>
<script>
import _ from 'underscore';
import mixin from "./mixin";
import exportData from '../../../public/exportData'
export default {
components:{
'export-data-dialog':exportData
},
mixins: [mixin],
data() {
return {
curKey: '',
timeLevel: "HOUR",
level: [],
levels: ['HOUR','MINUTE'],
configObj: {},
};
},
props: {
mparam: {},
},
watch: {
mparam: {
handler(newVal) {
this.newVal = newVal
this.setCurLevel(newVal);
newVal && this.loadChartData();
},
deep: true,
},
},
created() {
},
methods: {
setCurLevel(parmaObj) {
let dateType = parmaObj.dateType;
if (dateType == 'day') {
this.levels = ['HOUR', 'MINUTE'];
this.timeLevel = this.levels[0];
}else if (dateType == 'month') {
this.levels = ['WEEK', 'DAY', 'HOUR'];
this.timeLevel = this.levels[1];
} else if (dateType == 'year') {
this.levels = ['MONTH', 'WEEK', 'DAY'];
this.timeLevel = this.levels[0];
}
},
handleTimeChange(v) {
this.loadChartData();
},
loadChartData(params = this.mparam) {
params = _.omit(Object.assign({}, this.params, params), 'level');
params.timeLevel = this.timeLevel;
this.$api.ipageReport.getAccountPassenger({
orgId:params.accountIds,
option:params.timeLevel.toLowerCase() ,
startDate:params.startDate,
endDate:params.endDate,
type:'line',
}).then(res => {
let { data } = res.data;
this.setChartData(data);
})
},
setChartData(data) {
let addConfig = {};
if (this.timeLevel && this.timeLevel == "MINUTE") {
addConfig.periodTime = true;
addConfig.nextTimeNum = 10;
}
this.chartData = Object.assign({}, data, {
otherConf: {
...addConfig,
_color: ["#acc6f6", "#4BBEFF", "#87D14B", "#FFC62E", "#FF9631"],
perUnit: this.$t('format.perTime'),
},
});
},
exportBtn(){
let exportNeed = {
domId: "trendChart1",
title: this.chartData.title,
data: {
url: `/report/account/passenger/export`,
params: `orgId=${this.mparam.accountIds}&type=line&startDate=${this.mparam.startDate}&endDate=${this.mparam.endDate}&option=${this.timeLevel.toLowerCase()}`
}
};
this.$refs.exportDialog.dialogInit(exportNeed);
},
},
};
</script>
<style scoped lang="less">
.wact {
display: flex;
align-items: center;
}
.asis-table-download {
float: none;
margin-left: 20px;
}
.asis-table-download:after {
top: 2px
}
</style>