index.vue
13.4 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
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
445
446
447
<template>
<LayoutContent :breads="[{title: '退款登记'}]">
<div class="header-container">
<LayoutFilter
@on-filter="onFilter"
@on-clear="onClear">
<i-form ref="filterForm" inline :model="filter">
<i-form-item prop="uid">
<i-input placeholder="输入UID" v-model="filter.uid"></i-input>
</i-form-item>
<i-form-item prop="refundStatus">
<i-select placeholder="状态" v-model="filter.refundStatus" style="width: 100px;">
<i-option :value="1">待退款</i-option>
<i-option :value="2">已退款</i-option>
<i-option :value="3">驳回退款</i-option>
</i-select>
</i-form-item>
<i-form-item prop="sponsorName">
<i-input placeholder="退款发起人" v-model="filter.sponsorName"></i-input>
</i-form-item>
<i-form-item prop="time">
<i-date-picker type="datetimerange" v-model="filter.time" placeholder="开始-结束时间" format="yyyy-MM-dd HH:mm" style="width: 280px"></i-date-picker>
</i-form-item>
</i-form>
</LayoutFilter>
<i-button type="success" icon="md-add" @click="onCreateRefund">新增退款信息</i-button>
</div>
<LayoutTools class="export-container">
<i-button type="primary" icon="ios-cloud-download" @click="onExport">导出</i-button>
</LayoutTools>
<LayoutTable
:page="page"
:total="total"
ref="applyRefundList"
:columns="columns"
:data="refundList"
@on-page-change="fetchData"
:onSelect="onSelect">
<template slot="footer" class="btns">
<i-button type="warning" @click="onDelete()">批量删除</i-button>
</template>
</LayoutTable>
<!-- 新增退款信息 -->
<Modal
v-model="addModelShow"
@on-cancel="handleReset('addRefundForm')"
:footer-hide='true'>
<Form
ref="addRefundForm"
:model="addRefundFormItem"
label-position="left"
:rules="ruleValidate"
label-width="100">
<FormItem label="日期" prop="createDate">
{{addRefundFormItem.createDate}}
</FormItem>
<FormItem label="订单编号" prop="orderCode">
<Row>
<Col span="10">
<Input v-model="addRefundFormItem.orderCode" @on-blur="onOrderCodeBlur"/>
</Col>
<Col offset="1" span="13">
<div>当前订单已有<span :style="{color: 'red'}">{{refundNumber}}</span>条退款记录</div>
</Col>
</Row>
</FormItem>
<FormItem label="UID" prop="uid">
<Row>
<Col span="10"><Input v-model="addRefundFormItem.uid"/></Col>
</Row>
</FormItem>
<FormItem label="退款说明" prop="refundDesc">
<Input v-model="addRefundFormItem.refundDesc" />
</FormItem>
<FormItem label="退款类型" prop="refundType">
<Row>
<Col span="10">
<Select v-model="addRefundFormItem.refundType" placeholder="退款类型">
<Option value="0">无</Option>
<Option value="1">补偿类</Option>
<Option value="2">吃货类</Option>
<Option value="3">打款类</Option>
</Select>
</Col>
</Row>
</FormItem>
<FormItem label="退款金额" prop="refundAmount">
<Row>
<Col span="10"><Input v-model="addRefundFormItem.refundAmount"/></Col>
</Row>
</FormItem>
<FormItem label="退款渠道" prop="refundChannel">
<Row>
<Col span="10">
<Select v-model="addRefundFormItem.refundChannel" placeholder="退款渠道">
<Option value="1">支付宝</Option>
<Option value="2">银行卡</Option>
</Select>
</Col>
</Row>
</FormItem>
<FormItem label="收款人姓名" prop="payeeName">
<Row>
<Col span="10"><Input v-model="addRefundFormItem.payeeName" /></Col>
</Row>
</FormItem>
<FormItem label="收款人账号" prop="payeeAccount">
<Input v-model="addRefundFormItem.payeeAccount" />
</FormItem>
<FormItem label="退回地址" prop="refundAddress">
<Row>
<Col span="10"><Input v-model="addRefundFormItem.refundAddress" /></Col>
</Row>
</FormItem>
<FormItem label="处理人" v-if="operatorName">
{{addRefundFormItem.operatorName}}
</FormItem>
<FormItem label="打款状态">
{{addRefundFormItem.refundStatusName}}
</FormItem>
<FormItem>
<Button type="primary" @click="handleSubmit('addRefundForm')">确认</Button>
<Button type="error" @click="handleReset('addRefundForm')" style="margin-left: 8px">取消</Button>
</FormItem>
</Form>
</Modal>
</LayoutContent>
</template>
<script>
import qs from 'qs';
import dayjs from "dayjs";
import Api from 'api/api';
const api = new Api();
import { Button } from 'iview';
import BlobUtil from 'libs/blob';
export default {
name: 'ApplyRefund',
data() {
return {
filter: {
uid: '',
sponsorName: '',
refundStatus: '',
time: []
},
page: 1,
total: 0,
// 新增退款信息
addModelShow: false,
addRefundFormItem: {
createDate: dayjs().format('YYYY/MM/DD'),
orderCode: '',
uid: '',
refundDesc: '',
refundType: '',
refundAmount: '',
refundChannel: '',
payeeName: '',
payeeAccount: '',
refundAddress: '',
operatorName: '',
refundStatusName: '待退款'
},
// 退款次数
refundNumber: 0,
isEdit: false,
selectedIds: [],
ruleValidate: {
uid: [{required: true, message: '请输入uid', trigger: 'blur'}],
orderCode: [{required: true, message: '请输入订单编号', trigger: 'blur'}],
refundDesc: [{required: true, message: '请输入退款说明', trigger: 'blur'}],
refundType: [{required: true, message: '请选择退款类型', trigger: 'blur'}],
refundAmount: [{required: true, message: '请输入退款金额', trigger: 'blur'}],
refundChannel: [{required: true, message: '请选择退款渠道', trigger: 'blur'}],
payeeName: [{required: true, message: '请输入收款人姓名', trigger: 'blur'}],
payeeAccount: [{required: true, message: '请输入收款人账号', trigger: 'blur'}]
},
refundList: [],
columns: [{
type: 'selection',
width: 60,
align: 'center'
},{
title: '日期',
key: 'createDate',
width: 120,
align: 'center'
}, {
title: '退款发起人',
key: 'sponsorName',
width: 120,
align: 'center'
},{
title: '订单号',
key: 'orderCode',
width: 160,
align: 'center'
},{
title: 'UID',
key: 'uid',
width: 120,
align: 'center'
}, {
title: '说明',
key: 'refundDesc',
width: 150,
},
{
title: '退款类型',
key: 'refundTypeName',
width: 100,
align: 'center'
},
{
title: '金额',
key: 'refundAmount',
width: 90,
},
{
title: '退款渠道',
key: 'refundChannelName',
width: 100
},{
title: '收款人姓名',
key: 'payeeName',
align:'center',
width: 90
}, {
title: '收款账号',
align: 'center',
key: 'payeeAccount',
width: 150
},{
title: '商品名称',
align: 'center',
key: 'goodsName',
width: 165
},
{
title: '商品尺码',
key: 'goodsSize',
align:'center',
width: 100
}, {
title: '退回地址',
align: 'center',
key: 'refundAddress',
width: 150
},{
title: '处理人',
aligin: 'center',
key: 'operatorName',
width: 90
},{
title: '状态',
key: 'refundStatusName',
align:'center',
width: 100
},{
title: '备注',
align: 'center',
key: 'remark',
align: 'center',
width: 200
}, {
title: '操作',
align: 'center',
fixed: 'right',
width: 200,
render: (h, {row}) => {
return (
<div>
{row.refundStatus == 1 ? <Button type="success" size="small" onClick={() => this.onEdit(row, true, true)}>编辑</Button> : null}
{row.refundStatus == 1 ? <Button type="error" size="small" style="margin-left: 8px" onClick={() => this.onDelete([row.id])}>删除</Button> : null }
</div>
);
}
}]
}
},
computed: {
filterParam(vm) {
const keys = Object.keys(vm.filter);
const res = Object.create(null);
for(const key of keys) {
if(key === 'time') {
const [startTime, endTime] = vm.filter.time;
if(startTime && endTime) {
res.startTime = dayjs(startTime).format('YYYY-MM-DD');
res.endTime = dayjs(endTime).format('YYYY-MM-DD');
}
continue
}
if(vm.filter[key]) {
res[key] = vm.filter[key];
}
}
return res;
}
},
mounted(){
this.fetchData();
},
methods: {
async fetchData(page = 1) {
this.page = page;
this.$Loading.start();
const result = await api._get('/ufoPlatform/refundRecord/list', {page, ...this.filterParam});
if (result.code === 200) {
this.total = result.data.total;
this.refundList = result.data.list.map(item => {
const {refundStatus} = item;
return {...item, _disabled: refundStatus !== 1}
})
this.$Loading.finish();
} else {
result.message && this.$Message.warning(result.message);
this.$Loading.error();
}
},
onFilter() {
this.fetchData()
},
onOrderCodeBlur() {
if(this.addRefundFormItem.orderCode) {
this.fetchRefundCount(this.addRefundFormItem.orderCode);
}
},
onClear() {
this.$refs.filterForm.resetFields();
this.fetchData();
},
onCreateRefund() {
this.isEdit = false;
this.refundNumber = 0;
this.addModelShow = true;
},
fetchRefundCount(orderCode) {
api._get('/ufoPlatform/refundRecord/getOrderExistedCount', {orderCode}).then(res=> {
if(res.code === 200) {
this.refundNumber = res.data || 0;
}
})
},
onEdit(row) {
this.isEdit = true;
const keys = Object.keys(this.addRefundFormItem);
// 查询订单退款纪录
const {orderCode} = row;
this.fetchRefundCount(orderCode);
for(const key of keys) {
if(key === 'createDate') continue;
this.addRefundFormItem[key] = `${row[key] || ''}`
}
this.addRefundFormItem.id = row.id;
this.addModelShow = true;
},
onSelect(items) {
this.selectedIds = items.map(item=> item.id);
},
onDelete(ids) {
this.$Modal.confirm({
render: h => {
return h('div', {}, '确定删除?');
},
onOk: () => {
this.onBatchDelete(ids)
}
})
},
onBatchDelete(ids = []) {
if(this.selectedIds.length) {
ids = this.selectedIds;
}
if(ids && !ids.length) {
return
}
api._get('/ufoPlatform/refundRecord/delete', {ids:ids.join()}).then(res=> {
if(res.code === 200) {
this.$Message.success(res.message);
this.fetchData();
}else{
this.$Message.error(res && res.message || '删除失败');
}
})
},
handleSubmit(name) {
this.$refs[name].validate((valid)=> {
if (valid) {
const {operatorName, refundStatusName, ...params} = this.addRefundFormItem
api._get(`/ufoPlatform/refundRecord/${this.isEdit ? 'update' : 'add'}`, params).then((res = {})=> {
if(res && res.code === 200) {
this.isEdit = false;
this.fetchData(this.page);
this.$refs[name].resetFields();
this.addModelShow = false;
this.$Message.success(res.message);
}else{
this.$Message.error(res.message);
}
});
} else {
this.$Message.error('请完善信息!');
}
});
},
handleReset(name) {
this.addModelShow = false;
this.isEdit = false;
this.$refs[name].resetFields();
},
onExport() {
this.$Loading.start();
api._get('/ufoPlatform/refundRecord/export', {
param: api._2params(this.filterParam)
}, {
responseType: 'blob'
}).then(result => {
if (result instanceof Blob) {
BlobUtil.downloadBlob(result, `退款申请_${dayjs().format('YYYY-MM-DD')}.xlsx`);
this.$Loading.finish();
} else if (result) {
result.message && this.$Message.warning(result.message);
this.$Loading.error();
}
})
}
},
}
</script>
<style lang="scss" scoped>
.header-container {
display: flex;
justify-content: space-between;
}
.export-container {
display: flex;
justify-content: flex-end;
}
</style>