浏览代码

账单收款方式记忆,添加附属房,会用默认收款方式

gqx 2 年之前
父节点
当前提交
702709fa93
共有 1 个文件被更改,包括 148 次插入81 次删除
  1. 148 81
      src/views/room/modules/checkIn/BillRoomForm.vue

+ 148 - 81
src/views/room/modules/checkIn/BillRoomForm.vue

@@ -1186,6 +1186,8 @@ export default {
       oldBusMarketAgreementUnitList: [],
       busMarketAgreementUnitList: [],
       ruZhuHistoryList: [],
+      remenmberPayState: null,
+      loadRemenmberPayState: false,
     };
   },
   computed: {
@@ -1218,18 +1220,23 @@ export default {
       let copy = JSON.parse(JSON.stringify(this.model.roomPrices));
       for (let i = 0; i < copy.length; i++) {
         let money = copy[i].prefPrice;
-        let brr = []
+        let brr = [];
         brr.length = this.model.orderInfo.dayCount;
         for (let j = 0; j < brr.length; j++) {
           brr[j] = {
             day: this.addDate(this.model.orderInfo.arrivalTime2, j),
-            price:money
+            price: money,
           };
-          if (this.model.roomPrices[i].editPriceTime && this.model.roomPrices[i].editPriceTime.length > 0) {
-            let idx = this.model.roomPrices[i].editPriceTime.findIndex((item) => item == brr[j].day);
+          if (
+            this.model.roomPrices[i].editPriceTime &&
+            this.model.roomPrices[i].editPriceTime.length > 0
+          ) {
+            let idx = this.model.roomPrices[i].editPriceTime.findIndex(
+              (item) => item == brr[j].day
+            );
             if (idx > -1) {
               brr[j].price = this.model.roomPrices[i].editPrice[idx];
-            }            
+            }
           }
         }
         // brr.fill({day: this.addDate(this.model.orderInfo.arrivalTime2, i),price:money})
@@ -1237,8 +1244,8 @@ export default {
         //   day: this.addDate(this.model.orderInfo.arrivalTime2, i),
         //   price:money
         // };
-        copy[i].edit = brr
-        copy[i].day = this.model.orderInfo.dayCount
+        copy[i].edit = brr;
+        copy[i].day = this.model.orderInfo.dayCount;
       }
       this.PriceData = copy;
       return copy;
@@ -1314,51 +1321,55 @@ export default {
       }
     },
     paymentSplit(value) {
-      if (!value) {
-        var list2 = this.model.orderFees.filter(
-          (t) => t.subjectType == 2 && (!t.add || t.add != 1)
-        );
-        var list1 = this.model.orderFees.filter((t) => t.subjectType == 1);
-        var list = this.model.orderFees.filter(
-          (t) =>
-            (t.subjectType != 1 && t.subjectType != 2) || (t.add && t.add == 1)
-        );
-        list2.forEach((t) => {
-          var yjList = list1.filter((b) => b.roomId == t.roomId);
-          var yajin = yjList.reduce((sum, val) => {
-            let total = sum + val.money;
-            return isNaN(total) ? 0 : total;
-          }, 0);
-          t.yajing = yajin;
-          t.money += yajin;
-          t.receivable = t.money;
-        });
-        this.model.orderFees = [...list, ...list2];
-      } else {
-        // var list2 = this.model.orderFees.filter(
-        //   (t) => t.subjectType == 2 && (!t.add || t.add != 1)
-        // );
-        // var list1 = [];
+      if (this.loadRemenmberPayState) {
+        console.log(1111111, this.loadRemenmberPayState);
+        if (!value) {
+          var list2 = this.model.orderFees.filter(
+            (t) => t.subjectType == 2 && (!t.add || t.add != 1)
+          );
+          var list1 = this.model.orderFees.filter((t) => t.subjectType == 1);
+          var list = this.model.orderFees.filter(
+            (t) =>
+              (t.subjectType != 1 && t.subjectType != 2) ||
+              (t.add && t.add == 1)
+          );
+          list2.forEach((t) => {
+            var yjList = list1.filter((b) => b.roomId == t.roomId);
+            var yajin = yjList.reduce((sum, val) => {
+              let total = sum + val.money;
+              return isNaN(total) ? 0 : total;
+            }, 0);
+            t.yajing = yajin;
+            t.money += yajin;
+            t.receivable = t.money;
+          });
+          this.model.orderFees = [...list, ...list2];
+        } else {
+          // var list2 = this.model.orderFees.filter(
+          //   (t) => t.subjectType == 2 && (!t.add || t.add != 1)
+          // );
+          // var list1 = [];
 
-        // var list = this.model.orderFees.filter(
-        //   (t) =>
-        //     (t.subjectType != 1 && t.subjectType != 2) || (t.add && t.add == 1)
-        // );
-        // list2.forEach((t) => {
-        //   if (t.yajing && t.yajing > 0) {
-        //     t.money -= t.yajing;
-        //     t.receivable = t.money;
-        //     var item = JSON.parse(JSON.stringify(t));
-        //     item.subjectType = 1;
-        //     item.money = t.yajing;
-        //     item.yajing = 0;
-        //     item.receivable = item.money;
-        //     list1.push(item);
-        //   }
-        // });
-        // list = [...list, ...list1];
-        // this.model.orderFees = [...list, ...list2];
-        this.loadOrderFees();
+          // var list = this.model.orderFees.filter(
+          //   (t) =>
+          //     (t.subjectType != 1 && t.subjectType != 2) || (t.add && t.add == 1)
+          // );
+          // list2.forEach((t) => {
+          //   if (t.yajing && t.yajing > 0) {
+          //     t.money -= t.yajing;
+          //     t.receivable = t.money;
+          //     var item = JSON.parse(JSON.stringify(t));
+          //     item.subjectType = 1;
+          //     item.money = t.yajing;
+          //     item.yajing = 0;
+          //     item.receivable = item.money;
+          //     list1.push(item);
+          //   }
+          // });
+          // list = [...list, ...list1];
+          // this.model.orderFees = [...list, ...list2];
+          this.loadOrderFees();
+        }
       }
     },
     // "model.roomIds": {
@@ -1517,7 +1528,7 @@ export default {
     //  this.getcesRoomLayout();
   },
   methods: {
-    priceInput(e,idx,sidx){
+    priceInput(e, idx, sidx) {
       console.log(e, idx, sidx);
       this.editPriceData[idx].edit[sidx].price = e;
     },
@@ -1563,18 +1574,15 @@ export default {
     },
 
     loadOrderFees() {
+      var arr = [];
+      if (!this.loadRemenmberPayState) {
+        arr = this.remenmberPayState.split("-");
+        this.paymentSplit = arr[0] == "1";
+      }
       var orderFees = [];
       var roomIndex = 0;
       var payType = this.payTypeList[0];
-      // roomNo: item.name,
-      //         roomId: item.id,
-      //         marketPrice: item.marketPrice,
-      //         prefPrice: item.marketPrice,
-      //         day: this.model.orderInfo.dayCount,
-      //         roomFee: item.marketPrice * this.model.orderInfo.dayCount,
-      //         deposit: this.compuleDeposit(item.marketPrice),
-      //         layoutName: roomLayout ? roomLayout.name : "",
-      //         layoutId: item.layoutId,
+
       this.model.roomPrices.forEach((item) => {
         var money = item.roomFee;
         var deposit = item.deposit;
@@ -1582,15 +1590,52 @@ export default {
           if (!this.paymentSplit) {
             money = item.roomFee + deposit;
           }
-          orderFees.push({
-            subjectType: 2,
-            subjectTypeLabel: "预收房费",
-            payType: payType ? payType.id : "",
-            payTypeLabel: payType ? payType.name : "",
-            receivable: money,
-            money: money,
-            roomId: this.model.roomIds[0].id,
-          });
+          if (!this.paymentSplit) {
+            if (arr.length === 3) {
+              if (arr[1] == "1") {
+                orderFees.push({
+                  subjectType: 2,
+                  subjectTypeLabel: "预收房费",
+                  payType: payType ? payType.id : "",
+                  payTypeLabel: payType ? payType.name : "",
+                  receivable: money,
+                  money: money,
+                  roomId: this.model.roomIds[0].id,
+                });
+              } else if (arr[1] == "2") {
+                orderFees.push({
+                  subjectType: 1,
+                  subjectTypeLabel: "押金",
+                  payType: payType ? payType.id : "",
+                  payTypeLabel: payType ? payType.name : "",
+                  receivable: deposit,
+                  money: deposit,
+                  roomId: this.model.roomIds[0].id,
+                });
+              }
+            } else {
+              orderFees.push({
+                subjectType: 2,
+                subjectTypeLabel: "预收房费",
+                payType: payType ? payType.id : "",
+                payTypeLabel: payType ? payType.name : "",
+                receivable: money,
+                money: money,
+                roomId: this.model.roomIds[0].id,
+              });
+            }
+          } else {
+            orderFees.push({
+              subjectType: 2,
+              subjectTypeLabel: "预收房费",
+              payType: payType ? payType.id : "",
+              payTypeLabel: payType ? payType.name : "",
+              receivable: money,
+              money: money,
+              roomId: this.model.roomIds[0].id,
+            });
+          }
+
           if (this.paymentSplit) {
             if (deposit > 0) {
               orderFees.push({
@@ -1640,7 +1685,11 @@ export default {
         }
         roomIndex++;
       });
+
       this.model.orderFees = orderFees;
+      setTimeout(() => {
+        this.loadRemenmberPayState = true;
+      }, 100);
     },
     readCardNo() {
       this.$message.error("接口程序未打开,请打开接口程序");
@@ -1762,7 +1811,7 @@ export default {
       this.$refs.modalAgreementUnitTable.disableSubmit = true;
     },
     //批量调价
-    batchPrice(e,index) {
+    batchPrice(e, index) {
       console.log(e);
       // this.editPriceData.forEach((ele) => {
       //   ele.price = e;
@@ -1793,10 +1842,7 @@ export default {
     onCellExpand(idx) {
       console.log(idx);
       this.editPriceIndex = idx;
-      console.log(
-        "11111111111111111111111",
-        this.model.roomPrices
-      );
+      console.log("11111111111111111111111", this.model.roomPrices);
       this.editPriceModal = true;
     },
 
@@ -1823,15 +1869,14 @@ export default {
       //   ele.price = 0;
       // });
       this.model.roomPrices = JSON.parse(JSON.stringify(this.editPriceData));
-      this.model.roomPrices.forEach((ele,index)=>{
+      this.model.roomPrices.forEach((ele, index) => {
         ele.editPriceTime = [];
         ele.editPrice = [];
-        ele.edit.forEach((t,tdx)=>{
-          ele.editPriceTime.push(t.day),
-          ele.editPrice.push(t.price)
-        })
+        ele.edit.forEach((t, tdx) => {
+          ele.editPriceTime.push(t.day), ele.editPrice.push(t.price);
+        });
         ele.prefPrice = ele.edit[0].price;
-      })
+      });
       // this.editPriceData.forEach((ele, index) => {
       //   if (this.model.roomPrices[index].roomId==ele.roomId) {
       //     this.model.roomPrices[index].editPriceTime = [];
@@ -2454,6 +2499,9 @@ export default {
       if (this.payTypeList == 0) {
         await this.getbusRoomPayType();
       }
+      if (!this.remenmberPayState) {
+        await this.getHotelInfo();
+      }
       if (this.customerSourceList) {
         if (!this.model.orderInfo.customerSource) {
           this.model.orderInfo.customerSource = this.customerSourceList[0].id;
@@ -2610,6 +2658,16 @@ export default {
         // this.model.orderFees = [...this.model.orderFees, ...orderFees];
       }
     },
+    async getHotelInfo() {
+      var _info = JSON.parse(localStorage.getItem("storeInfo"));
+      await getAction("/business/busHotel/queryById", { id: _info.id }).then(
+        (res) => {
+          if (res.success) {
+            this.remenmberPayState = res.result.remenmberPayState || "1-1-2";
+          }
+        }
+      );
+    },
     submitForm() {
       const that = this;
       that.model.livingRoomDayPrices = [];
@@ -2690,6 +2748,15 @@ export default {
               if (res.success) {
                 that.$message.success(res.message);
                 that.$emit("ok", { order: res.result, model: that.model });
+                var arr = [
+                  that.paymentSplit ? 1 : 2,
+                  this.model.orderFees[0].subjectType == 1 ? 2 : 1,
+                  this.model.orderFees[0].subjectType == 1 ? 2 : 1,
+                ];
+                getAction("/business/busHotel/set-pay-state", {
+                  hotelId: this.model.hotelId,
+                  type: arr.join("-"),
+                }).then((res) => {});
               } else {
                 if (res.message.indexOf("与预约时间有冲突") >= 0) {
                   that.$confirm({