代客下单增加无台桌下单

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

@ -4,7 +4,7 @@
<view class="search bg-fff u-flex u-col-center ">
<view class="u-flex-1">
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="输入桌号" @confirm="search"
v-model="searchValue">
v-model="searchValue">
</uni-search-bar>
</view>
<!-- <view class="u-flex">
@ -24,27 +24,33 @@
<view class="list ">
<view class=" bg-fff box bg-fff">
<view class="u-flex item u-row-between" v-for="(item,index) in tables.list" :key="index"
@tap="chooseTable(index,item)">
<view class="u-flex">
<view class="">
<view class="u-flex">
<view>{{item.name}}</view>
<view class="line"></view>
<view>{{''}}</view>
<template v-if="tables.list.length">
<view class="u-flex item u-row-between" v-for="(item,index) in tables.list" :key="index"
@tap="chooseTable(index,item)">
<view class="u-flex">
<view class="">
<view class="u-flex">
<view>{{item.name}}</view>
<view class="line"></view>
<view>{{''}}</view>
</view>
<view class="color-999 u-font-24 u-m-t-12">
<text
:style="{color:returnStutasColor(item.status)}">{{returnStutasText(item.status)}}</text>
</view>
</view>
<view class="color-999 u-font-24 u-m-t-12">
<text
:style="{color:returnStutasColor(item.status)}">{{returnStutasText(item.status)}}</text>
</view>
<view class="my-radio u-font-28 u-flex color-333">
<view class="circle u-flex u-row-center" :class="{active:index==tables.selIndex}">
<uni-icons type="checkmarkempty" :size="16" color="#fff"></uni-icons>
</view>
</view>
</view>
<view class="my-radio u-font-28 u-flex color-333">
<view class="circle u-flex u-row-center" :class="{active:index==tables.selIndex}">
<uni-icons type="checkmarkempty" :size="16" color="#fff"></uni-icons>
</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">
<my-img-empty tips="未找到相关的桌台"></my-img-empty>
</template>
@ -94,10 +100,13 @@
uni.navigateBack()
}, 100)
}
let searchValue=ref('')
function search(){
let searchValue = ref('')
function search() {
query.page=1
getTable()
}
function chooseTable(index, item) {
if (item.status == 'closed') {
return uni.showToast({
@ -109,7 +118,7 @@
nouser.value = true
return emitChooeTable()
} else {
tables.selIndex=index
tables.selIndex = index
emitChooeTable(item)
}
}
@ -128,11 +137,20 @@
function areaChange(e) {
area.defaultCateIndex = e.detail.value
area.sel = area.list[e.detail.value]
query.page=1
getTable()
}
const query = {
page: 0,
size: 100,
areaId: 0
page: 1,
size: 10,
areaId: 0,
totalElements:0
}
//
function pageChange(page) {
console.log(page);
query.page = page
getTable()
}
const tables = reactive({
hasAjax: false,
@ -141,15 +159,15 @@
list: []
})
async function getTable() {
// let state=status.list[status.active].key
// state=state?(state=='all'?'':state):''
const areaId=area.list[area.defaultCateIndex].id
let {
content
} = await $table.get(query)
tables.hasAjax = true
content = content.filter(v =>{
// return v.status == 'idle'||(v.status=='using')
return v.status == 'idle'
})
console.log(content );
content,total
} = await $table.get({...query,areaId,name:searchValue.value,state:'idle'})
query.totalElements=total||0;
tables.hasAjax = true;
console.log(content);
tables.list = content
tables.selIndex = content.findIndex(v => v.tableId == option.tableId)
tables.originList = content
@ -172,11 +190,7 @@
}
watch(() => area.sel, (newval) => {
if(!newval){
tables.list = tables.originList
return
}
tables.list = tables.originList.filter(v => v.areaId == newval.id)
getTable()
})
let option = {}
onLoad(opt => {
@ -197,11 +211,12 @@
}
.my-radio {
.circle {
background: #FFFFFF;
width: 18px;
height: 18px;
&.active {
background-color: $my-main-color;
border-color: $my-main-color;
@ -225,11 +240,14 @@
.scale7 {
transform: scale(0.7);
}
::v-deep .uni-searchbar{
padding: 0!important;
::v-deep .uni-searchbar {
padding: 0 !important;
}
.search {
padding: 20rpx 28rpx 20rpx 28rpx;
.icon-saoma {
margin-left: 20rpx;
width: 34rpx;
@ -239,6 +257,7 @@
.list {
padding: 32rpx 24rpx;
.no-choose {
padding: 36rpx 30rpx 36rpx 24rpx;
}

View File

@ -1,7 +1,7 @@
<template>
<view class="page-gray color-333 u-font-28">
<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 class="font-bold u-font-32 u-m-t-16">
{{table.name||''}}

View File

@ -63,8 +63,9 @@
</view>
<up-modal title="提示" content="是否清空全部已添加的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay @confirm="confirmModelConfirm"
@cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)" width="300px"></up-modal>
<up-modal title="提示" content="是否清空全部已添加的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay
@confirm="confirmModelConfirm" @cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)"
width="300px"></up-modal>
</view>
</template>
@ -114,7 +115,7 @@
})
const modal = reactive({
key: '',
clear:false
clear: false
})
function confirmModelConfirm() {
@ -124,7 +125,7 @@
}
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('购物车是空的!')
}
modal.key = key
@ -132,7 +133,7 @@
console.log(modal);
}
const edmits = defineEmits(['clear', 'updateNumber'])
@ -163,6 +164,13 @@
status,
type
} = 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', {
masterId: props.masterId,
type,
@ -200,7 +208,7 @@
}
function clear() {
setModalShow('clear',false)
setModalShow('clear', false)
edmits('clear')
hideGoods()
}

View File

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