feat: 代客下单修改,订单列表详情退款修改

This commit is contained in:
2025-03-05 13:39:06 +08:00
parent a7b7c1cd7e
commit ed9a3335c8
8 changed files with 195 additions and 100 deletions

View File

@@ -1,19 +1,22 @@
<template>
<div>
<el-drawer title="订单详情" size="60%" v-model="drawer" direction="rtl" v-loading="loading">
<div v-loading="loading">
<el-drawer title="订单详情" size="60%" v-model="drawer" direction="rtl" @close="reset">
<div class="header">
<div class="title" style="text-align: center">收银订单</div>
<div class="container">
<div class="container" v-if="user">
<div class="info_content">
<div class="item">
<div class="label">会员信息</div>
<div class="row">
<div>会员昵称-</div>
<div>联系电话-</div>
<div>会员昵称-{{ user.nickName || "" }}</div>
<div>联系电话-{{ user.phone || "" }}</div>
</div>
</div>
</div>
</div>
<div v-else>
<h3>服务员下单</h3>
</div>
<div class="table">
<div class="item">
<div class="t">订单状态</div>
@@ -73,7 +76,7 @@
<div class="row">
<div>打包费{{ detail.packFee || "-" }}</div>
<div>订单原价{{ detail.originAmount }}</div>
<div>优惠金额{{ youHuiJinE }}</div>
<div>优惠金额{{ detail.discountAmount }}</div>
<div>
实收金额
<span style="color: red">{{ detail.payAmount }}</span>
@@ -98,7 +101,13 @@
<div style="margin-bottom: 16px; font-size: 16px">商品信息</div>
<template v-for="(item, index) in detail.detailMap" :key="index">
<h4>{{ index }}次下单</h4>
<el-table :data="item">
<el-table
:data="item"
:ref="'refTable' + index"
@selection-change="selectionChange"
@row-click="rowClick($event, index)"
>
<el-table-column type="selection" width="55" />
<el-table-column label="商品">
<template v-slot="scope">
<div class="shop_info">
@@ -125,18 +134,21 @@
<template v-slot="scope">x{{ scope.row.num }}</template>
</el-table-column>
<el-table-column label="单价">
<template v-slot="scope">{{ scope.row.price }}</template>
<template v-slot="scope">{{ scope.row.unitPrice }}</template>
</el-table-column>
<el-table-column label="小计">
<template v-slot="scope">{{ scope.row.payAmount }}</template>
</el-table-column>
<el-table-column label="实付">
<template v-slot="scope">{{ scope.row.payAmount }}</template>
</el-table-column>
<el-table-column label="操作">
<template v-slot="scope">
<template v-if="detail.status != 'unpaid'">
<el-button
v-if="canTuikuan(scope.row)"
link
size="mini"
size="small"
@click="tuikuan(scope.row)"
>
<span>退款</span>
@@ -147,7 +159,7 @@
<el-button
v-if="canTuicai(scope.row)"
type="text"
size="mini"
size="small"
@click="tuiCai(scope.row)"
>
<span>退菜</span>
@@ -158,6 +170,14 @@
</el-table-column>
</el-table>
</template>
<div class="u-p-20 u-flex u-row-right">
<el-checkbox
v-model="allSelected"
@change="allSelectedChange"
label="全选"
></el-checkbox>
<el-button type="danger" class="u-m-l-20" @click.stop="tuikuan('all')">退款</el-button>
</div>
</div>
</div>
</el-drawer>
@@ -177,6 +197,7 @@ import { ElMessage } from "element-plus";
import { returnOptionsLabel } from "../config/config";
import * as $util from "../order_goods_util.js";
import orderApi from "@/api/order/order";
import shopUserApi from "@/api/account/shopUser";
import orderEnum from "./orderEnum";
import dayjs from "dayjs";
export default {
@@ -185,6 +206,8 @@ export default {
},
data() {
return {
allSelected: false,
user: "",
orderEnum,
drawer: false,
type: "1",
@@ -230,6 +253,26 @@ export default {
},
},
methods: {
rowClick(row, index) {
this.$refs["refTable" + index][0].toggleRowSelection(row);
},
selectionChange(e) {
console.log(e);
},
allSelectedChange(newval) {
for (let i in this.detail.detailMap) {
this.detail.detailMap[i].forEach((item) => {
if (newval) {
this.$refs["refTable" + i][0].toggleRowSelection(item, true);
} else {
this.$refs["refTable" + i][0].toggleRowSelection(item, false);
}
});
}
},
reset() {
this.user = "";
},
returnPayType(payType) {
if (!payType) {
return "";
@@ -304,9 +347,19 @@ export default {
this.update();
},
tuikuan(item) {
let arr = [];
if (item === "all") {
for (let i in this.detail.detailMap) {
arr.push(...this.$refs["refTable" + i][0].getSelectionRows());
}
} else {
arr = [item];
}
if (arr.length == 0) {
return ElMessage.error("请选择要退款的商品");
}
this.selGoods = item;
console.log(item);
this.$refs.refReturnMoney.open({ ...item, priceAmount: item.canReturnAmount });
this.$refs.refReturnMoney.open(arr, this.detail);
},
tuiCai(item) {
this.selGoods = item;
@@ -337,7 +390,13 @@ export default {
async tbOrderInfoDetail(id) {
try {
this.loading = true;
const res = await orderApi.getHistoryList({ orderId: id });
const res = await orderApi.get({ orderId: id });
if (res.userId) {
shopUserApi.get({ userId: res.userId }).then((res1) => {
this.user = res1;
});
}
this.detail = res;
this.loading = false;
} catch (error) {