customly.vue
11.7 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<template>
<div class="customly">
<!-- 每日报表 -->
<div class="asis-table-wrapper single-report-wrapper">
<h3 class="asis-table-header single-report-header">
<!-- <el-select v-model="kpiValue" class="select-box" size="mini" @change="changeSel('detailData', kpiValue)" :placeholder="$t('pholder.select')" v-if="emitData.asis_object == 2">
<el-option v-for="item in kpiOption" :key="item.value" :label="i18n(item.label)" :value="item.value">
</el-option>
</el-select> -->
<span class="asis-table-download" @click="downloadData(
$t('asisTab.' + asisLevel) + '-' +
i18nFormatter(detailData_title) + '-' + Time()
)">{{ $t('allPages.load') }}</span>
<span class="report-type-box">
<span :class="barLineIcon" @click="selReport('line')"></span>
<span :class="isCTabChart ? 'report-item report-item-tab' : 'report-item'" @click="selReport('table')"></span>
</span>
</h3>
<div class="date-radio-wrapper tf-ratio-group single-ratio-group" v-if="emitData.asis_object == 1">
<el-radio-group v-model="radioDate" size="mini" fill="#0069FF" @change="changeTabSelect(radioDate)">
<el-radio-button label="detailData" border>{{$t('button.day')}}</el-radio-button>
<el-radio-button label="trafficHourForDates" border>{{$t('button.hour')}}</el-radio-button>
<el-radio-button label="trafficMinuteForDates" border>{{$t('button.min')}}</el-radio-button>
</el-radio-group>
</div>
<div class="date-radio-wrapper tf-ratio-group single-ratio-group" v-else>
<el-radio-group v-model="multipleRadio" size="mini" fill="#0069FF" @change="multipleChangeTabSelect(multipleRadio)">
<el-radio-button label="detailData" border>{{$t('button.day')}}</el-radio-button>
<el-radio-button label="hourAverageTraffic" border>{{$t('button.hour')}}</el-radio-button>
</el-radio-group>
</div>
<div class="asis-table-content" v-loading="loading">
<el-table
v-if="isCTabChart"
id="domBcTrafficFlow"
class="asis-table"
:data="tabData"
header-row-class-name="asis-table-head"
style="width: 100%"
:max-height="tableHeight">
<el-table-column :prop="item.prop" :label="item.label" align="center" v-for="(item,index) in tabHeadData" :key="index" min-width="110" :fixed="index == 0">
</el-table-column>
<el-table-column prop="averageVal" :label="$t('table.average')" show-overflow-tooltip align="center">
</el-table-column>
<el-table-column prop="sums" :label="$t('table.total')" show-overflow-tooltip align="center">
</el-table-column>
</el-table>
<!-- <basic-chart v-else id="bclineChart" class="basic-line-chart" :style="{ height: tableHeight + 'px' }" :options="chartData" chartType="BasicLine"></basic-chart> -->
<mix-charts v-else chartId="bclineChart" class="basic-line-chart" :style="{ height: tableHeight + 'px' }" :chartData="chartData" chartType="AreaLine" />
</div>
</div>
<export-data-dialog ref="exportDialog"></export-data-dialog>
</div>
</template>
<script>
// import commonTable from '../../public/tableCommon'
import exportData from '../../public/exportData'
import publicChart from '../common/publicChart'
export default {
props: {
propparam: Object
},
components: {
// 'common-tab': commonTable
'export-data-dialog': exportData,
'basic-chart': publicChart,
},
data() {
return {
loading: true,
kpiValue: 'TRAFFIC',
kpiOption: [{
label: 'TRAFFIC',
value: 'TRAFFIC'
}, {
label: 'SALES',
value: 'SALES'
}, {
label: 'DEPTH',
value: 'DEPTH'
}, {
label: 'PREPRICE',
value: 'PREPRICE'
}, {
label: 'PERAREAVALUE',
value: 'PERAREAVALUE'
}, {
label: 'DURATIONTIME',
value: 'DURATIONTIME'
}],
detailData_title: '', //本年每日报表
tableKeyToId: {},
tableIds: '',
emitData: {},
tableHeight:0,
isCTabChart: true,
tabHeadData: [],
tabOps: [],
chartData: {},
startDate: '',
endDate: '',
radioDate: 'detailData',
multipleRadio: 'detailData',
asisLevel: 'mall'
}
},
computed:{
barLineIcon() {
if(this.isCTabChart) {
return 'report-item line-report'
} else {
return 'report-item line-report report-item-line'
}
},
tabData() {
return this.computeData(this.tabOps)
},
},
watch: {
propparam: {
handler: 'refreshHandle',
immediate: true
},
},
created() {
let winH = $(window).height(),scale = 0.34;
if(winH <= 720){
scale = 0.4
}else if (winH <= 768){
scale = 0.38
}else if (winH <= 900){
scale = 0.36
}else if (winH <= 1080){
scale = 0.34
}
this.tableHeight = winH - winH * scale
this.isCTabChart = window._vionConfig.reportType && window._vionConfig.reportType === 'table'
? true : false;
},
mounted() {
},
methods: {
i18n(title){
let languageTitle = 'format.' + title;
return this.$t(languageTitle)
},
refreshHandle(param) {
if(param.dateType !== '/baseasis/customly') return;
this.emitData = param.data;
if(this.emitData.asis_object === 1){
this.getTableId('BasicDayReport',this.radioDate);
}else{
this.getTableId('BasicReport',this.multipleRadio);
}
},
changeTabSelect(val) {
if(val == 'detailData') {
this.getTableId('BasicReport',val)
}else{
this.getTableId('BasicDayReport',val)
};
},
multipleChangeTabSelect(val) {
this.getTableId('BasicReport',val)
},
getTableId(basicType,keyVal) {
this.tableKeyToId = {};
this.tableIds = '';
// let chartIds = '';
this.$api.baseReport.reportChart({
report: basicType ? basicType : 'BasicReport',
})
.then(res => {
let tableItem = res.data.data;
tableItem.forEach((item, index) => {
this.tableKeyToId[item.key] = item.id;
// if (item.key === 'kpiData' || item.key === 'detailData') {
// if (index == tableItem.length - 1) {
// chartIds += item.id;
// } else {
// chartIds += item.id + ',';
// }
// }
});
this.tableIds = this.tableKeyToId[keyVal || 'detailData'];
this.getData(this.tableIds,keyVal);
})
},
getData(chartIds,keyVal) {
this.loading = true;
this.tabHeadData = [];
this.tabOps = [];
this.chartData = {};
if(!chartIds) return;
if (this.emitData.asis_time) {
this.startDate = this.emitData.asis_time[0];
this.endDate = this.emitData.asis_time[1];
} else {
this.startDate = this.dayReduce(new Date(), 15);
this.endDate = dateUnit.dateFormat(new Date(), 'yyyy-MM-dd');
}
let param = {
orgIds: this.emitData.asis_org,
startDate: this.startDate,
endDate: this.endDate,
chartIds: chartIds,
kpiType: keyVal == 'trafficHourForDates' && this.emitData.asis_object === 1 ? '' : this.kpiValue,
option: this.isCTabChart ? 'TAB_TABLE' : 'TAB_CHART',
}
let {params,asisLevel} = this.dealFormat(param,this.emitData);
this.asisLevel = asisLevel
this.$api.analysisReport.baseAnalysis(((keyVal == 'trafficHourForDates' || keyVal == 'trafficMinuteForDates') ? 'day/' : '') + asisLevel, params)
.then(res => {
let result = res.data;
let resData = result.data.body[keyVal ? keyVal : 'detailData'];
this.detailData_title = 'BasicReportdetailData';
setTimeout(() => {
this.loading = false
}, 500)
if(resData) {
// 判断是否是表格还是图
if(this.isCTabChart) { // 表格
let flowBodyData = resData.series;
let flowHeadData = resData.xaxis.data;
this.tabHeadData = this.autoComplateHead('detail', flowHeadData);
this.tabOps = this.dealData(flowBodyData, this.tabHeadData, true, flowHeadData.length);
} else { // 图
let chartOption = resData;
// chartOption.chartKey = keyVal || true;
// chartOption.isRadioObject = this.emitData.asis_object === 1 ? true : false;
// chartOption['hasYaxisName'] = false
// chartOption['color'] = ['#3BB8FF', '#FFC62E', '#4396ec', '#4054af', '#d83965', '#9036aa', '#6041b0', '#4fb9d1', '#3f9488', '#97c05c', '#154bee', '#FF9631', '#f39c38', '#e35241']
chartOption['otherConf'] = {
_color: ['#3BB8FF', '#FFC62E', '#4396ec', '#4054af', '#d83965', '#9036aa', '#6041b0', '#4fb9d1', '#3f9488', '#97c05c', '#154bee', '#FF9631', '#f39c38', '#e35241'],
hasYaxisName: false,
chartKey: keyVal || true,
isRadioObject: this.emitData.asis_object === 1 ? true : false
}
if (/\,/.test(this.emitData.asis_org)) {
chartOption['otherConf']['selectedLen'] = this.emitData.asis_org.split(',').length
}
this.chartData = chartOption;
}
}
})
.catch(err => {
this.catchErrorHandle(err)
setTimeout(() => {
this.loading = false
}, 500)
})
},
selReport(iconType) {
if(iconType === 'line') {
if(this.isCTabChart) {
this.isCTabChart = false;
this.getData(this.tableIds,this.emitData.asis_object == 1 ? this.radioDate : this.multipleRadio);
}
} else {
if(!this.isCTabChart) {
this.isCTabChart = true;
this.getData(this.tableIds,this.emitData.asis_object == 1 ? this.radioDate : this.multipleRadio);
}
}
},
changeSel(tableKey, kpiVal) {
this.getData(this.tableIds);
},
downloadData(title) {
if(this.isCTabChart) {
this.dealExport('domBcTrafficFlow', title)
} else {
let chartKey = this.emitData.asis_object == 1
? this.radioDate
: this.multipleRadio
this.exportDataHandle(title, chartKey)
}
},
exportDataHandle(title, chartKey) {
let chartId = this.tableKeyToId[chartKey];
let exportNeed = {
domId: this.isCTabChart ? 'domBcTrafficFlow' : 'bclineChart',
title: title,
data: {
url: `/report/basics/${this.emitData.asis_level}/${chartId}/excel`,
params: `orgIds=${this.emitData.asis_org}&startDate=${this.startDate}&endDate=${this.endDate}&kpiType=${this.kpiValue}&option=${this.isCTabChart ? 'TAB_TABLE' : 'TAB_CHART'}`
}
}
this.$refs.exportDialog.dialogInit(exportNeed);
},
}
}
</script>
<style scoped>
</style>