浏览代码

点餐台加刷新按钮

licc 1 月之前
父节点
当前提交
98fe49017b
共有 1 个文件被更改,包括 26 次插入21 次删除
  1. 26 21
      src/views/order/console.vue

+ 26 - 21
src/views/order/console.vue

@@ -14,7 +14,12 @@
                             class="justify-between items-center flex text-xl font-semibold font-mono"
                         >
                             <span>{{ '桌台:' + data.deskName }}</span>
-                            <span>{{ data.currentNum + '/' + data.deskCap }}</span>
+                            <div class="flex items-center">
+                                <span>{{ data.currentNum + '/' + data.deskCap }}</span>
+                                <el-icon class="ml-2 cursor-pointer" @click="open({name: data.deskName, num: data.deskCap, userNum: data.currentNum, ordersId: params.number})">
+                                    <Refresh />
+                                </el-icon>
+                            </div>
                         </div>
                     </template>
                     <el-scrollbar ref="scrollbarRef" class="scrollbar">
@@ -363,8 +368,8 @@ const open = (item: any, num?: number, orderNumber?: any) => {
     data.deskCap = item.num
     data.currentNum = item.userNum ? item.userNum : num
     params.number = item.ordersId ? item.ordersId : orderNumber
-    params.userId = null;
-    params.couponId = null;
+    params.userId = '';
+    params.couponId = '';
     //查询当前订单下的所有菜品
     deskOrderedDishListAll({ id: params.number }).then((res) => {
         res.forEach((good: { id:number, ordersDishId: number }) => {
@@ -635,37 +640,37 @@ const reduce = (item: any) => {
     }
     orderLoading.value = true
     //查找未出单的餐品列表
-    const list = data.selectGoods.filter((element: any) => {return element.status != 1})
-    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(',')
-    })
+    // const list = data.selectGoods.filter((element: any) => {return element.status != 1})
+    // 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('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(() => {
+    const t = data.selectGoods.indexOf(item)
+    // const n = data.selectGoods[t].num
+    console.log('reduce', t, item)
+    if (item.num > 1) {
+        dishDec({ id: item.ordersDishId}).then(() => {
             data.selectGoods[t].num--
             reduceHandle(item)
         }).finally(()=>{
             orderLoading.value = false;
         })
     } else {//餐品数量为0,要删减该餐品
-        dishDel({ id: item.ordersDishId || tempGoods[0].id}).then(() => {
+        dishDel({ id: item.ordersDishId}).then(() => {
             data.selectGoods.splice(t, 1)
             reduceHandle(item)
         }).finally(()=>{