This commit is contained in:
duan
2025-09-29 10:42:48 +08:00
parent 89db955ec1
commit 096f591123
80 changed files with 8735 additions and 3286 deletions

View File

@@ -1,19 +1,11 @@
<template>
<view class="min-page bg-gray u-font-28 u-p-30">
<user-vue :orderInfo="orderDetail.info" :user="user"></user-vue>
<!-- <view class="default-box-padding bg-fff border-r-12 u-m-t-32">
<text class="">桌位号</text>
<text class="">{{orderDetail.info.tableName}}</text>
</view> -->
<goods-list @printOrder="onPrintOrder" @tuikuan="onTuikuan" :orderInfo="orderDetail.info"
:user="user"
:data="orderDetail.goodsList" :seatFee="orderDetail.seatFee" @tuicai="onTuiCai"></goods-list>
<!-- <template v-if="orderDetail.seatFee.totalNumber&&orderDetail.seatFee.totalAmount"> -->
<!-- <view class="default-box-padding bg-fff border-r-12 u-m-t-20 u-flex u-row-between" v-if="orderDetail.info.discountAmount>0">
<view>服务员改价</view>
<view class="color-red">-{{orderDetail.info.discountAmount}}</view>
</view> -->
<template v-if="true">
<extra-vue @tuicai="onSeatFeeTuicai" @tuikuan="onSeatFeeTuiKuan" :orderInfo="orderDetail.info"
:data="orderDetail.seatFee"></extra-vue>
@@ -23,7 +15,7 @@
<view style="height: 200rpx;"></view>
<view class="u-fixed bottom bg-fff ">
<view class="u-flex u-abso">
<template v-if="orderDetail.info.useType=='takeout'||!orderDetail.info.tableId||orderDetail.info.useType=='dine-in-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'">
<my-button @tap="toPay" borderRadius="100rpx" shape="circle"
type="primary">结账</my-button>
@@ -49,40 +41,98 @@
</template>
<script setup>
import * as Api from '@/http/yskApi/Instead.js'
import * as orderApi from '@/http/yskApi/order.js'
import {queryAllShopUser} from '@/http/yskApi/shop-user.js'
import {
objToArrary
} from '@/commons/utils/returrn-data.js'
import { onLoad, onShow } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import userVue from './components/user.vue';
import orderVue from './components/order.vue';
import goodsList from './components/list.vue';
import stepVue from './components/step.vue';
import extraVue from './components/extra.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 {
onLoad,
onShow,
onHide
} from '@dcloudio/uni-app';
import {
reactive,
ref
} from 'vue';
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 {data:res} = await getHistoryOrder({orderId: options.id})
// console.log("订单详情===",res)
if(res.userId){
let {data: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) {
seatFee={...seatFee,num:seatFee.num,productName:seatFee.productName}
console.log(seatFee);
tuicai.show = true
tuicai.isSeatFee = seatFee
tuicai.selGoods = seatFee
@@ -90,11 +140,11 @@
//是否有允许退款权限
async function hasTuiKuan(){
const isHas=await hasPermission('允许退款')
console.log(isHas,'11111111');
return isHas
}
async function onSeatFeeTuiKuan(seatFee) {
console.log(seatFee);
const canTuikuan=await hasTuiKuan()
if(!canTuikuan){
return
@@ -117,49 +167,45 @@
productName,
num,
number: 0,
productSkuName: '',
skuName: '',
priceAmount,
price
})
}
function onTuiCai(goods, index) {
console.log(goods);
tuicai.show = true
tuicai.selGoods = goods
}
async function tuicaiConfirm(e) {
console.log(tuicai.selGoods);
const res = await Api.$returnCart({
...e,
cartId: tuicai.selGoods.hasOwnProperty('cartId') ? tuicai.selGoods.cartId : tuicai.selGoods.id,
tableId: orderDetail.info.tableId,
})
const res = await refundOrder(e)
tuicai.show = false
init()
}
async function printDishes() {
try {
const res = await Api.$printDishes({
tableId: orderDetail.info.tableId
})
infoBox.showToast('已发送打印请求')
} catch (e) {
infoBox.showToast('发送打印请求失败')
//TODO handle the exception
if(res){
go.back()
}else{
getOrderDetail()
}
}
/**
* 打印订单
*/
function onPrintOrder() {
uni.showModal({
title: '提示',
content: '是否打印当前台桌菜品',
success(res) {
async success(res) {
if (res.confirm) {
printDishes()
try {
const res = await printOrder({
id: orderDetail.info.id,
type: orderDetail.info.status == 'unpaid' ? 1 : 0
})
infoBox.showToast('已发送打印请求')
} catch (e) {
infoBox.showToast('发送打印请求失败')
}
}
}
})
@@ -171,34 +217,25 @@
if(!canTuikuan){
return
}
console.log(goods);
const {
id,
productId,
productSkuId,
productName,
productSkuName,
cartId,
orderId,
num,
priceAmount,
price,userCouponId
} = goods
go.to('PAGES_ORDER_TUIKUAN', {
id,
cartId,
orderId,
productId,
productSkuId,
productName,
num,
number: 0,
productSkuName: productSkuName || '',
priceAmount:priceAmount?priceAmount:(num*price).toFixed(2),
price,
userCouponId:userCouponId?userCouponId:''
})
if (Array.isArray(goods)) {
go.to('PAGES_ORDER_TUIKUAN', {
orderInfo: JSON.stringify(orderDetail.info),
goodsList:JSON.stringify(goods)
})
} else {
goods.number = 0
goods.skuName = goods.skuName || ''
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])
})
}
}
@@ -217,9 +254,10 @@
clearEmit()
go.to('PAGES_CREATE_ORDER', {
tableId: options.tableId || orderDetail.info.tableId,
tableCode: options.tableCode || orderDetail.info.tableCode,
name: options.name || orderDetail.info.tableName,
masterId:orderDetail.info.masterId,
type: 'add'
type: 'add',
vipUserId: orderDetail.info.userId?orderDetail.info.userId:''
})
}
@@ -228,102 +266,27 @@
if(!canJieZhang){
return
}
const memberId=orderDetail.info.memberId||''
const userId=orderDetail.info.userId||''
clearEmit()
go.to('PAGES_ORDER_PAY', {
tableId: options.tableId|| orderDetail.info.tableId,
tableName: options.name,
masterId: options.masterId,
tableCode: options.tableCode || orderDetail.info.tableCode,
tableName: options.name || orderDetail.info.tableName,
orderId: orderDetail.info.id,
discount: 1,
memberId
userId
})
}
const orderDetail = reactive({
goodsList: [],
info: {},
seatFee: {
totalAmount: 0
}
})
const options = reactive({})
async function init() {
const res = await orderApi.tbOrderInfoDetail(options.id)
if(res.memberId){
queryAllShopUser({id:res.memberId}).then(res=>{
if(res.content[0]){
user.value=res.content[0]
}
})
}
if (res.detailList.length) {
uni.setStorageSync('useType', res.detailList[0].useType)
}
const masterId = res.masterId
options.masterId = res.masterId
// if (res.status == 'unpaid') {
if (false) {
const {
records,
seatFee
} = await Api.getCart({
masterId,
tableId: res.tableId,
page: 1,
size: 200
})
orderDetail.goodsList = records
orderDetail.seatFee = seatFee ? seatFee : orderDetail.seatFee
} else {
const goodsMap = {}
for (let i in res.detailList) {
const goods = res.detailList[i]
if (goods.productName != '客座费') {
if (goodsMap.hasOwnProperty(goods.placeNum)) {
goodsMap[goods.placeNum].push(goods)
} else {
goodsMap[goods.placeNum] = [goods]
}
}
}
console.log(res.seatInfo);
orderDetail.seatFee = res.seatInfo|| {
// name: '客座费',
// number: res.seatCount,
// num: res.seatCount,
// totalNumber: res.seatCount,
// priceAmount: res.seatAmount,
// status:'',
totalNumber:0,
}
orderDetail.goodsList = Object.entries(goodsMap).map(([key, value]) => ({
info: value,
placeNum: key
}))
console.log(orderDetail.goodsList);
}
orderDetail.info = res
}
function watchEmit() {
uni.$off('orderDetail:update')
uni.$once('orderDetail:update', (newval) => {
console.log(newval);
init()
getOrderDetail()
})
}
// 监听选择用户事件
let user = ref({
headImg:'',
telephone:'',
amount:'0.00',
accountPoints:'0.00'
})
//更新选择用户
async function setUser(par) {
const submitPar = {
@@ -335,7 +298,7 @@
}
Object.assign(submitPar, par)
const res=await Api.$setUser(submitPar)
init()
getOrderDetail()
return res
}
@@ -354,15 +317,7 @@
})
}
onShow(() => {
watchEmit()
watchChooseuser()
init()
})
onLoad((opt) => {
Object.assign(options, opt)
console.log(options);
})
</script>
<style lang="scss" scoped>