product.vue
6.45 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
<template>
<div class="stat-shop">
<layout-body>
<p slot="title">商品看板</p>
<layout-filter class="box-filter" :inline="true" :col="1">
<filter-item label="时间">
<Date-picker
type="daterange"
v-model="dateRange"
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>
</Poptip>
</filter-item>
</layout-filter>
<layout-list>
<Table border :columns="tableCols" :data="tableData"></Table>
<Page :total="pageData.total" :current="pageData.current"
@on-change="pageChange" :page-size="20" show-total></Page>
</layout-list>
</layout-body>
</div>
</template>
<script>
import moment from 'moment';
import productStore from './store';
import ProductService from 'services/statistics/product-service';
export default {
data() {
return productStore.call(this);
},
created() {
this.productService = new ProductService();
},
mounted() {
this.loadData();
},
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(Array.isArray(newDate) ? newDate[0] : newDate).format('YYYY-MM-DD');
this.endDate = moment(Array.isArray(newDate) ? newDate[1] : newDate).format('YYYY-MM-DD');
this.day = this.beginDate === this.endDate === this.today ? '' : this.beginDate;
this.pageData.current = 1;
this.list();
}
},
methods: {
loadData() {
this.list();
},
changeLimit(limit) {
this.dateRange = [this[`day${limit}`], this.today];
this.pageData.current = 1;
},
pageChange(page) {
this.pageData.current = page;
this.list();
},
filtersParams() {
let params = {};
let pageNo = this.pageData.current;
let pageSize = this.pageData.pageSize;
params.pageSize = this.pageData.pageSize;
params.pageNo = this.pageData.current;
return Promise.resolve({
params,
pageNo,
pageSize
});
},
list() {
this.$Loading.start();
return this.filtersParams().then((params) => {
return this.productService.getShopOverview({
begin: this.beginDate,
end: this.endDate,
pageNo: params.pageNo
});
}).then(result => {
this.pageData.total = result.data.totalCount;
this.pageData.current = result.data.pageNo;
this.tableData = result.data.records;
this.$Loading.finish();
}).catch(() => {
this.$Loading.finish();
});
},
exportFile() {
let param = {};
param.begin = this.beginDate;
param.end = this.endDate;
param.platform = '1,2';
const href = '/Api/platform/exportOneShopProductOverview?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>