代客下单增加无台桌下单

This commit is contained in:
YeMingfei666 2024-10-25 18:09:30 +08:00
parent 1de0a53abe
commit 5fa402dca2
5 changed files with 185 additions and 91 deletions

View File

@ -24,6 +24,7 @@
<view class="list "> <view class="list ">
<view class=" bg-fff box bg-fff"> <view class=" bg-fff box bg-fff">
<template v-if="tables.list.length">
<view class="u-flex item u-row-between" v-for="(item,index) in tables.list" :key="index" <view class="u-flex item u-row-between" v-for="(item,index) in tables.list" :key="index"
@tap="chooseTable(index,item)"> @tap="chooseTable(index,item)">
<view class="u-flex"> <view class="u-flex">
@ -45,6 +46,11 @@
</view> </view>
</view> </view>
</view> </view>
<my-pagination :page="query.page" :totalElements="query.totalElements" :size="query.size"
@change="pageChange"></my-pagination>
</template>
<template v-if="tables.list.length<=0"> <template v-if="tables.list.length<=0">
<my-img-empty tips="未找到相关的桌台"></my-img-empty> <my-img-empty tips="未找到相关的桌台"></my-img-empty>
</template> </template>
@ -94,10 +100,13 @@
uni.navigateBack() uni.navigateBack()
}, 100) }, 100)
} }
let searchValue=ref('') let searchValue = ref('')
function search(){
function search() {
query.page=1
getTable()
} }
function chooseTable(index, item) { function chooseTable(index, item) {
if (item.status == 'closed') { if (item.status == 'closed') {
return uni.showToast({ return uni.showToast({
@ -109,7 +118,7 @@
nouser.value = true nouser.value = true
return emitChooeTable() return emitChooeTable()
} else { } else {
tables.selIndex=index tables.selIndex = index
emitChooeTable(item) emitChooeTable(item)
} }
} }
@ -128,11 +137,20 @@
function areaChange(e) { function areaChange(e) {
area.defaultCateIndex = e.detail.value area.defaultCateIndex = e.detail.value
area.sel = area.list[e.detail.value] area.sel = area.list[e.detail.value]
query.page=1
getTable()
} }
const query = { const query = {
page: 0, page: 1,
size: 100, size: 10,
areaId: 0 areaId: 0,
totalElements:0
}
//
function pageChange(page) {
console.log(page);
query.page = page
getTable()
} }
const tables = reactive({ const tables = reactive({
hasAjax: false, hasAjax: false,
@ -141,15 +159,15 @@
list: [] list: []
}) })
async function getTable() { async function getTable() {
// let state=status.list[status.active].key
// state=state?(state=='all'?'':state):''
const areaId=area.list[area.defaultCateIndex].id
let { let {
content content,total
} = await $table.get(query) } = await $table.get({...query,areaId,name:searchValue.value,state:'idle'})
tables.hasAjax = true query.totalElements=total||0;
content = content.filter(v =>{ tables.hasAjax = true;
// return v.status == 'idle'||(v.status=='using') console.log(content);
return v.status == 'idle'
})
console.log(content );
tables.list = content tables.list = content
tables.selIndex = content.findIndex(v => v.tableId == option.tableId) tables.selIndex = content.findIndex(v => v.tableId == option.tableId)
tables.originList = content tables.originList = content
@ -172,11 +190,7 @@
} }
watch(() => area.sel, (newval) => { watch(() => area.sel, (newval) => {
if(!newval){ getTable()
tables.list = tables.originList
return
}
tables.list = tables.originList.filter(v => v.areaId == newval.id)
}) })
let option = {} let option = {}
onLoad(opt => { onLoad(opt => {
@ -202,6 +216,7 @@
background: #FFFFFF; background: #FFFFFF;
width: 18px; width: 18px;
height: 18px; height: 18px;
&.active { &.active {
background-color: $my-main-color; background-color: $my-main-color;
border-color: $my-main-color; border-color: $my-main-color;
@ -225,11 +240,14 @@
.scale7 { .scale7 {
transform: scale(0.7); transform: scale(0.7);
} }
::v-deep .uni-searchbar{
padding: 0!important; ::v-deep .uni-searchbar {
padding: 0 !important;
} }
.search { .search {
padding: 20rpx 28rpx 20rpx 28rpx; padding: 20rpx 28rpx 20rpx 28rpx;
.icon-saoma { .icon-saoma {
margin-left: 20rpx; margin-left: 20rpx;
width: 34rpx; width: 34rpx;
@ -239,6 +257,7 @@
.list { .list {
padding: 32rpx 24rpx; padding: 32rpx 24rpx;
.no-choose { .no-choose {
padding: 36rpx 30rpx 36rpx 24rpx; padding: 36rpx 30rpx 36rpx 24rpx;
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="page-gray color-333 u-font-28"> <view class="page-gray color-333 u-font-28">
<template v-if="true"> <template v-if="true">
<view class="block u-p-t-32 u-p-b-32"> <view class="block u-p-t-32 u-p-b-32" v-if="table&&table.tableId">
<view>桌位号</view> <view>桌位号</view>
<view class="font-bold u-font-32 u-m-t-16"> <view class="font-bold u-font-32 u-m-t-16">
{{table.name||''}} {{table.name||''}}

View File

@ -63,8 +63,9 @@
</view> </view>
<up-modal title="提示" content="是否清空全部已添加的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay @confirm="confirmModelConfirm" <up-modal title="提示" content="是否清空全部已添加的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay
@cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)" width="300px"></up-modal> @confirm="confirmModelConfirm" @cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)"
width="300px"></up-modal>
</view> </view>
</template> </template>
@ -114,7 +115,7 @@
}) })
const modal = reactive({ const modal = reactive({
key: '', key: '',
clear:false clear: false
}) })
function confirmModelConfirm() { function confirmModelConfirm() {
@ -124,7 +125,7 @@
} }
function setModalShow(key = 'show', show = true) { function setModalShow(key = 'show', show = true) {
if (key == 'clear'&&show&&props.data.length<=0) { if (key == 'clear' && show && props.data.length <= 0) {
return infoBox.showToast('购物车是空的!') return infoBox.showToast('购物车是空的!')
} }
modal.key = key modal.key = key
@ -163,6 +164,13 @@
status, status,
type type
} = props.table } = props.table
if (props.table.tableId == '') {
go.to('PAGES_CONFIRM_ORDER', {
masterId: props.masterId,
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
})
return
}
go.to('PAGES_CONFIRM_ORDER', { go.to('PAGES_CONFIRM_ORDER', {
masterId: props.masterId, masterId: props.masterId,
type, type,
@ -200,7 +208,7 @@
} }
function clear() { function clear() {
setModalShow('clear',false) setModalShow('clear', false)
edmits('clear') edmits('clear')
hideGoods() hideGoods()
} }

View File

@ -53,6 +53,7 @@
toRefs, toRefs,
watch watch
} from 'vue'; } from 'vue';
import util from '../util.js';
const props = defineProps({ const props = defineProps({
img:{ img:{
type:Object, type:Object,
@ -99,7 +100,7 @@
} }
return ( return (
item.isPauseSale || item.isPauseSale ||
(item.typeEnum !== "sku" && item.specList[0].stockNumber <= 0) (item.typeEnum !== "sku" && item.isStock==1&& item.stockNumber <= 0)
); );
}) })

View File

@ -103,8 +103,8 @@
<list-goods-item :img="{width:'330rpx',height:'330rpx'}" <list-goods-item :img="{width:'330rpx',height:'330rpx'}"
@chooseGuige="chooseGuige(goodsItem.goodsIndex,goodsItem.index)" @chooseGuige="chooseGuige(goodsItem.goodsIndex,goodsItem.index)"
@add="searchGoodsUpdate(goodsItem,goodsIndex,true)" @add="searchGoodsUpdate(goodsItem,goodsIndex,true)"
@reduce="searchGoodsUpdate(goodsItem,goodsIndex,false)" :index="goodsItem.goodsIndex" @reduce="searchGoodsUpdate(goodsItem,goodsIndex,false)"
:data="goodsItem"></list-goods-item> :index="goodsItem.goodsIndex" :data="goodsItem"></list-goods-item>
</view> </view>
</view> </view>
@ -122,20 +122,27 @@
</view> </view>
<!-- 选择规格 --> <!-- 选择规格 -->
<guige-model @update-sku="updateSkuSel" @confirm="guigeConfirm" ref="chooseGuigeModel" <guige-model @update-sku="updateSkuSel" @confirm="guigeConfirm" ref="chooseGuigeModel" :goodsData="selGoods"
:goodsData="selGoods"
:title="guigeModelData.title" :sku-map="guigeModelData.chooseGoods.skuMap" :title="guigeModelData.title" :sku-map="guigeModelData.chooseGoods.skuMap"
:skus="guigeModelData.chooseGoods.skus"></guige-model> :skus="guigeModelData.chooseGoods.skus"></guige-model>
<!-- 添加附加费 --> <!-- 添加附加费 -->
<my-surcharge @confirm="surchargeConfirm" ref="surcharge" title="添加附加费"></my-surcharge> <my-surcharge @confirm="surchargeConfirm" ref="surcharge" title="添加附加费"></my-surcharge>
</view>
</view>
<up-modal title="提示" content="该台桌购物车里有商品,是否清除该台桌里的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay
@confirm="confirmModelConfirm" @cancel="confirmModelConfirm('cancel')" @close="setModalShow('clear',false)"
width="300px">
</up-modal>
</template> </template>
<script setup> <script setup>
import _ from 'lodash'; import _ from 'lodash';
import * as Api from '@/http/yskApi/Instead.js' import * as Api from '@/http/yskApi/Instead.js'
import { import {
$table $table,
$choseTable,
$returnTableDetail
} from '@/http/yskApi/table.js' } from '@/http/yskApi/table.js'
import { import {
$tbShopCategory $tbShopCategory
@ -158,7 +165,8 @@
reactive, reactive,
ref, ref,
nextTick, nextTick,
watch,getCurrentInstance watch,
getCurrentInstance
} from 'vue'; } from 'vue';
import myCar from './components/car' import myCar from './components/car'
import go from '@/commons/utils/go.js'; import go from '@/commons/utils/go.js';
@ -173,11 +181,45 @@
import { import {
tbShopInfo tbShopInfo
} from '@/http/yskApi/user.js' } from '@/http/yskApi/user.js'
import {hasPermission} from '@/commons/utils/hasPermission.js' import {
hasPermission
} from '@/commons/utils/hasPermission.js'
const modal = reactive({
key: '',
clear: false,
data: ''
})
async function confirmModelConfirm(isCancel = false) {
if (modal.key == 'clear') {
try {
await $choseTable({
masterId: data.masterId,
tableId: modal.data.tableId,
isClear: !isCancel ? true : false,
});
} catch (e) {
console.log(e)
//TODO handle the exception
}
data.table = modal.data;
setModalShow('clear', false, '')
}
}
function setModalShow(key = 'show', show = true, data) {
modal.key = key
modal[key] = show
modal.data = data
}
const instance = getCurrentInstance(); const instance = getCurrentInstance();
let canXiadan=ref(false) let canXiadan = ref(false)
async function xiadanClick(){ async function xiadanClick() {
canXiadan.value=await hasPermission('允许下单') canXiadan.value = await hasPermission('允许下单')
} }
xiadanClick() xiadanClick()
// //
@ -198,9 +240,9 @@
menuHeight: 0, // menuHeight: 0, //
menuItemHeight: 0, // item menuItemHeight: 0, // item
itemId: '', // scroll-viewid itemId: '', // scroll-viewid
tabbar: storageManage.cacheGoods()||[], tabbar: storageManage.cacheGoods() || [],
menuItemPos: [], menuItemPos: [],
arr: storageManage.cacheGoodsNode()||[],// arr: storageManage.cacheGoodsNode() || [], //
scrollRightTop: 0, // scroll-view scrollRightTop: 0, // scroll-view
timer: null, // timer: null, //
topZhanwei: 136 + 24, topZhanwei: 136 + 24,
@ -305,8 +347,8 @@
page: 0, page: 0,
size: 300 size: 300
}) { }) {
const showLoading=data.tabbar.length<=0?true:false const showLoading = data.tabbar.length <= 0 ? true : false
return Api.getGoodsLists(par,showLoading) return Api.getGoodsLists(par, showLoading)
} }
// //
async function getCart(par = { async function getCart(par = {
@ -400,7 +442,7 @@
// //
async function getTableInfo() { async function getTableInfo() {
if(data.table.tableId){ if (data.table.tableId) {
const res = await $table.get({ const res = await $table.get({
qrcode: data.table.tableId qrcode: data.table.tableId
}) })
@ -414,7 +456,7 @@
let $category = [] let $category = []
async function init() { async function init() {
const masterRes = await getMasterId() const masterRes = await getMasterId()
data.masterId =masterRes.masterId data.masterId = masterRes.masterId
const shopInfo = await tbShopInfo() const shopInfo = await tbShopInfo()
$shop.value = shopInfo $shop.value = shopInfo
const useType = data.table.status == 'using' ? data.table.useType : $returnUseType(shopInfo) const useType = data.table.status == 'using' ? data.table.useType : $returnUseType(shopInfo)
@ -508,7 +550,7 @@
} }
function search() { function search() {
if(searchValue.value===''){ if (searchValue.value === '') {
isSearch.value = false isSearch.value = false
return return
} }
@ -533,8 +575,27 @@
function watchChooseTable() { function watchChooseTable() {
uni.$off('choose-table') uni.$off('choose-table')
uni.$on('choose-table', (tableData) => { uni.$on('choose-table', async (item) => {
data.table = tableData if (data.table.tableId || cars.length <= 0) {
data.table = item
return;
}
if (item.status != "idle") {
return infoBox.showToast('该台桌已在使用中')
}
const res = await $returnTableDetail({
tableId: item.tableId,
});
if (res.cartCount > 0) {
setModalShow('clear', true, item)
} else {
await $choseTable({
masterId: data.masterId,
tableId: item.tableId,
isClear:false
});
data.table = item
}
}) })
} }
@ -590,7 +651,7 @@
return prve; return prve;
}, {}); }, {});
const canBudyGoods = specList const canBudyGoods = specList
.filter((v) => util.isCanBuy(v,guigeModelData.chooseGoods.item)) .filter((v) => util.isCanBuy(v, guigeModelData.chooseGoods.item))
.sort((a, b) => { .sort((a, b) => {
const aNumber = a.specSnap.split(",").reduce((prve, cur) => { const aNumber = a.specSnap.split(",").reduce((prve, cur) => {
return prve + skuMapNumber[cur]; return prve + skuMapNumber[cur];
@ -679,7 +740,7 @@
prve[i] = matchArr prve[i] = matchArr
.filter((v) => v.specSnap.match(i)) .filter((v) => v.specSnap.match(i))
.every((v) => { .every((v) => {
return !util.isCanBuy(v,guigeModelData.chooseGoods.item) return !util.isCanBuy(v, guigeModelData.chooseGoods.item)
}); });
} }
} }
@ -696,7 +757,8 @@
} }
let selGoods=ref({}) let selGoods = ref({})
function chooseGuige(foodsindex, index) { function chooseGuige(foodsindex, index) {
if (!canAddGoods()) { if (!canAddGoods()) {
return infoBox.showToast('请先选择桌台', 0.5).then(res => { return infoBox.showToast('请先选择桌台', 0.5).then(res => {
@ -704,7 +766,7 @@
}) })
} }
const $goods = data.tabbar[index].foods[foodsindex] const $goods = data.tabbar[index].foods[foodsindex]
selGoods.value=$goods selGoods.value = $goods
guigeModelData.title = $goods.name guigeModelData.title = $goods.name
const specList = $goods.specList; const specList = $goods.specList;
const tagSnap = JSON.parse($goods.skuResult.tagSnap) const tagSnap = JSON.parse($goods.skuResult.tagSnap)
@ -808,15 +870,16 @@
return true return true
} }
function searchGoodsUpdate(goodsItem,goodsIndex, isAdd) { function searchGoodsUpdate(goodsItem, goodsIndex, isAdd) {
goodsUpdate(goodsItem.goodsIndex, goodsItem.index, isAdd,goodsIndex) goodsUpdate(goodsItem.goodsIndex, goodsItem.index, isAdd, goodsIndex)
} }
function setSearchGoods(index,chooseNumber){
if(index!==undefined){ function setSearchGoods(index, chooseNumber) {
searchResult.value[index].chooseNumber=chooseNumber if (index !== undefined) {
searchResult.value[index].chooseNumber = chooseNumber
} }
} }
async function goodsUpdate(foodsindex, index, isAdd,searchGoodsIndex) { async function goodsUpdate(foodsindex, index, isAdd, searchGoodsIndex) {
// if (!canAddGoods()) { // if (!canAddGoods()) {
// return infoBox.showToast('', 0.5).then(res => { // return infoBox.showToast('', 0.5).then(res => {
// chooseTable() // chooseTable()
@ -841,7 +904,7 @@
// //
cars.splice(goodsInCarIndex, 1) cars.splice(goodsInCarIndex, 1)
$goods.chooseNumber = 0 $goods.chooseNumber = 0
setSearchGoods(searchGoodsIndex,0) setSearchGoods(searchGoodsIndex, 0)
return await removeCartGoods({ return await removeCartGoods({
cartId cartId
}) })
@ -856,7 +919,7 @@
}) })
carGoods.number = number carGoods.number = number
$goods.chooseNumber = number $goods.chooseNumber = number
setSearchGoods(searchGoodsIndex,number) setSearchGoods(searchGoodsIndex, number)
} else { } else {
// //
const num = suit const num = suit
@ -991,8 +1054,8 @@
if (!data.menuHeight) { if (!data.menuHeight) {
await getElRect('menu-scroll-view', 'menuHeight'); await getElRect('menu-scroll-view', 'menuHeight');
} }
if(e.detail.scrollTop==0){ if (e.detail.scrollTop == 0) {
isTabClickOver=true isTabClickOver = true
return swichMenu(0) return swichMenu(0)
} }
setTimeout(() => { // setTimeout(() => { //
@ -1230,10 +1293,12 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
::v-deep .uni-searchbar{
padding-top: 12px!important; ::v-deep .uni-searchbar {
padding-bottom: 16px!important; padding-top: 12px !important;
padding-bottom: 16px !important;
} }
.right-box { .right-box {
width: 572rpx; width: 572rpx;
// background-color: rgb(250, 250, 250); // background-color: rgb(250, 250, 250);
@ -1257,7 +1322,8 @@
.item-title { .item-title {
font-size: 26rpx; font-size: 26rpx;
font-weight: bold; font-weight: bold;
&.active{
&.active {
color: $my-main-color; color: $my-main-color;
} }
} }