wecomp.vue
6.41 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
<template>
<div class="wecomp-wrapper">
<div class="wecomp-chart-wrapper">
<div class="weekend-chart-wrapper">
<!-- <span class="ehcarts-title">{{ i18nFormatter(chartTitle) }}</span> -->
<!-- <wecomp-chart id="wecompChart" class="wecomp-chart-box" :options="weekdayOrEnd_ops" chartType="LineBar"></wecomp-chart> -->
<mix-charts chartId="wecompChart" class="wecomp-chart-box" :chartData="weekdayOrEnd_ops" chartType='LineBar' />
<span class="download-text" @click="exportDataHandle('wecompChart',i18nFormatter(chartTitle),'weekdayOrEnd')">{{$t('allPages.load')}}</span>
</div>
</div>
<export-data-dialog ref="exportDialog"></export-data-dialog>
</div>
</template>
<script>
import exportData from '../../public/exportData'
import publicChart from '../common/publicChart'
export default {
props: {
propparam: Object
},
data () {
return {
weekdayOrEnd_ops: {},
tableKeyToId: {},
tableIds: '',
emitData: [],
chartTitle: '',
startTime:'',
endTime:'',
}
},
components: {
'wecomp-chart': publicChart,
'export-data-dialog': exportData,
},
watch: {
propparam: {
handler: 'refreshHandle',
immediate: true
}
},
mounted() {
// this.getTableId();
},
methods: {
refreshHandle(param) {
if(param.dateType !== '/weekComp/wecomp') return;
this.emitData = param.data;
// this.getMock();
if(this.tableIds && JSON.stringify(this.tableKeyToId) !== '{}') {
this.getChartData(this.tableIds);
} else {
this.getChartId();
}
},
getMock() {
// this.weekdayOrEnd_ops = {
// title: '周中周末对比',
// series: [{
// name: '工作日平均客流',
// type: 'bar',
// data: [600, 230, 800, 364, 160, 440, 600]
// }, {
// name: '双休日平均客流',
// type: 'bar',
// data: [200, 230, 800, 364, 160, 440, 600]
// }, {
// name: '增长率',
// type: 'line',
// data: [25, 28, 100, 45, 19, 55, 75]
// }],
// xaxis: {
// data: ['1', '2', '3', '4', '5', '6', '7']
// }
// }
},
getChartId() {
this.tableKeyToId = {};
this.tableIds = '';
this.$api.baseReport.reportChart({
report: 'WeekCompared',
// _t: Date.parse(new Date()) / 1000
})
.then(res => {
let tableItem = res.data.data;
tableItem.forEach((item, index) => {
this.tableKeyToId[item.key] = item.id;
if(item.key === 'weekdayOrEnd') {
if(index == tableItem.length - 1) {
this.tableIds += item.id;
} else {
this.tableIds += item.id + ',';
}
}
});
this.getChartData(this.tableIds);
})
},
getChartData(tableIds) {
if(!tableIds) return;
this.weekdayOrEnd_ops = {};
if(this.emitData.asis_time) {
this.startTime = this.emitData.asis_time[0];
this.endTime = this.emitData.asis_time[1];
} else {
// this.startTime = this.dayAdd(new Date(this.emitData.asis_time[0].replace(/\-/g, '/')), 0);
this.startTime = this.dayReduce(new Date(), 30);
this.endTime = dateUnit.dateFormat(new Date(), 'yyyy-MM-dd');
}
let param = {
orgIds: this.emitData.asis_org,
startDate: this.startTime,
endDate: this.endTime,
chartIds: tableIds,
kpiType: this.emitData.asis_kpi,
}
let {params,asisLevel} = this.dealFormat(param,this.emitData);
this.$api.analysisReport.weekComparedAnalysis(asisLevel, params)
.then(res => {
let report = 'WeekCompared';
let { weekdayOrEnd } = res.data.data.body
weekdayOrEnd['otherConf'] = {
_color: ['#3BB8FF', '#87D14B', '#FFC62E'],
grid: { top: 68, right: 60, bottom: 66, left: 60 },
isCylindrical: true,
legendBottom: 16,
yAxisName: [this.$t('echarts.traffic'), this.$t('echarts.growthRate')]
}
this.weekdayOrEnd_ops = weekdayOrEnd;
// this.chartTitle = res.data.data.body.weekdayOrEnd.title;
this.chartTitle = report + 'weekdayOrEnd';
})
.catch(err => {
this.catchErrorHandle(err)
})
},
exportDataHandle(domId, title, chartKey) {
//
let chartId = this.tableKeyToId[chartKey];
let exportNeed = {
domId: domId,
title: title,
data: {
url: '/report/weekCompared/' + this.emitData.asis_level + '/' + chartId + '/excel',
params: 'orgIds=' + this.emitData.asis_org + '&startDate=' + this.startTime + '&endDate=' + this.endTime + '&kpiType=' + this.emitData.asis_kpi
}
}
// console.log('wecomp exportNeed', exportNeed)
this.$refs.exportDialog.dialogInit(exportNeed);
},
}
}
</script>
<style scoped>
.wecomp-wrapper {
width: 100%;
}
.weekend-chart-wrapper {
background: #fff;
position: relative;
}
.ehcarts-title {
z-index: 1;
}
.wecomp-chart-box {
height: 569px;
}
@media only screen and (max-width: 1680px) {
.wecomp-chart-box {
height: 500px;
}
}
@media only screen and (max-width: 1440px) {
.wecomp-chart-box {
height: 400px;
}
}
@media only screen and (max-width: 1366px) {
.wecomp-chart-box {
height: 400px;
}
}
@media only screen and (max-width: 1280px) {
.wecomp-chart-box {
height: 400px;
}
}
</style>