Quellcode durchsuchen

桌台点餐fix

gqx vor 2 Jahren
Ursprung
Commit
f6d812e459

+ 1 - 1
src/views/pos/diandan.vue

@@ -390,7 +390,7 @@ export default {
             this.selectRoomOrder = {};
             this.loadGoods();
             if (callback) {
-              callback(res.result);
+              callback(res.result.code);
             }
           } else {
             this.$message.warning(res.message);

+ 4 - 4
src/views/pos/posInfo.vue

@@ -1,17 +1,17 @@
 <template>
   <a-card style="width: 100%; height: 100%">
-    <a-tabs default-active-key="1">
+    <a-tabs v-model="activeKey">
       <a-tab-pane key="1">
         <span slot="tab"> 点单 </span>
         <diandan></diandan>
       </a-tab-pane>
       <a-tab-pane key="2">
         <span slot="tab"> 桌台点单 </span>
-        <tablediandangallery></tablediandangallery>
+        <tablediandangallery v-if="activeKey == '2'"></tablediandangallery>
       </a-tab-pane>
       <a-tab-pane key="3">
         <span slot="tab"> 订单列表 </span>
-        <goods-order></goods-order>
+        <goods-order v-if="activeKey == '3'"></goods-order>
       </a-tab-pane>
       <a-tab-pane key="4">
         <span slot="tab"> pos类型管理 </span>
@@ -42,7 +42,7 @@ export default {
     tablediandangallery,
   },
   data() {
-    return {};
+    return { activeKey: "1" };
   },
 };
 </script>

+ 33 - 24
src/views/pos/tablediandan.vue

@@ -232,30 +232,10 @@ export default {
     //重新进入界面可能参数id不一样,需要重新加载数据,使用钩子方式
     this.tableId = this.$route.params.tableId;
     this.isShow = true;
-    this.tableId = this.$route.params.tableId;
     this.dataSource = [{ id: "0" }];
-    getAction("/pos/posTable/queryById", { id: this.tableId }).then((res) => {
-      if (res.success) {
-        this.tableOrderInfo = res.result;
-        if (this.tableOrderInfo.state == 2 || this.tableOrderInfo.state == 3) {
-          this.selectOrderInfo = this.tableOrderInfo.posOrderGoods;
-          getAction("/pos/posOrderGoodsDetail/list", {
-            pageNo: 1,
-            pageSize: 99,
-            orderId: this.tableOrderInfo.posOrderGoods.code,
-          }).then((res2) => {
-            if (res2.success) {
-              res2.result.records.forEach((t) => {
-                t.sellingPrice = t.payMoney;
-                t.name = t.goodsName;
-                t.id = t.goodsId;
-              });
-              this.selectGoodsList = res2.result.records;
-            }
-          });
-        }
-      }
-    });
+    this.selectGoodsList = [];
+    this.oldSelectGoodsList = [];
+    this.getSelectGoodsList();
     this.loadTree();
     this.loadGoodsType();
   },
@@ -263,6 +243,33 @@ export default {
   //   this.isShow = false;
   // },
   methods: {
+    getSelectGoodsList() {
+      getAction("/pos/posTable/queryById", { id: this.tableId }).then((res) => {
+        if (res.success) {
+          this.tableOrderInfo = res.result;
+          if (
+            this.tableOrderInfo.state == 2 ||
+            this.tableOrderInfo.state == 3
+          ) {
+            this.selectOrderInfo = this.tableOrderInfo.posOrderGoods;
+            getAction("/pos/posOrderGoodsDetail/list", {
+              pageNo: 1,
+              pageSize: 99,
+              orderId: this.tableOrderInfo.posOrderGoods.code,
+            }).then((res2) => {
+              if (res2.success) {
+                res2.result.records.forEach((t) => {
+                  t.sellingPrice = t.payMoney;
+                  t.name = t.goodsName;
+                  t.id = t.goodsId;
+                });
+                this.selectGoodsList = res2.result.records;
+              }
+            });
+          }
+        }
+      });
+    },
     loadTree() {
       var that = this;
       tree().then((res) => {
@@ -431,9 +438,11 @@ export default {
             // this.selectGoodsList = [];
             // this.selectOrderInfo = {};
             // this.selectRoomOrder = {};
+            this.tableId = res.result.posTableId;
+            this.getSelectGoodsList();
             this.loadGoods();
             if (callback) {
-              callback(res.result);
+              callback(res.result.code);
             }
           } else {
             this.$message.warning(res.message);

+ 52 - 4
src/views/pos/tablediandangallery.vue

@@ -59,10 +59,12 @@
               <div>
                 <a-icon type="user" />{{ item.userNum }}/{{ item.num }}人
               </div>
-              <div><a-icon type="clock-circle" />00:55</div>
+              <div>
+                <a-icon type="clock-circle" />{{ hours(item.orderTime) }}
+              </div>
             </div></template
           >
-          <template v-else-if="item.state === 2">
+          <template v-else-if="item.state === 2 || item.state === 4">
             <div>{{ item.name }}</div>
             <div style="margin-top: 10px">
               ¥{{ item.posOrderGoods ? item.posOrderGoods.money : 0 }}
@@ -77,7 +79,9 @@
               <div>
                 <a-icon type="user" />{{ item.userNum }}/{{ item.num }}人
               </div>
-              <div><a-icon type="clock-circle" />00:55</div>
+              <div>
+                <a-icon type="clock-circle" />{{ hours(item.orderTime) }}
+              </div>
             </div></template
           >
           <template v-else>
@@ -249,6 +253,20 @@ export default {
     },
   },
   created() {
+    console.log("created");
+    this.dataSource = [{ id: "0" }];
+    getAction("/pos/posType/list", { pageNo: 1, pageSize: 99 }).then((res) => {
+      if (res.success) {
+        this.posTypeList = res.result.records;
+        if (this.posTypeList && this.posTypeList.length > 0) {
+          this.tabPosTypeId = this.posTypeList[0].id;
+          this.loadRegion();
+        }
+      }
+    });
+  },
+  activated() {
+    console.log("activated");
     this.dataSource = [{ id: "0" }];
     getAction("/pos/posType/list", { pageNo: 1, pageSize: 99 }).then((res) => {
       if (res.success) {
@@ -261,6 +279,17 @@ export default {
     });
   },
   methods: {
+    hours(start) {
+      var beginDate = new Date(start);
+      var endDate = new Date();
+      let hours = parseInt((endDate - beginDate) / (1000 * 60 * 60));
+      let leave1 =
+        (endDate.getTime() - beginDate.getTime()) % (24 * 3600 * 1000);
+      let leave2 = leave1 % (3600 * 1000);
+      let minutes = Math.floor(leave2 / (60 * 1000));
+      // return minutes == 0 ? hours : hours + 1;
+      return hours.toString().padStart(2, "0") + ":" + minutes.toString().padStart(2, "0");
+    },
     getStatusColor(status) {
       var find = this.statusColorList.find((t) => t.status == status);
       return find ? find.color : "#fff";
@@ -439,7 +468,7 @@ export default {
             this.selectRoomOrder = {};
             this.loadGoods();
             if (callback) {
-              callback(res.result);
+              callback(res.result.code);
             }
           } else {
             this.$message.warning(res.message);
@@ -455,12 +484,31 @@ export default {
       });
     },
     itemClick(row) {
+      var that = this;
       console.log(row);
       this.selectTable = row;
       if (row.state === 0) {
         this.$refs.modalUserNmumForm.edit({ id: row.id, userNum: 1 });
         this.$refs.modalUserNmumForm.title = "就餐人数";
         this.$refs.modalUserNmumForm.disableSubmit = false;
+      } else if (row.state === 4) {
+        this.$confirm({
+          content: "确定是否要清除房台?",
+          onOk: function () {
+            var model = JSON.parse(JSON.stringify(row));
+            model.state = 0;
+            model.userNum = 0;
+            model.orderTime = null;
+            postAction("/pos/posTable/edit", model).then((res) => {
+              if (res.success) {
+                that.$message.success(res.message);
+                that.loadTables();
+              } else {
+                that.$message.warning(res.message);
+              }
+            });
+          },
+        });
       } else {
         this.$router.push({
           name: "pos-tablediandan",