electripper-v2-ui/src/views/bst/order/components/OrderRefundDialog.vue

170 lines
4.9 KiB
Vue
Raw Normal View History

2025-03-29 18:07:17 +08:00
<template>
2025-05-06 22:17:32 +08:00
<el-dialog
2025-05-21 18:17:23 +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">
2025-05-23 14:07:37 +08:00
<el-row>
<form-col :span="24" label="骑行退款" prop="ridingRefund" :tip="`最多可退 ${detail.actualReceivedRidingFee || 0} 元`">
<el-input-number
v-model="form.ridingRefund"
:max="detail.actualReceivedRidingFee || 0"
:min="0"
:precision="2"
style="width: 100%;"
controls-position="right"
/>
</form-col>
<form-col :span="24" label="调度退款" prop="dispatchRefund" :tip="`最多可退 ${detail.actualReceivedDispatchFee || 0} 元`">
<el-input-number
v-model="form.dispatchRefund"
:min="0"
:max="detail.actualReceivedDispatchFee || 0"
:precision="2"
style="width: 100%;"
controls-position="right"
/>
</form-col>
<form-col :span="24" label="管理退款" prop="manageRefund" :tip="`最多可退 ${detail.actualReceivedManageFee || 0} 元`">
<el-input-number
v-model="form.manageRefund"
:min="0"
:max="detail.actualReceivedManageFee || 0"
:precision="2"
style="width: 100%;"
controls-position="right"
/>
</form-col>
<form-col :span="24" label="车损退款" prop="deductionRefund" :tip="`最多可退 ${detail.actualReceivedDeductionFee || 0} 元`">
<el-input-number
v-model="form.deductionRefund"
:min="0"
:max="detail.actualReceivedDeductionFee || 0"
:precision="2"
style="width: 100%;"
controls-position="right"
/>
</form-col>
<form-col :span="24" label="总计退款">
{{ totalRefundAmount | fix2 | dv }}
</form-col>
<form-col :span="24" label="退款原因" prop="reason">
<el-input v-model="form.reason" type="textarea" placeholder="请输入退款原因" show-word-limit maxlength="200" />
</form-col>
</el-row>
2025-03-29 18:07:17 +08:00
</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-05-23 14:07:37 +08:00
import { isEmpty } from '@/utils';
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: {
2025-05-23 14:07:37 +08:00
ridingRefund: [
{ required: true, message: '请输入骑行费退款金额', trigger: 'blur' },
2025-03-29 18:07:17 +08:00
],
2025-05-23 14:07:37 +08:00
dispatchRefund: [
{ required: true, message: '请输入调度费退款金额', trigger: 'blur' },
],
manageRefund: [
{ required: true, message: '请输入管理费退款金额', trigger: 'blur' },
],
deductionRefund: [
{ required: true, message: '请输入车损费退款金额', trigger: 'blur' },
2025-05-21 18:17:23 +08:00
],
2025-03-29 18:07:17 +08:00
}
}
},
computed: {
dialogVisible: {
get() {
return this.visible;
},
set(val) {
this.$emit('update:visible', val);
}
},
2025-05-23 14:07:37 +08:00
totalRefundAmount() {
return this.dv(this.form.ridingRefund)
+ this.dv(this.form.dispatchRefund)
+ this.dv(this.form.manageRefund)
+ this.dv(this.form.deductionRefund);
2025-03-29 18:07:17 +08:00
}
},
methods: {
2025-05-23 14:07:37 +08:00
dv(val) {
if (isEmpty(val)) {
return 0;
}
return val;
2025-05-21 18:17:23 +08:00
},
2025-03-29 18:07:17 +08:00
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-23 14:07:37 +08:00
ridingRefund: null,
dispatchRefund: null,
manageRefund: null,
deductionRefund: 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>