增加就餐人数限制处理

This commit is contained in:
2024-10-30 14:54:23 +08:00
parent 1f099e2174
commit b6d79c9319

View File

@@ -40,7 +40,7 @@
</view> </view>
</view> </view>
</view> </view>
<!-- <view class="u-p-b-24 u-m-b-24 border-bottom"> <!-- <view class="u-p-b-24 u-m-b-24 border-bottom">
<view>就餐类型</view> <view>就餐类型</view>
<view class="u-m-t-24 u-flex "> <view class="u-m-t-24 u-flex ">
@@ -116,7 +116,7 @@
<view class="u-p-b-24 "> <view class="u-p-b-24 ">
<view class="font-bold">订单备注</view> <view class="font-bold">订单备注</view>
<view class="u-m-t-32 u-flex "> <view class="u-m-t-32 u-flex ">
<uni-easyinput type="textarea" v-model="note" placeholder="请输入备注"></uni-easyinput> <uni-easyinput type="textarea" v-model="note" placeholder="请输入备注"></uni-easyinput>
</view> </view>
</view> </view>
@@ -183,7 +183,7 @@
<button class="tag" hover-class="hover-class" <button class="tag" hover-class="hover-class"
@tap="toggleGoodsItemKey(item,index,'isGift')">{{item.isGift?'取消赠送':'赠送'}}</button> @tap="toggleGoodsItemKey(item,index,'isGift')">{{item.isGift?'取消赠送':'赠送'}}</button>
</view> </view>
<view class="u-flex u-m-r-20 " > <view class="u-flex u-m-r-20 ">
<button class="tag" hover-class="hover-class" <button class="tag" hover-class="hover-class"
@tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button> @tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button>
</view> </view>
@@ -201,24 +201,24 @@
</view> </view>
<view class="border-bottom"> <view class="border-bottom">
<template v-if="$seatFee&&$seatFee.totalAmount"> <template v-if="$seatFee&&$seatFee.totalAmount">
<view class="u-flex u-row-between u-m-t-18 u-p-b-34 "> <view class="u-flex u-row-between u-m-t-18 u-p-b-34 ">
<view> <view>
<text >桌位费</text> <text>桌位费</text>
</view> </view>
<view>{{$seatFee.totalAmount||'0.00'}}</view> <view>{{$seatFee.totalAmount||'0.00'}}</view>
</view> </view>
</template> </template>
<template v-if="$packFee>0"> <template v-if="$packFee>0">
<view class="u-flex u-row-between u-m-t-18 u-p-b-34 "> <view class="u-flex u-row-between u-m-t-18 u-p-b-34 ">
<view> <view>
<text >打包费</text> <text>打包费</text>
</view> </view>
<view>{{$packFee||'0.00'}}</view> <view>{{$packFee||'0.00'}}</view>
</view> </view>
</template> </template>
</view> </view>
<view class="u-flex u-row-right u-m-t-38"> <view class="u-flex u-row-right u-m-t-38">
<!-- <template v-if="$shop.registerType=='munchies'"> <!-- <template v-if="$shop.registerType=='munchies'">
@@ -273,7 +273,9 @@
computed, computed,
watch watch
} from 'vue'; } from 'vue';
import {getSafeBottomHeight} from '@/commons/utils/safe-bottom.js' import {
getSafeBottomHeight
} from '@/commons/utils/safe-bottom.js'
import modelDiscount from './components/discount' import modelDiscount from './components/discount'
import giveFood from './components/give-food' import giveFood from './components/give-food'
import oneRemark from './components/remark' import oneRemark from './components/remark'
@@ -291,7 +293,9 @@
import { import {
getNowCart getNowCart
} from '@/pagesCreateOrder/util.js' } from '@/pagesCreateOrder/util.js'
import {hasPermission} from '@/commons/utils/hasPermission.js' import {
hasPermission
} from '@/commons/utils/hasPermission.js'
const models = new Map(); const models = new Map();
const modelData = reactive({ const modelData = reactive({
data: {}, data: {},
@@ -311,7 +315,7 @@
modelData.selIndex = index modelData.selIndex = index
const model = models.get(key) const model = models.get(key)
model && model.open({ model && model.open({
remark: modelData.data.note||'' remark: modelData.data.note || ''
}) })
} }
@@ -325,7 +329,7 @@
const userNumbers = reactive({ const userNumbers = reactive({
list: new Array(100).fill(1).map((v, index) => { list: new Array(100).fill(1).map((v, index) => {
// return index === 0 ? '无' : index + '人' // return index === 0 ? '无' : index + '人'
return (index+1)+ '人' return (index + 1) + '人'
}), }),
defaultCateIndex: 0, defaultCateIndex: 0,
}) })
@@ -336,15 +340,23 @@
//更新就餐人数 //更新就餐人数
async function updateChoseCount() { async function updateChoseCount() {
console.log($shop.value); console.log($shop.value);
if (!$shop.value.isTableFee&& table.value.tableId) { const maxCapacity = table.value.tableId ? (table.value.maxCapacity || 0) : 100
if (table.value.tableId && userNumbers.defaultCateIndex * 1 + 1 > maxCapacity) {
uni.showToast({
title: '当前台桌最大人数为: ' + maxCapacity
})
userNumbers.defaultCateIndex=maxCapacity-1
return
}
if (!$shop.value.isTableFee && table.value.tableId) {
//不免餐位费 //不免餐位费
const res = await Api.$choseCount({ const res = await Api.$choseCount({
masterId: option.masterId, masterId: option.masterId,
tableId: table.value.tableId||'', tableId: table.value.tableId || '',
num: userNumbers.defaultCateIndex+1, num: userNumbers.defaultCateIndex * 1 + 1,
}) })
Object.assign($seatFee, res) Object.assign($seatFee, res)
userNumbers.defaultCateIndex = res.totalNumber-1 userNumbers.defaultCateIndex = res.totalNumber - 1
} }
} }
@@ -362,14 +374,15 @@
skuId, skuId,
id, id,
number, number,
isPack,isGift isPack,
isGift
} = item } = item
const par = { const par = {
cartId:id, cartId: id,
isPack, isPack,
isGift, isGift,
masterId: option.masterId, masterId: option.masterId,
tableId: table.value.tableId||'', tableId: table.value.tableId || '',
productId, productId,
num: number, num: number,
skuId skuId
@@ -377,7 +390,7 @@
par[key] = !item[key] par[key] = !item[key]
const res = await Api.$updateCart(par) const res = await Api.$updateCart(par)
goods.list[index][key] = returnBoolean(res[key]) goods.list[index][key] = returnBoolean(res[key])
if(key=='isPack'){ if (key == 'isPack') {
getCart() getCart()
} }
} }
@@ -400,11 +413,11 @@
], ],
active: 'dine-in' active: 'dine-in'
}) })
const $packFee=computed(()=>{ const $packFee = computed(() => {
return goods.list.reduce((prve,cur)=>{ return goods.list.reduce((prve, cur) => {
return prve+cur.packFee return prve + cur.packFee
},0).toFixed(2) }, 0).toFixed(2)
}) })
function chooseUser() { function chooseUser() {
@@ -427,7 +440,7 @@
console.log(option); console.log(option);
const submitPar = { const submitPar = {
masterId: option.masterId, masterId: option.masterId,
tableId: table.value.tableId||"", tableId: table.value.tableId || "",
vipUserId: user.value.id ? user.value.id : '', vipUserId: user.value.id ? user.value.id : '',
type: user.value.id ? 0 : 1 //0 设置 1 取消 type: user.value.id ? 0 : 1 //0 设置 1 取消
} }
@@ -481,16 +494,16 @@
}) })
const goodsPrice = computed(() => { const goodsPrice = computed(() => {
const goodsTotalPrice = goods.list.reduce((prve, cur) => { const goodsTotalPrice = goods.list.reduce((prve, cur) => {
const tPrice=cur.salePrice * cur.number const tPrice = cur.salePrice * cur.number
console.log(cur.isPack); console.log(cur.isPack);
const tpackFee=cur.isPack? cur.packFee*1:0 const tpackFee = cur.isPack ? cur.packFee * 1 : 0
return prve +(cur.isGift?0:tPrice) +tpackFee return prve + (cur.isGift ? 0 : tPrice) + tpackFee
}, 0) }, 0)
return (goodsTotalPrice|| 0).toFixed(2) return (goodsTotalPrice || 0).toFixed(2)
}) })
const allPrice = computed(() => { const allPrice = computed(() => {
console.log(goodsPrice.value); console.log(goodsPrice.value);
const n=goodsPrice.value*1 + $seatFee.totalAmount const n = goodsPrice.value * 1 + $seatFee.totalAmount
return n.toFixed(2) return n.toFixed(2)
// const goodsTotalPrice = goods.list.reduce((prve, cur) => { // const goodsTotalPrice = goods.list.reduce((prve, cur) => {
// return prve + cur.salePrice * cur.number * (cur.isGift ? 0 : 1) // return prve + cur.salePrice * cur.number * (cur.isGift ? 0 : 1)
@@ -510,7 +523,7 @@
page: 0, page: 0,
size: 300, size: 300,
masterId: option.masterId, masterId: option.masterId,
tableId: table.value.tableId||'' tableId: table.value.tableId || ''
}) { }) {
const { const {
records, records,
@@ -524,10 +537,10 @@
} }
goods.list = getNowCart(records) goods.list = getNowCart(records)
if (seatFee && seatFee.totalNumber) { if (seatFee && seatFee.totalNumber) {
userNumbers.defaultCateIndex = seatFee.totalNumber-1 || 0 userNumbers.defaultCateIndex = seatFee.totalNumber - 1 || 0
Object.assign($seatFee, seatFee) Object.assign($seatFee, seatFee)
}else{ } else {
$seatFee.totalAmount=0 $seatFee.totalAmount = 0
} }
console.log(userNumbers.defaultCateIndex); console.log(userNumbers.defaultCateIndex);
} }
@@ -550,20 +563,20 @@
note: note.value, note: note.value,
postPay: true, postPay: true,
orderId: '', orderId: '',
tableId: table.value.tableId||'' tableId: table.value.tableId || ''
}) { }) {
if (!$shop.value.isTableFee) { if (!$shop.value.isTableFee) {
//不免餐位费 //不免餐位费
await Api.$choseCount({ await Api.$choseCount({
masterId: option.masterId, masterId: option.masterId,
tableId: table.value.tableId||"", tableId: table.value.tableId || "",
num: userNumbers.defaultCateIndex+1, num: userNumbers.defaultCateIndex + 1,
}) })
} }
if ($shop.value.registerType == 'munchies'||eatTypes.active=='takeout') { if ($shop.value.registerType == 'munchies' || eatTypes.active == 'takeout') {
const canJiesuan=await hasPermission('允许收款') const canJiesuan = await hasPermission('允许收款')
if(!canJiesuan){ if (!canJiesuan) {
return return
} }
} }
// updateChoseCount() // updateChoseCount()
@@ -571,21 +584,20 @@
uni.$emit('update:createOrderIndex') uni.$emit('update:createOrderIndex')
console.log($shop.value); console.log($shop.value);
console.log(res); console.log(res);
if ($shop.value.registerType == 'munchies'||eatTypes.active=='takeout') { if ($shop.value.registerType == 'munchies' || eatTypes.active == 'takeout') {
//先付 //先付
return go.to('PAGES_ORDER_PAY', { return go.to('PAGES_ORDER_PAY', {
orderId: res.id, orderId: res.id,
isNowPay:true isNowPay: true
},'redirect' }, 'redirect')
)
} else { } else {
//后付 //后付
console.log(option.isCreateOrderToDetail); console.log(option.isCreateOrderToDetail);
if (option.isCreateOrderToDetail!='0') { if (option.isCreateOrderToDetail != '0') {
console.log('PAGES_ORDER_DETAIL'); console.log('PAGES_ORDER_DETAIL');
go.to('PAGES_ORDER_DETAIL', { go.to('PAGES_ORDER_DETAIL', {
id: res.id id: res.id
},'redirect') }, 'redirect')
} else { } else {
console.log('back'); console.log('back');
uni.navigateBack({ uni.navigateBack({
@@ -616,7 +628,7 @@
cartId: cart.id, cartId: cart.id,
productId: cart.productId, productId: cart.productId,
skuId: cart.skuId, skuId: cart.skuId,
tableId: option.tableId||"", tableId: option.tableId || "",
note: e.remark, note: e.remark,
num: cart.number // 0会删除此商品 num: cart.number // 0会删除此商品
}) })
@@ -634,22 +646,27 @@
onLoad((opt) => { onLoad((opt) => {
Object.assign(option, opt) Object.assign(option, opt)
console.log(option,); console.log(opt);
if (opt) { if (opt) {
table.value = { table.value = {
tableId: opt.tableId||'', ...option,
tableId: opt.tableId || '',
name: opt.name name: opt.name
} }
userNumbers.list = new Array(opt.maxCapacity?opt.maxCapacity*1:100).fill(1).map((v, index) => {
return (index + 1) + '人'
})
// console.log(userNumbers.list);
} }
init() init()
// updateChoseCount() // updateChoseCount()
}) })
let bottomHeight=ref(100) let bottomHeight = ref(100)
onReady(()=>{ onReady(() => {
getSafeBottomHeight('safe-bottom').then(res=>{ getSafeBottomHeight('safe-bottom').then(res => {
console.log(res); console.log(res);
bottomHeight.value=res bottomHeight.value = res
}) })
}) })
@@ -668,12 +685,12 @@
uni.setStorageSync("useType", useType); uni.setStorageSync("useType", useType);
} }
const tableId = useType == 'takeout' ? undefined : table.value.tableId; const tableId = useType == 'takeout' ? undefined : table.value.tableId;
if(!goods.list.length){ if (!goods.list.length) {
return return
} }
const res = await Api.$changeUseType({ const res = await Api.$changeUseType({
useType, useType,
tableId:tableId||'', tableId: tableId || '',
cartIds: goods.list.map((v) => v.id), cartIds: goods.list.map((v) => v.id),
}) })
getCart() getCart()
@@ -712,6 +729,7 @@
border-radius: 18rpx; border-radius: 18rpx;
margin-bottom: 32rpx; margin-bottom: 32rpx;
} }
.textarea { .textarea {
border-radius: 12rpx 12rpx 12rpx 12rpx; border-radius: 12rpx 12rpx 12rpx 12rpx;
padding: 32rpx 0 32rpx 24rpx; padding: 32rpx 0 32rpx 24rpx;
@@ -722,6 +740,7 @@
.goods { .goods {
// padding-bottom: 30rpx; // padding-bottom: 30rpx;
border-bottom: 1px dashed #E5E5E5; border-bottom: 1px dashed #E5E5E5;
.item { .item {
.img { .img {
width: 84rpx; width: 84rpx;