|
@@ -113,9 +113,7 @@
|
|
|
</div></el-scrollbar
|
|
|
>
|
|
|
</div>
|
|
|
- <div
|
|
|
- class="p-2 md:w-1/2 w-full md:h-full h-auto float-left flex-wrap"
|
|
|
- >
|
|
|
+ <div class="p-2 md:w-1/2 w-full md:h-full h-auto float-left flex-wrap">
|
|
|
<div class="w-full h-auto">
|
|
|
<div class="justify-end flex">
|
|
|
<el-input
|
|
@@ -126,16 +124,31 @@
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="w-full md:h-5/6 h-auto inline-block" style="height: calc(100% - 40px);">
|
|
|
+ <div class="w-full md:h-5/6 h-auto inline-block" style="height: calc(100% - 40px)">
|
|
|
<!-- 菜单内容 -->
|
|
|
<el-scrollbar height="100%">
|
|
|
<div
|
|
|
v-for="item in dishList"
|
|
|
:key="item.id"
|
|
|
class="float-left md:w-40 w-1/2 md:h-38 h-auto p-1"
|
|
|
+ style="user-select: none"
|
|
|
>
|
|
|
- <a href="javascript:void(0);" @click="addGoods(item)"
|
|
|
- ><el-card shadow="never" :body-style="{ padding: '0px' }">
|
|
|
+ <a
|
|
|
+ href="javascript:void(0);"
|
|
|
+ @click="addGoods(item)"
|
|
|
+ :class="{ 'pointer-events-none': item.isShow == 0 }"
|
|
|
+ ><el-card
|
|
|
+ shadow="never"
|
|
|
+ :body-style="{ padding: '0px' }"
|
|
|
+ :class="{ relative: item.isShow == 0 }"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ v-if="item.isShow == 0"
|
|
|
+ class="absolute inset-0 bg-white z-10 pointer-events-none flex items-center justify-center select-none"
|
|
|
+ style="opacity: 0.5; color: red; font-size: 25px"
|
|
|
+ >
|
|
|
+ <span class="text-gray-600 font-medium">已售罄</span>
|
|
|
+ </div>
|
|
|
<el-image
|
|
|
style="width: 100%; height: 100px"
|
|
|
:src="item.image"
|
|
@@ -157,19 +170,36 @@
|
|
|
<div class="flex items-center px-4 space-x-5">
|
|
|
<div class="relative mr-auto">
|
|
|
<el-badge :value="orderData.sumNumSum" :max="99" class="mr-3">
|
|
|
- <el-icon size="50" style="width: 32px; height: 32px; font-size: 32px"><ShoppingCart /></el-icon>
|
|
|
+ <el-icon size="50" style="width: 32px; height: 32px; font-size: 32px"
|
|
|
+ ><ShoppingCart
|
|
|
+ /></el-icon>
|
|
|
</el-badge>
|
|
|
- <span class="ml-5 text-base">合计: ¥{{ orderData.sumPriceSum.toFixed(2) }}</span>
|
|
|
+ <span class="ml-5 text-base"
|
|
|
+ >合计: ¥{{ orderData.sumPriceSum.toFixed(2) }}</span
|
|
|
+ >
|
|
|
</div>
|
|
|
- <el-button type="primary" class="action-btn !w-[50px] !h-[40px]" @click="toEmpty()"
|
|
|
- :disabled="data.selectGoods.length > 0 && data.selectGoods.every(good => good.status === 1)"
|
|
|
- >清空</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ class="action-btn !w-[50px] !h-[40px]"
|
|
|
+ @click="toEmpty()"
|
|
|
+ :disabled="data.selectGoods.length <= 0"
|
|
|
+ >清空</el-button
|
|
|
+ >
|
|
|
<el-badge :value="params.couponId ? 1 : ''" :hidden="!params.couponId">
|
|
|
- <el-button type="primary" class="action-btn !w-[200px] !h-[40px]" @click="showCouponDialog = true">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ class="action-btn !w-[200px] !h-[40px]"
|
|
|
+ @click="showCouponDialog = true"
|
|
|
+ >
|
|
|
优惠 {{ params.couponAmount !== '-' ? `¥${params.couponAmount}` : '' }}
|
|
|
</el-button>
|
|
|
</el-badge>
|
|
|
- <el-button type="danger" class="submit-btn !w-[300px] !h-[40px]" @click="submit()">去结算 ¥{{ orderData.payAmount }}</el-button>
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ class="submit-btn !w-[300px] !h-[40px]"
|
|
|
+ @click="submit()"
|
|
|
+ >去结算 ¥{{ orderData.payAmount }}</el-button
|
|
|
+ >
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-drawer>
|
|
@@ -277,48 +307,63 @@
|
|
|
</div>
|
|
|
<template #footer>
|
|
|
<span class="dialog-footer">
|
|
|
- <el-button type="primary" @click="showCouponDialog = false">确认</el-button>
|
|
|
+ <el-button type="primary" @click="ticketConfirm">确认</el-button>
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
<el-dialog
|
|
|
- v-model="scanDialogVisible"
|
|
|
- title="请使用扫码枪扫码支付"
|
|
|
- width="300px"
|
|
|
- center
|
|
|
- :show-close="false"
|
|
|
- :close-on-click-modal="false"
|
|
|
- :close-on-press-escape="false"
|
|
|
- >
|
|
|
- <div class="text-center">
|
|
|
- <img
|
|
|
- src="@/assets/images/scan.gif"
|
|
|
- alt="扫码"
|
|
|
- class="mx-auto mb-4"
|
|
|
- style="width: 150px"
|
|
|
- />
|
|
|
+ v-model="scanDialogVisible"
|
|
|
+ title="请引导顾客扫码支付"
|
|
|
+ width="300px"
|
|
|
+ center
|
|
|
+ :show-close="false"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ >
|
|
|
+ <div class="text-center">
|
|
|
+ <img
|
|
|
+ src="@/assets/images/scan.gif"
|
|
|
+ alt="扫码"
|
|
|
+ class="mx-auto mb-4"
|
|
|
+ style="width: 150px"
|
|
|
+ />
|
|
|
+ <b style="font-size: 20px">金额 {{ orderData.payAmount }} 元</b>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button @click="scanDialogVisible = false">取消支付</el-button>
|
|
|
</div>
|
|
|
- <template #footer>
|
|
|
- <div class="dialog-footer">
|
|
|
- <el-button @click="scanDialogVisible = false">取消支付</el-button>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
- <el-dialog
|
|
|
- v-model="payingDialogVisible"
|
|
|
- title="支付处理中"
|
|
|
- width="300px"
|
|
|
- :show-close="false"
|
|
|
- :close-on-click-modal="false"
|
|
|
- :close-on-press-escape="false"
|
|
|
- >
|
|
|
- <div class="flex flex-col items-center justify-center py-4">
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ v-model="payingDialogVisible"
|
|
|
+ title="支付处理中"
|
|
|
+ width="300px"
|
|
|
+ :show-close="false"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ >
|
|
|
+ <div class="flex flex-col items-center justify-center py-4">
|
|
|
<el-icon class="is-loading mb-4" :size="32">
|
|
|
<Loading />
|
|
|
</el-icon>
|
|
|
<p class="text-gray-600">正在支付中,请不要关闭或退出界面</p>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ v-model="takeNumberDialogVisible"
|
|
|
+ title="取餐号"
|
|
|
+ width="30%"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ >
|
|
|
+ <el-input v-model="takeNumber" placeholder="请输入取餐号" maxlength="10" show-word-limit />
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="takeNumberDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="confirmSubmit">确认结算</el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
@@ -384,6 +429,9 @@ const params = reactive({
|
|
|
couponAmount: '-',
|
|
|
diningMethods: 1 // 就餐方式:1店内就餐 2打包外带
|
|
|
})
|
|
|
+// 添加取餐号相关的变量
|
|
|
+const takeNumberDialogVisible = ref(false)
|
|
|
+const takeNumber = ref('')
|
|
|
const submit = () => {
|
|
|
//出单
|
|
|
if (data.selectGoods.length == 0) {
|
|
@@ -394,92 +442,124 @@ const submit = () => {
|
|
|
feedback.alert('支付金额需大于0!')
|
|
|
return false
|
|
|
}
|
|
|
+ // 显示取餐号输入弹框
|
|
|
+ takeNumberDialogVisible.value = true
|
|
|
+}
|
|
|
+// 添加确认提交函数
|
|
|
+const confirmSubmit = () => {
|
|
|
+ if (!takeNumber.value) {
|
|
|
+ feedback.msgError('请输入取餐号')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ takeNumberDialogVisible.value = false
|
|
|
feedback.loading('正在出单...')
|
|
|
orderSubmit({
|
|
|
...params,
|
|
|
userId: params.userId || null,
|
|
|
- couponId: params.couponId || null
|
|
|
- }).then(() => {
|
|
|
- // data.selectGoods.length = 0
|
|
|
- // orderData.priceSum = 0
|
|
|
- // orderData.numSum = 0
|
|
|
- //把所有餐品的状态修改为出单
|
|
|
- data.selectGoods.forEach((good: { status: number }) => {
|
|
|
- good.status = 1
|
|
|
- })
|
|
|
- // emit('init')
|
|
|
- feedback.closeLoading()
|
|
|
- // feedback.notifySuccess('出单成功')
|
|
|
- checkout()
|
|
|
+ couponId: params.couponId || null,
|
|
|
+ mealCode: takeNumber.value
|
|
|
})
|
|
|
-}
|
|
|
+ .then(() => {
|
|
|
+ // data.selectGoods.length = 0
|
|
|
+ // orderData.priceSum = 0
|
|
|
+ // orderData.numSum = 0
|
|
|
+ //把所有餐品的状态修改为出单
|
|
|
+ data.selectGoods.forEach((good: { status: number }) => {
|
|
|
+ good.status = 1
|
|
|
+ })
|
|
|
+ // emit('init')
|
|
|
+ feedback.closeLoading()
|
|
|
+ // feedback.notifySuccess('出单成功')
|
|
|
+ checkout()
|
|
|
+ }).catch((e)=>{
|
|
|
+ if (e.msg === "券不存在" || e.msg === "券不存在或已过期") {
|
|
|
+ params.couponId = null
|
|
|
+ params.couponAmount = '-'
|
|
|
+ // 计算支付金额
|
|
|
+ orderData.payAmount = Number(orderData.sumPriceSum).toFixed(2)
|
|
|
+ searchUserCoupons()
|
|
|
+ }
|
|
|
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ feedback.closeLoading()
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
// 添加扫码事件监听函数
|
|
|
const handleScanInput = (event: KeyboardEvent) => {
|
|
|
- if (event.key === 'Enter') {
|
|
|
- const code = scanCode.value
|
|
|
- console.log('扫码内容:', code)
|
|
|
- if (!data.canScan) {
|
|
|
- feedback.notifyWarning('正在处理支付,请勿重复扫码')
|
|
|
- return
|
|
|
- }
|
|
|
- data.canScan = false
|
|
|
- payingDialogVisible.value = true // 显示支付中对话框
|
|
|
|
|
|
- document.removeEventListener('keydown', handleScanInput)
|
|
|
- // 修改支付处理逻辑
|
|
|
- orderPay({ oid: params.number, code: code })
|
|
|
- .then((res) => {
|
|
|
- console.log(res)
|
|
|
- // 实际上支付成功之后,res返回的是[],如果不是实时成功,返回的是个对象, 形如:{orderId: '123456789', sn: '7895004131583689'}
|
|
|
- if (res == null || res.length == 0) {
|
|
|
- feedback.notifySuccess('成功结账' + orderData.payAmount + '元')
|
|
|
- scanDialogVisible.value = false
|
|
|
- payingDialogVisible.value = false // 隐藏支付中对话框
|
|
|
- showOrderConsole.value = false
|
|
|
- emit('init')
|
|
|
- } else {
|
|
|
- console.log('支付中')
|
|
|
- return queryPayStatusWithRetry(res)
|
|
|
- .then((paySuccess) => {
|
|
|
- if (paySuccess) {
|
|
|
- feedback.notifySuccess('成功结账' + orderData.payAmount + '元')
|
|
|
- scanDialogVisible.value = false
|
|
|
- showOrderConsole.value = false
|
|
|
- emit('init')
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- // 支付失败
|
|
|
+ console.log("event.key", event.key)
|
|
|
+ if (event.key === 'Enter') {
|
|
|
+ document.removeEventListener('keydown', handleScanInput)
|
|
|
+ if (!data.canScan) {
|
|
|
+ feedback.notifyWarning('正在处理支付,请勿重复扫码')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const code = scanCode.value
|
|
|
+ console.log('扫码内容:', code)
|
|
|
+ payingDialogVisible.value = true // 显示支付中对话框
|
|
|
+
|
|
|
+ // 修改支付处理逻辑
|
|
|
+ orderPay({ oid: params.number, code: code })
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res)
|
|
|
+ // 实际上支付成功之后,res返回的是[],如果不是实时成功,返回的是个对象, 形如:{orderId: '123456789', sn: '7895004131583689'}
|
|
|
+ if (res == null || res.length == 0) {
|
|
|
+ feedback.notifySuccess('成功结账' + orderData.payAmount + '元')
|
|
|
+ scanDialogVisible.value = false
|
|
|
payingDialogVisible.value = false // 隐藏支付中对话框
|
|
|
- feedback.confirm('支付失败,请重试').then(() => {
|
|
|
- data.canScan = true
|
|
|
- scanDialogVisible.value = true
|
|
|
- // 添加键盘事件监听
|
|
|
- document.addEventListener('keydown', handleScanInput)
|
|
|
- })
|
|
|
+ showOrderConsole.value = false
|
|
|
+ emit('init')
|
|
|
+ } else {
|
|
|
+ console.log('支付中')
|
|
|
+ return queryPayStatusWithRetry(res)
|
|
|
+ .then((paySuccess) => {
|
|
|
+ if (paySuccess) {
|
|
|
+ feedback.notifySuccess('成功结账' + orderData.payAmount + '元')
|
|
|
+ scanDialogVisible.value = false
|
|
|
+ payingDialogVisible.value = false // 隐藏支付中对话框
|
|
|
+ showOrderConsole.value = false
|
|
|
+ emit('init')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ console.log("=====---", e)
|
|
|
+ // 支付失败
|
|
|
+ payingDialogVisible.value = false // 隐藏支付中对话框
|
|
|
+ feedback.notifySuccess('支付失败,请重试')
|
|
|
+ data.canScan = true
|
|
|
+ scanDialogVisible.value = true
|
|
|
+ // 添加键盘事件监听
|
|
|
+ setTimeout(()=>{
|
|
|
+ scanCode.value = ''
|
|
|
+ document.removeEventListener('keydown', handleScanInput)
|
|
|
+ document.addEventListener('keydown', handleScanInput)
|
|
|
+ }, 2000)
|
|
|
})
|
|
|
- scanCode.value = ''
|
|
|
- } else {
|
|
|
- scanCode.value += event.key
|
|
|
- }
|
|
|
+ scanCode.value = ''
|
|
|
+ } else {
|
|
|
+ scanCode.value += event.key
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 定义查询支付状态的函数
|
|
|
const queryPayStatusWithRetry = (data): Promise<boolean> => {
|
|
|
- const intervals = [3000, 5000, 10000]
|
|
|
+ const intervals = [3000, 5000, 10000, 10000, 10000, 10000, 10000]
|
|
|
let currentIndex = 0
|
|
|
payingDialogVisible.value = true
|
|
|
|
|
|
const tryQuery = () => {
|
|
|
return new Promise<boolean>((resolve) => {
|
|
|
setTimeout(() => {
|
|
|
- queryPayStatus({ orderId: data.orderId,sn: data.sn })
|
|
|
+ queryPayStatus({ orderId: data.orderId, sn: data.sn })
|
|
|
.then((result) => {
|
|
|
- if (result.result_code == '200' && result.biz_response.data.order_status == 'SUCCESS') {
|
|
|
+ if (
|
|
|
+ result.result_code == '200' &&
|
|
|
+ result.biz_response.data.order_status == 'SUCCESS'
|
|
|
+ ) {
|
|
|
resolve(true)
|
|
|
} else if (currentIndex < intervals.length - 1) {
|
|
|
currentIndex++
|
|
@@ -503,7 +583,7 @@ const queryPayStatusWithRetry = (data): Promise<boolean> => {
|
|
|
return tryQuery().then((success) => {
|
|
|
payingDialogVisible.value = false
|
|
|
if (!success) {
|
|
|
- return cancelOrder({ orderId: data.orderId,sn: data.sn })
|
|
|
+ return cancelOrder({ orderId: data.orderId, sn: data.sn })
|
|
|
.then(() => {
|
|
|
feedback.notifyWarning('支付超时,已自动撤销本次支付')
|
|
|
return false
|
|
@@ -518,6 +598,17 @@ const queryPayStatusWithRetry = (data): Promise<boolean> => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+const ticketConfirm = () => {
|
|
|
+ if (data.phone == '') {
|
|
|
+ params.couponId = null
|
|
|
+ params.couponAmount = '-'
|
|
|
+ params.userId = null
|
|
|
+ // 计算支付金额
|
|
|
+ orderData.payAmount = Number(orderData.sumPriceSum).toFixed(2)
|
|
|
+ }
|
|
|
+ showCouponDialog.value = false
|
|
|
+}
|
|
|
+
|
|
|
const checkout = () => {
|
|
|
refreshdishes()
|
|
|
//结账
|
|
@@ -526,16 +617,20 @@ const checkout = () => {
|
|
|
// feedback.notify('请点击商品开始点单吧!')
|
|
|
// return false
|
|
|
// }
|
|
|
- feedback.confirm('结账金额为' + orderData.payAmount + ',确定要结账吗?').then(() => {
|
|
|
- data.canScan = true
|
|
|
- scanDialogVisible.value = true
|
|
|
- // 添加键盘事件监听
|
|
|
- document.addEventListener('keydown', handleScanInput)
|
|
|
- })
|
|
|
+ // feedback.confirm('结账金额为' + orderData.payAmount + ',确定要结账吗?').then(() => {
|
|
|
+
|
|
|
+ scanCode.value = ''
|
|
|
+ data.canScan = true
|
|
|
+ scanDialogVisible.value = true
|
|
|
+ // 添加键盘事件监听
|
|
|
+
|
|
|
+ document.removeEventListener('keydown', handleScanInput)
|
|
|
+ document.addEventListener('keydown', handleScanInput)
|
|
|
+ // })
|
|
|
}
|
|
|
// 添加优惠券点击处理方法
|
|
|
const handleCouponClick = (coupon: any) => {
|
|
|
- if (orderData.sumPriceSum < coupon.consumeScore / 100) {
|
|
|
+ if (orderData.sumPriceSum <= coupon.consumeScore / 100) {
|
|
|
return
|
|
|
}
|
|
|
if (params.couponId === coupon.ticketRecordId) {
|
|
@@ -561,6 +656,7 @@ const open = (item: any, num?: number, orderNumber?: any) => {
|
|
|
params.number = item.ordersId ? item.ordersId : orderNumber
|
|
|
params.userId = ''
|
|
|
params.couponId = ''
|
|
|
+ takeNumber.value = ''
|
|
|
//查询当前订单下的所有菜品
|
|
|
deskOrderedDishListAll({ id: params.number }).then((res) => {
|
|
|
res.forEach((good: { id: number; ordersDishId: number }) => {
|
|
@@ -575,6 +671,7 @@ const open = (item: any, num?: number, orderNumber?: any) => {
|
|
|
params.userId = res[0].userId || null
|
|
|
params.couponId = res[0].ticketId || null
|
|
|
params.diningMethods = res[0].diningMethods || 1
|
|
|
+ takeNumber.value = res[0].mealCode || ''
|
|
|
if (params.couponId && params.userId) {
|
|
|
searchUserCoupons()
|
|
|
}
|
|
@@ -604,8 +701,9 @@ const open = (item: any, num?: number, orderNumber?: any) => {
|
|
|
0
|
|
|
)
|
|
|
orderData.payAmount = Number(
|
|
|
- orderData.sumPriceSum - (params.couponAmount === '-' ? 0 : Number(params.couponAmount))
|
|
|
- ).toFixed(2)
|
|
|
+ orderData.sumPriceSum -
|
|
|
+ (params.couponAmount === '-' ? 0 : Number(params.couponAmount))
|
|
|
+ ).toFixed(2)
|
|
|
} else {
|
|
|
orderData.priceSum = 0
|
|
|
orderData.numSum = 0
|
|
@@ -625,52 +723,58 @@ const open = (item: any, num?: number, orderNumber?: any) => {
|
|
|
|
|
|
const refreshdishes = async () => {
|
|
|
orderLoading.value = true
|
|
|
- await deskOrderedDishListAll({ id: params.number }).then((res) => {
|
|
|
- res.forEach((good: { id: number; ordersDishId: number }) => {
|
|
|
- good.ordersDishId = good.id
|
|
|
+ await deskOrderedDishListAll({ id: params.number })
|
|
|
+ .then((res) => {
|
|
|
+ res.forEach((good: { id: number; ordersDishId: number }) => {
|
|
|
+ good.ordersDishId = good.id
|
|
|
+ })
|
|
|
+ console.log('***refreshdishes***', res)
|
|
|
+ data.selectGoods = res
|
|
|
+ console.log('***res.length***', res.length)
|
|
|
+ if (res.length > 0) {
|
|
|
+ // const _list = res.filter((it: { status: number }) => it.status != 1) //找到没有出单的餐品来计算价格
|
|
|
+ const _list = res
|
|
|
+ orderData.priceSum = _list.reduce(
|
|
|
+ (accumulator: number, currentValue: { summary: number; num: number }) =>
|
|
|
+ accumulator + currentValue.summary * currentValue.num,
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ orderData.numSum = _list.reduce(
|
|
|
+ (accumulator: number, currentValue: { summary: number; num: number }) =>
|
|
|
+ accumulator + currentValue.num,
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ //所有餐品的总价以及总数量
|
|
|
+ orderData.sumPriceSum = res.reduce(
|
|
|
+ (accumulator: number, currentValue: { summary: number; num: number }) =>
|
|
|
+ accumulator + currentValue.summary * currentValue.num,
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ orderData.sumNumSum = res.reduce(
|
|
|
+ (accumulator: number, currentValue: { summary: number; num: number }) =>
|
|
|
+ accumulator + currentValue.num,
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ console.log(
|
|
|
+ '***res[0].payAmount***',
|
|
|
+ res[0].payAmount,
|
|
|
+ Number(res[0].payAmount / 100).toFixed(2)
|
|
|
+ )
|
|
|
+ orderData.payAmount = res[0].payAmount
|
|
|
+ ? Number(res[0].payAmount / 100).toFixed(2)
|
|
|
+ : Number(orderData.sumPriceSum).toFixed(2)
|
|
|
+ console.log('***orderData***', orderData)
|
|
|
+ } else {
|
|
|
+ orderData.priceSum = 0
|
|
|
+ orderData.numSum = 0
|
|
|
+ orderData.sumPriceSum = 0
|
|
|
+ orderData.sumNumSum = 0
|
|
|
+ orderData.payAmount = 0
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ orderLoading.value = false
|
|
|
})
|
|
|
- console.log('***refreshdishes***', res)
|
|
|
- data.selectGoods = res
|
|
|
- console.log('***res.length***', res.length)
|
|
|
- if (res.length > 0) {
|
|
|
- // const _list = res.filter((it: { status: number }) => it.status != 1) //找到没有出单的餐品来计算价格
|
|
|
- const _list = res
|
|
|
- orderData.priceSum = _list.reduce(
|
|
|
- (accumulator: number, currentValue: { summary: number; num: number }) =>
|
|
|
- accumulator + currentValue.summary * currentValue.num,
|
|
|
- 0
|
|
|
- )
|
|
|
- orderData.numSum = _list.reduce(
|
|
|
- (accumulator: number, currentValue: { summary: number; num: number }) =>
|
|
|
- accumulator + currentValue.num,
|
|
|
- 0
|
|
|
- )
|
|
|
- //所有餐品的总价以及总数量
|
|
|
- orderData.sumPriceSum = res.reduce(
|
|
|
- (accumulator: number, currentValue: { summary: number; num: number }) =>
|
|
|
- accumulator + currentValue.summary * currentValue.num,
|
|
|
- 0
|
|
|
- )
|
|
|
- orderData.sumNumSum = res.reduce(
|
|
|
- (accumulator: number, currentValue: { summary: number; num: number }) =>
|
|
|
- accumulator + currentValue.num,
|
|
|
- 0
|
|
|
- )
|
|
|
- console.log('***res[0].payAmount***', res[0].payAmount, Number(res[0].payAmount / 100).toFixed(2))
|
|
|
- orderData.payAmount = res[0].payAmount
|
|
|
- ? Number(res[0].payAmount / 100).toFixed(2)
|
|
|
- : Number(orderData.sumPriceSum).toFixed(2)
|
|
|
- console.log('***orderData***', orderData)
|
|
|
- } else {
|
|
|
- orderData.priceSum = 0
|
|
|
- orderData.numSum = 0
|
|
|
- orderData.sumPriceSum = 0
|
|
|
- orderData.sumNumSum = 0
|
|
|
- orderData.payAmount = 0
|
|
|
- }
|
|
|
- }).finally(() => {
|
|
|
- orderLoading.value = false
|
|
|
- })
|
|
|
}
|
|
|
watch(search, (value) => {
|
|
|
if (!value) {
|
|
@@ -706,13 +810,10 @@ const clickSortButton = (name: any) => {
|
|
|
//清空订单下的菜品
|
|
|
const toEmpty = () => {
|
|
|
if (data.selectGoods.length != 0) {
|
|
|
- orderLoading.value = true
|
|
|
- toEmptyy({ id: params.number }).finally(()=>{
|
|
|
-
|
|
|
+ orderLoading.value = true
|
|
|
+ toEmptyy({ id: params.number }).finally(() => {
|
|
|
//清空未出单的餐品-保留出单餐品
|
|
|
- data.selectGoods = data.selectGoods.filter((good: { status: number }) => {
|
|
|
- return good.status == 1
|
|
|
- })
|
|
|
+ data.selectGoods = []
|
|
|
orderData.sumPriceSum = data.selectGoods.reduce(
|
|
|
(accumulator: number, currentValue: { summary: number; num: number }) =>
|
|
|
accumulator + currentValue.summary * currentValue.num,
|
|
@@ -736,10 +837,11 @@ const toEmpty = () => {
|
|
|
params.couponAmount = '-'
|
|
|
orderData.payAmount = orderData.sumPriceSum
|
|
|
}
|
|
|
- orderData.payAmount = Number(
|
|
|
- orderData.sumPriceSum - (params.couponAmount === '-' ? 0 : Number(params.couponAmount))
|
|
|
- ).toFixed(2)
|
|
|
- orderLoading.value = false
|
|
|
+ orderData.payAmount = Number(
|
|
|
+ orderData.sumPriceSum -
|
|
|
+ (params.couponAmount === '-' ? 0 : Number(params.couponAmount))
|
|
|
+ ).toFixed(2)
|
|
|
+ orderLoading.value = false
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -1056,7 +1158,7 @@ defineExpose({
|
|
|
}
|
|
|
|
|
|
:deep(.el-divider--horizontal) {
|
|
|
- margin: 8px 0;
|
|
|
+ margin: 8px 0;
|
|
|
}
|
|
|
|
|
|
.cate-buttons :deep(.el-button) {
|