2 Commits
test ... gyq

Author SHA1 Message Date
gyq
23e4407459 优化台桌 2025-06-03 10:09:56 +08:00
gyq
53a1442cf7 优化 2025-05-28 10:38:40 +08:00
5 changed files with 1377 additions and 1313 deletions

View File

@@ -149,6 +149,10 @@ function qingtai() {
} }
}); });
} }
defineExpose({
diancan
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -50,7 +50,7 @@
<template v-if="pageData.tabList.length"> <template v-if="pageData.tabList.length">
<view class="u-flex u-flex-wrap u-row-between"> <view class="u-flex u-flex-wrap u-row-between">
<view class="u-m-b-30" v-for="(item, index) in pageData.tabList" :key="index"> <view class="u-m-b-30" v-for="(item, index) in pageData.tabList" :key="index">
<table-item @bind="scanCode" @update="getTable" :areaMap="pageData.areaMap" @more="moreShow(item)" :data="item"></table-item> <table-item ref="tableItemRefs" @bind="scanCode" @update="getTable" :areaMap="pageData.areaMap" @more="moreShow(item, index)" :data="item"></table-item>
</view> </view>
</view> </view>
<my-pagination :page="pageData.query.page" :totalElements="pageData.totalElements" :size="pageData.query.size" @change="pageChange"></my-pagination> <my-pagination :page="pageData.query.page" :totalElements="pageData.totalElements" :size="pageData.query.size" @change="pageChange"></my-pagination>
@@ -115,7 +115,7 @@ const pageData = reactive({
const refMoreSheet = ref(null); const refMoreSheet = ref(null);
const actionSheet = reactive({ const actionSheet = reactive({
list: ['结账', '清台', '增减菜', '换台', '打印订单', '历史订单', '绑定码牌'], list: ['结账', '清台', '菜', '换台', '打印订单', '历史订单', '绑定码牌'],
title: '', title: '',
selTable: '' selTable: ''
}); });
@@ -182,7 +182,8 @@ function changeAreaSel(item) {
* 更多操作打开 * 更多操作打开
* @param {Object} table * @param {Object} table
*/ */
function moreShow(table) { function moreShow(table, index) {
tableItemRefsIndex.value = index;
actionSheet.title = table.name; actionSheet.title = table.name;
actionSheet.selTable = table; actionSheet.selTable = table;
refMoreSheet.value.open(); refMoreSheet.value.open();
@@ -197,6 +198,8 @@ function moreShow(table) {
* 更多操作选择 * 更多操作选择
* @param {Object} index * @param {Object} index
*/ */
const tableItemRefsIndex = ref(0);
const tableItemRefs = ref([]);
async function actionSheetClick(index) { async function actionSheetClick(index) {
console.log(index); console.log(index);
const item = actionSheet.selTable; const item = actionSheet.selTable;
@@ -229,7 +232,7 @@ async function actionSheetClick(index) {
}); });
} }
if (index == 2) { if (index == 2) {
return uni.$utils.showToast('待开放,请敬请期待!'); tableItemRefs.value[tableItemRefsIndex.value].diancan();
} }
if (index == 3) { if (index == 3) {
return uni.$utils.showToast('待开放,请敬请期待!'); return uni.$utils.showToast('待开放,请敬请期待!');

View File

@@ -6,7 +6,7 @@ export default [{
{ {
label: "空闲", label: "空闲",
type: "idle", type: "idle",
color: "#3F9EFF", color: "#187CAA",
}, },
{ {
label: "点餐中", label: "点餐中",

View File

@@ -2,34 +2,38 @@
<view class="min-page bg-gray u-font-28 u-p-30"> <view class="min-page bg-gray u-font-28 u-p-30">
<user-vue :orderInfo="orderDetail.info" :user="user"></user-vue> <user-vue :orderInfo="orderDetail.info" :user="user"></user-vue>
<goods-list @printOrder="onPrintOrder" @tuikuan="onTuikuan" :orderInfo="orderDetail.info" <goods-list
@printOrder="onPrintOrder"
@tuikuan="onTuikuan"
:orderInfo="orderDetail.info"
:user="user" :user="user"
:data="orderDetail.goodsList" :seatFee="orderDetail.seatFee" @tuicai="onTuiCai"></goods-list> :data="orderDetail.goodsList"
:seatFee="orderDetail.seatFee"
@tuicai="onTuiCai"
></goods-list>
<template v-if="true"> <template v-if="true">
<extra-vue @tuicai="onSeatFeeTuicai" @tuikuan="onSeatFeeTuiKuan" :orderInfo="orderDetail.info" <extra-vue @tuicai="onSeatFeeTuicai" @tuikuan="onSeatFeeTuiKuan" :orderInfo="orderDetail.info" :data="orderDetail.seatFee"></extra-vue>
:data="orderDetail.seatFee"></extra-vue>
</template> </template>
<order-vue :data="orderDetail.info" :table="options" :seatFee="orderDetail.seatFee"></order-vue> <order-vue :data="orderDetail.info" :table="options" :seatFee="orderDetail.seatFee"></order-vue>
<!-- <step-vue></step-vue> --> <!-- <step-vue></step-vue> -->
<view style="height: 200rpx;"></view> <view style="height: 200rpx"></view>
<view class="u-fixed bottom bg-fff "> <view class="u-fixed bottom bg-fff">
<view class="u-flex u-abso"> <view class="u-flex u-abso">
<template v-if="orderDetail.info.dineMode=='take-out'||!orderDetail.info.tableCode||pageData.shopInfo.registerType=='before'"> <template v-if="orderDetail.info.dineMode == 'take-out' || !orderDetail.info.tableCode || pageData.shopInfo.registerType == 'before'">
<view class="u-flex-1" v-if="orderDetail.info.status=='unpaid'"> <view class="u-flex-1" v-if="orderDetail.info.status == 'unpaid'">
<my-button @tap="toPay" borderRadius="100rpx" shape="circle" <my-button @tap="toPay" borderRadius="100rpx" shape="circle" type="primary">结账</my-button>
type="primary">结账</my-button>
</view> </view>
</template> </template>
<template v-else> <template v-else>
<template v-if="orderDetail.info.status=='unpaid'"> <template v-if="orderDetail.info.status == 'unpaid'">
<view class="u-flex-1"> <view class="u-flex-1">
<my-button @tap="diancan" color="#fff" bgColor="rgb(57,53,52)" borderRadius="100rpx 0 0 100rpx" fontWeight="700" <my-button @tap="diancan" color="#fff" bgColor="rgb(57,53,52)" borderRadius="100rpx 0 0 100rpx" fontWeight="700" shape="circle" plain type="primary">
shape="circle" plain type="primary">加菜</my-button> 加菜
</my-button>
</view> </view>
<view class="u-flex-1"> <view class="u-flex-1">
<my-button @tap="toPay" borderRadius="0 100rpx 100rpx 0" shape="circle" fontWeight="700" <my-button @tap="toPay" borderRadius="0 100rpx 100rpx 0" shape="circle" fontWeight="700" type="primary">结账</my-button>
type="primary">结账</my-button>
</view> </view>
</template> </template>
</template> </template>
@@ -41,124 +45,129 @@
</template> </template>
<script setup> <script setup>
import { onLoad, onShow } from '@dcloudio/uni-app'; import { onLoad, onShow } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue'; import { reactive, ref, inject } from 'vue';
import userVue from './components/user.vue'; import userVue from './components/user.vue';
import orderVue from './components/order.vue'; import orderVue from './components/order.vue';
import goodsList from './components/list.vue'; import goodsList from './components/list.vue';
import stepVue from './components/step.vue'; import stepVue from './components/step.vue';
import extraVue from './components/extra.vue'; import extraVue from './components/extra.vue';
import tuicaiVue from './components/tuicai.vue'; import tuicaiVue from './components/tuicai.vue';
import go from '@/commons/utils/go.js' import go from '@/commons/utils/go.js';
import infoBox from '@/commons/utils/infoBox.js' import infoBox from '@/commons/utils/infoBox.js';
import {hasPermission} from '@/commons/utils/hasPermission.js' import { hasPermission } from '@/commons/utils/hasPermission.js';
import OrderDetail from './page.js' import OrderDetail from './page.js';
import { getHistoryOrder, refundOrder,getOrderById,printOrder } from '@/http/api/order.js' import { getHistoryOrder, refundOrder, getOrderById, printOrder } from '@/http/api/order.js';
import { shopStaffDetail } from '@/http/api/staff.js' import { shopStaffDetail } from '@/http/api/staff.js';
import { shopUserDetail } from '@/http/api/shopUser.js' import { shopUserDetail } from '@/http/api/shopUser.js';
import { getShopInfo } from '@/http/api/shop.js' import { getShopInfo } from '@/http/api/shop.js';
const tuicai = reactive({ const websocketUtil = inject('websocketUtil');
const tuicai = reactive({
show: false, show: false,
isSeatFee: false, isSeatFee: false,
selGoods: {} selGoods: {}
}) });
const orderDetail = reactive({ const orderDetail = reactive({
goodsList: [], goodsList: [],
info: {}, info: {},
seatFee: { seatFee: {
totalAmount: 0 totalAmount: 0
} }
}) });
const options = reactive({}) const options = reactive({});
// 监听选择用户事件 // 监听选择用户事件
let user = ref({ let user = ref({
headImg:'', headImg: '',
phone:'', phone: '',
amount:'0.00', amount: '0.00',
accountPoints:'0.00' accountPoints: '0.00'
}) });
const pageData = reactive({ const pageData = reactive({
shopInfo: {}, shopInfo: {}
}) });
onLoad((opt) => {
Object.assign(options, opt)
getShopInfoData()
})
onShow(() => {
watchEmit()
watchChooseuser()
getOrderDetail()
})
/** onShow(() => {
watchEmit();
watchChooseuser();
getOrderDetail();
});
/**
* 获取店铺信息 * 获取店铺信息
*/ */
function getShopInfoData () { function getShopInfoData() {
getShopInfo({id:uni.getStorageSync('shopInfo').id}).then(res=>{ getShopInfo({ id: uni.getStorageSync('shopInfo').id }).then((res) => {
pageData.shopInfo = res; pageData.shopInfo = res;
uni.setStorageSync('shopInfo',res) uni.setStorageSync('shopInfo', res);
}) });
} }
/** /**
* 获取订单详情 * 获取订单详情
*/ */
async function getOrderDetail () { async function getOrderDetail() {
let res = await getHistoryOrder({orderId: options.id}) let res = await getHistoryOrder({ orderId: options.id });
// console.log("订单详情===",res) console.log('订单详情===', res);
if(res.userId){ // 初始化socket
let resUser = await shopUserDetail({userId:res.userId}) // if (res.tableName && res.tableCode) {
user.value = resUser // let shopInfo = uni.getStorageSync('shopInfo');
// websocketUtil.send(
// JSON.stringify({
// type: 'onboc',
// account: shopInfo.account,
// operate_type: 'init',
// table_code: res.tableCode,
// shop_id: shopInfo.id
// })
// );
// }
if (res.userId) {
let resUser = await shopUserDetail({ userId: res.userId });
user.value = resUser;
} }
orderDetail.seatFee = { orderDetail.seatFee = {
seatNum: res.seatNum, seatNum: res.seatNum,
seatAmount: res.seatAmount, seatAmount: res.seatAmount
} };
orderDetail.goodsList = Object.entries(res.detailMap).map(([key, value]) => ({ orderDetail.goodsList = Object.entries(res.detailMap).map(([key, value]) => ({
info: value, info: value,
placeNum: key placeNum: key
})) }));
orderDetail.goodsList.map(item=>{ orderDetail.goodsList.map((item) => {
item.info.map(item=>{ item.info.map((item) => {
item.unitPrice = uni.$utils.isGoodsPrice(item,user.value) item.unitPrice = uni.$utils.isGoodsPrice(item, user.value);
}) });
}) });
orderDetail.info = res orderDetail.info = res;
} }
function onSeatFeeTuicai(seatFee) { function onSeatFeeTuicai(seatFee) {
seatFee={...seatFee,num:seatFee.num,productName:seatFee.productName} seatFee = { ...seatFee, num: seatFee.num, productName: seatFee.productName };
tuicai.show = true tuicai.show = true;
tuicai.isSeatFee = seatFee tuicai.isSeatFee = seatFee;
tuicai.selGoods = seatFee tuicai.selGoods = seatFee;
} }
//是否有允许退款权限 //是否有允许退款权限
async function hasTuiKuan(){ async function hasTuiKuan() {
const isHas=await hasPermission('允许退款') const isHas = await hasPermission('允许退款');
return isHas return isHas;
} }
async function onSeatFeeTuiKuan(seatFee) { async function onSeatFeeTuiKuan(seatFee) {
const canTuikuan=await hasTuiKuan() const canTuikuan = await hasTuiKuan();
if(!canTuikuan){ if (!canTuikuan) {
return return;
} }
const { const { id, cartId, productId, productSkuId, productName, num, priceAmount, price } = seatFee;
id,cartId,
productId,
productSkuId,
productName,
num,
priceAmount,
price
} = seatFee
go.to('PAGES_ORDER_TUIKUAN', { go.to('PAGES_ORDER_TUIKUAN', {
orderId:orderDetail.info.id, orderId: orderDetail.info.id,
id, id,
cartId, cartId,
productId, productId,
@@ -169,27 +178,27 @@
skuName: '', skuName: '',
priceAmount, priceAmount,
price price
}) });
} }
function onTuiCai(goods, index) { function onTuiCai(goods, index) {
tuicai.show = true tuicai.show = true;
tuicai.selGoods = goods tuicai.selGoods = goods;
} }
async function tuicaiConfirm(e) { async function tuicaiConfirm(e) {
const res = await refundOrder(e) const res = await refundOrder(e);
tuicai.show = false tuicai.show = false;
if(res){ if (res) {
go.back() go.back();
}else{ } else {
getOrderDetail() getOrderDetail();
}
} }
}
/** /**
* 打印订单 * 打印订单
*/ */
function onPrintOrder() { function onPrintOrder() {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '是否打印当前台桌菜品', content: '是否打印当前台桌菜品',
@@ -199,128 +208,134 @@
const res = await printOrder({ const res = await printOrder({
id: orderDetail.info.id, id: orderDetail.info.id,
type: orderDetail.info.status == 'unpaid' ? 1 : 0 type: orderDetail.info.status == 'unpaid' ? 1 : 0
});
}) infoBox.showToast('已发送打印请求');
infoBox.showToast('已发送打印请求')
} catch (e) { } catch (e) {
infoBox.showToast('发送打印请求失败') infoBox.showToast('发送打印请求失败');
} }
} }
} }
}) });
} }
async function onTuikuan(goods, index) {
async function onTuikuan(goods, index) { const canTuikuan = await hasTuiKuan();
const canTuikuan=await hasTuiKuan() if (!canTuikuan) {
if(!canTuikuan){ return;
return
} }
if (Array.isArray(goods)) { if (Array.isArray(goods)) {
go.to('PAGES_ORDER_TUIKUAN', { go.to('PAGES_ORDER_TUIKUAN', {
orderInfo: JSON.stringify(orderDetail.info), orderInfo: JSON.stringify(orderDetail.info),
goodsList:JSON.stringify(goods) goodsList: JSON.stringify(goods)
});
})
} else { } else {
goods.number = 0 goods.number = 0;
goods.skuName = goods.skuName || '' goods.skuName = goods.skuName || '';
goods.priceAmount = goods.priceAmount ? goods.priceAmount : (goods.num*uni.$utils.isGoodsPrice(goods,user.value)).toFixed(2) goods.priceAmount = goods.priceAmount ? goods.priceAmount : (goods.num * uni.$utils.isGoodsPrice(goods, user.value)).toFixed(2);
console.log(goods) console.log(goods);
goods.unitPrice = uni.$utils.isGoodsPrice(goods,user.value) goods.unitPrice = uni.$utils.isGoodsPrice(goods, user.value);
goods.userCouponId = goods.userCouponId ? goods.userCouponId:'' goods.userCouponId = goods.userCouponId ? goods.userCouponId : '';
go.to('PAGES_ORDER_TUIKUAN', { go.to('PAGES_ORDER_TUIKUAN', {
orderInfo: JSON.stringify(orderDetail.info), orderInfo: JSON.stringify(orderDetail.info),
goodsList:JSON.stringify([goods]) goodsList: JSON.stringify([goods])
}) });
}
} }
}
const uiPage = new OrderDetail();
const uiPage = new OrderDetail() setTimeout(() => {
setTimeout(() => {
uiPage.setVal('user', { uiPage.setVal('user', {
name: 1 name: 1
}) });
}, 1500) }, 1500);
async function diancan() { async function diancan() {
const canXiadan=await hasPermission('允许下单') const canXiadan = await hasPermission('允许下单');
if(!canXiadan){ if (!canXiadan) {
return return;
} }
clearEmit() clearEmit();
go.to('PAGES_CREATE_ORDER', { go.to('PAGES_CREATE_ORDER', {
tableId: options.tableId || orderDetail.info.tableId, tableId: options.tableId || orderDetail.info.tableId,
tableCode: options.tableCode || orderDetail.info.tableCode, tableCode: options.tableCode || orderDetail.info.tableCode,
name: options.name || orderDetail.info.tableName, name: options.name || orderDetail.info.tableName,
type: 'add', type: 'add',
vipUserId: orderDetail.info.userId?orderDetail.info.userId:'' vipUserId: orderDetail.info.userId ? orderDetail.info.userId : ''
}) });
} }
async function toPay() { async function toPay() {
const canJieZhang=await hasPermission('允许收款') const canJieZhang = await hasPermission('允许收款');
if(!canJieZhang){ if (!canJieZhang) {
return return;
} }
const userId=orderDetail.info.userId||'' const userId = orderDetail.info.userId || '';
clearEmit() clearEmit();
go.to('PAGES_ORDER_PAY', { go.to('PAGES_ORDER_PAY', {
tableId: options.tableId|| orderDetail.info.tableId, tableId: options.tableId || orderDetail.info.tableId,
tableCode: options.tableCode || orderDetail.info.tableCode, tableCode: options.tableCode || orderDetail.info.tableCode,
tableName: options.name || orderDetail.info.tableName, tableName: options.name || orderDetail.info.tableName,
orderId: orderDetail.info.id, orderId: orderDetail.info.id,
discount: 1, discount: 1,
userId userId
}) });
} }
function watchEmit() {
function watchEmit() { uni.$off('orderDetail:update');
uni.$off('orderDetail:update')
uni.$once('orderDetail:update', (newval) => { uni.$once('orderDetail:update', (newval) => {
getOrderDetail() getOrderDetail();
}) });
} }
//更新选择用户
//更新选择用户 async function setUser(par) {
async function setUser(par) {
const submitPar = { const submitPar = {
orderId:options.id||'', orderId: options.id || '',
masterId: options.masterId, masterId: options.masterId,
tableId: options.tableId|| orderDetail.info.tableId, tableId: options.tableId || orderDetail.info.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 取消
} };
Object.assign(submitPar, par) Object.assign(submitPar, par);
const res=await Api.$setUser(submitPar) const res = await Api.$setUser(submitPar);
getOrderDetail() getOrderDetail();
return res return res;
} }
function clearEmit() {
uni.$off('choose-user');
uni.$off('orderDetail:update');
}
function clearEmit(){ function watchChooseuser() {
uni.$off('choose-user') uni.$off('choose-user');
uni.$off('orderDetail:update')
}
function watchChooseuser() {
uni.$off('choose-user')
uni.$on('choose-user', (data) => { uni.$on('choose-user', (data) => {
console.log(data); console.log(data);
user.value = data user.value = data;
setUser() setUser();
}) });
}
// 监听购物车
function onMessage() {
websocketUtil.onMessage(async (res) => {
let data = JSON.parse(res);
console.log(data);
if (data.operate_type == 'onboc_init' && data.data.length) {
} }
});
}
onLoad((opt) => {
Object.assign(options, opt);
getShopInfoData();
// onMessage();
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.bottom { .bottom {
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
@@ -331,5 +346,5 @@
left: 28rpx; left: 28rpx;
right: 28rpx; right: 28rpx;
} }
} }
</style> </style>

File diff suppressed because it is too large Load Diff