signRefundDialog.vue
4.67 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
<!-- 标记退款 -->
<template>
<d2-dialog title="退款备注"
:is-visible="signRefundVisible"
class="accountDailog"
@closeDialog="handleClose"
@confirmDialog="handleAddConfirm">
<el-form ref="refundForm"
:model="infoForm"
:rules="formRules"
:label-width="isPartialRefund ? '100px': '0'">
<template v-if="isPartialRefund">
<el-form-item prop="refundType"
label="退款明细:">
<el-radio-group v-model="infoForm.refundType"
@change="changeType">
<el-radio label="1">
退全款
</el-radio>
<el-radio label="2">
退部分款
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item prop="refundAmount"
label="退款金额:">
<el-input style="width: 432px;"
:disabled="infoForm.refundType == '1'"
placeholder="请输入退款金额"
@input="refoundAmountInput"
v-model="infoForm.refundAmount"></el-input>
</el-form-item>
</template>
<el-form-item prop="remark"
:label="isPartialRefund ? '备注:' : ''">
<el-input v-clear-emoij
type="textarea"
:rows="5"
placeholder="请备注客户退款的原因,有助于您的售后"
maxlength="200"
show-word-limit
v-model="infoForm.remark" />
</el-form-item>
</el-form>
</d2-dialog>
</template>
<script>
// import { getMerchantPageSearch } from '@api/publicAccount'
import { markAsRefunded } from '@api/order'
import { deepClone } from '@/common/util'
import { limitPrice } from '@/common/format'
export default {
name: 'SignRefundDialog',
data() {
var checkRefundAmount = (rule, value, callback) => {
if (this.infoForm?.refundType == '2') {
if (value == 0) {
callback('退款金额要大于0')
} else if (+value >= this.detail?.totalPrice) {
callback('退款金额只能小于订单总金额')
} else {
callback()
}
} else {
callback()
}
}
return {
userInfo: this.$store.state.d2admin.user.info,
infoForm: {
remark: '',
refundType: '1',
refundAmount: ''
},
formRules: {
remark: [{ required: true, message: '请输入备注信息', trigger: 'change' }],
refundAmount: [
{ required: true, message: '请输入退款金额', trigger: 'blur' },
{
validator: checkRefundAmount, trigger: 'blur'
}
]
},
reg: {
priceReg: /^\d[\d\.]*$/
}
}
},
props: {
signRefundVisible: {
type: Boolean,
default: false
},
detail: {
type: Object,
default: null
},
isPartialRefund: {
type: Boolean,
default: false
}
},
watch: {
},
created() {
},
components: {},
mounted() {
console.log(this.detail)
this.changeType(this.infoForm.refundType)
},
methods: {
// 切换退款类型
changeType(value) {
// 退全款带入订单总金额
if (value == 1) this.infoForm.refundAmount = this.detail?.totalPrice
else this.infoForm.refundAmount = ''
},
// 退款金额输入框
refoundAmountInput(newValue) {
if (newValue < 0 || !this.reg.priceReg.test(newValue)) {
newValue = ''
}
var oldValue = newValue
this.$set(this.infoForm, 'refundAmount', limitPrice(newValue, oldValue, 15, 2))
},
handleAddConfirm() {
this.$refs.refundForm.validate(valid => {
if (valid) {
var infoForm = deepClone(this.infoForm)
var params = {}
params.refundRemark = infoForm.remark
params.orderCode = this.detail.orderCode
if (this.isPartialRefund) { // 精品升级
params.refundType = infoForm.refundType
params.refundAmount = infoForm.refundAmount
} else { // 会员权益 默认退全款
params.refundType = 1
params.refundAmount = this.detail.totalPrice
}
markAsRefunded(params).then(res => {
this.notice.okTips('操作成功')
this.handleClose(true)
})
}
})
},
handleClose(flag) {
this.$emit('dialogClose', flag)
}
}
}
</script>
<style scoped>
.accountDailog .el-dialog {
margin-top: 20vh !important;
min-width: 700px;
}
.accountDailog .el-select-dropdown__item {
width: 395px !important;
}
</style>