This commit is contained in:
魏啾 2024-11-01 13:35:57 +08:00
commit 281a4d200a
9 changed files with 483 additions and 188 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;">{{
@ -130,14 +135,18 @@
{{ scope.row.priceAmount }}
</template>
</el-table-column>
<!-- <el-table-column label="操作">
<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-column>
</el-table>
</div>
<!-- </el-tab-pane> -->
@ -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,
@ -280,6 +307,7 @@ export default {
num:e.num
}]
});
this.$message.success("退款成功");
this.update();
},
update(){
@ -288,9 +316,10 @@ 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("退菜成功");
this.update();
},
tuikuan(item){
@ -345,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

@ -146,9 +146,12 @@
{{ scope.row.createdAt | timeFilter }}
</template>
</el-table-column>
<el-table-column label="操作" width="100">
<el-table-column label="操作">
<template v-slot="scope">
<el-button type="text" @click="$refs.orderDetail.show(scope.row)">详情</el-button>
<div class="u-flex gap-10">
<el-button type="text" @click="$refs.orderDetail.show(scope.row)">详情</el-button>
<el-button v-if="scope.row.status == 'unpaid'" type="primary" size="mini" @click="payOrder(scope.row)">结账</el-button>
</div>
</template>
</el-table-column>
</el-table>
@ -158,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>
@ -247,6 +250,21 @@ export default {
},
methods: {
//
payOrder(order){
console.log(order);
this.$router.push({
path: "/tool/Instead/index",
query: {
table_name: order.tableName,
tableId: order.tableId,
useType: order.useType,
masterId: order.masterId,
orderId: order.id,
key:'isJieZhang'
},
});
},
//
async payCount() {
try {

View File

@ -76,7 +76,7 @@
}"
>
<span v-if="isSeatFee"> {{ item.totalAmount }}</span>
<span v-else> {{ item.totalAmount }}</span>
<span v-else> {{ (item.salePrice*item.number+(item.packAmount||0)).toFixed(2) }}</span>
</div>
</div>
</div>

View File

@ -154,7 +154,7 @@ export default {
}
if (curretnMoney > money) {
this.$message.error("实收金额不能大于总金额");
this.form.curretnMoney = 0;
this.form.curretnMoney = form.money;
}
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount =toFixedNoRounding( ((this.form.curretnMoney / money) * 100).toFixed(3) );

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

@ -46,11 +46,12 @@
trigger="click"
v-model="tableShow"
>
<el-input
<el-input
placeholder="请输入内容"
prefix-icon="el-icon-search"
v-model="tableSearchText"
@input="searchInput">
@input="searchInput"
>
</el-input>
<div style="max-height: 398px; overflow-y: scroll" class="u-m-t-12">
<div
@ -233,7 +234,9 @@
<div class="u-flex">
<div class="u-p-r-14 border-r u-m-r-14">
<template v-if="!shopInfo.isTableFee">
<template
v-if="!shopInfo.isTableFee && key != 'isJieZhang'"
>
<div
class="u-flex cur-pointer"
@click="
@ -404,7 +407,11 @@
<div class="flex mt-14">
<template v-if="table">
<template v-if="!postPay">
<template v-if="isCreateOrder">
<template
v-if="
postPay && isCreateOrder && table && table.tableId
"
>
<!-- <template v-if="false"> -->
<button
class="my-btn flex-1 default"
@ -414,26 +421,28 @@
</button>
</template>
<template v-else>
<button
class="my-btn flex-1 primary"
@click="scanPayClick"
>
<span>微信/支付宝</span>
</button>
<div style="width: 15px"></div>
<button
class="my-btn flex-1 primary"
@click="cashPayClick"
>
<span>现金</span>
</button>
<div style="width: 15px"></div>
<button
class="my-btn flex-1 default"
@click="morePayClick"
>
<span>更多支付</span>
</button>
<template v-if="key != 'isJieZhang'">
<button
class="my-btn flex-1 primary"
@click="scanPayClick"
>
<span>微信/支付宝</span>
</button>
<div style="width: 15px"></div>
<button
class="my-btn flex-1 primary"
@click="cashPayClick"
>
<span>现金</span>
</button>
<div style="width: 15px"></div>
<button
class="my-btn flex-1 default"
@click="morePayClick"
>
<span>更多支付</span>
</button>
</template>
</template>
</template>
<template v-else>
@ -590,7 +599,7 @@
</div> -->
<div
class="btn"
:class="{ disabled: order.selIndex < 0 }"
:class="{ disabled: order.selIndex < 0 && key != 'isJieZhang' }"
@click="refNoteShow(true)"
>
单品备注
@ -1254,6 +1263,7 @@ import moneyKeyboard from "./components/money-keyboard.vue";
import dayjs from "dayjs";
import { tbShopInfo } from "@/api/user";
import { hasPermission } from "@/utils/limits.js";
import { tbOrderInfoDetail } from "@/api/order";
import {
getGoodsLists,
@ -1283,12 +1293,15 @@ import {
isCanBuy,
arrayContainsAll,
generateCombinations,
returnReverseVal,$strMatch,
returnReverseVal,
$strMatch,
returnGiftArr,
returnPackFee,
formatOrderGoodsList,
} from "./util.js";
import { $status } from "@/utils/table.js";
let $originTableList=[]
let $originTableList = [];
export default {
components: {
returnCart,
@ -1305,7 +1318,7 @@ export default {
data() {
return {
//
tableSearchText:"",
tableSearchText: "",
//
canShoukuan: false,
//
@ -1512,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
@ -1605,12 +1619,17 @@ export default {
.reduce((a, b) => {
return a + b.number * b.salePrice;
}, 0);
return (
oldPrice +
price +
+this.order.packFee.totalAmount +
const nowPackFee = returnPackFee(this.order.list, false);
const oldackFee = returnPackFee(this.order.old.list);
const packFee = nowPackFee + oldackFee;
const returnStatus = ["return", "refunding", "refund"];
const seatFee =
this.order.seatFee.totalAmount *
(this.order.seatFee.status == "return" ? 0 : 1)
(returnStatus.includes(this.order.seatFee.status) ? 0 : 1);
return (
(oldPrice + price + +packFee + seatFee) *
this.createOrder.discount
).toFixed(2);
},
allNumber() {
@ -1687,8 +1706,22 @@ export default {
// })
}
},
table(oldval, newval) {
this.onTableChange();
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 = "";
this.onTableChange();
}
},
masterId: function (val) {
console.log(val);
@ -1699,15 +1732,15 @@ export default {
}
},
"vipUser.id": async function (val) {
if (!this.table.tableId) {
return;
}
let masterId = this.order.masterId;
if (!masterId) {
const res = await this.getMasterId();
masterId = res.masterId;
}
this.masterId = masterId;
// if (!this.table.tableId) {
// return;
// }
// let masterId = this.order.masterId;
// if (!masterId) {
// const res = await this.getMasterId();
// masterId = res.masterId;
// }
// this.masterId = masterId;
$setUser({
tableId: this.table.tableId,
masterId: this.masterId,
@ -1826,13 +1859,15 @@ export default {
// this.getCategory();
// this.refToggle('refScanCode',true)
// this.refToggle("refDiscount", true);
console.log(this.$route.query.tableId);
this.open(this.$route.query.tableId ? this.$route.query : "");
// this.open(this.$route.query.tableId ? this.$route.query : "");
this.open(this.$route.query);
},
methods: {
searchInput(e){
console.log(e)
this.tableList=$originTableList.filter(v=>$strMatch(v.name,e.trim()))
searchInput(e) {
console.log(e);
this.tableList = $originTableList.filter((v) =>
$strMatch(v.name, e.trim())
);
},
returnTableColor(key) {
const item = $status[key];
@ -1861,7 +1896,7 @@ export default {
this.order.extra.selIndex = index;
},
async morePayClick() {
if (this.order.list.length <= 0) {
if (!this.createOrder.data.id && this.order.list.length <= 0) {
return this.$message("请选择菜品");
}
const canJiesuan = await this.shoukuanClick();
@ -1871,13 +1906,14 @@ export default {
// if(this.isCreateOrder){
// return
// }
const res = await this.returnCreateOrderData();
await this.returnCreateOrderData();
this.payBeforeClear();
this.createOrder.data = res;
this.order.payType = "";
this.isCreateOrder = true;
// this.order.payType = "";
},
async cashPayClick() {
if (!this.createOrder.data.id && this.order.list.length <= 0) {
return this.$message("没有要结算的订单或商品!");
}
const canJiesuan = await this.shoukuanClick();
if (!canJiesuan) {
return;
@ -1892,6 +1928,13 @@ export default {
});
},
async returnCreateOrderData() {
if (this.key == "isJieZhang" || this.order.list.length <= 0) {
//
// this.order.old.list = formatOrderGoodsList(this.createOrder.data.detailList||[]);
this.isCreateOrder = true;
return this.createOrder.data;
}
this.order.list = [];
const res = await $createOrder({
masterId: this.order.masterId || this.masterId,
vipUserId: this.vipUser.id,
@ -1900,6 +1943,9 @@ export default {
postPay: this.postPay,
orderld: this.order.orderId,
});
this.isCreateOrder = true;
this.order.old.list = formatOrderGoodsList(res.detailList || []);
this.getOrderData({ orderId: res.id });
this.createOrder.data = res;
this.createOrder.discount = 1;
// const lastItem = this.order.old.list[this.order.old.list.length - 1];
@ -1908,27 +1954,21 @@ export default {
// ...this.order.old.list,
// { info: this.order.list, placeNum: nowPlaceNum + 1 },
// ];
this.order.list = [];
this.order.old.list = [];
console.log(this.order.old.list);
return res;
},
async payBeforeClear() {
this.getMasterId().then((res) => {
this.masterId = res.masterId;
});
this.loading = false;
this.order.list = [];
this.order.query.page = 1;
this.goods.total = 0;
this.order.list = [];
this.order.selIndex = -1;
this.order.selPlaceNum = -1;
this.order.selGoods = "";
this.order.seatFee = { totalAmount: 0 }; //
this.prveOrder.list = [];
this.prveOrder.selIndex = -1;
this.order.old.selIndex = -1;
this.isCreateOrder = false;
// this.isCreateOrder = false;
this.createOrder.status = "";
this.createOrder.code = "";
this.note.content = "";
@ -1942,7 +1982,6 @@ export default {
this.key = "";
this.order.orderId = "";
this.perpole = "";
// this.useTypes.sel = "dine-in";
},
async cachePay() {
const canJiesuan = await this.shoukuanClick();
@ -1954,12 +1993,14 @@ export default {
this.pays();
},
async scanPayClick() {
if (!this.createOrder.data.id && this.order.list.length <= 0) {
return this.$message("没有要结算的订单或商品!");
}
const canJiesuan = await this.shoukuanClick();
if (!canJiesuan) {
return;
}
const order = await this.returnCreateOrderData();
console.log(this.createOrder.data);
this.order.payType = "scanCode";
this.payTypeItemClick({ payType: "scanCode", order });
this.payBeforeClear();
@ -1999,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() {
@ -2028,11 +2071,21 @@ export default {
tableId: this.table.tableId,
num: this.perpole,
});
this.order.seatFee = res;
this.order.seatFee = res
this.perpole = res.totalNumber || res.number;
return res;
},
//
async onTableChange() {
const perpole=this.perpole || ''
const tableRes = await $returnTableDetail({
tableId: this.table.tableId,
});
console.log(tableRes);
const orderId=tableRes.orderId ||this.table.orderId
if (orderId) {
this.getOrderData({ orderId:orderId });
}
const res = await this.getMasterId();
this.masterId = res.masterId;
//1
@ -2041,7 +2094,6 @@ export default {
this.table.status == "idle" &&
!this.shopInfo.isTableFee
) {
this.perpole = 1;
await this.changePerpole();
}
//
@ -2053,23 +2105,19 @@ export default {
? item.useType
: item.useType.replace(/-after|-before/g, "");
}
this.getCart();
if (!orderId) {
this.getCart();
}
this.getCacheOrder();
console.log(this.isCreateOrder);
this.perpole=perpole||this.perpole
if (!this.shopInfo.isTableFee && this.table.tableId && this.perpole > 0) {
//
const seatFee = await $choseCount({
masterId: this.masterId,
tableId: this.table.tableId,
num: res.seatFee ? res.seatFee.totalNumber : this.perpole,
});
console.log(seatFee);
this.order.seatFee = seatFee;
this.perpole = seatFee.totalNumber;
}
if (this.isCreateOrder) {
this.toCreateOrder(true);
await this.changePerpole();
}
// if (this.isCreateOrder) {
// this.toCreateOrder(true);
// }
},
//
async getTableDetail() {
@ -2099,15 +2147,17 @@ export default {
},
//退
async refReturnCartConfirm(e) {
console.log(this.order.selGoods);
const res = await $returnCart({
...e,
cartId: this.order.selGoods.id,
cartId: this.order.selGoods.cartId,
tableId: this.table.tableId,
});
this.order.selGoods.status = "return";
this.order.old.selIndex = -1;
this.getCart();
console.log(this.order.selGoods);
// this.getCart();
this.getOrderData();
// console.log(this.order.selGoods);
},
//
@ -2120,16 +2170,16 @@ export default {
this.tableList = content.filter(
(v) => v.status != "closed" && v.status != "cleaning"
);
$originTableList=this.tableList
$originTableList = this.tableList;
} catch (error) {
console.log(error);
}
},
async changeTable(item) {
console.log(this.table);
if (this.table || this.order.list.length <= 0) {
this.table = item;
this.tableShow = false;
console.log(this.table);
return;
}
if (item.status != "idle") {
@ -2229,9 +2279,7 @@ export default {
//
isSellOut(item) {
return (
item.isPauseSale ||
(item.typeEnum !== "sku" &&
(item.isStock == 1 ? item.stockNumber <= 0 : false))
item.isPauseSale || (item.isStock == 1 ? item.stockNumber <= 0 : false)
);
},
toggleFullScreen() {
@ -2414,18 +2462,10 @@ export default {
this.toCreateOrder(isNowPay);
},
async toCreateOrder(isNowPay = false) {
console.log(this.order);
console.log(this.order.orderId);
let res = "";
try {
if (!this.shopInfo.isTableFee) {
const seatFee = await $choseCount({
masterId: this.masterId,
tableId: this.table.tableId,
num: this.perpole,
});
this.order.seatFee = seatFee;
this.order.seatFee = res;
await this.changePerpole();
}
res = await $createOrder({
masterId: this.order.masterId || this.masterId,
@ -2435,17 +2475,16 @@ export default {
postPay: this.postPay,
orderld: this.order.orderId,
});
this.getOrderData({ orderId: res.id });
} catch (error) {}
if (!res) {
this.createOrder.status = "success";
return;
}
//
console.log(this.postPay);
console.log(isNowPay);
console.log(this.postPay && isNowPay);
this.createOrder.status = "success";
this.getCart();
this.order.list=[];
// this.getCart();
if (this.postPay && !isNowPay) {
this.$notify({
title: "下单成功",
@ -2453,7 +2492,6 @@ export default {
});
return this.close();
}
this.createOrder.data = res;
if (!this.isPrverOrder) {
const { masterId } = await this.getMasterId();
this.masterId = masterId;
@ -2481,7 +2519,7 @@ export default {
//
updateOrder(par = {}) {
let item = this.order.list[this.order.selIndex];
console.log(item.specSnap);
console.log(this.table);
const { productId, skuId, isPack, isGift, number, id } = item;
$updateCart({
cartId: id,
@ -2547,7 +2585,9 @@ export default {
//
orderBtnsClick(key) {
const orderGoods = this.order.list[this.order.selIndex];
this.createOrderClose();
if (this.key != "isJieZhang" && this.postPay) {
this.createOrderClose();
}
if (key === "sku") {
this.selGoods.title = orderGoods.name;
this.selGoods.isEdit = true;
@ -2721,8 +2761,7 @@ export default {
this.$nextTick(() => {
this.getCacheOrder();
});
const masterIdRes = await this.getMasterId();
this.masterId = masterIdRes.masterId;
await this.getMasterId();
},
//
removeCart() {
@ -2949,6 +2988,7 @@ export default {
}
} else {
//
console.log(this.table)
res = await addCart({
masterId: this.masterId,
vipUserId: this.vipUser.id,
@ -3095,7 +3135,17 @@ export default {
//
setCart(res) {
console.log(res);
this.order.seatFee = res.seatFee ? res.seatFee : this.order.seatFee;
const { seatFee } = res;
this.order.seatFee = seatFee
? {
...seatFee,
totalNumber: seatFee.num||seatFee.number,
num: seatFee.number,
name: seatFee.name|| seatFee.productName,
totalAmount: seatFee.priceAmount || seatFee.totalAmount,
}
: this.order.seatFee;
console.log(this.order.seatFee);
this.perpole = res.seatFee ? res.seatFee.totalNumber : 1;
const nowCart = res.records.find((v) => v.placeNum == 0);
// this.order.list = nowCart ? nowCart.info.filter(v=>v.isGift!=='true') : [];
@ -3277,6 +3327,19 @@ export default {
this.$goodsData = goods;
},
async open(params) {
const item = {
name: params.table_name,
tableId: params.tableId,
useType: params.useType,
maxCapacity: params.maxCapacity * 1,
masterId: params.masterId,
orderId: params.orderId,
},
key = params.key,
perpoleNumber = params.num || "";
this.key = key;
this.perpole = perpoleNumber;
const shopId = localStorage.getItem("shopId");
const shopInfo = await tbShopInfo(shopId);
for (let i in shopInfo.eatModel) {
@ -3290,28 +3353,47 @@ export default {
}
}
this.shopInfo = shopInfo;
this.setPostPay();
if (!params.masterId) {
await this.getMasterId();
this.getCart();
} else {
this.masterId = params.masterId;
}
if (key == "isJieZhang") {
this.postPay = false;
} else {
this.setPostPay();
}
this.setUseType();
this.getGoods();
this.getCategory();
this.getTable();
console.log(params);
const res = await this.getMasterId();
console.log(res);
if (!params) {
//
if (key == "isJieZhang") {
this.table = params.tableId ? { name: item.name } : "";
if (params.orderId) {
const orderRes = await this.getOrderData(params);
if (orderRes.status != "unpaid") {
this.$router.replace({ path: "/tool/Instead/index" });
}
}
this.isCreateOrder = true;
return;
}
const item = {
name: params.table_name,
tableId: params.tableId,
useType: params.useType,
maxCapacity: params.maxCapacity * 1,
masterId: params.masterId,
orderId: params.orderId,
},
key = params.key,
perpoleNumber = params.num;
if( key == "isPayOrder" ){
this.isCreateOrder =true
}
if(params.orderId) {
const orderRes = await this.getOrderData(params);
}
// this.getCart();
// this.getCacheOrder();
// if (!params) {
// //
// return;
// }
//
if (item && item.useType) {
localStorage.setItem("useType", item.useType);
@ -3320,17 +3402,71 @@ export default {
? item.useType
: item.useType.replace(/-after|-before/g, "");
}
this.key = key;
this.isCreateOrder = this.key == "isPayOrder" ? true : false;
this.perpole = perpoleNumber;
this.table = item;
this.masterId = item.masterId;
this.table = params.tableId ? item : "";
},
async getOrderData(params) {
const res = await tbOrderInfoDetail(
params ? params.orderId : this.createOrder.data.id
);
if (res.status != "unpaid") {
return res;
}
this.createOrder.data = res;
this.order.packFee.totalAmount = res.seatInfo || { totalAmount: 0 };
const goodsMap = {};
for (let i in res.detailList) {
const goods = res.detailList[i];
if (goods.productId != "-999") {
if (goodsMap.hasOwnProperty(goods.placeNum)) {
goodsMap[goods.placeNum].push(goods);
} else {
goodsMap[goods.placeNum] = [goods];
}
}
}
this.order.seatFee = res.seatInfo
? {
...res.seatInfo,
totalNumber: res.seatInfo.num,
number: res.seatInfo.num,
name: res.seatInfo.productName,
totalAmount: res.seatInfo.priceAmount,
}
: {
name: "客座费",
number: res.seatCount || 0,
totalNumber: res.seatCount || 0,
totalAmount: res.seatAmount || 0,
status: "",
};
this.order.old.list = Object.entries(goodsMap).map(([key, value]) => ({
info: value.map((v) => {
return {
...v,
coverImg: v.productImg,
name: v.productName,
specSnap: v.productSkuName,
number: v.num,
totalAmount: v.priceAmount,
salePrice: v.price,
isGift: v.gift ? "true" : "false",
isPack: v.pack ? "true" : "false",
};
}),
placeNum: key,
}));
console.log(this.order.old.list);
return res;
},
close() {
this.reset();
if (this.table.tableId) {
this.$router.replace({ path: "/tool/table_list" });
} else {
this.$router.go(0);
this.$router.replace({ path: "/tool/Instead/index" });
// this.$router.go(0);
// this.reset();
// this.$router.replace({ path: "/tool/Instead/index" });
}

View File

@ -1,16 +1,34 @@
//计算打包费
export function returnPackFee(arr, isOld = true) {
if (isOld) {
return arr.reduce((a, b) => {
const bTotal = b.info
.filter((v) => v.isGift !== "true" && v.status !== "return")
.reduce((prve, cur) => {
return prve + (cur.packFee || cur.packAmount||0);
}, 0);
return a + bTotal;
}, 0);
} else {
return arr.filter(v => v.status !== 'return' && v.isGift !== 'true').reduce((a, b) => {
return a + (b.packFee || b.packAmount||0);
}, 0);
}
}
//判断商品是否可以下单
export function isCanBuy(skuGoods,goods) {
if(goods.typeEnum=='normal'){
export function isCanBuy(skuGoods, goods) {
if (goods.typeEnum == 'normal') {
//单规格
return goods.isGrounding&&goods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
}else{
return goods.isGrounding && goods.isPauseSale == 0 && (goods.isStock ? goods.stockNumber > 0 : true);
} else {
//多规格
return goods.isGrounding&&goods.isPauseSale==0&&skuGoods.isGrounding&&skuGoods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
return goods.isGrounding && goods.isPauseSale == 0 && skuGoods.isGrounding && skuGoods.isPauseSale == 0 && (goods.isStock ? goods.stockNumber > 0 : true);
}
}
//字符匹配
export function $strMatch(matchStr,str){
export function $strMatch(matchStr, str) {
return matchStr.toLowerCase().includes(str.toLowerCase())
}
@ -59,15 +77,41 @@ export function returnReverseVal(val, isReturnString = true) {
return reverseNewval;
}
export function returnGiftArr(arr){
let result=[]
for(let i=0;i<arr.length;i++){
const info=arr[i].info
for(let j=0;j<info.length;j++){
if(info[j].isGift==='true'){
export function returnGiftArr(arr) {
let result = []
for (let i = 0; i < arr.length; i++) {
const info = arr[i].info
for (let j = 0; j < info.length; j++) {
if (info[j].isGift === 'true') {
result.push(info[j])
}
}
}
return result
}
export function formatOrderGoodsList(arr){
const goodsMap = {}
for (let i in arr) {
const goods = arr[i]
if (goods.productName != '客座费') {
if (goodsMap.hasOwnProperty(goods.placeNum)) {
goodsMap[goods.placeNum||1].push(goods)
} else {
goodsMap[goods.placeNum||1] = [goods]
}
}
}
return Object.entries(goodsMap).map(([key, value]) => ({
info: value,
placeNum: key||1
}))
}
export function returnIsSeatFee(item){
if(!item){
return false
}
return item.productId=="-999"
}