yearly.vue
11.4 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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<template>
<div class="yearly">
<div class="asis-table-wrapper weather-echart-wrapper download-parent">
<!-- 天气分析图 -->
<!-- <scatter-chart id="yearScatterChart" class="year-scatter-block" :options="WeatherAnalyze_ops" chartType="YearScatter"></scatter-chart> -->
<mix-charts chartId="yearScatterChart" class="year-scatter-block" :chartData="WeatherAnalyze_ops" chartType="Scatter" />
<span class="ehcarts-title">{{ i18nFormatter(WeatherAnalyze_title) }}</span>
<!-- <span class="download-text">{{$t('allPages.load')}}</span> -->
<!-- <span class="download-text" @click="getechartsId('yearScatterChart','YearScatter','WeatherAnalyze',WeatherAnalyze_ops)">导出数据</span> -->
</div>
<div class="asis-table-wrapper">
<h3 class="asis-table-header">
<span class="asis-table-title">{{ i18nFormatter(WeatherSynthetical_title) }}</span>
<span class="asis-table-download" @click="dealExport('domAsis', i18nFormatter(WeatherSynthetical_title))">{{$t('allPages.load')}}</span>
</h3>
<div class="asis-table-content">
<common-tab v-loading="loading" :tableData="WeatherSynthetical_ops" id="domAsis" :headData="WeatherSynthetical_head" :tabHeight="''"></common-tab>
</div>
</div>
<div class="asis-table-wrapper">
<h3 class="asis-table-header">
<span class="asis-table-title">{{ i18nFormatter(WeatherDetail_title) }}</span>
<div class="date-radio-wrapper quarter-sel-wrapper">
<el-radio-group v-model="quarterVal" size="mini" fill="#0069FF" @change="getQuarterData('domDetail', quarterVal, 'WeatherDetail')">
<!-- <el-tooltip content="1-3月" placement="top-start" popper-class="quarter-tooltip"> -->
<el-radio-button label="Q1th" border title="1-3月">{{ $t('format.quarter1th') }}</el-radio-button>
<!-- </el-tooltip> -->
<!-- <el-tooltip content="4-6月" placement="top-start" popper-class="quarter-tooltip"> -->
<el-radio-button label="Q2nd" border title="4-6月">{{ $t('format.quarter2nd') }}</el-radio-button>
<!-- </el-tooltip> -->
<!-- <el-tooltip content="7-9月" placement="top-start" popper-class="quarter-tooltip"> -->
<el-radio-button label="Q3rd" border title="7-9月">{{ $t('format.quarter3rd') }}</el-radio-button>
<!-- </el-tooltip> -->
<!-- <el-tooltip content="10-12月" placement="top-start" popper-class="quarter-tooltip"> -->
<el-radio-button label="Q4th" border title="10-12月">{{ $t('format.quarter4th') }}</el-radio-button>
<!-- </el-tooltip> -->
</el-radio-group>
</div>
<span class="asis-table-download" @click="dealExport('domDetail', i18nFormatter(WeatherDetail_title))">{{$t('allPages.load')}}</span>
</h3>
<div class="asis-table-content">
<common-tab v-loading="loading" :tableData="WeatherDetail_ops" id="domDetail" :headData="WeatherDetail_head" :tabHeight="''"></common-tab>
</div>
</div>
</div>
</template>
<script>
import publicChart from '../common/publicChart'
import commonTable from '../../public/tableCommon'
export default {
props: {
propparam: {
type: Object,
default: () => {}
}
},
data() {
return {
startDate: '',
endDate: '',
loading: true,
detailLoading: true,
yearScatter_ops: {},
quarterVal: 'Q1th',
WeatherSynthetical_head: [],
WeatherDetail_head: [],
WeatherAnalyze_title: '',
WeatherSynthetical_title: '', //
WeatherDetail_title: '',
WeatherAnalyze_ops: {}, // 天气分析
WeatherSynthetical_ops: [], // 天气综合列表
WeatherDetail_ops: [], // 每日详情
tableKeyToId: {},
tableIds: '',
emitData: [],
kpiArr: {
'TRAFFIC': '客流量',
'SALES': '销售额',
'ENTERINGRATE': '进店率',
'PREPRICE': '客单价',
'PERAREAVALUE': '坪效',
'ORDER': '成交量',
'HANDBAGRATE': '提袋率',
'DURATIONTIME': '滞留时间',
}
}
},
components: {
'scatter-chart': publicChart,
'common-tab': commonTable,
},
watch: {
propparam: {
handler: 'refreshHandle',
immediate: true
}
},
mounted() {
// this.getMonthScatter();
},
methods: {
refreshHandle(param) {
if (param.dateType !== '/weatherasis/yearly') return;
this.emitData = param.data;
this.loading = true;
this.detailLoading = true;
this.quarterVal = 'Q1th'
if (this.tableIds && JSON.stringify(this.tableKeyToId) !== '{}') {
this.getChartData(this.tableIds);
this.quarterChart(this.tableKeyToId['WeatherDetail'])
} else {
this.getChartId();
}
},
getChartId() {
this.tableKeyToId = {};
this.tableIds = '';
this.$api.baseReport.reportChart({
report: 'WeatherReport',
// _t: Date.parse(new Date()) / 1000
})
.then(res => {
let tableItem = res.data.data;
tableItem.forEach((item, index) => {
this.tableKeyToId[item.key] = item.id;
// WeatherDetail
if (item.key === 'WeatherAnalyze' || item.key === 'WeatherSynthetical') {
if (index == tableItem.length - 1) {
this.tableIds += item.id;
} else {
this.tableIds += item.id + ',';
}
}
});
this.getChartData(this.tableIds)
this.quarterChart(this.tableKeyToId['WeatherDetail'])
})
},
chartDataFetch(tableIds, startDate, endDate) {
const { emitData } = this
const {
asis_level, asis_org, asis_time, asis_kpi, asis_format
} = emitData
const { startTime, endTime } = this.newDateFormat('year', asis_time)
const param = {
orgIds: asis_org,
startDate: startDate || startTime,
endDate: endDate || endTime,
chartIds: tableIds,
kpiType: asis_kpi
}
asis_level === 'format' && (param.formatIds = asis_format)
const { params, asisLevel } = this.dealFormat(param, emitData)
return new Promise(resolve => {
this.$api.analysisReport.weatherAnalysis(asisLevel === 'format' ? 'mall' : asisLevel, params)
.then(res => {
resolve(res)
})
.catch(err => {
this.catchErrorHandle(err)
})
})
},
async getChartData(tableIds) {
if (!tableIds) return
this.WeatherAnalyze_ops = {}
this.WeatherSynthetical_ops = []
let chartTitlePrefix = 'WeatherReport'
this.WeatherAnalyze_title = chartTitlePrefix + 'WeatherAnalyze'
this.WeatherSynthetical_title = chartTitlePrefix + 'WeatherSynthetical'
this.WeatherDetail_title = chartTitlePrefix + 'WeatherDetail'
const { data } = await this.chartDataFetch(tableIds)
const {
WeatherAnalyze = {},
WeatherSynthetical = {},
// WeatherDetail = {}
} = data.data.body
WeatherAnalyze.otherConf = {
_color: ['#3BB8FF', '#3D97CB', '#87D14B', '#0069FF', '#FF9631', '#FFC62E', '#6784E3', '#3BB8FF', '#3D97CB', '#87D14B', '#0069FF', '#FF9631', '#FFC62E', '#6784E3', '#3BB8FF', '#3D97CB', '#87D14B', '#0069FF', '#FF9631', '#FFC62E'],
kpiName: this.kpiArr[this.emitData.asis_kpi],
isYear: true
}
WeatherAnalyze.kpiName = this.kpiArr[this.emitData.asis_kpi]
this.WeatherAnalyze_ops = WeatherAnalyze
let WeatherSynthetical_series = this.dealColWeatherCode(WeatherSynthetical.series, 0)
this.WeatherSynthetical_head = this.dealHead(WeatherSynthetical.xaxis.data);
this.WeatherSynthetical_ops = this.dealData(WeatherSynthetical_series, this.WeatherSynthetical_head);
// let WeatherDetail_series = this.dealColWeatherCode(WeatherDetail.series, 2);
// this.WeatherDetail_head = this.dealHead(WeatherDetail.xaxis.data);
// this.WeatherDetail_ops = this.dealData(WeatherDetail_series, this.WeatherDetail_head);
this.loading = false
// this.detailLoading = false
},
dealHead(headData) {
let resultHead = [];
headData.forEach((item, index) => {
resultHead.push({
prop: 'defaultOrg' + index,
label: item
})
})
return resultHead;
},
weatherFormat(row, column, cellValue) {
let dicWeather = this.getSessionLocal('weather', cellValue)
return dicWeather ? this.$t('dictionary.' + dicWeather) : this.$t('dictionary.unknow');
},
dealColWeatherCode(data, colNum) {
if (!data.length) return data
return data.map(item => {
item.data = item.data.map((dataItem, dataIndex) => {
dataItem = dataIndex === colNum ? this.weatherFormat(0, 0, dataItem) : dataItem
return dataItem
})
return item
})
},
quarterToDate() {
const quarterDate = {}
switch (this.quarterVal) {
case 'Q1th':
quarterDate.start_date = '01-01'
quarterDate.end_date = '03'
break;
case 'Q2nd':
quarterDate.start_date = '04-01'
quarterDate.end_date = '06'
break;
case 'Q3rd':
quarterDate.start_date = '07-01'
quarterDate.end_date = '09'
break;
case 'Q4th':
quarterDate.start_date = '10-01'
quarterDate.end_date = '12'
break;
default:
break;
}
return quarterDate
},
// 单独处理每日详情 展示每个季度的数据
async quarterChart(chartId) {
if (!chartId) return
this.detailLoading = true
this.WeatherDetail_ops = []
const chartTitlePrefix = 'WeatherReport'
this.WeatherDetail_title = chartTitlePrefix + 'WeatherDetail'
const { asis_time } = this.emitData
const _year = asis_time ? asis_time.getFullYear() : new Date().getFullYear()
const { start_date, end_date } = this.quarterToDate()
const monthLastDay = this.getMonthLastDay(new Date(_year, end_date, 0))
const startDate = _year + '-' + start_date
const endDate = _year + '-' + end_date + '-' + monthLastDay
// 获取报表数据
const { data } = await this.chartDataFetch(chartId, startDate, endDate)
const {
WeatherDetail = {}
} = data.data.body
let WeatherDetail_series = this.dealColWeatherCode(WeatherDetail.series, 2)
this.WeatherDetail_head = this.dealHead(WeatherDetail.xaxis.data);
this.WeatherDetail_ops = this.dealData(WeatherDetail_series, this.WeatherDetail_head)
this.detailLoading = false
},
getQuarterData(dom, value, reportType) {
this.detailLoading = true;
const chartId = this.tableKeyToId[reportType]
this.quarterChart(chartId)
},
getMonthLastDay(date) {
return new Date(date.getFullYear(), (date.getMonth() + 1), 0).getDate();
},
}
}
</script>
<style scoped>
.quarter-sel-wrapper {
float: left;
font-size: 13px !important;
color: #444;
}
.quarter-sel-wrapper label {
margin-right: 10px;
}
.weatherasis-title {
position: absolute;
/* */
top: 26px;
left: 26px;
color: #444;
font-size: 18px;
}
/* #yearScatterChart, */
.year-scatter-block {
height: 731px;
}
.chart-title {
left: 26px;
top: 26px;
}
@media only screen and (max-width: 1366px) {
.year-scatter-block {
height: 500px;
}
}
@media only screen and (max-width: 1280px) {
.year-scatter-block {
height: 500px;
}
}
</style>