2 Commits
ymf ... 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

@@ -1,35 +1,39 @@
<template> <template>
<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
:user="user" @printOrder="onPrintOrder"
:data="orderDetail.goodsList" :seatFee="orderDetail.seatFee" @tuicai="onTuiCai"></goods-list> @tuikuan="onTuikuan"
:orderInfo="orderDetail.info"
:user="user"
: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,295 +45,306 @@
</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 infoBox from '@/commons/utils/infoBox.js'
import {hasPermission} from '@/commons/utils/hasPermission.js'
import OrderDetail from './page.js'
import { getHistoryOrder, refundOrder,getOrderById,printOrder } from '@/http/api/order.js'
import { shopStaffDetail } from '@/http/api/staff.js'
import { shopUserDetail } from '@/http/api/shopUser.js'
import { getShopInfo } from '@/http/api/shop.js'
const tuicai = reactive({
show: false,
isSeatFee: false,
selGoods: {}
})
const orderDetail = reactive({
goodsList: [],
info: {},
seatFee: {
totalAmount: 0
}
})
const options = reactive({})
// 监听选择用户事件
let user = ref({
headImg:'',
phone:'',
amount:'0.00',
accountPoints:'0.00'
})
const pageData = reactive({
shopInfo: {},
})
onLoad((opt) => {
Object.assign(options, opt)
getShopInfoData()
})
onShow(() => {
watchEmit()
watchChooseuser()
getOrderDetail()
})
/**
* 获取店铺信息
*/
function getShopInfoData () {
getShopInfo({id:uni.getStorageSync('shopInfo').id}).then(res=>{
pageData.shopInfo = res;
uni.setStorageSync('shopInfo',res)
})
}
/**
* 获取订单详情
*/
async function getOrderDetail () {
let res = await getHistoryOrder({orderId: options.id})
// console.log("订单详情===",res)
if(res.userId){
let resUser = await shopUserDetail({userId:res.userId})
user.value = resUser
}
orderDetail.seatFee = {
seatNum: res.seatNum,
seatAmount: res.seatAmount,
}
orderDetail.goodsList = Object.entries(res.detailMap).map(([key, value]) => ({
info: value,
placeNum: key
}))
orderDetail.goodsList.map(item=>{
item.info.map(item=>{
item.unitPrice = uni.$utils.isGoodsPrice(item,user.value)
})
})
orderDetail.info = res
}
function onSeatFeeTuicai(seatFee) { import go from '@/commons/utils/go.js';
seatFee={...seatFee,num:seatFee.num,productName:seatFee.productName} import infoBox from '@/commons/utils/infoBox.js';
tuicai.show = true import { hasPermission } from '@/commons/utils/hasPermission.js';
tuicai.isSeatFee = seatFee
tuicai.selGoods = seatFee
}
//是否有允许退款权限
async function hasTuiKuan(){
const isHas=await hasPermission('允许退款')
return isHas
}
async function onSeatFeeTuiKuan(seatFee) {
const canTuikuan=await hasTuiKuan()
if(!canTuikuan){
return
}
const {
id,cartId,
productId,
productSkuId,
productName,
num,
priceAmount,
price
} = seatFee
go.to('PAGES_ORDER_TUIKUAN', {
orderId:orderDetail.info.id,
id,
cartId,
productId,
productSkuId,
productName,
num,
number: 0,
skuName: '',
priceAmount,
price
})
}
function onTuiCai(goods, index) { import OrderDetail from './page.js';
tuicai.show = true import { getHistoryOrder, refundOrder, getOrderById, printOrder } from '@/http/api/order.js';
tuicai.selGoods = goods import { shopStaffDetail } from '@/http/api/staff.js';
import { shopUserDetail } from '@/http/api/shopUser.js';
import { getShopInfo } from '@/http/api/shop.js';
const websocketUtil = inject('websocketUtil');
const tuicai = reactive({
show: false,
isSeatFee: false,
selGoods: {}
});
const orderDetail = reactive({
goodsList: [],
info: {},
seatFee: {
totalAmount: 0
} }
async function tuicaiConfirm(e) { });
const res = await refundOrder(e) const options = reactive({});
tuicai.show = false // 监听选择用户事件
if(res){ let user = ref({
go.back() headImg: '',
}else{ phone: '',
getOrderDetail() amount: '0.00',
} accountPoints: '0.00'
});
const pageData = reactive({
shopInfo: {}
});
onShow(() => {
watchEmit();
watchChooseuser();
getOrderDetail();
});
/**
* 获取店铺信息
*/
function getShopInfoData() {
getShopInfo({ id: uni.getStorageSync('shopInfo').id }).then((res) => {
pageData.shopInfo = res;
uni.setStorageSync('shopInfo', res);
});
}
/**
* 获取订单详情
*/
async function getOrderDetail() {
let res = await getHistoryOrder({ orderId: options.id });
console.log('订单详情===', res);
// 初始化socket
// if (res.tableName && res.tableCode) {
// 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 = {
/** seatNum: res.seatNum,
* 打印订单 seatAmount: res.seatAmount
*/ };
function onPrintOrder() {
uni.showModal({ orderDetail.goodsList = Object.entries(res.detailMap).map(([key, value]) => ({
title: '提示', info: value,
content: '是否打印当前台桌菜品', placeNum: key
async success(res) { }));
if (res.confirm) {
try { orderDetail.goodsList.map((item) => {
const res = await printOrder({ item.info.map((item) => {
id: orderDetail.info.id, item.unitPrice = uni.$utils.isGoodsPrice(item, user.value);
type: orderDetail.info.status == 'unpaid' ? 1 : 0 });
});
}) orderDetail.info = res;
infoBox.showToast('已发送打印请求') }
} catch (e) {
infoBox.showToast('发送打印请求失败') function onSeatFeeTuicai(seatFee) {
} seatFee = { ...seatFee, num: seatFee.num, productName: seatFee.productName };
tuicai.show = true;
tuicai.isSeatFee = seatFee;
tuicai.selGoods = seatFee;
}
//是否有允许退款权限
async function hasTuiKuan() {
const isHas = await hasPermission('允许退款');
return isHas;
}
async function onSeatFeeTuiKuan(seatFee) {
const canTuikuan = await hasTuiKuan();
if (!canTuikuan) {
return;
}
const { id, cartId, productId, productSkuId, productName, num, priceAmount, price } = seatFee;
go.to('PAGES_ORDER_TUIKUAN', {
orderId: orderDetail.info.id,
id,
cartId,
productId,
productSkuId,
productName,
num,
number: 0,
skuName: '',
priceAmount,
price
});
}
function onTuiCai(goods, index) {
tuicai.show = true;
tuicai.selGoods = goods;
}
async function tuicaiConfirm(e) {
const res = await refundOrder(e);
tuicai.show = false;
if (res) {
go.back();
} else {
getOrderDetail();
}
}
/**
* 打印订单
*/
function onPrintOrder() {
uni.showModal({
title: '提示',
content: '是否打印当前台桌菜品',
async success(res) {
if (res.confirm) {
try {
const res = await printOrder({
id: orderDetail.info.id,
type: orderDetail.info.status == 'unpaid' ? 1 : 0
});
infoBox.showToast('已发送打印请求');
} catch (e) {
infoBox.showToast('发送打印请求失败');
} }
} }
})
}
async function onTuikuan(goods, index) {
const canTuikuan=await hasTuiKuan()
if(!canTuikuan){
return
} }
if (Array.isArray(goods)) { });
}
go.to('PAGES_ORDER_TUIKUAN', {
orderInfo: JSON.stringify(orderDetail.info), async function onTuikuan(goods, index) {
goodsList:JSON.stringify(goods) const canTuikuan = await hasTuiKuan();
if (!canTuikuan) {
}) return;
} else { }
goods.number = 0 if (Array.isArray(goods)) {
goods.skuName = goods.skuName || '' go.to('PAGES_ORDER_TUIKUAN', {
goods.priceAmount = goods.priceAmount ? goods.priceAmount : (goods.num*uni.$utils.isGoodsPrice(goods,user.value)).toFixed(2) orderInfo: JSON.stringify(orderDetail.info),
console.log(goods) goodsList: JSON.stringify(goods)
goods.unitPrice = uni.$utils.isGoodsPrice(goods,user.value) });
goods.userCouponId = goods.userCouponId ? goods.userCouponId:'' } else {
go.to('PAGES_ORDER_TUIKUAN', { goods.number = 0;
orderInfo: JSON.stringify(orderDetail.info), goods.skuName = goods.skuName || '';
goodsList:JSON.stringify([goods]) goods.priceAmount = goods.priceAmount ? goods.priceAmount : (goods.num * uni.$utils.isGoodsPrice(goods, user.value)).toFixed(2);
}) console.log(goods);
goods.unitPrice = uni.$utils.isGoodsPrice(goods, user.value);
goods.userCouponId = goods.userCouponId ? goods.userCouponId : '';
go.to('PAGES_ORDER_TUIKUAN', {
orderInfo: JSON.stringify(orderDetail.info),
goodsList: JSON.stringify([goods])
});
}
}
const uiPage = new OrderDetail();
setTimeout(() => {
uiPage.setVal('user', {
name: 1
});
}, 1500);
async function diancan() {
const canXiadan = await hasPermission('允许下单');
if (!canXiadan) {
return;
}
clearEmit();
go.to('PAGES_CREATE_ORDER', {
tableId: options.tableId || orderDetail.info.tableId,
tableCode: options.tableCode || orderDetail.info.tableCode,
name: options.name || orderDetail.info.tableName,
type: 'add',
vipUserId: orderDetail.info.userId ? orderDetail.info.userId : ''
});
}
async function toPay() {
const canJieZhang = await hasPermission('允许收款');
if (!canJieZhang) {
return;
}
const userId = orderDetail.info.userId || '';
clearEmit();
go.to('PAGES_ORDER_PAY', {
tableId: options.tableId || orderDetail.info.tableId,
tableCode: options.tableCode || orderDetail.info.tableCode,
tableName: options.name || orderDetail.info.tableName,
orderId: orderDetail.info.id,
discount: 1,
userId
});
}
function watchEmit() {
uni.$off('orderDetail:update');
uni.$once('orderDetail:update', (newval) => {
getOrderDetail();
});
}
//更新选择用户
async function setUser(par) {
const submitPar = {
orderId: options.id || '',
masterId: options.masterId,
tableId: options.tableId || orderDetail.info.tableId,
vipUserId: user.value.id ? user.value.id : '',
type: user.value.id ? 0 : 1 //0 设置 1 取消
};
Object.assign(submitPar, par);
const res = await Api.$setUser(submitPar);
getOrderDetail();
return res;
}
function clearEmit() {
uni.$off('choose-user');
uni.$off('orderDetail:update');
}
function watchChooseuser() {
uni.$off('choose-user');
uni.$on('choose-user', (data) => {
console.log(data);
user.value = data;
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) => {
const uiPage = new OrderDetail() Object.assign(options, opt);
setTimeout(() => { getShopInfoData();
uiPage.setVal('user', { // onMessage();
name: 1 });
})
}, 1500)
async function diancan() {
const canXiadan=await hasPermission('允许下单')
if(!canXiadan){
return
}
clearEmit()
go.to('PAGES_CREATE_ORDER', {
tableId: options.tableId || orderDetail.info.tableId,
tableCode: options.tableCode || orderDetail.info.tableCode,
name: options.name || orderDetail.info.tableName,
type: 'add',
vipUserId: orderDetail.info.userId?orderDetail.info.userId:''
})
}
async function toPay() {
const canJieZhang=await hasPermission('允许收款')
if(!canJieZhang){
return
}
const userId=orderDetail.info.userId||''
clearEmit()
go.to('PAGES_ORDER_PAY', {
tableId: options.tableId|| orderDetail.info.tableId,
tableCode: options.tableCode || orderDetail.info.tableCode,
tableName: options.name || orderDetail.info.tableName,
orderId: orderDetail.info.id,
discount: 1,
userId
})
}
function watchEmit() {
uni.$off('orderDetail:update')
uni.$once('orderDetail:update', (newval) => {
getOrderDetail()
})
}
//更新选择用户
async function setUser(par) {
const submitPar = {
orderId:options.id||'',
masterId: options.masterId,
tableId: options.tableId|| orderDetail.info.tableId,
vipUserId: user.value.id ? user.value.id : '',
type: user.value.id ? 0 : 1 //0 设置 1 取消
}
Object.assign(submitPar, par)
const res=await Api.$setUser(submitPar)
getOrderDetail()
return res
}
function clearEmit(){
uni.$off('choose-user')
uni.$off('orderDetail:update')
}
function watchChooseuser() {
uni.$off('choose-user')
uni.$on('choose-user', (data) => {
console.log(data);
user.value = data
setUser()
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.bottom { .bottom {
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
height: 68rpx; height: 68rpx;
.u-abso { .u-abso {
bottom: 84rpx; bottom: 84rpx;
left: 28rpx; left: 28rpx;
right: 28rpx; right: 28rpx;
}
} }
</style> }
</style>

File diff suppressed because it is too large Load Diff