daily.vue
8.58 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
<template>
<div class="daily">
<el-row class="chartRow" :gutter="12">
<el-col :span="24" class="download-parent">
<!-- 时刻对比 -->
<comprehen-chart id="dmomentChart" class="moment-wrapper" :options="hourTrend_ops" chartType="Line"></comprehen-chart>
<span class="ehcarts-title">{{ i18nFormatter(hourTrend_title) }}</span>
<span class="download-text" @click="exportDataHandle('dmomentChart','hourTrend',i18nFormatter(hourTrend_title),'hourTrend')">{{$t('allPages.load')}}</span>
</el-col>
</el-row>
<el-row class="chartRow" :gutter="12">
<el-col :span="24" class="download-parent">
<!-- 累计对比 -->
<comprehen-chart id="dcumulativeChart" class="cumulative-wrapper" :options="accumulative_ops" chartType="Line"></comprehen-chart>
<span class="ehcarts-title">{{ i18nFormatter(accumulative_title) }}</span>
<span class="download-text" @click="exportDataHandle('dcumulativeChart','accumulative',i18nFormatter(accumulative_title),'accumulative')">{{$t('allPages.load')}}</span>
</el-col>
</el-row>
<el-row class="chartRow" :gutter="12">
<el-col :span="24" class="download-parent">
<!-- 近15天对比 -->
<comprehen-chart id="dnearfifChart" class="nearfif-wrapper" :options="dayTrend_ops" chartType="Line"></comprehen-chart>
<span class="ehcarts-title">{{ i18nFormatter(CompareDaydayTrend_title) }}</span>
<span class="download-text" @click="exportDataHandle('dnearfifChart','dayTrend',i18nFormatter(CompareDaydayTrend_title),'dayTrend')">{{$t('allPages.load')}}</span>
</el-col>
</el-row>
<el-row class="chartRow" :gutter="12">
<el-col :span="12" class="download-parent">
<!-- 顾客性别对比 -->
<comprehen-chart id="dgenderChart" class="gender-wrapper" :options="customerfeatureGender_ops" chartType="GenderBar"></comprehen-chart>
<span class="ehcarts-title">{{ i18nFormatter(customerfeature_gender_title) }}</span>
<span class="download-text" @click="exportDataHandle('dgenderChart','customerfeature_gender',i18nFormatter(customerfeature_gender_title),'customerfeature_gender')">{{$t('allPages.load')}}</span>
</el-col>
<el-col :span="12" class="download-parent">
<!-- 顾客年龄对比 -->
<comprehen-chart id="dageChart" class="age-wrapper" :options="customerfeatureAge_ops" chartType="AgeBar"></comprehen-chart>
<span class="ehcarts-title">{{ i18nFormatter(customerfeature_age_title) }}</span>
<span class="download-text" @click="exportDataHandle('dageChart','customerfeature_age',i18nFormatter(customerfeature_age_title,'customerfeature_age'),'customerfeature_age')">{{$t('allPages.load')}}</span>
</el-col>
</el-row>
<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 {
customerfeatureGender_ops: {}, // 顾客性别对比
customerfeatureAge_ops: {}, // 顾客年龄对比
hourTrend_ops: {}, // 时刻对比
accumulative_ops: {}, // 时刻累加对比
dayTrend_ops: {}, // 近15天趋势对比
tableKeyToId: {},
tableIds: '',
emitData: [],
searchTime:'',
apiUrl:'',
hourTrend_title: '',
accumulative_title: '',
dayTrend_title: '',
customerfeature_gender_title: '',
customerfeature_age_title: '',
CompareDaydayTrend_title: '', // 近15天对比
}
},
components: {
'comprehen-chart': publicChart,
'export-data-dialog': exportData,
},
watch: {
// propparam(data) {
// this.refreshHandle(data);
// }
propparam: {
handler: 'refreshHandle',
immediate: true
}
},
mounted() {
// this.refreshHandle(this.propparam);
},
methods: {
refreshHandle(param) {
if(param.dateType !== '/comprehen/daily') return;
this.emitData = param.data;
if(this.tableIds && JSON.stringify(this.tableKeyToId) !== '{}') {
this.getChartData(this.tableIds);
} else {
this.getChartId();
}
},
getChartId() {
this.tableKeyToId = {};
this.tableIds = '';
this.$api.baseReport.reportChart({
report: 'SynthesizeCompareDay',
// _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 === 'customerfeature_gender' || item.key === 'customerfeature_age' || item.key === 'hourTrend' || item.key === 'accumulative' || item.key === 'dayTrend') {
if(index == tableItem.length - 1) {
this.tableIds += item.id;
} else {
this.tableIds += item.id + ',';
}
}
});
this.getChartData(this.tableIds);
})
},
getChartData(tableIds) {
if(!tableIds) return;
this.customerfeatureGender_ops = {};
this.customerfeatureAge_ops = {};
this.hourTrend_ops = {};
this.accumulative_ops = {};
this.dayTrend_ops = {};
let param = {};
// if(this.emitData.asis_time == '' || this.emitData.asis_time == undefined) {
if(this.emitData.asis_time) {
if(typeof this.emitData.asis_time === 'string') {
this.searchTime = this.emitData.asis_time;
} else {
this.searchTime = dateUnit.dateFormat(this.emitData.asis_time, 'yyyy-MM-dd');
}
} else {
this.searchTime = dateUnit.dateFormat(new Date(), 'yyyy-MM-dd');
}
if(this.emitData.asis_level === 'format') {
// this.apiUrl = '/report/synthesize/day/mall';
this.emitData.asis_level = 'mall';
param = {
orgIds: this.emitData.asis_org,
date: this.searchTime,
chartIds: tableIds,
kpiType: this.emitData.asis_kpi,
formatIds: this.emitData.asis_format,
// _t: Date.parse(new Date()) / 1000
}
} else {
// this.apiUrl = '/report/synthesize/day/' + this.emitData.asis_level;
param = {
orgIds: this.emitData.asis_org,
date: this.searchTime,
chartIds: tableIds,
kpiType: this.emitData.asis_kpi,
// _t: Date.parse(new Date()) / 1000
}
}
this.apiUrl = '/report/synthesize/day/' + this.emitData.asis_level;
this.$api.analysisReport.synthesizeAnalysis(`day/${this.emitData.asis_level}`, param)
.then(res => {
let report = 'SynthesizeCompareDay';
let gender_ops = {}, age_ops = {};
gender_ops = res.data.data.body.customerfeature_gender;
gender_ops['color'] = ['#3BB8FF', '#FFC62E'];
this.customerfeatureGender_ops = gender_ops;
// this.customerfeature_gender_title = gender_ops.title;
this.customerfeature_gender_title = report + 'customerfeature_gender'
age_ops = res.data.data.body.customerfeature_age;
age_ops['color'] = ['#6e6fc1', '#33bafe', '#fec62b', '#ff9c01', '#38d4be', '#79ce4c'];
this.customerfeatureAge_ops = age_ops;
// this.customerfeature_age_title = age_ops.title;
this.customerfeature_age_title = report + 'customerfeature_age';
this.hourTrend_ops = res.data.data.body.hourTrend;
// this.hourTrend_title = res.data.data.body.hourTrend.title;
this.hourTrend_title = report + 'hourTrend';
this.accumulative_ops = res.data.data.body.accumulative;
// this.accumulative_title = res.data.data.body.accumulative.title;
this.accumulative_title = report + 'accumulative';
this.dayTrend_ops = res.data.data.body.dayTrend;
// this.CompareDaydayTrend_title = res.data.data.body.dayTrend.title
this.CompareDaydayTrend_title = report + 'dayTrend';
})
.catch(err => {
this.catchErrorHandle(err)
})
},
exportDataHandle(domId, title, chartKey) {
//
let chartId = this.tableKeyToId[chartKey];
let exportNeed = {
domId: domId,
title: title,
data: {
url: window._vionConfig.apiUrl + this.apiUrl + '/' + chartId + '/excel',
params: 'orgIds=' + this.emitData.asis_org + '&date=' + this.searchTime + '&kpiType=' + this.emitData.asis_kpi
}
}
// console.log('comprehen day exportNeed', exportNeed)
this.$refs.exportDialog.dialogInit(exportNeed);
},
}
}
</script>
<style scoped>
/* @import url(./public/css/common.css); */
</style>