monthly.vue
9.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
298
299
300
301
302
303
304
305
306
<template>
<div class="monthly">
<!-- 本月每日报表 -->
<div class="asis-table-wrapper single-report-wrapper">
<h3 class="asis-table-header single-report-header">
<span
class="asis-table-download"
@click="downloadData(i18nFormatter(detailData_title) + '-' + Time(),radioDate)"
>{{$t('allPages.load')}}</span>
<span class="report-type-box">
<span :class="barLineIcon" @click="selReport('bar')"></span>
<span
:class="isMTabChart ? 'report-item report-item-tab' : 'report-item'"
@click="selReport('table')"
></span>
</span>
</h3>
<div class="date-radio-wrapper tf-ratio-group single-ratio-group">
<el-radio-group
v-model="radioDate"
size="mini"
fill="#0069FF"
@change="changeTabSelect(radioDate)"
>
<!-- 天汇总 小时级 周汇总 月汇总 -->
<!-- <el-radio-button label="month" border>{{ $t('button.month') }}</el-radio-button> -->
<el-radio-button label="week" border>{{ $t('button.week') }}</el-radio-button>
<el-radio-button label="day" border>{{$t('button.day')}}</el-radio-button>
<el-radio-button label="hour" border>{{$t('button.hour')}}</el-radio-button>
<el-radio-button label="minute" border>{{$t('button.min')}}</el-radio-button>
</el-radio-group>
</div>
<ul class="legend">
<li v-for="(item,index) in mallNameList" :key="index">
<span :style="{'background-color': colorArr[index]}"></span><span>{{item}}</span>
</li>
</ul>
<div class="asis-table-content" v-loading="loading">
<el-table
v-if="isMTabChart"
id="domBmTrafficFlow"
class="asis-table"
:data="tabOps"
header-row-class-name="asis-table-head"
style="width: 100%"
:max-height="tableHeight"
>
<comp-column v-for="(item, index) in tabHeadData" :key="index" :col="item" />
</el-table>
<div v-else>
<el-row>
<el-col :span="8" v-for="(item,index) in chartData.length" :key="item">
<p>{{chartData[index].title}}</p>
<mix-charts
:chartId="'bmlineChart'+item"
class="area-line-chart"
:style="{ height: 300 + 'px' }"
:chartData="chartData[index]"
chartType="AreaLineNew"
/>
</el-col>
</el-row>
</div>
</div>
</div>
<export-data-dialog ref="exportDialog"></export-data-dialog>
</div>
</template>
<script>
import publicChart from "../common/publicChart";
import exportData from "../../public/exportData";
import CompCol from "../../public/myColum";
export default {
props: {
propparam: Object
},
components: {
"export-data-dialog": exportData,
"basic-chart": publicChart,
"comp-column": CompCol
},
data() {
return {
loading: true,
detailData_title: "comprehensiveIndicators", //本月每日报表
tableIds: "",
emitData: {},
tableHeight: 0,
isMTabChart: false,
tabHeadData: [],
tabOps: [],
chartData: [],
startDate: "",
endDate: "",
radioDate: "day",
configHeadData:[],
colorArr:["#3BB8FF", "#FFC62E", "#97c05c", "#154bee", "#d83965",
"#9036aa", "#e35241", "#4fb9d1", "#3f9488", "#97c05c",
"#154bee", "#FF9631", "#f39c38", "#e35241"],
mallNameList:[]
};
},
computed: {
barLineIcon() {
if (this.isMTabChart) {
return "report-item bar-report";
} else {
return "report-item line-report report-item-line";
}
}
},
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;
},
methods: {
i18n(title) {
let languageTitle = "format." + title;
return this.$t(languageTitle);
},
refreshHandle(param) {
if(param.data){
this.emitData = param.data;
this.mallNameList = param.data.asis_nameList
this.configHeadData = param.data.indicatorVal
this.getData();
}
},
changeTabSelect(val) {
this.getData()
},
getData(chartIds, keyVal) {
this.loading = true;
this.tabHeadData = [];
this.tabOps = [];
this.chartData = [];
let params = {
orgIds: this.emitData.asis_org,
startDate: this.emitData.startDate,
endDate: this.emitData.endDate,
type: this.isMTabChart ? "table" : "line",
option: this.radioDate
};
this.$api.analysisReport .getPassengerFlowMultiMallStatistics(params).then(res => {
let resData = res.data.data.body;
this.loading = false;
if (resData) {
// 判断是否是表格还是图
if (this.isMTabChart) {
// 表格
this.getTableData(resData)
} else {
Object.keys(resData).forEach((key) => {
resData[key].key = key
this.chartData.push(resData[key])
})
this.chartData.forEach((item,index)=>{
this.getEcartsData(item,index)
})
}
}
})
},
getEcartsData(resData,index) {
let chartOption = resData;
chartOption["otherConf"] = {
_color:this.colorArr ,
hasYaxisName: false,
chartKey: this.radioDate,
yAxisName:(resData.key=="deepShoppingRateChart" || resData.key=="enterRateChart")?'%':((resData.key=="humanEffectChart"||resData.key=="perAreaValueChart")?'':this.i18n("perTime"))
};
if (/\,/.test(this.emitData.asis_org)) {
chartOption["otherConf"][
"selectedLen"
] = this.emitData.asis_org.split(",").length;
}
this.chartData[index] = chartOption;
},
getTableData(resData) {
if(resData['multiMallPassengerFlowTable']){
let originData = JSON.parse(JSON.stringify(resData['multiMallPassengerFlowTable'].series))
let flowHeadData = JSON.parse(JSON.stringify(resData.multiMallPassengerFlowTable.xaxis.data));
this.tabHeadData = this.dealThead(flowHeadData);
if(this.configHeadData && this.configHeadData.length>0){
this.tabHeadData.forEach((item,index)=>{
if(index>0){
if(this.configHeadData.includes(item.label)){
item.isShow = 1
}else{
item.isShow = 2
}
}
})
}
resData['multiMallPassengerFlowTable'].series.forEach((item,index)=>{
let temp = {};
item.data.forEach((dataItem, dataIndex)=>{
temp["defaultOrg" + dataIndex] = dataItem != null ? dataItem : "--";
})
this.tabOps.push(temp);
})
}
},
dealThead(theadData) {
let cols = [],
$index = 0;
cols = theadData.map((item, index) => {
if (/^\[.+\]$/.test(item)) {
let formatItem = eval(item);
return {
label: formatItem[0],
children: formatItem
.map((childItem, childIndex) => {
if (childIndex > 0) {
return {
prop: "defaultOrg" + $index++,
label: childItem,
width: 150
};
} else {
return false;
}
})
.filter(Boolean)
};
} else {
return {
prop: "defaultOrg" + $index++,
label: item,
fixed: true,
width: 120
};
}
});
return cols;
},
selReport(iconType) {
if (iconType === "line") {
if (this.isMTabChart) {
this.isMTabChart = false;
this.getData();
}
} else {
if (!this.isMTabChart) {
this.isMTabChart = true;
this.getData();
}
}
},
downloadData(title) {
if (this.isMTabChart) {
this.dealExport("domBmTrafficFlow", title);
} else {
let language = localStorage.getItem('lang');
if(language){
var languageObj = {
zh_CN: 'zh_CN',
en_US: 'en_US',
zh_TW: 'zh_TW',
}
language = '&localLanguage=' + languageObj[language];
}
let Url = window._vionConfig.apiUrl + '/multiMall/passengerFlow/export?'
let dowloadUrl = Url + language + `&orgIds=${this.emitData.asis_org}&startDate=${this.emitData.startDate}&endDate=${this.emitData.endDate}&type=${this.isDTabChart ? "table" : "line"}&option=${this.radioDate}&authorization=${this.$cookie.get("atoken")}`;
window.open(dowloadUrl)
}
},
}
};
</script>
<style scoped lang="less">
.legend{
li{
display: inline-block;
margin-right: 15px;
margin-bottom: 10px;
span{
display: inline-block;
border-radius: 50%;
&:first-child{
width: 15px;
height: 15px;
margin-right: 5px;
}
}
}
}
</style>