优化订单退款

This commit is contained in:
gyq
2025-03-12 09:55:07 +08:00
parent 1e66b2ad1f
commit 48c9f24d4c
17 changed files with 191 additions and 16211 deletions

View File

@@ -29,11 +29,11 @@
<template #prepend></template>
</el-input>
<template v-else>
退款金额{{ formatDecimal(refundType == 1 ? item.originAmount : amount) }}
退款金额{{ formatDecimal(refundType == 1 ? item.originAmount - item.refundAmount : amount) }}
</template>
</div>
</div>
<el-table ref="tableRef" :data="item.goods" brder stripe @selection-change="tabSelectChange">
<el-table ref="tableRef" :data="item.onGoods" brder stripe @selection-change="tabSelectChange">
<el-table-column type="selection" width="35" :selectable="selectable"></el-table-column>
<el-table-column label="商品信息">
<template v-slot="scope">
@@ -57,12 +57,45 @@
</el-table-column>
<el-table-column label="退款数量" width="170">
<template v-slot="scope">
<el-input-number v-model="scope.row.refundNum" :min="1" :max="+scope.row.num"
<el-input-number v-model="scope.row.refund_number" :min="1" :max="scope.row.num"
style="width: 130px;" @change="numberChange">
</el-input-number>
</template>
</el-table-column>
</el-table>
<template v-if="item.returnGoods.length">
<div class="tips" style="margin-top: 20px;padding-bottom: 10px;">以下为已退部分退单/退菜</div>
<el-table :data="item.returnGoods" brder stripe>
<el-table-column label="商品信息">
<template v-slot="scope">
<div class="goods_info">
<el-image :src="scope.row.productImg" style="width: 50px;height: 50px;"></el-image>
<div class="info">
<div class="name">
<span>{{ scope.row.productName }}</span>
</div>
<div class="sku" v-if="scope.row.skuName">{{ scope.row.skuName }}</div>
<div class="sku">{{ formatDecimal(+scope.row.payAmount) }}</div>
</div>
</div>
</template>
</el-table-column>
<el-table-column label="订单数量" prop="num" width="100"></el-table-column>
<el-table-column label="支付金额" width="100">
<template v-slot="scope">
{{ formatDecimal(+scope.row.payAmount) }}
</template>
</el-table-column>
<el-table-column label="已退款数量" width="170">
<template v-slot="scope">
<div class="column">
<div class="row">退单数量{{ scope.row.refundNum }}</div>
<div class="row">退菜数量{{ scope.row.returnNum }}</div>
</div>
</template>
</el-table-column>
</el-table>
</template>
<div class="ipt">
<el-input type="textarea" v-model="remark" placeholder="请输入退单原因" />
</div>
@@ -153,9 +186,9 @@ async function refundHandle(cash = false) {
if (refundType.value != 1) {
refundDetails = tableRef.value.getSelectionRows().map(val => {
return {
id: item.value.id,
id: val.id,
returnAmount: val.payAmount,
num: val.refundNum
num: val.refund_number
}
})
}
@@ -209,7 +242,7 @@ function numberChange() {
function tabSelectChange(val) {
amount.value = 0
val.map(item => {
amount.value += item.refundNum * item.payAmount
amount.value += item.refund_number * item.payAmount
})
}
@@ -230,10 +263,29 @@ function resetDrawer() {
function show(row) {
isShow.value = true
item.value = { ...row }
let onGoods = []
let returnGoods = []
item.value.goods.map(item => {
item.refundNum = item.num
// 可退的最大数量,下单数量 - 已退数量 - 退菜数量
let refundMaxNum = item.num - item.refundNum - item.returnNum
if (refundMaxNum <= 0) {
// 已经退过,不在允许操作
returnGoods.push(item)
} else {
// 可以操作的退款数量
item.refund_number = item.num
onGoods.push(item)
}
})
item.value.onGoods = onGoods
item.value.returnGoods = returnGoods
console.log('item.value===', item.value);
resetDrawer()
setTimeout(() => {