Explorar el Código

选择钟点房时可调价天数问题

DESKTOP-B78GIPM\admin hace 2 años
padre
commit
af53d79301
Se han modificado 1 ficheros con 29 adiciones y 4 borrados
  1. 29 4
      src/views/room/modules/checkIn/BillRoomForm.vue

+ 29 - 4
src/views/room/modules/checkIn/BillRoomForm.vue

@@ -722,10 +722,11 @@
                     </div>
                   </template>
                   <template slot="deposit" slot-scope="text, record, index">
-                    <editable-cell
+                    <!-- <editable-cell
                       :text="text"
                       @change="onCellChangeCopy('deposit', index, $event)"
-                    />
+                    /> -->
+                    <a-input-number v-model="record.deposit" @change="onCellChangeCopy('deposit', index, $event)"></a-input-number>
                   </template>
                 </a-table>
                 <div
@@ -1220,11 +1221,13 @@ export default {
       //     price:0
       //   };
       // }
+      console.log('99999999999999999999999',this.daysBetween(this.model.orderInfo.arrivalTime2, this.model.orderInfo.dueOutTimeSpan));
       let copy = JSON.parse(JSON.stringify(this.model.roomPrices));
       for (let i = 0; i < copy.length; i++) {
         let money = copy[i].prefPrice;
         let brr = [];
-        brr.length = this.model.orderInfo.dayCount;
+        // brr.length = this.model.orderInfo.dayCount;
+        brr.length = this.daysBetween(this.model.orderInfo.arrivalTime2, this.model.orderInfo.dueOutTime2)
         for (let j = 0; j < brr.length; j++) {
           brr[j] = {
             day: this.addDate(this.model.orderInfo.arrivalTime2, j),
@@ -1248,8 +1251,10 @@ export default {
         //   price:money
         // };
         copy[i].edit = brr;
-        copy[i].day = this.model.orderInfo.dayCount;
+        // copy[i].day = this.model.orderInfo.dayCount;
+        copy[i].day = this.daysBetween(this.model.orderInfo.arrivalTime2, this.model.orderInfo.dueOutTime2)
       }
+      console.log(copy);
       this.PriceData = copy;
       return copy;
     },
@@ -1531,6 +1536,21 @@ export default {
     //  this.getcesRoomLayout();
   },
   methods: {
+    //计算两个日期之间相隔多少天
+    daysBetween(date1, date2) {
+        const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
+        const firstDate = new Date(date1);
+        const secondDate = new Date(date2);
+        if (secondDate<firstDate) {
+            this.$message.warning("离开时间不能小于预离时间");
+            return
+        }
+        const diffDays = Math.round(Math.abs((firstDate - secondDate) / oneDay));
+        if (diffDays == 0) {
+            return 1          
+        }
+        return diffDays;
+    },
     priceInput(e, idx, sidx) {
       console.log(e, idx, sidx);
       this.editPriceData[idx].edit[sidx].price = e;
@@ -2059,6 +2079,11 @@ export default {
             "HH:mm"
           );
         }
+        this.model.orderInfo.dayCount = this.daysBetween(
+          this.model.orderInfo.arrivalTime2,
+          this.model.orderInfo.dueOutTime2
+        );
+        this.dayCountChange()
       } else if (this.model.orderInfo.bookingType === 1) {
         var mDate = moment(this.model.orderInfo.arrivalTime2).add(1, "days");
         this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");