Browse Source

点餐结账

gqx 2 years ago
parent
commit
d82c7d37d8
2 changed files with 45 additions and 60 deletions
  1. 34 5
      src/views/pos/diandan.vue
  2. 11 55
      src/views/pos/modules/Payment.vue

+ 34 - 5
src/views/pos/diandan.vue

@@ -41,9 +41,10 @@
           <a-button @click="handleClear" :disabled="btnDisabled">清空</a-button>
           <!-- <a-button @click="handleAdd" :disabled="btnDisabled">备注</a-button> -->
           <a-button :disabled="btnDisabled">退货</a-button>
-          <a-button @click="handleAdd">挂单</a-button>
+          <a-button v-if="!btnDisabled" @click="handleAdd">挂单</a-button>
+          <a-button v-else @click="handleAdd">取单</a-button>
           <a-button>挂房帐</a-button>
-          <a-button type="danger" @click="handlePayment"
+          <a-button :disabled="btnDisabled" type="danger" @click="handlePayment"
             >结账¥{{ amount.toFixed(2) }}</a-button
           >
         </div>
@@ -88,6 +89,7 @@
       </a-card>
     </div>
     <payment-modal ref="modalPaymentForm" @ok="modalFormOk"></payment-modal>
+    <goods-modal ref="modalGoodsForm" @ok="modalFormOk"></goods-modal>
   </a-card>
 </template>
   
@@ -97,6 +99,9 @@
 import { filterObj } from "@/utils/util";
 import { getAction, postAction, deleteAction } from "@/api/manage";
 import PaymentModal from "./modules/PaymentModal.vue";
+import goodsModal from "./modules/goodStock/goodsModal.vue";
+import { computed } from "vue";
+import { tree } from "@/api/good";
 const columns = [
   {
     title: "商品名称",
@@ -116,6 +121,7 @@ export default {
   name: "memberList",
   components: {
     PaymentModal,
+    goodsModal,
   },
   data() {
     return {
@@ -159,6 +165,11 @@ export default {
       oldSelectGoodsList: [],
     };
   },
+  provide() {
+    return {
+      treeData: computed(() => this.treeData),
+    };
+  },
   computed: {
     sum() {
       return this.selectGoodsList.reduce(function (total, item) {
@@ -186,8 +197,17 @@ export default {
         }
       }
     });
+    this.loadTree()
   },
   methods: {
+    loadTree() {
+      var that = this;
+      tree().then((res) => {
+        if (res.success) {
+          this.treeData = res.result;
+        }
+      });
+    },
     modalFormOk() {},
     numChange(e, index) {
       console.log(e);
@@ -251,10 +271,15 @@ export default {
         })
         .finally(() => {});
     },
+    handleAddTempGoods() {
+      this.$refs.modalGoodsForm.add();
+      this.$refs.modalGoodsForm.title = "新增菜品";
+      this.$refs.modalGoodsForm.disableSubmit = false;
+    },
     handlePayment() {
       this.handleAdd((e) => {
         var amount = this.oldSelectGoodsList.reduce(function (total, item) {
-          return total + item.sellingPrice;
+          return total + item.sellingPrice * item.num;
         }, 0);
         this.$refs.modalPaymentForm.edit({
           billAmount: amount,
@@ -265,9 +290,9 @@ export default {
           preferentialType: 1,
           couponFirstAmount: 0,
           discount: 9,
-          orderId: e,
+          orderCode: e,
         });
-        this.$refs.modalPaymentForm.title = "POS结账" + e;
+        this.$refs.modalPaymentForm.title = "POS结账";
         this.$refs.modalPaymentForm.disableSubmit = false;
       });
     },
@@ -311,6 +336,10 @@ export default {
     },
     itemClick(row) {
       console.log(row);
+      if (row.id == "0") {
+        this.handleAddTempGoods();
+        return;
+      }
       if (row.isSellClear) {
         this.$message.warning("选择的商品已沽清");
         return;

+ 11 - 55
src/views/pos/modules/Payment.vue

@@ -398,67 +398,23 @@ export default {
             that.$message.warning("实收金额和实收合计必须相等");
             return;
           }
-          var obj = {};
+          var obj = {
+            couponPrice: this.couponAmount.toFixed(2),
+            orderCode: this.model.orderCode,
+            paymentList: [],
+          };
           var fees = [];
-          if (this.model.coupon) {
-            fees.push({
-              feeType: this.model.feeType,
-              preferentialType: this.model.preferentialType,
-              money: this.couponAmount.toFixed(2),
-              custorerOrderRemark: "优惠金额",
-              isPreferential: true,
-            });
-          }
-          if (this.model.couponCard && this.model.couponId) {
-            var find = this.memeberCouponList.find(
-              (t) => t.id == this.model.couponId
-            );
-            if (find) {
-              fees.push({
-                feeType: this.model.feeType,
-                money: find.cost.toFixed(2),
-                custorerOrderRemark: "优惠券",
-                isPreferential: true,
-              });
-            }
-          }
           this.payList.forEach((item) => {
             fees.push({
-              feeType: this.model.feeType,
-              money: item.money.toFixed(2),
-              payType: item.payType,
-              custorerOrderRemark: "结账退房",
-              isPreferential: false,
+              payMoney: item.money.toFixed(2),
+              paymentMethod: item.payType,
+              orderId: this.model.orderCode,
             });
           });
-
+          obj.paymentList = fees;
           that.confirmLoading = true;
-          var url =
-            "/business/busRoomBookingOrders/settle-checkout?bookingOrderId=" +
-            this.model.bookingOrderId;
-          if (this.model.livingOrderId) {
-            url =
-              "/business/busRoomBookingOrders/living-settle-checkout?livingOrderId=" +
-              this.model.livingOrderId;
-          }
-          if (
-            this.model.selectedFeeIds &&
-            this.model.selectedFeeIds.length > 0
-          ) {
-            url = "/business/busRoomBookingOrders/partial-settle";
-            obj = {
-              fees: fees,
-              livingOrderId: this.model.livingOrderId,
-              selectedFeeIds: this.model.selectedFeeIds,
-            };
-          }
-          httpAction(
-            url,
-            this.model.selectedFeeIds && this.model.selectedFeeIds.length > 0
-              ? obj
-              : fees,
-            "post"
-          )
+          var url = "/pos/posOrderGoodsPayment/add";
+          httpAction(url, obj, "post")
             .then((res) => {
               if (res.success) {
                 that.$message.success("结账成功");