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> <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="header">
<div class="title" style="text-align: center;">收银订单</div> <div class="title" style="text-align: center;">收银订单</div>
<div class="container"> <div class="container">
@ -105,7 +105,12 @@
<el-table-column label="商品"> <el-table-column label="商品">
<template v-slot="scope"> <template v-slot="scope">
<div class="shop_info"> <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"> <div class="info">
<span :class="[scope.row.isVip == 1 ? 'colorStyle' : '']">{{ scope.row.productName }}</span> <span :class="[scope.row.isVip == 1 ? 'colorStyle' : '']">{{ scope.row.productName }}</span>
<span style="color: #999;">{{ <span style="color: #999;">{{
@ -130,14 +135,18 @@
{{ scope.row.priceAmount }} {{ scope.row.priceAmount }}
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column label="操作"> <el-table-column label="操作">
<template v-slot="scope"> <template v-slot="scope">
<template v-if="scope.row.status!='refund'"> <template v-if="scope.row.status!='unpaid'">
<el-button v-if="detail.status=='closed'||detail.status=='refund'" type="text" size="mini" @click="tuikuan(scope.row)"><span >退款</span></el-button> <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> </template>
<el-button v-if="detail.status=='unpaid'" type="text" size="mini" @click="tuiCai(scope.row)"><span >退菜</span></el-button>
</template> </template>
</el-table-column> --> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- </el-tab-pane> --> <!-- </el-tab-pane> -->
@ -226,6 +235,7 @@ import returnMoney from "@/views/tool/Instead/components/return-money.vue";
import { import {
$returnCart,$returnOrder $returnCart,$returnOrder
} from "@/api/table"; } from "@/api/table";
import * as $util from '../order_goods_util.js'
export default { export default {
components: { returnCart,returnMoney }, components: { returnCart,returnMoney },
@ -270,7 +280,24 @@ export default {
} }
} }
}, },
watch:{
drawer:function(newval){
if(!newval){
this.close();
}
}
},
methods: { 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){ async refReturnMoneyConfirm(e){
const res = await $returnOrder({ const res = await $returnOrder({
...e, ...e,
@ -280,6 +307,7 @@ export default {
num:e.num num:e.num
}] }]
}); });
this.$message.success("退款成功");
this.update(); this.update();
}, },
update(){ update(){
@ -288,9 +316,10 @@ export default {
async refReturnCartConfirm(e){ async refReturnCartConfirm(e){
const res = await $returnCart({ const res = await $returnCart({
...e, ...e,
cartId: this.selGoods.id, cartId: this.selGoods.cartId,
tableId: this.detail.tableId, tableId: this.detail.tableId,
}); });
this.$message.success("退菜成功");
this.update(); this.update();
}, },
tuikuan(item){ tuikuan(item){
@ -345,6 +374,18 @@ export default {
</script> </script>
<style scoped lang="scss"> <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 { .shop_info {
display: flex; 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 }} {{ scope.row.createdAt | timeFilter }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="100"> <el-table-column label="操作">
<template v-slot="scope"> <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> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -158,7 +161,7 @@
@current-change="paginationChange" @size-change="sizeChange" @current-change="paginationChange" @size-change="sizeChange"
layout="total, sizes, prev, pager, next, jumper"></el-pagination> layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div> </div>
<orderDetail ref="orderDetail" /> <orderDetail ref="orderDetail" @close="getTableData" />
</div> </div>
</template> </template>
@ -247,6 +250,21 @@ export default {
}, },
methods: { 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() { async payCount() {
try { try {

View File

@ -76,7 +76,7 @@
}" }"
> >
<span v-if="isSeatFee"> {{ item.totalAmount }}</span> <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> </div>
</div> </div>

View File

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

View File

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

View File

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

View File

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