|
@@ -3,21 +3,21 @@
|
|
|
<div class="refund-container">
|
|
<div class="refund-container">
|
|
|
<div class="section-title">选择要退款的商品及数量</div>
|
|
<div class="section-title">选择要退款的商品及数量</div>
|
|
|
|
|
|
|
|
- <el-table ref="tableRef" :data="order?.products || []"
|
|
|
|
|
|
|
+ <el-table ref="tableRef" :data="order?.detailList || []"
|
|
|
style="width: 100%; border: 1px solid #ebeef5; border-bottom: none;"
|
|
style="width: 100%; border: 1px solid #ebeef5; border-bottom: none;"
|
|
|
@selection-change="handleSelectionChange" header-row-class-name="custom-header">
|
|
@selection-change="handleSelectionChange" header-row-class-name="custom-header">
|
|
|
<el-table-column type="selection" width="55" />
|
|
<el-table-column type="selection" width="55" />
|
|
|
<el-table-column label="商品信息">
|
|
<el-table-column label="商品信息">
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
|
<div class="product-info">
|
|
<div class="product-info">
|
|
|
- <el-image :src="row.image" class="product-img" fit="cover" />
|
|
|
|
|
- <span class="product-title">{{ row.title }}</span>
|
|
|
|
|
|
|
+ <el-image :src="row.cover" class="product-img" fit="cover" />
|
|
|
|
|
+ <span class="product-title">{{ row.bookName }} {{ row.isbn }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="数量" width="150">
|
|
<el-table-column label="数量" width="150">
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
|
- <el-input-number v-model="row.refundQty" :min="1" :max="row.qty" size="small"
|
|
|
|
|
|
|
+ <el-input-number v-model="row.refundQty" :min="1" :max="row.num" size="small"
|
|
|
controls-position="right" style="width: 100px;" />
|
|
controls-position="right" style="width: 100px;" />
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
@@ -55,7 +55,7 @@
|
|
|
|
|
|
|
|
<template #footer>
|
|
<template #footer>
|
|
|
<el-button @click="visible = false">取消</el-button>
|
|
<el-button @click="visible = false">取消</el-button>
|
|
|
- <el-button type="primary" @click="handleSubmit">确定并退款</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" @click="handleSubmit" :loading="loading">确定并退款</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</ele-modal>
|
|
</ele-modal>
|
|
|
</template>
|
|
</template>
|
|
@@ -63,6 +63,7 @@
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import { ref, reactive, computed, watch } from 'vue';
|
|
import { ref, reactive, computed, watch } from 'vue';
|
|
|
import { EleMessage } from 'ele-admin-plus/es';
|
|
import { EleMessage } from 'ele-admin-plus/es';
|
|
|
|
|
+ import request from '@/utils/request';
|
|
|
|
|
|
|
|
const visible = defineModel({ type: Boolean });
|
|
const visible = defineModel({ type: Boolean });
|
|
|
const order = ref(null);
|
|
const order = ref(null);
|
|
@@ -70,18 +71,22 @@
|
|
|
const shippingRefund = ref(0);
|
|
const shippingRefund = ref(0);
|
|
|
const sendCoupon = ref(true);
|
|
const sendCoupon = ref(true);
|
|
|
const maxShippingFee = ref(5);
|
|
const maxShippingFee = ref(5);
|
|
|
|
|
+ const loading = ref(false);
|
|
|
|
|
+
|
|
|
|
|
+ const emit = defineEmits(['success']);
|
|
|
|
|
|
|
|
const handleOpen = (row) => {
|
|
const handleOpen = (row) => {
|
|
|
// Deep copy to avoid mutating original list directly until save
|
|
// Deep copy to avoid mutating original list directly until save
|
|
|
if (row) {
|
|
if (row) {
|
|
|
order.value = JSON.parse(JSON.stringify(row));
|
|
order.value = JSON.parse(JSON.stringify(row));
|
|
|
// Initialize refundQty for each product
|
|
// Initialize refundQty for each product
|
|
|
- if (order.value.products) {
|
|
|
|
|
- order.value.products.forEach(p => {
|
|
|
|
|
- p.refundQty = p.qty; // Default to max qty
|
|
|
|
|
|
|
+ if (order.value.detailList) {
|
|
|
|
|
+ order.value.detailList.forEach(p => {
|
|
|
|
|
+ p.refundQty = p.num; // Default to max qty
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- shippingRefund.value = 0;
|
|
|
|
|
|
|
+ shippingRefund.value = order.value.expressMoney || 0;
|
|
|
|
|
+ maxShippingFee.value = order.value.expressMoney || 0;
|
|
|
sendCoupon.value = true;
|
|
sendCoupon.value = true;
|
|
|
selectedRows.value = [];
|
|
selectedRows.value = [];
|
|
|
}
|
|
}
|
|
@@ -111,7 +116,7 @@
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const originalTotal = computed(() => {
|
|
const originalTotal = computed(() => {
|
|
|
- return order.value?.payment?.total || 0;
|
|
|
|
|
|
|
+ return parseFloat(order.value?.payMoney) || 0;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const newTotal = computed(() => {
|
|
const newTotal = computed(() => {
|
|
@@ -131,8 +136,32 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- EleMessage.success('退款申请已提交');
|
|
|
|
|
- visible.value = false;
|
|
|
|
|
|
|
+ loading.value = true;
|
|
|
|
|
+ const detailList = selectedRows.value.map(item => ({
|
|
|
|
|
+ isbn: item.isbn,
|
|
|
|
|
+ conditionType: item.conditionType,
|
|
|
|
|
+ num: item.refundQty
|
|
|
|
|
+ }));
|
|
|
|
|
+
|
|
|
|
|
+ request.post('/shop/shopOrder/refundOutOfStock', {
|
|
|
|
|
+ orderId: order.value.orderId,
|
|
|
|
|
+ refundExpressMoney: shipping,
|
|
|
|
|
+ sendCoupon: sendCoupon.value ? 1 : 0,
|
|
|
|
|
+ detailList: detailList
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ if (res.data.code === 200) {
|
|
|
|
|
+ EleMessage.success('退款申请已提交');
|
|
|
|
|
+ visible.value = false;
|
|
|
|
|
+ emit('success');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ EleMessage.error(res.data.msg || '提交失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(e => {
|
|
|
|
|
+ console.error(e);
|
|
|
|
|
+ EleMessage.error('网络错误');
|
|
|
|
|
+ }).finally(() => {
|
|
|
|
|
+ loading.value = false;
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
defineExpose({
|
|
defineExpose({
|