Procházet zdrojové kódy

点餐台的bug修改

licc před 1 měsícem
rodič
revize
8aa370dcdc
3 změnil soubory, kde provedl 63 přidání a 55 odebrání
  1. 34 43
      src/views/order/console.vue
  2. 2 1
      src/views/order/index.vue
  3. 27 11
      src/views/orders/list.vue

+ 34 - 43
src/views/order/console.vue

@@ -313,7 +313,7 @@ const handleCouponClick = (coupon: any) => {
     params.couponId = coupon.ticketRecordId
     params.couponAmount = (coupon.consumeScore / 100).toFixed(2)
     // 计算支付金额
-    orderData.payAmount = orderData.sumPriceSum - Number((coupon.consumeScore / 100).toFixed(2))
+orderData.payAmount = (Number(orderData.sumPriceSum) - Number(coupon.consumeScore / 100)).toFixed(2)
 }
 
 // 添加双击处理方法
@@ -348,13 +348,13 @@ const open = (item: any, num?: number, orderNumber?: any) => {
                 searchUserCoupons();
             }
             params.couponAmount = res[0].ticketAmount? Number(res[0].ticketAmount / 100).toFixed(2) : '-'
-            orderData.payAmount = Number((res[0].payAmount / 100).toFixed(2));
             let _list = res.filter((it: { status: number })=>it.status!=1);//找到没有出单的餐品来计算价格
             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);
+            orderData.payAmount = res[0].payAmount ? Number((res[0].payAmount / 100).toFixed(2)) : orderData.sumPriceSum;
         }else{
             orderData.priceSum = 0
             orderData.numSum = 0
@@ -536,30 +536,16 @@ const handleAddGoods = (item: any) => {
   const list = data.selectGoods.filter((element: any) => {return element.status != 1})
   console.log('list', list)
   var tempGoods: string | any[] = [];
-  if(item.artId){//说明操作的是历史已经添加过的餐品
-      tempGoods = [item];
-  }else{
-      //先从历史下单但是没有结单的餐品中找出要操作的餐品
-      tempGoods = list.filter((element: any) => {
-          //如果有specsIds,说明是有规格的餐品
-          let specsIds: number[] = [];
-          element.specsList?.forEach((spec: any) => {
-            specsIds.push(spec.specsId)
-          })
-          return element.artId && element.artId == item.id && 
-            specsIds.sort((a: number, b: number) => a - b).join(',') == (item.selectedSpecIds || []).sort((a: number, b: number) => a - b).join(',')
+  //先从历史下单但是没有结单的餐品中找出要操作的餐品
+  tempGoods = list.filter((element: any) => {
+      //如果有specsIds,说明是有规格的餐品
+      let specsIds: number[] = [];
+      element.specsList?.forEach((spec: any) => {
+        specsIds.push(spec.specsId)
       })
-    //   if(tempGoods.length==0){//历史没有,则从当次下单的餐品列表中找
-    //       tempGoods = list.filter((element: any) => {
-    //             let specsIds: number[] = [];
-    //             element.specsList?.forEach((spec: any) => {
-    //                 specsIds.push(spec.specsId)
-    //             })
-    //             return element.id == item.id && !element.artId && 
-    //                 specsIds.sort((a, b) => a - b).join(',') == (item.selectedSpecIds || []).sort((a: number, b: number) => a - b).join(',')
-    //       })
-    //   }
-  }
+      return element.artId && element.artId == item.id &&
+        specsIds.sort((a: number, b: number) => a - b).join(',') == (item.selectedSpecIds || []).sort((a: number, b: number) => a - b).join(',')
+  })
   console.log('tempGoods', tempGoods)
   if (tempGoods.length == 0) {
       item.num = 1
@@ -607,7 +593,7 @@ const addHandle = (item: { summary: any })=>{
     orderData.sumNumSum++
     orderData.priceSum += Number(item.summary)
     orderData.sumPriceSum += Number(item.summary)
-    orderData.payAmount = Number((orderData.sumPriceSum - (params.couponAmount === '-' ? 0 : Number(params.couponAmount))).toFixed(2))
+    orderData.payAmount = Number(orderData.sumPriceSum - (params.couponAmount === '-' ? 0 : Number(params.couponAmount))).toFixed(2)
 }
 const reduce = (item: any) => {
     if(orderLoading.value){
@@ -616,22 +602,27 @@ const reduce = (item: any) => {
     orderLoading.value = true
     //查找未出单的餐品列表
     const list = data.selectGoods.filter((element: any) => {return element.status != 1})
-    var tempGoods: string | any[] = [];
-    if(item.artId){//说明操作的是历史已经添加过的餐品
-        tempGoods = [item];
-    }else{
-        //先从历史下单但是没有结单的餐品中找出要操作的餐品
-        tempGoods = list.filter((element: any) => {
-            return element.artId == item.id && element.artId
-        })
-        if(tempGoods.length==0){//历史没有,则从当次下单的餐品列表中找
-            tempGoods = list.filter((element: any) => {
-                return element.id == item.id && !element.artId
-            })
-        }
-    }
+    let tempGoods: string | any[] = []
+    //先从历史下单但是没有结单的餐品中找出要操作的餐品
+    tempGoods = list.filter((element: any) => {
+      const specsIds: number[] = [];
+      element.specsList?.forEach((spec: any) => {
+        specsIds.push(spec.specsId)
+      })
+      return element.artId && element.artId == item.artId &&
+          specsIds.sort((a: number, b: number) => a - b).join(',') == (item.selectedSpecIds || []).sort((a: number, b: number) => a - b).join(',')
+    })
+    // if(tempGoods.length==0){//历史没有,则从当次下单的餐品列表中找
+    //     tempGoods = list.filter((element: any) => {
+    //         return element.id == item.id && !element.artId
+    //     })
+    // }
+
+    console.log('tempGoods', tempGoods)
+    console.log('data.selectGoods', data.selectGoods)
     const t = data.selectGoods.indexOf(tempGoods[0])
     const n = data.selectGoods[t].num
+    console.log('reduce', n, tempGoods)
     if (n > 1) {
         dishDec({ id: item.ordersDishId || tempGoods[0].id}).then(() => {
             data.selectGoods[t].num--
@@ -687,8 +678,8 @@ const searchUserCoupons = () => {
     searchLoading.value = true
     searchCoupons({ mobile: data.phone}).then((res: any) => {
         if (res) {
-            data.couponList = res || []
-            params.userId = res[0].userId || null
+            data.couponList = res ? res.couponList || [] : []
+            params.userId = res ? res.userId || null : null
         }
     }).finally(() => {
         searchLoading.value = false
@@ -764,7 +755,7 @@ defineExpose({
     display: flex;
     align-items: center;
     justify-content: center;
-    
+
     .amount-wrapper {
         display: flex;
         align-items: center;

+ 2 - 1
src/views/order/index.vue

@@ -15,7 +15,7 @@
                 :key="i"
                 class="p-1 flex-wrap float-left text-center md:w-28 h-28 w-1/3"
             >
-            
+
                 <a href="javascript:void(0);" @click="order_(i)"
                     ><div
                         class="rounded w-full h-full pt-3 relative"
@@ -142,6 +142,7 @@ const refresh = () => {
     init()
 }
 const checkout = () => {
+    refresh()
     //结账
     console.warn("***结账***",currentDesk)
     if(currentDesk && !currentDesk.amount){

+ 27 - 11
src/views/orders/list.vue

@@ -48,7 +48,23 @@
                                                 class="dish-image" fit="cover" />
                                         </template>
                                     </el-table-column>
-                                    <el-table-column prop="name" label="菜品名称" />
+                                    <el-table-column prop="name" label="菜品名称">
+                                        <template #default="{ row }">
+                                            <div>
+                                                {{ row.name }}
+                                                <div v-if="row.specsList && row.specsList.length" class="mt-1">
+                                                    <el-tag
+                                                        v-for="spec in row.specsList"
+                                                        :key="spec.id"
+                                                        size="small"
+                                                        class="mr-1 mb-1"
+                                                    >
+                                                        {{ spec.name }}: {{ spec.value }}
+                                                    </el-tag>
+                                                </div>
+                                            </div>
+                                        </template>
+                                    </el-table-column>
                                     <el-table-column prop="amount" label="单价">
                                         <template #default="{ row }">
                                             ¥{{ row.amount }}
@@ -96,11 +112,11 @@
                     </template> -->
                 </el-table-column>
                 <el-table-column label="类型" prop="type"
-                    :formatter="(row) => (row.type == 0 ? '后台点单' : '扫码点单')"></el-table-column>
+                    :formatter="(row: any) => (row.type == 0 ? '后台点单' : '扫码点单')"></el-table-column>
                 <el-table-column label="状态" min-width="160" prop="status" >
                     <template #default="{ row }">
                         <div>
-                            {{ row.status == 4 ? '退款成功' : row.status == 2 ? '已完成' : row.status == 0 ? '待下单' 
+                            {{ row.status == 4 ? '退款成功' : row.status == 2 ? '已完成' : row.status == 0 ? '待下单'
                             : row.status == 1 ? '待支付' : row.status == 5 ? '退款中' : '已取消' }}
                             <div v-if="row.refundStatus=='SUCCESS'" class="refund-info">
                                 <div>退款时间:{{ row.refundTime }}</div>
@@ -122,14 +138,14 @@
                 <pagination v-model="pager" @change="getLists" />
             </div>
         </el-card>
-        <el-dialog 
+        <el-dialog
             v-model="refundDialogVisible"
-            title="退款" 
+            title="退款"
             width="400px"
             @close="refundDialogVisible = false">
             <div class="refund-dialog-content">
-                <el-input 
-                    v-model="refundAmount" 
+                <el-input
+                    v-model="refundAmount"
                     placeholder="请输入退款金额"
                     type="number">
                     <template #prepend><icon :size="25" name="el-icon-money" /></template>
@@ -197,7 +213,7 @@
         refundAmount: number;
         payAmount: number;
         amount: number;
-        status: number; id: any; 
+        status: number; id: any;
     };
     // 修改refund函数
     const refund = async (row: any) => {
@@ -338,7 +354,7 @@
 
     .refund-dialog-content {
         padding: 20px 0px;
-        
+
         :deep(.el-input) {
             width: 100%;
         }
@@ -346,7 +362,7 @@
 
     .dialog-footer {
         text-align: right;
-        
+
         .el-button + .el-button {
             margin-left: 12px;
         }
@@ -368,4 +384,4 @@
         line-height: 1.5;
         max-height: 3em; // 2行的高度
     }
-</style>
+</style>