代客下单部分逻辑处理优化,订单管理退款退菜结账跳转功能问题处理

This commit is contained in:
YeMingfei666 2024-11-01 11:16:12 +08:00
parent 924f296ad1
commit 8c99f49700
7 changed files with 162 additions and 52 deletions

View File

@ -1,5 +1,5 @@
<template>
<el-drawer title="订单详情" size="50%" :visible.sync="drawer" direction="rtl" v-loading="loading">
<el-drawer title="订单详情" size="50%" :visible.sync="drawer" direction="rtl" v-loading="loading" >
<div class="header">
<div class="title" style="text-align: center;">收银订单</div>
<div class="container">
@ -105,7 +105,12 @@
<el-table-column label="商品">
<template v-slot="scope">
<div class="shop_info">
<el-image :src="scope.row.productImg" style="width: 40px;height: 40px;"></el-image>
<el-image v-if="scope.row.productSkuId!='-999'" :src="scope.row.productImg" style="width: 40px;height: 40px;"></el-image>
<div class="packeFee" v-else>
<span>
{{ scope.row.productName ||'客座费'}}
</span>
</div>
<div class="info">
<span :class="[scope.row.isVip == 1 ? 'colorStyle' : '']">{{ scope.row.productName }}</span>
<span style="color: #999;">{{
@ -132,10 +137,14 @@
</el-table-column>
<el-table-column label="操作">
<template v-slot="scope">
<template v-if="scope.row.status!='refund'">
<el-button v-if="detail.status=='closed'||detail.status=='refund'" type="text" size="mini" @click="tuikuan(scope.row)"><span >退款</span></el-button>
<template v-if="scope.row.status!='unpaid'">
<el-button v-if="canTuikuan(scope.row)" type="text" size="mini" @click="tuikuan(scope.row)"><span >退款</span></el-button>
<span class="color-999" v-else>已退款</span>
</template>
<template v-if="scope.row.status=='unpaid'">
<el-button v-if="canTuicai(scope.row)" type="text" size="mini" @click="tuiCai(scope.row)"><span >已退菜</span></el-button>
<span class="color-999" v-else>已退</span>
</template>
<el-button v-if="detail.status=='unpaid'" type="text" size="mini" @click="tuiCai(scope.row)"><span >退菜</span></el-button>
</template>
</el-table-column>
</el-table>
@ -226,6 +235,7 @@ import returnMoney from "@/views/tool/Instead/components/return-money.vue";
import {
$returnCart,$returnOrder
} from "@/api/table";
import * as $util from '../order_goods_util.js'
export default {
components: { returnCart,returnMoney },
@ -270,7 +280,24 @@ export default {
}
}
},
watch:{
drawer:function(newval){
if(!newval){
this.close();
}
}
},
methods: {
close(){
console.log('drawer close')
this.$emit('close');
},
canTuikuan(item){
return $util.canTuiKuan(this.detail,item);
},
canTuicai(item){
return $util.canTuicai(this.detail,item);
},
async refReturnMoneyConfirm(e){
const res = await $returnOrder({
...e,
@ -289,7 +316,7 @@ export default {
async refReturnCartConfirm(e){
const res = await $returnCart({
...e,
cartId: this.selGoods.id,
cartId: this.selGoods.cartId,
tableId: this.detail.tableId,
});
this.$message.success("退菜成功");
@ -347,6 +374,18 @@ export default {
</script>
<style scoped lang="scss">
.packeFee{
width: 40px;
box-sizing: border-box;
height: 40px;
background: #3f9eff;
color: #fff;
font-size: 12px;
display: flex;
justify-content: center;
align-items: center;
white-space: nowrap;
}
.shop_info {
display: flex;

View File

@ -0,0 +1,27 @@
export function canComputedPackFee(v) {
return v.pack && v.status != 'return' && v.status != 'refund' && v.status != 'refunding'
}
export function returnCanComputedGoodsArr(arr) {
return arr.filter(v=>canComputedPackFee(v))
}
export function returnPackFee(arr) {
return arr.reduce((prve, cur) => {
return prve + cur.packAmount
}, 0).toFixed(2)
}
export function canTuicai(orderInfo,item){
return orderInfo.status=='unpaid'&&orderInfo.useType!='dine-in-before'&& item.status!='return'
}
export function canTuiKuan(orderInfo,item){
return orderInfo.status!='unpaid'&& item.status!='return'&&item.status!='refund'&&item.status!='refunding'
}
export function isTui(item){
return item.status=='return'||item.status=='refund'||item.status=='refunding'
}
export function numSum(arr){
const sum=arr.reduce((a,b)=>{
return a+b*100
},0)
return (sum/100).toFixed(2)
}

View File

@ -161,7 +161,7 @@
@current-change="paginationChange" @size-change="sizeChange"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
<orderDetail ref="orderDetail" />
<orderDetail ref="orderDetail" @close="getTableData" />
</div>
</template>

View File

@ -96,6 +96,8 @@ export default {
<style lang="scss" scoped>
::v-deep .number-box .el-input__inner {
border: none;
padding: 0 2px;
text-align: center;
}
.icon-add {
color: #1890ff;

View File

@ -1,19 +1,32 @@
<template>
<el-dialog title="退菜" width="410px" :visible.sync="show" @close="reset" :modal="modal">
<div class="flex u-row-between u-p-b-20 border-bottom">
<span>退菜数量</span>
<div class="u-flex">
<number-box v-model="number" :min="1" :max="max"></number-box>
<el-dialog
title="退菜"
width="410px"
:visible.sync="show"
@close="reset"
:modal="modal"
>
<div class="u-p-b-16 border-bottom">
<div class="flex u-row-between">
<span>退菜数量</span>
<div class="u-flex" v-if="!isSeatFee">
<number-box v-model="number" :min="1" :max="max"></number-box>
</div>
<div class="u-flex" v-else>
{{ number }}
</div>
</div>
<div class="u-font-12 color-999 u-m-t-8" v-if="isSeatFee">
<div><span class="color-red">*</span><span>客座费只能全退</span> </div>
</div>
</div>
<div class="u-m-t-10 u-font-12 color-999">
菜品已点数量 {{max}}
</div>
<div class="u-m-t-10 u-font-12 color-999">菜品已点数量 {{ max }} </div>
<div class="u-m-t-26">
<div><span>退菜原因</span> <span class="color-red">*</span></div>
</div>
<div class="u-flex u-flex-wrap tags ">
<div class="u-flex u-flex-wrap tags">
<div
class="tag"
v-for="(tag, index) in tags"
@ -41,28 +54,23 @@
</el-dialog>
</template>
<script>
import numberBox from './number-box.vue';
import numberBox from "./number-box.vue";
import {returnIsSeatFee} from '../util.js'
export default {
components:{numberBox},
props:{
modal:{
type:Boolean,
default:true
components: { numberBox },
props: {
modal: {
type: Boolean,
default: true,
},
goods:{
type:Object,
default:()=>{
return{}
}
max: {
type: Number,
default: 1,
},
max:{
type:Number,
default:1
}
},
data() {
return {
number:1,
number: 1,
isPrint: false,
tagSel: -1,
show: false,
@ -72,17 +80,27 @@ export default {
{ label: "等待时间过长", checked: false },
],
note: "",
goods:{
productId: -999
}
};
},
computed:{
isSeatFee(){
return returnIsSeatFee(this.goods)
}
},
methods: {
changeSel(item) {
item.checked = !item.checked;
},
reset() {
this.note = "";
this.number=1;
console.log(this.number)
this.number = 1;
this.tags.map(v=>{
v.checked = false;
})
console.log(this.number);
},
delTag(index) {
this.tags.splice(index, 1);
@ -93,22 +111,30 @@ export default {
}
this.note = tag + "," + this.note;
},
open(note) {
open(item) {
this.goods = item?item:this.goods;
this.show = true;
this.number=1;
if (item != "-999") {
this.number = 1;
} else {
this.number = item.num;
}
},
close() {
this.show = false;
this.number=1;
this.number = 1;
},
confirm() {
const selTag=this.tags.filter(item=>item.checked).map(item=>item.label).join(",")
const note=selTag+(this.note.length>0?","+this.note:"");
console.log(note)
if(!note){
const selTag = this.tags
.filter((item) => item.checked)
.map((item) => item.label)
.join(",");
const note = selTag + (this.note.length > 0 ? "," + this.note : "");
console.log(note);
if (!note) {
return this.$message.error("请输入退菜原因");
}
this.$emit("confirm", {note:note,num:this.number});
this.$emit("confirm", { note: note, num: this.number });
this.close();
},
},
@ -120,6 +146,7 @@ export default {
::v-deep .el-dialog__body {
margin-bottom: 14px;
margin-top: 14px;
padding: 0 20px;
}
::v-deep .el-tag {
margin-top: 10px;

View File

@ -1525,7 +1525,8 @@ export default {
);
},
title() {
return this.table ? "代客下单" + `(${this.table.name})` : "代客下单";
// return this.table ? "" + `(${this.table.name})` : "";
return '代客下单'
},
allGiftMoney() {
const nowprice = this.order.list
@ -1623,11 +1624,9 @@ export default {
const oldackFee = returnPackFee(this.order.old.list);
const packFee = nowPackFee + oldackFee;
const returnStatus = ["return", "refunding", "refund"];
console.log(this.order.seatFee);
const seatFee =
this.order.seatFee.totalAmount *
(returnStatus.includes(this.order.seatFee.status) ? 0 : 1);
console.log(nowPackFee, oldackFee, packFee, seatFee);
return (
(oldPrice + price + +packFee + seatFee) *
this.createOrder.discount
@ -1708,9 +1707,16 @@ export default {
}
},
table(newval, oldval) {
this.setPostPay();
this.setUseType();
if(oldval.tableId&&newval.tableId){
this.perpole = 1;
this.isCreateOrder = false;
}
if(this.key=='isJieZhang'){
this.isCreateOrder = false;
this.key=''
}
if (newval && newval.tableId) {
this.createOrder.data.amount = 0;
this.createOrder.data.id = "";
@ -2034,6 +2040,8 @@ export default {
//munchies restaurant
this.postPay = this.shopInfo.registerType == "munchies" ? false : true;
}
console.log('this.postPay')
console.log(this.postPay)
},
//
async getShopInfo() {
@ -2069,6 +2077,7 @@ export default {
},
//
async onTableChange() {
const perpole=this.perpole || ''
const tableRes = await $returnTableDetail({
tableId: this.table.tableId,
});
@ -2085,7 +2094,6 @@ export default {
this.table.status == "idle" &&
!this.shopInfo.isTableFee
) {
this.perpole = 1;
await this.changePerpole();
}
//
@ -2102,6 +2110,7 @@ export default {
}
this.getCacheOrder();
console.log(this.isCreateOrder);
this.perpole=perpole||this.perpole
if (!this.shopInfo.isTableFee && this.table.tableId && this.perpole > 0) {
//
await this.changePerpole();
@ -3130,9 +3139,9 @@ export default {
this.order.seatFee = seatFee
? {
...seatFee,
totalNumber: seatFee.num,
number: seatFee.num,
name: seatFee.productName,
totalNumber: seatFee.num||seatFee.number,
num: seatFee.number,
name: seatFee.name|| seatFee.productName,
totalAmount: seatFee.priceAmount || seatFee.totalAmount,
}
: this.order.seatFee;
@ -3329,6 +3338,7 @@ export default {
key = params.key,
perpoleNumber = params.num || "";
this.key = key;
this.perpole = perpoleNumber;
const shopId = localStorage.getItem("shopId");
const shopInfo = await tbShopInfo(shopId);
@ -3361,7 +3371,6 @@ export default {
console.log(params);
if (key == "isJieZhang") {
this.perpole = perpoleNumber;
this.table = params.tableId ? { name: item.name } : "";
if (params.orderId) {
const orderRes = await this.getOrderData(params);
@ -3395,7 +3404,6 @@ export default {
}
this.perpole = perpoleNumber;
this.table = params.tableId ? item : "";
},
async getOrderData(params) {

View File

@ -107,4 +107,11 @@ export function formatOrderGoodsList(arr){
info: value,
placeNum: key||1
}))
}
export function returnIsSeatFee(item){
if(!item){
return false
}
return item.productId=="-999"
}