zonerelations.vue
10.1 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
<!--店鋪关联-->
<template>
<div class="customgroup-wrapper">
<el-header>
<span class="asis-title"
>{{ asisName }} {{ $t("asis.Zonerelations") }}</span
>
</el-header>
<zonerelations-option
ref="relationsinit"
@reportTime="reportHandler"
></zonerelations-option>
<div class="element-main sr-main">
<div v-show="level=='zone'" class="store-relations">
<el-col :span="24">
<div class="asis-table-wrapper dt-content-wrapper">
<h3 class="asis-table-header relations-header-op">
<span class="asis-table-title">{{emitData.asis_zoneTit}}-店铺关联</span>
</h3>
<div class="asis-table-content" v-loading="loading">
<sort-table
:isZone="true"
:showTime="true"
:tableData="tableData"
v-if="isTabChart"
class="sort-box"
></sort-table>
</div>
</div>
</el-col>
<el-col :span="12">
<div class="asis-table-wrapper dt-content-wrapper">
<h3 class="asis-table-header relations-header-op">
<span class="asis-table-title">{{
$t("table.Source")
}}</span>
<span
class="asis-table-download"
@click="exportDataHandle('source')"
>{{ $t("allPages.load") }}</span
>
</h3>
<div class="asis-table-content" v-loading="loading1">
<!-- 店铺客流排行Table -->
<sort-table
:isSource="true"
:tableData="tableData1"
v-if="isTabChart"
class="sort-box"
></sort-table>
<div class="page-wrapper">
<el-pagination
background
:current-page="curPage1"
:page-sizes="pageArr"
:page-size="pageSize1"
@size-change="sizeChange(1,$event)"
@current-change="handleCurrentChange(1,$event)"
layout="prev, pager, next, slot,sizes"
:total="total1"
>
<span
class="slot-ele-total"
>{{$t('table.pageHead')}} {{ total1 }} {{$t('table.pageTail')}}</span>
</el-pagination>
</div>
</div>
</div>
</el-col>
<el-col :span="12">
<div class="asis-table-wrapper dt-content-wrapper">
<h3 class="asis-table-header relations-header-op">
<span class="asis-table-title">{{
$t("table.Target")
}}</span>
<span
class="asis-table-download"
@click="exportDataHandle('target')"
>{{ $t("allPages.load") }}</span
>
</h3>
<div class="asis-table-content" v-loading="loading2">
<sort-table
:isTarget="true"
:tableData="tableData2"
v-if="isTabChart"
class="sort-box"
></sort-table>
<div class="page-wrapper">
<el-pagination
background
:current-page="curPage2"
:page-sizes="pageArr"
:page-size="pageSize2"
@size-change="sizeChange(2,$event)"
@current-change="handleCurrentChange(2,$event)"
layout="prev, pager, next, slot,sizes"
:total="total2"
>
<span
class="slot-ele-total"
>{{$t('table.pageHead')}} {{ total2 }} {{$t('table.pageTail')}}</span>
</el-pagination>
</div>
</div>
</div>
</el-col>
</div>
</div>
<export-data-dialog ref="exportDialog"></export-data-dialog>
</div>
</template>
<script>
import zonerelations from "../common/option/zonerelations";
import enterChart from "../../Mall/common/enterChart";
import sorttable from "../../Mall/common/pflowsort.vue";
import exportData from '../../public/exportData'
import Cookies from 'js-cookie'
export default {
data() {
return {
asisName: "",
chartData:null,
parameter:{},
tableData: [],
tableData1: [],
tableData2: [],
level: "zone",
isTabChart: "TAB_TABLE",
loading: false,
loading1:false,
loading2:false,
emitData:{},
curPage1:1,
total1:0,
pageSize1: 10,
curPage2:1,
total2:0,
pageSize2: 10,
pageArr: [10, 50, 100],
};
},
components: {
"zonerelations-option": zonerelations,
"enter-chart": enterChart,
"sort-table": sorttable,
"export-data-dialog":exportData
},
created() {
window.addEventListener("resize", () => {
try {
let timeHeatEChartsUtil = {
chart1: $("#storeRatio")[0],
};
for (let k in timeHeatEChartsUtil) {
if (
timeHeatEChartsUtil.hasOwnProperty(k) &&
timeHeatEChartsUtil[k] != undefined
) {
timeHeatEChartsUtil[k] = this.$echarts.init(timeHeatEChartsUtil[k]);
var element = timeHeatEChartsUtil[k];
element.resize();
}
}
} catch (err) {}
});
},
mounted() {
this.getMallOpt();
},
computed: {
tableHeight() {
const windowHeight = window.innerHeight;
const scale =
windowHeight <= 720
? 0.35
: windowHeight <= 768
? 0.33
: windowHeight <= 900
? 0.28
: windowHeight <= 1080
? 0.31
: 0.1;
return windowHeight - windowHeight * scale;
},
},
methods: {
exportDataHandle(type){
let language = localStorage.getItem("lang");
const { apiUrl } = window._vionConfig;
const params = this.serializeJSON(Object.assign({},this.parameter,{
title:this.asisName,
type
}));
const downloadUrl = `${apiUrl}/report/zoneAssociation/zone/export?${params}&localLanguage=${language}&authorization=${this.$cookie.get(
"atoken"
)}`;
console.info(downloadUrl)
window.open(downloadUrl);
},
changeFieldName(list=[],type){
return list.map((item,index)=>{
item.storeName = item.zoneName;
item.floorName = item.zoneFloorName;
item.formatName = item.zoneFormatName
item.trafficNum = item.zoneTrafficCount;
if(item.startDate&&item.endDate){
item.startDate = dateUnit.dateFormat(item.startDate, 'yyyy-MM-dd');
item.endDate = dateUnit.dateFormat(item.endDate, 'yyyy-MM-dd');
if(item.startDate == item.endDate){
item.timeDate = item.startDate
}else{
item.timeDate = item.startDate+'-'+item.endDate;
}
}
if(type){
item.order = (this['curPage'+type]-1)*this['pageSize'+type]+index+1;
}
return item;
})
},
sizeChange(type,size){
this['curPage'+type] = 1;
this['pageSize'+type] = size;
this.getTableData({type,size});
},
handleCurrentChange(type,page) {
if (this['curPage'+type] != page) {
this['curPage'+type] = page;
this.getTableData({type,page});
}
},
getTableData({type,size,page}){
this['loading'+type] = true;
const params = Object.assign({},this.parameter,{page,pageSize:size?size:this['pageSize'+type]});
this.$api.analysisReport[type==1?'getSourceList':'getTargetList'](params).then(res=>{
let { data } = res.data;
this['total'+type] = data.total;
this['curPage'+type] = data.pageNum;
this['pageSize'+type]= data.pageSize;
this['tableData' + type] = this.changeFieldName(data.list,type);
this['loading'+type] = false;
});
},
getMallOpt() {
this.getCommonMalls().then(
(resolveData) => {
let { mallData, localMallId, titleName, multiMallId } = resolveData;
this.$refs.relationsinit.initAsis(localMallId, mallData);
},
(rejectData) => {}
);
},
dataFetch() {
return new Promise((resolve, reject) => {
let {
emitData: {asis_date, asis_time,asis_zoneId},
} = this,
{ startTime, endTime } = this.newDateFormat(asis_date, asis_time);
let parameter = {
startDate: startTime,
endDate: endTime,
zoneId:asis_zoneId,
};
this.parameter = parameter;
this.$api.analysisReport
.getZoneInfo(parameter)
.then((res) => {
let { data } = res.data;
resolve(data);
})
.catch((err) => {
this.catchErrorHandle(err);
});
});
},
async getData() {
this.loading = true;
this.tableData = this.changeFieldName([await this.dataFetch()]);
this.loading = false;
this.curPage1 = this.curPage2 = 1;
this.pageSize1 = this.pageSize2 = 10;
this.getTableData({type:1,page:this.curPage1,size:this.pageSize1});
this.getTableData({type:2,page:this.curPage2,size:this.pageSize2});
},
reportHandler(emitData) {
this.emitData = emitData;
this.asisName = emitData.asis_tit;
if(!this.emitData.asis_zoneId){
this.$message({
showClose: true,
type: "error",
message: "请选择店铺"
});
this.tableData = this.tableData1 = this.tableData2 = [];
this.total1 = this.total2 = 0;
return false;
}
this.getData();
},
},
};
</script>
<style scoped>
.seq-analysis {
width: 100%;
height: 100%;
}
.store-relations{
background: #fff;
}
.sort-box{
overflow: hidden;
}
.el-pagination{
text-align: center;
padding: 20px 5px;
}
</style>