fix: 订单管理页面增加退菜功能,修复代客下单清空后无法正常添加商品
This commit is contained in:
@@ -110,7 +110,18 @@
|
||||
<!-- <el-table-column type="selection" width="55" /> -->
|
||||
<el-table-column label="数量" type="selection">
|
||||
<template v-slot="scope">
|
||||
<el-checkbox v-model="scope.row.checked" />
|
||||
<div v-if="detail.status == 'unpaid'">
|
||||
<el-checkbox
|
||||
v-if="scope.row.num - scope.row.returnNum > 0"
|
||||
v-model="scope.row.checked"
|
||||
/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-checkbox
|
||||
v-if="scope.row.num - scope.row.refundNum > 0"
|
||||
v-model="scope.row.checked"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品">
|
||||
@@ -141,20 +152,35 @@
|
||||
<el-table-column label="实付">
|
||||
<template v-slot="scope">¥{{ scope.row.payAmount }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="可退款数量" align="center">
|
||||
|
||||
<el-table-column v-if="detail.status == 'unpaid'" label="可退菜数量" align="center">
|
||||
<template v-slot="scope">
|
||||
<el-input-number
|
||||
v-if="scope.row.checked"
|
||||
:min="0"
|
||||
style="width: 120px"
|
||||
v-model="scope.row.selNumber"
|
||||
:max="scope.row.num - scope.row.returnNum"
|
||||
></el-input-number>
|
||||
<span class="" v-else>{{ scope.row.num - scope.row.returnNum }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-else label="可退款数量" align="center">
|
||||
<template v-slot="scope">
|
||||
<el-input-number
|
||||
v-if="scope.row.checked"
|
||||
:min="0"
|
||||
style="width: 120px"
|
||||
v-model="scope.row.selNumber"
|
||||
:max="scope.row.num - scope.row.refundNum"
|
||||
></el-input-number>
|
||||
<span class="" v-else>0</span>
|
||||
<span class="" v-else>{{ scope.row.num - scope.row.refundNum }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="已退" width="100" align="center">
|
||||
<template v-slot="scope">
|
||||
<span>{{ scope.row.refundNum }}</span>
|
||||
<span v-if="detail.status == 'unpaid'">{{ scope.row.returnNum }}</span>
|
||||
<span v-else>{{ scope.row.refundNum }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作">
|
||||
@@ -173,18 +199,19 @@
|
||||
<template v-if="detail.status == 'unpaid'">
|
||||
<el-button
|
||||
v-if="canTuicai(scope.row)"
|
||||
type="text"
|
||||
link
|
||||
size="small"
|
||||
@click="tuiCai(scope.row)"
|
||||
@click="tuicai(scope.row)"
|
||||
>
|
||||
<span>退菜</span>
|
||||
</el-button>
|
||||
<span class="color-999" v-if="scope.row == 'return'">已退菜</span>
|
||||
<span class="color-999" v-else>已退菜</span>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
<!-- 退款 -->
|
||||
<div
|
||||
class="u-p-20 u-flex u-row-right"
|
||||
v-if="detail.status !== 'refund' && detail.status !== 'unpaid'"
|
||||
@@ -196,9 +223,19 @@
|
||||
></el-checkbox>
|
||||
<el-button type="danger" class="u-m-l-20" @click.stop="tuikuan('all')">退款</el-button>
|
||||
</div>
|
||||
<!-- 退菜 -->
|
||||
<div class="u-p-20 u-flex u-row-right" v-if="detail.status == 'unpaid'">
|
||||
<el-checkbox
|
||||
v-model="allSelected"
|
||||
@change="allSelectedChange"
|
||||
label="全选"
|
||||
></el-checkbox>
|
||||
<el-button type="danger" class="u-m-l-20" @click.stop="tuicai('all')">退菜</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
<!-- 退款 -->
|
||||
<return-money
|
||||
:modal="false"
|
||||
ref="refReturnMoney"
|
||||
@@ -206,11 +243,14 @@
|
||||
:goods="selGoods"
|
||||
@confirm="refReturnMoneyConfirm"
|
||||
></return-money>
|
||||
<!-- 退菜 -->
|
||||
<return-cart ref="refReturnCart" @confirm="refReturnCartConfirm"></return-cart>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import returnMoney from "./return-money.vue";
|
||||
import returnCart from "./return-cart.vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { returnOptionsLabel } from "../config/config";
|
||||
import * as $util from "../order_goods_util.js";
|
||||
@@ -221,6 +261,7 @@ import dayjs from "dayjs";
|
||||
export default {
|
||||
components: {
|
||||
returnMoney,
|
||||
returnCart,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -366,10 +407,9 @@ export default {
|
||||
this.tbOrderInfoDetail(this.detail.id);
|
||||
},
|
||||
async refReturnCartConfirm(e) {
|
||||
const res = await $returnCart({
|
||||
const res = await orderApi.refundOrder({
|
||||
...e,
|
||||
cartId: this.selGoods.cartId,
|
||||
tableId: this.detail.tableId,
|
||||
orderId: this.detail.id,
|
||||
});
|
||||
ElMessage.success("退菜成功");
|
||||
this.update();
|
||||
@@ -393,10 +433,24 @@ export default {
|
||||
this.selGoods = item;
|
||||
this.$refs.refReturnMoney.open(arr, this.detail);
|
||||
},
|
||||
tuiCai(item) {
|
||||
this.selGoods = item;
|
||||
console.log(item);
|
||||
this.$refs.refReturnCart.open(item);
|
||||
tuicai(item) {
|
||||
let arr = [];
|
||||
if (item === "all") {
|
||||
for (let i in this.detail.detailMap) {
|
||||
this.detail.detailMap[i].map((v) => {
|
||||
if (v.checked && v.selNumber) {
|
||||
arr.push(v);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
arr = [item];
|
||||
}
|
||||
if (arr.length == 0) {
|
||||
return ElMessage.error("请选择要退菜的商品和数量");
|
||||
}
|
||||
console.log(arr);
|
||||
this.$refs.refReturnCart.open(arr, this.detail);
|
||||
},
|
||||
|
||||
// 获取订单详情
|
||||
@@ -411,10 +465,11 @@ export default {
|
||||
}
|
||||
for (let i in res.detailMap) {
|
||||
res.detailMap[i] = res.detailMap[i].map((v) => {
|
||||
console.log(v.num - (res.status == "unpaid" ? v.returnNum : v.refundNum));
|
||||
return {
|
||||
...v,
|
||||
checked: false,
|
||||
selNumber: v.num - v.returnNum,
|
||||
selNumber: v.num - (res.status == "unpaid" ? v.returnNum : v.refundNum),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user