Ver código fonte

结账改成只在点餐页面

licc 4 semanas atrás
pai
commit
f4303de326
2 arquivos alterados com 331 adições e 279 exclusões
  1. 230 198
      src/views/order/console.vue
  2. 101 81
      src/views/order/index.vue

+ 230 - 198
src/views/order/console.vue

@@ -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,21 +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;"
+                            style="user-select: none"
                         >
-                            <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>
+                            <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"
@@ -162,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>
@@ -287,63 +312,58 @@
         </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"
-                />
-              <b style="font-size: 20px;">{{ orderData.payAmount }} 元</b>
+        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>
-        <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>
+        </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">
@@ -438,76 +458,78 @@ const confirmSubmit = () => {
         userId: params.userId || null,
         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()
-    }).finally(()=>{
-      feedback.closeLoading()
     })
+        .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()
+        })
+        .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 // 显示支付中对话框
+  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((e) => {
-            console.log(e)
-            // 支付失败
+    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 // 隐藏支付中对话框
-            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.confirm('支付失败,请重试').then(() => {
+            data.canScan = true
+            scanDialogVisible.value = true
+            // 添加键盘事件监听
+            document.addEventListener('keydown', handleScanInput)
           })
-        scanCode.value = ''
-    } else {
-        scanCode.value += event.key
-    }
+        })
+    scanCode.value = ''
+  } else {
+    scanCode.value += event.key
+  }
 }
 
 // 定义查询支付状态的函数
@@ -519,9 +541,12 @@ const queryPayStatusWithRetry = (data): Promise<boolean> => {
     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++
@@ -545,7 +570,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
@@ -561,14 +586,14 @@ 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
+    if (data.phone == '') {
+        params.couponId = null
+        params.couponAmount = '-'
+        params.userId = null
+        // 计算支付金额
+        orderData.payAmount = Number(orderData.sumPriceSum).toFixed(2)
+    }
+    showCouponDialog.value = false
 }
 
 const checkout = () => {
@@ -659,8 +684,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
@@ -680,52 +706,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) {
@@ -761,9 +793,8 @@ 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
@@ -791,10 +822,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
         })
     }
 }
@@ -1111,7 +1143,7 @@ defineExpose({
 }
 
 :deep(.el-divider--horizontal) {
-  margin: 8px 0;
+    margin: 8px 0;
 }
 
 .cate-buttons :deep(.el-button) {

+ 101 - 81
src/views/order/index.vue

@@ -62,15 +62,15 @@
                     继续点餐
                 </el-button>
                 <br />
-                <el-button
-                    class="w-full mt-1"
-                    plain
-                    :disabled="currentDeskStatus == 2"
-                    @click="checkout()"
-                >
-                    结账
-                </el-button>
-                <br />
+<!--                <el-button-->
+<!--                    class="w-full mt-1"-->
+<!--                    plain-->
+<!--                    :disabled="currentDeskStatus == 2"-->
+<!--                    @click="checkout()"-->
+<!--                >-->
+<!--                    结账-->
+<!--                </el-button>-->
+<!--                <br />-->
             </div>
             <div v-if="currentDeskStatus == 2">
                 <el-radio-group v-model="data.userNum" size="small">
@@ -85,7 +85,9 @@
                 </el-radio-group>
                 <el-button class="w-full" plain @click="order()">开始点餐</el-button>
             </div>
-            <el-button v-if="currentDeskStatus != 2" class="w-full mt-1" plain @click="rockover()">翻台</el-button>
+            <el-button v-if="currentDeskStatus != 2" class="w-full mt-1" plain @click="rockover()"
+                >翻台</el-button
+            >
         </el-dialog>
         <el-dialog
             v-model="scanDialogVisible"
@@ -103,7 +105,7 @@
                     class="mx-auto mb-4"
                     style="width: 150px"
                 />
-                <b style="font-size: 20px;">{{ currentDeskAmount }} 元</b>
+                <b style="font-size: 20px">金额 {{ currentDeskAmount }} 元</b>
             </div>
             <template #footer>
                 <div class="dialog-footer">
@@ -120,10 +122,10 @@
             :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>
+                <el-icon class="is-loading mb-4" :size="32">
+                    <Loading />
+                </el-icon>
+                <p class="text-gray-600">正在支付中,请不要关闭或退出界面</p>
             </div>
         </el-dialog>
     </div>
@@ -133,7 +135,15 @@
 // 在 script setup 部分添加
 import { Loading } from '@element-plus/icons-vue'
 import { postAll } from '@/api/org/post'
-import { orderDeskList, createOrders, orderCheckout, orderPay, queryPayStatus, cancelOrder, rockoverDesk } from '@/api/order'
+import {
+    orderDeskList,
+    createOrders,
+    orderCheckout,
+    orderPay,
+    queryPayStatus,
+    cancelOrder,
+    rockoverDesk
+} from '@/api/order'
 import Console from './console.vue'
 import { getOrdersCurrent } from '@/api/orders'
 import feedback from '@/utils/feedback'
@@ -175,15 +185,18 @@ const order = () => {
     // router.push({ path: '/order/console', query: { deskID: id } })
 }
 const rockover = () => {
-  feedback.confirm('将重置桌号状态, 确定翻台吗?').then(() => {
-    rockoverDesk(data).then(() => {
-      feedback.notifySuccess('翻台成功!')
-      dialogVisible.value = false
-      init()
-    })
-  }).catch(()=>{
-    dialogVisible.value = false
-  })
+    feedback
+        .confirm('将重置桌号状态, 确定翻台吗?')
+        .then(() => {
+            rockoverDesk(data).then(() => {
+                feedback.notifySuccess('翻台成功!')
+                dialogVisible.value = false
+                init()
+            })
+        })
+        .catch(() => {
+            dialogVisible.value = false
+        })
 }
 const reorder = () => {
     dialogVisible.value = false
@@ -202,55 +215,57 @@ const payingDialogVisible = ref(false)
 
 // 添加扫码事件监听函数
 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)
+  if (event.key === 'Enter') {
+    const code = scanCode.value
+    console.log('扫码内容:', code)
+    if (!data.canScan) {
+      feedback.notifyWarning('正在处理支付,请勿重复扫码')
+      return
+    }
+    data.canScan = false
+    payingDialogVisible.value = true // 显示支付中对话框
 
-        // 修改支付处理逻辑
-        orderPay({ oid: currentDesk.oid, code: code })
-          .then((res) => {
-            console.log(res)
-            // 实际上支付成功之后,res返回的是[],如果不是实时成功,返回的是个对象, 形如:{orderId: '123456789', sn: '7895004131583689'}
-            if (res == null || res.length == 0) {
-              feedback.notifySuccess('成功结账' + currentDesk.amount + '元')
-              scanDialogVisible.value = false
-              dialogVisible.value = false
-              payingDialogVisible.value = false // 隐藏支付中对话框
-              init()
-            } else {
-              console.log('支付中')
-              return queryPayStatusWithRetry(res)
-                  .then((paySuccess) => {
-                    if (paySuccess) {
-                      feedback.notifySuccess('成功结账' + currentDesk.amount + '元')
-                      scanDialogVisible.value = false
-                      dialogVisible.value = false
-                      init()
-                    }
-                  })
-            }
-          })
-          .catch(() => {
+    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 // 隐藏支付中对话框
-
-            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.confirm('支付失败,请重试').then(() => {
+            data.canScan = true
+            scanDialogVisible.value = true
+            // 添加键盘事件监听
+            document.addEventListener('keydown', handleScanInput)
           })
-        scanCode.value = ''
-    } else {
-        scanCode.value += event.key
-    }
+        })
+    scanCode.value = ''
+  } else {
+    scanCode.value += event.key
+  }
 }
 
 // 定义查询支付状态的函数
@@ -262,9 +277,12 @@ const queryPayStatusWithRetry = (data): Promise<boolean> => {
     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++
@@ -288,7 +306,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
@@ -314,13 +332,15 @@ const checkout = () => {
     orderCheckout({ did: currentDesk.id }).then((res) => {
         console.log('结账', res)
         currentDesk.oid = res.id
-        feedback.confirm(currentDesk.name + ' 结账金额为' + currentDesk.amount + ',确定要结账吗?').then(() => {
-            data.canScan = true
-          currentDeskAmount.value = currentDesk.amount
-          scanDialogVisible.value = true
-            // 添加键盘事件监听
-            document.addEventListener('keydown', handleScanInput)
-        })
+        feedback
+            .confirm(currentDesk.name + ' 结账金额为' + currentDesk.amount + ',确定要结账吗?')
+            .then(() => {
+                data.canScan = true
+                currentDeskAmount.value = currentDesk.amount
+                scanDialogVisible.value = true
+                // 添加键盘事件监听
+                document.addEventListener('keydown', handleScanInput)
+            })
     })
 }