2025-03-29 18:07:17 +08:00
|
|
|
|
<template>
|
2025-05-06 22:17:32 +08:00
|
|
|
|
<el-dialog
|
2025-05-20 17:17:21 +08:00
|
|
|
|
title="押金退款"
|
2025-05-06 22:17:32 +08:00
|
|
|
|
:visible.sync="dialogVisible"
|
|
|
|
|
width="500px"
|
|
|
|
|
append-to-body
|
2025-03-29 18:07:17 +08:00
|
|
|
|
@open="handleOpen"
|
2025-05-06 22:17:32 +08:00
|
|
|
|
>
|
2025-03-29 18:07:17 +08:00
|
|
|
|
<el-form :model="form" :rules="rules" ref="form" label-width="6em" v-loading="loading" size="small">
|
|
|
|
|
<el-form-item label="退款金额" prop="amount">
|
2025-05-20 17:17:21 +08:00
|
|
|
|
<el-input-number v-model="form.amount" :max="canRefundAmount" :min="0" :placeholder="`请输入退款金额,最多可退款 ${canRefundAmount} 元`" :precision="2" style="width: 100%;" />
|
|
|
|
|
<div>当前最多可退款:{{canRefundAmount | fix2 | dv}} 元</div>
|
2025-03-29 18:07:17 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="退款原因" prop="reason">
|
|
|
|
|
<el-input v-model="form.reason" type="textarea" placeholder="请输入退款原因" show-word-limit maxlength="200" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
2025-05-20 17:17:21 +08:00
|
|
|
|
<el-button type="primary" @click="handleSubmit" :loading="submitLoading" icon="el-icon-wallet">确认退款</el-button>
|
|
|
|
|
<el-button @click="dialogVisible = false" icon="el-icon-close">取消</el-button>
|
2025-03-29 18:07:17 +08:00
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-05-06 18:42:44 +08:00
|
|
|
|
import { getOrder, refundOrder } from '@/api/bst/order';
|
2025-03-29 18:07:17 +08:00
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
id: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
visible: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
detail: {},
|
|
|
|
|
form: {},
|
|
|
|
|
loading: false,
|
2025-04-16 17:49:20 +08:00
|
|
|
|
submitLoading: false,
|
2025-03-29 18:07:17 +08:00
|
|
|
|
rules: {
|
|
|
|
|
amount: [
|
|
|
|
|
{ required: true, message: '请输入退款金额', trigger: 'blur' },
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
dialogVisible: {
|
|
|
|
|
get() {
|
|
|
|
|
return this.visible;
|
|
|
|
|
},
|
|
|
|
|
set(val) {
|
|
|
|
|
this.$emit('update:visible', val);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 可退款金额
|
|
|
|
|
canRefundAmount() {
|
2025-05-20 17:17:21 +08:00
|
|
|
|
if (this.detail == null || this.detail.id == null) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return this.detail.payedAmount - this.detail.payRefunded - this.detail.payRefunding;
|
2025-03-29 18:07:17 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
getDetail() {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
getOrder(this.id).then(response => {
|
|
|
|
|
this.detail = response.data;
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
handleOpen() {
|
|
|
|
|
this.getDetail();
|
|
|
|
|
this.reset();
|
|
|
|
|
},
|
|
|
|
|
reset() {
|
|
|
|
|
this.form = {
|
|
|
|
|
orderId: this.id,
|
2025-05-20 17:17:21 +08:00
|
|
|
|
amount: null,
|
2025-03-29 18:07:17 +08:00
|
|
|
|
reason: null,
|
|
|
|
|
};
|
|
|
|
|
this.resetForm('form');
|
|
|
|
|
},
|
|
|
|
|
handleSubmit() {
|
|
|
|
|
this.$refs.form.validate().then(() => {
|
2025-04-16 17:49:20 +08:00
|
|
|
|
this.submitLoading = true;
|
2025-03-29 18:07:17 +08:00
|
|
|
|
refundOrder(this.form).then((response) => {
|
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
this.$message.success('退款成功');
|
|
|
|
|
this.dialogVisible = false;
|
|
|
|
|
this.$emit('success');
|
|
|
|
|
}
|
|
|
|
|
}).finally(() => {
|
2025-04-16 17:49:20 +08:00
|
|
|
|
this.submitLoading = false;
|
2025-03-29 18:07:17 +08:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
2025-05-06 22:17:32 +08:00
|
|
|
|
</style>
|