shop.vue
13.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<template>
<div class="stat-shop">
<layout-body>
<Card class="shop-card">
<p slot="title">店铺看板</p>
<layout-filter class="box-filter" :inline="true" :col="1">
<filter-item label="时间">
<Date-picker
type="daterange"
v-model="dateRange"
placement="bottom-start"
format="yyyy-MM-dd"
placeholder="选择开始结束日期"></Date-picker>
<div class="quick">
<a href="javascript:;" @click="() => {changeLimit(7)}">近7天</a>
<a href="javascript:;" @click="() => {changeLimit(30)}">近30天</a>
</div>
<Poptip trigger="hover" placement="bottom-end">
<div slot="content">
* 仅支持导出历史数据,时间跨度不得超过30天
</div>
<Button type="primary" @click="exportFile">导出</Button>
<p style="display: inline-block;font-size: 10px;color: #c90;">* 当日数据不支持导出</p>
</Poptip>
</filter-item>
</layout-filter>
<Row style="marginTop: 20px; marginBottom: 30px; marginBottom: 20px;">
<!--<Col span="6">-->
<!--<div class="box-item bg-red" >-->
<!--<Icon type="person"></Icon>-->
<!--<span class="box-item-label">{{filters.targetColumns[0].title}}</span>-->
<!--<span class="box-item-value">{{this.overviewData.uv}}</span>-->
<!--</div>-->
<!--<div class="box-item bg-yellow">-->
<!--<Icon type="eye"></Icon>-->
<!--<span class="box-item-label">{{filters.targetColumns[1].title}}</span>-->
<!--<span class="box-item-value">{{this.overviewData.pv}}</span>-->
<!--</div>-->
<!--</Col>-->
<Col span="6">
<div class="box-item bg-aqua">
<Icon type="android-cart"></Icon>
<span class="box-item-label">{{filters.targetColumns[2].title}}</span>
<span class="box-item-value">{{this.overviewData.orderCount}}</span>
</div>
</Col>
<Col span="6">
<div class="box-item bg-blue">
<Icon type="social-yen"></Icon>
<span class="box-item-label">{{filters.targetColumns[3].title}}</span>
<span class="box-item-value">{{this.overviewData.orderAmount}}</span>
</div>
</Col>
<Col span="6">
<div class="box-item bg-light-blue">
<Icon type="clipboard"></Icon>
<span class="box-item-label">{{filters.targetColumns[4].title}}</span>
<span class="box-item-value">{{this.overviewData.shipmentOrderCount}}</span>
</div>
</Col>
<Col span="6">
<div class="box-item bg-green">
<Icon type="social-yen"></Icon>
<span class="box-item-label">{{filters.targetColumns[5].title}}</span>
<span class="box-item-value">{{this.overviewData.shipmentOrderAmount}}</span>
</div>
</Col>
<!--<Col span="6">-->
<!--<div class="box-item bg-purple">-->
<!--<Icon type="loop"></Icon>-->
<!--<span class="box-item-label">{{filters.targetColumns[6].title}}</span>-->
<!--<span class="box-item-value">{{this.overviewData.uvOrderRate}}</span>-->
<!--</div>-->
<!--</Col>-->
</Row>
</Card>
<Card class="shop-card">
<p slot="title">最近30天运营趋势</p>
<div class="tabs-col">
<Tabs size="small" v-model="curTarget">
<Tab-pane v-for="item in targetList" :label="item.label" :key="item.name" :name="item.name">
<EChart v-if="item.chatOpt.series" :className="item.name" :echartParams="item.chatOpt"></EChart>
<Spin fix size="large" v-else></Spin>
</Tab-pane>
</Tabs>
</div>
</Card>
</layout-body>
</div>
</template>
<script>
import _ from 'lodash';
import moment from 'moment';
import goodStore from './store';
import GoodService from 'services/statistics/shop-service';
export default {
data() {
return goodStore.call(this);
},
created() {
this.goodService = new GoodService();
},
watch: {
date() {
this.loadData();
},
day(newDay) {
let curDay = moment().format('YYYY-MM-DD');
if (newDay === this.beginDate || !newDay) {
return;
}
this.dateRange = newDay !== this.curDay ? [newDay, curDay] : [newDay, newDay];
},
dateRange(newDate) {
this.beginDate = moment(newDate[0]).format('YYYY-MM-DD');
this.endDate = moment(newDate[1]).format('YYYY-MM-DD');
this.day = this.beginDate === this.endDate === this.today ? '' : this.beginDate;
// this.curTarget = 'uv';
this.curTarget = 'orderCount';
this.getDataFlag = true;
this.getOverviewData();
_.each(this.targetList, tar => {
tar.chatOpt = {};
});
this.getOverviewTrend();
},
curTarget(value) {
this.curTarget = value;
this.getOverviewTrend(this.curTarget);
return value;
}
},
mounted() {
this.loadData();
},
methods: {
loadData() {
this.getOverviewData();
this.getOverviewTrend();
},
changeLimit(limit) {
this.dateRange = [this[`day${limit}`], this.today];
if (this.endDate !== this.today) {
_.each(this.targetList, tar => {
tar.chatOpt = {};
});
this.getOverviewTrend();
}
},
getOverviewTrend() {
let target = _.find(this.targetList,
tar => tar.name === this.curTarget);
if (target.chatOpt.series) {
return;
}
this.goodService.getOverviewTrend({
type: this.curTarget,
begin: moment(this.endDate).subtract(30, 'days').format('YYYY-MM-DD'),
end: this.endDate,
platform: '1,2,3,4'
}).then(ret => {
let data = ret.data;
this.overviewChartData.xAxis = _.map(data, 'date');
// this.overviewChartData.uv = _.map(data, 'uv');
// this.overviewChartData.pv = _.map(data, 'pv');
this.overviewChartData.orderCount = _.map(data, 'orderCount');
this.overviewChartData.orderAmount = _.map(data, 'orderAmount');
this.overviewChartData.paymentOrderCount = _.map(data, 'paymentOrderCount');
this.overviewChartData.paymentOrderAmount = _.map(data, 'paymentOrderAmount');
target.chatOpt = {
title: '',
color: '#000',
legend: [target.label],
xAxis: this.overviewChartData.xAxis,
yAxis: [''],
min: _.min(this.overviewChartData[this.curTarget]),
series: [
{name: [target.label], data: this.overviewChartData[this.curTarget]}
]
};
});
},
getOverviewData() {
this.goodService.getData({
begin: this.beginDate,
end: this.endDate,
platform: '1,2,3,4'
}).then(ret => {
if (!ret.data) {
// this.overviewData.uv = 0;
// this.overviewData.pv = 0;
this.overviewData.orderCount = 0;
this.overviewData.orderAmount = 0;
this.overviewData.shipmentOrderCount = 0;
this.overviewData.shipmentOrderAmount = 0;
// this.overviewData.uvOrderRate = 0;
return;
}
this.overviewData = ret.data;
this.overviewData.uv = _.get(ret.data, 'uv') ? ret.data.uv : '——';
this.overviewData.pv = _.get(ret.data, 'pv') ? ret.data.pv : '——';
this.overviewData.orderCount = _.get(ret.data, 'orderCount') ? ret.data.orderCount : '——';
this.overviewData.orderAmount = _.get(ret.data, 'orderAmount') ? ret.data.orderAmount : '——';
this.overviewData.shipmentOrderCount = _.get(ret.data, 'paymentOrderCount') ? ret.data.paymentOrderCount : '——';
this.overviewData.shipmentOrderAmount = _.get(ret.data, 'paymentOrderAmount') ? ret.data.paymentOrderAmount : '——';
this.overviewData.uvOrderRate = ((_.get(ret.data, 'uvOrderRate') && (ret.data.uvOrderRate <= 1) ?
(ret.data.uvOrderRate * 100) : ret.data.uvOrderRate)).toFixed(2) + '%';
if (this.beginDate !== this.endDate) {
let formatData = _.slice(ret.data, 0, ret.data.length - 1);
// this.overviewChartData.uv = _.get(ret, 'uv');
// this.overviewChartData.pv = _.get(ret, 'pv');
this.overviewChartData.orderCount = _.get(ret, 'orderCount');
this.overviewChartData.orderAmount = _.get(ret, 'orderAmount');
this.overviewChartData.paymentOrderCount = _.get(ret, 'paymentOrderCount');
this.overviewChartData.paymentOrderAmount = _.get(ret, 'paymentOrderAmount');
this.overviewChartData.xAxis = _.map(formatData, 'date');
}
});
},
exportFile() {
let param = {};
param.begin = this.beginDate;
param.end = this.endDate;
param.platform = '1,2';
const href = '/Api/platform/exportOneShopOverview?queryConf=' +
JSON.stringify(param);
window.open(href, '_blank');
},
}
};
</script>
<style lang="scss">
.stat-shop {
.ivu-tabs-tabpane {
height: 400px;
position: relative;
}
}
.layout-container {
min-height: 200px;
margin: 15px;
overflow: hidden;
background: #fff;
border-radius: 4px;
.layout-filter .line {
border-top: none;
margin-bottom: 0;
}
}
.shop-card {
margin-top: 10px;
margin-bottom: 10px;
}
.box-title {
font-weight: 700;
color: #495060;
font-size: 16px;
line-height: 22px;
margin: 5px;
&:before {
content: " ";
display: inline-block;
width: 5px;
margin-right: 2px;
height: 22px;
vertical-align: top;
background-color: #999;
}
}
.box-item {
width: 90%;
height: 50px;
padding: 0 0 0 15px;
line-height: 50px;
font-size: 14px;
overflow: hidden;
border-radius: 5px;
color: #fff;
margin-bottom: 10px;
.box-item-label {
display: inline-block;
min-width: 75px;
vertical-align: top;
font-weight: normal;
}
.box-item-value {
font-size: 20px;
font-weight: 600;
}
i {
display: inline-block;
width: 20px;
height: 20px;
font-size: 22px;
text-align: center;
margin-top: -7px;
vertical-align: middle;
margin-right: 3px;
}
}
.box-filter {
.ivu-date-picker {
margin-left: 0;
width: 220px !important;
}
.quick {
display: inline-block;
margin-left: 20px;
margin-right: 50px;
a {
margin-right: 5px;
}
}
}
</style>