forked from macrozheng/mall-admin-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.vue
446 lines (443 loc) · 14 KB
/
index.vue
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
<template>
<div class="app-container">
<el-card class="filter-container" shadow="never">
<div>
<i class="el-icon-search"></i>
<span>筛选搜索</span>
<el-button
style="float:right"
type="primary"
@click="handleSearchList()"
size="small">
查询搜索
</el-button>
<el-button
style="float:right;margin-right: 15px"
@click="handleResetSearch()"
size="small">
重置
</el-button>
</div>
<div style="margin-top: 15px">
<el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<el-form-item label="输入搜索:">
<el-input v-model="listQuery.orderSn" style="width: 203px" placeholder="订单编号"></el-input>
</el-form-item>
<el-form-item label="收货人:">
<el-input v-model="listQuery.receiverKeyword" style="width: 203px" placeholder="收货人姓名/手机号码"></el-input>
</el-form-item>
<el-form-item label="提交时间:">
<el-date-picker
v-model="listQuery.createTime"
value-format="yyyy-MM-dd"
type="date"
placeholder="选择开始时间">
</el-date-picker>
</el-form-item>
<el-form-item label="订单状态:">
<el-select v-model="listQuery.status" placeholder="全部" clearable>
<el-option v-for="item in statusOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="订单分类:">
<el-select v-model="listQuery.orderType" placeholder="全部" clearable>
<el-option v-for="item in orderTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="订单来源:">
<el-select v-model="listQuery.sourceType" placeholder="全部" clearable>
<el-option v-for="item in sourceTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-form>
</div>
</el-card>
<el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i>
<span>数据列表</span>
</el-card>
<div class="table-container">
<el-table ref="orderTable"
:data="list"
style="width: 100%;"
@selection-change="handleSelectionChange"
v-loading="listLoading" border>
<el-table-column type="selection" width="60" align="center"></el-table-column>
<el-table-column label="编号" width="80" align="center">
<template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column>
<el-table-column label="订单编号" width="180" align="center">
<template slot-scope="scope">{{scope.row.orderSn}}</template>
</el-table-column>
<el-table-column label="提交时间" width="180" align="center">
<template slot-scope="scope">{{scope.row.createTime | formatCreateTime}}</template>
</el-table-column>
<el-table-column label="用户账号" align="center">
<template slot-scope="scope">{{scope.row.memberUsername}}</template>
</el-table-column>
<el-table-column label="订单金额" width="120" align="center">
<template slot-scope="scope">¥{{scope.row.totalAmount}}</template>
</el-table-column>
<el-table-column label="支付方式" width="120" align="center">
<template slot-scope="scope">{{scope.row.payType | formatPayType}}</template>
</el-table-column>
<el-table-column label="订单来源" width="120" align="center">
<template slot-scope="scope">{{scope.row.sourceType | formatSourceType}}</template>
</el-table-column>
<el-table-column label="订单状态" width="120" align="center">
<template slot-scope="scope">{{scope.row.status | formatStatus}}</template>
</el-table-column>
<el-table-column label="操作" width="200" align="center">
<template slot-scope="scope">
<el-button
size="mini"
@click="handleViewOrder(scope.$index, scope.row)"
>查看订单</el-button>
<el-button
size="mini"
@click="handleCloseOrder(scope.$index, scope.row)"
v-show="scope.row.status===0">关闭订单</el-button>
<el-button
size="mini"
@click="handleDeliveryOrder(scope.$index, scope.row)"
v-show="scope.row.status===1">订单发货</el-button>
<el-button
size="mini"
@click="handleViewLogistics(scope.$index, scope.row)"
v-show="scope.row.status===2||scope.row.status===3">订单跟踪</el-button>
<el-button
size="mini"
type="danger"
@click="handleDeleteOrder(scope.$index, scope.row)"
v-show="scope.row.status===4">删除订单</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="batch-operate-container">
<el-select
size="small"
v-model="operateType" placeholder="批量操作">
<el-option
v-for="item in operateOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-button
style="margin-left: 20px"
class="search-button"
@click="handleBatchOperate()"
type="primary"
size="small">
确定
</el-button>
</div>
<div class="pagination-container">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes,prev, pager, next,jumper"
:current-page.sync="listQuery.pageNum"
:page-size="listQuery.pageSize"
:page-sizes="[5,10,15]"
:total="total">
</el-pagination>
</div>
<el-dialog
title="关闭订单"
:visible.sync="closeOrder.dialogVisible" width="30%">
<span style="vertical-align: top">操作备注:</span>
<el-input
style="width: 80%"
type="textarea"
:rows="5"
placeholder="请输入内容"
v-model="closeOrder.content">
</el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="closeOrder.dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="handleCloseOrderConfirm">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {fetchList,closeOrder,deleteOrder} from '@/api/order'
import {formatDate} from '@/utils/date';
const defaultListQuery = {
pageNum: 1,
pageSize: 5,
orderSn: null,
receiverKeyword: null,
status: null,
orderType: null,
sourceType: null,
createTime: null,
};
export default {
name: "orderList",
data() {
return {
listQuery: Object.assign({}, defaultListQuery),
listLoading: true,
list: null,
total: null,
operateType: null,
multipleSelection: [],
closeOrder:{
dialogVisible:false,
content:null,
orderIds:[]
},
statusOptions: [
{
label: '待付款',
value: 0
},
{
label: '待发货',
value: 1
},
{
label: '已发货',
value: 2
},
{
label: '已完成',
value: 3
},
{
label: '已关闭',
value: 4
}
],
orderTypeOptions: [
{
label: '正常订单',
value: 0
},
{
label: '秒杀订单',
value: 1
}
],
sourceTypeOptions: [
{
label: 'PC订单',
value: 0
},
{
label: 'APP订单',
value: 1
}
],
operateOptions: [
{
label: "批量发货",
value: 1
},
{
label: "关闭订单",
value: 2
},
{
label: "删除订单",
value: 3
}
],
}
},
created() {
this.getList();
},
filters: {
formatCreateTime(time) {
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
},
formatPayType(value) {
if (value === 1) {
return '支付宝';
} else if (value === 2) {
return '微信';
} else {
return '未支付';
}
},
formatSourceType(value) {
if (value === 1) {
return 'APP订单';
} else {
return 'PC订单';
}
},
formatStatus(value) {
if (value === 1) {
return '待发货';
} else if (value === 2) {
return '已发货';
} else if (value === 3) {
return '已完成';
} else if (value === 4) {
return '已关闭';
} else if (value === 5) {
return '无效订单';
} else {
return '待付款';
}
},
},
methods: {
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery);
},
handleSearchList() {
this.listQuery.pageNum = 1;
this.getList();
},
handleSelectionChange(val){
this.multipleSelection = val;
},
handleViewOrder(index, row){},
handleCloseOrder(index, row){
this.closeOrder.dialogVisible=true;
this.closeOrder.orderIds=[row.id];
},
handleDeliveryOrder(index, row){
let listItem = this.covertOrder(row);
this.$router.push({path:'/oms/deliverOrderList',query:{list:[listItem]}})
},
handleViewLogistics(index, row){},
handleDeleteOrder(index, row){
let ids=[];
ids.push(row.id);
this.deleteOrder(ids);
},
handleBatchOperate(){
if(this.multipleSelection==null||this.multipleSelection.length<1){
this.$message({
message: '请选择要操作的订单',
type: 'warning',
duration: 1000
});
return;
}
if(this.operateType===1){
//批量发货
let list=[];
for(let i=0;i<this.multipleSelection.length;i++){
if(this.multipleSelection[i].status===1){
list.push(this.covertOrder(this.multipleSelection[i]));
}
}
if(list.length===0){
this.$message({
message: '选中订单中没有可以发货的订单',
type: 'warning',
duration: 1000
});
return;
}
this.$router.push({path:'/oms/deliverOrderList',query:{list:list}})
}else if(this.operateType===2){
//关闭订单
this.closeOrder.orderIds=[];
for(let i=0;i<this.multipleSelection.length;i++){
this.closeOrder.orderIds.push(this.multipleSelection[i].id);
}
this.closeOrder.dialogVisible=true;
}else if(this.operateType===3){
//删除订单
let ids=[];
for(let i=0;i<this.multipleSelection.length;i++){
ids.push(this.multipleSelection[i].id);
}
this.deleteOrder(ids);
}
},
handleSizeChange(val){
this.listQuery.pageNum = 1;
this.listQuery.pageSize = val;
this.getList();
},
handleCurrentChange(val){
this.listQuery.pageNum = val;
this.getList();
},
handleCloseOrderConfirm() {
if (this.closeOrder.content == null || this.closeOrder.content === '') {
this.$message({
message: '操作备注不能为空',
type: 'warning',
duration: 1000
});
return;
}
let params = new URLSearchParams();
params.append('ids', this.closeOrder.orderIds);
params.append('note', this.closeOrder.content);
closeOrder(params).then(response=>{
this.closeOrder.orderIds=[];
this.closeOrder.dialogVisible=false;
this.getList();
this.$message({
message: '修改成功',
type: 'success',
duration: 1000
});
});
},
getList() {
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.listLoading = false;
this.list = response.data.list;
this.total = response.data.total;
});
},
deleteOrder(ids){
this.$confirm('是否要进行该删除操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = new URLSearchParams();
params.append("ids",ids);
deleteOrder(params).then(response=>{
this.getList();
});
})
},
covertOrder(order){
let address=order.receiverProvince+order.receiverCity+order.receiverRegion+order.receiverDetailAddress;
let listItem={
orderId:order.id,
orderSn:order.orderSn,
receiverName:order.receiverName,
receiverPhone:order.receiverPhone,
receiverPostCode:order.receiverPostCode,
address:address,
deliveryCompany:null,
deliverySn:null
};
return listItem;
}
}
}
</script>
<style></style>