Преглед на файлове

团队预定钟点房联动规则

gqx преди 2 години
родител
ревизия
f953b7cbe9

+ 15 - 3
src/views/room/fangtailive.vue

@@ -396,7 +396,7 @@
     ></schedule-room-modal>
     <schedule-team-room-modal
       ref="ModalScheduleTeamRoom"
-      @ok="modalFormOk"
+      @ok="modalTeamFormOk"
     ></schedule-team-room-modal>
     <edit-schedule-room-modal
       ref="ModalEditScheduleRoom"
@@ -728,8 +728,10 @@ export default {
     },
     toTeamPage() {
       this.$router.push({
-        path: "/room/scheduleteamdetail",
-        query: { id: "YD20230331115905024" },
+        // path: "/room/scheduleteamdetail",
+        // query: { id: "YD20230331115905024" },
+        name: "room-scheduleteamdetail",
+        params: { id: 'YD20230331115905024' },
       });
     },
     addScheduleTeam() {
@@ -864,6 +866,16 @@ export default {
         params: { id: e },
       });
     },
+    modalTeamFormOk(e) {
+      console.log("e", e);
+      // this.loadData();
+      this.$router.push({
+        // path: "/room/scheduledetail",
+        // query: { id: e },
+        name: "room-scheduleteamdetail",
+        params: { id: e },
+      });
+    },
     loadData() {
       // var _info = JSON.parse(localStorage.getItem("storeInfo"));
       // getAction("/business/busMeetingRoomSchedule/fetch", {

+ 23 - 3
src/views/room/modules/schedule/EditScheduleRoomForm.vue

@@ -152,6 +152,7 @@
                     :disabled="disabled"
                     placeholder="时长"
                     v-model="model.orderInfo.hourRoomId"
+                    @change="hourRoomIdChange"
                   >
                     <a-select-option
                       :value="item.id"
@@ -963,9 +964,7 @@ export default {
           );
         }
       } else if (this.model.orderInfo.bookingType === 1) {
-        var mDate = moment(
-          this.model.orderInfo.arrivalTime2
-        ).add(1, "days");
+        var mDate = moment(this.model.orderInfo.arrivalTime2).add(1, "days");
         this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
       }
       this.loadRooms();
@@ -1046,6 +1045,27 @@ export default {
       }
       this.loadRooms();
     },
+    hourRoomIdChange() {
+      if (this.model.orderInfo.bookingType === 2) {
+        var find = this.hourRoomRuleList.find(
+          (t) => t.id === this.model.orderInfo.hourRoomId
+        );
+        if (find) {
+          var mDate = moment(
+            this.model.orderInfo.arrivalTime2 +
+              " " +
+              moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm")
+          ).add(find.afterOpenRoom, "minutes");
+          this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
+
+          this.model.orderInfo.dueOutTimeSpan = moment(
+            mDate.format("HH:mm"),
+            "HH:mm"
+          );
+        }
+      }
+      this.loadRooms();
+    },
     tagClose2(rindex, bindex, index) {
       console.log(rindex, index);
       console.log(this.canUserRooms[index]);

+ 23 - 3
src/views/room/modules/schedule/ScheduleRoomForm.vue

@@ -113,6 +113,7 @@
                   <a-select
                     placeholder="时长"
                     v-model="model.orderInfo.hourRoomId"
+                    @change="hourRoomIdChange"
                   >
                     <a-select-option
                       :value="item.id"
@@ -709,9 +710,7 @@ export default {
           );
         }
       } else if (this.model.orderInfo.bookingType === 1) {
-        var mDate = moment(
-          this.model.orderInfo.arrivalTime2
-        ).add(1, "days");
+        var mDate = moment(this.model.orderInfo.arrivalTime2).add(1, "days");
         this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
       }
       this.loadRooms();
@@ -792,6 +791,27 @@ export default {
       }
       this.loadRooms();
     },
+    hourRoomIdChange() {
+      if (this.model.orderInfo.bookingType === 2) {
+        var find = this.hourRoomRuleList.find(
+          (t) => t.id === this.model.orderInfo.hourRoomId
+        );
+        if (find) {
+          var mDate = moment(
+            this.model.orderInfo.arrivalTime2 +
+              " " +
+              moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm")
+          ).add(find.afterOpenRoom, "minutes");
+          this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
+
+          this.model.orderInfo.dueOutTimeSpan = moment(
+            mDate.format("HH:mm"),
+            "HH:mm"
+          );
+        }
+      }
+      this.loadRooms();
+    },
     tagClose2(rindex, bindex, index) {
       var id =
         this.canUserRooms[index].buildingRooms[bindex].floorRooms[rindex].id;

+ 76 - 16
src/views/room/modules/scheduleTeam/BatchSelectRoomTypeForm.vue

@@ -28,6 +28,7 @@
                 v-model="model.arrivalTimeSpan"
                 format="HH:mm"
                 :allowClear="false"
+                @change="arrivalTimeSpanChange"
               />
             </a-form-model-item>
           </a-col>
@@ -45,12 +46,14 @@
                 :allowClear="false"
                 :disabled-date="disabledDate"
                 @change="arrivalTimeChange2"
+                :disabled="model.bookingType === 2"
               />
               <a-time-picker
                 style="width: 80px; margin-left: 2px"
                 v-model="model.dueOutTimeSpan"
                 format="HH:mm"
                 :allowClear="false"
+                :disabled="model.bookingType === 2"
               />
             </a-form-model-item>
           </a-col>
@@ -169,6 +172,10 @@ export default {
       type: Array,
       default: [],
     },
+    hourRoomRuleList: {
+      type: Array,
+      default: [],
+    },
   },
   data() {
     return {
@@ -275,7 +282,26 @@ export default {
     }
     //备份model原始值
     this.modelDefault = JSON.parse(JSON.stringify(this.model));
-    this.loadRooms();
+    if (this.model.bookingType === 2) {
+      var find = this.hourRoomRuleList.find(
+        (t) => t.id === this.model.hourRoomId
+      );
+
+      console.log("222222", this.hourRoomRuleList);
+      if (find) {
+        var mDate = moment(
+          this.model.arrivalTime2 +
+            " " +
+            moment(this.model.arrivalTimeSpan).format("HH:mm")
+        ).add(find.afterOpenRoom, "minutes");
+        this.model.dueOutTime2 = mDate.format("YYYY-MM-DD");
+
+        this.$nextTick(() => {
+          this.model.dueOutTimeSpan = moment(mDate.format("HH:mm"), "HH:mm");
+          this.loadRooms();
+        });
+      }
+    }
   },
   methods: {
     tagClose2(rindex, bindex, index) {
@@ -315,26 +341,60 @@ export default {
       return current && current < moment().add(-1, "days").endOf("day");
     },
     arrivalTimeChange(e) {
-      this.model.dueOutTime2 = moment(this.model.arrivalTime2)
-        .add(this.model.dayCount, "days")
-        .format("YYYY-MM-DD");
-      this.model.dayCount = Math.abs(
-        parseInt(
-          (new Date(this.model.arrivalTime2).getTime() -
-            new Date(this.model.dueOutTime2).getTime()) /
-            (1000 * 60 * 60 * 24)
-        )
+      var v = parseInt(
+        (new Date(this.model.dueOutTime2).getTime() -
+          new Date(this.model.arrivalTime2).getTime()) /
+          (1000 * 60 * 60 * 24)
+      );
+      if (v <= 0) {
+        this.model.dueOutTime2 = moment(this.model.arrivalTime2)
+          .add(1, "days")
+          .format("YYYY-MM-DD");
+      }
+      v = parseInt(
+        (new Date(this.model.dueOutTime2).getTime() -
+          new Date(this.model.arrivalTime2).getTime()) /
+          (1000 * 60 * 60 * 24)
       );
+      this.model.dayCount = Math.abs(v);
       this.loadRooms();
     },
     arrivalTimeChange2(e) {
-      this.model.dayCount = Math.abs(
-        parseInt(
-          (new Date(this.model.arrivalTime2).getTime() -
-            new Date(this.model.dueOutTime2).getTime()) /
-            (1000 * 60 * 60 * 24)
-        )
+      var v = parseInt(
+        (new Date(this.model.dueOutTime2).getTime() -
+          new Date(this.model.arrivalTime2).getTime()) /
+          (1000 * 60 * 60 * 24)
+      );
+      if (v <= 0) {
+        this.model.arrivalTime2 = moment(this.model.dueOutTime2)
+          .add(-1, "days")
+          .format("YYYY-MM-DD");
+      }
+      v = parseInt(
+        (new Date(this.model.dueOutTime2).getTime() -
+          new Date(this.model.arrivalTime2).getTime()) /
+          (1000 * 60 * 60 * 24)
       );
+      this.model.dayCount = Math.abs(v);
+      this.loadRooms();
+    },
+    arrivalTimeSpanChange(m, time) {
+      console.log(time);
+      console.log(moment(m).format("HH:mm"));
+      if (this.model.bookingType === 2) {
+        var find = this.hourRoomRuleList.find(
+          (t) => t.id === this.model.hourRoomId
+        );
+        if (find) {
+          var mDate = moment(
+            this.model.arrivalTime2 +
+              " " +
+              moment(this.model.arrivalTimeSpan).format("HH:mm")
+          ).add(find.afterOpenRoom, "minutes");
+          this.model.dueOutTime2 = mDate.format("YYYY-MM-DD");
+          this.model.dueOutTimeSpan = moment(mDate.format("HH:mm"), "HH:mm");
+        }
+      }
       this.loadRooms();
     },
     isDateIntersection(start1, end1, start2, end2) {

+ 5 - 0
src/views/room/modules/scheduleTeam/BatchSelectRoomTypeFormModal.vue

@@ -15,6 +15,7 @@
       :disabled="disableSubmit"
       :orderInfo="orderInfo"
       :batchRoomsTypeList="batchRoomsTypeList"
+      :hourRoomRuleList="hourRoomRuleList"
     ></batch-select-room-type-form>
   </j-modal>
 </template>
@@ -35,6 +36,10 @@ export default {
       type: Array,
       default: [],
     },
+    hourRoomRuleList: {
+      type: Array,
+      default: [],
+    },
   },
   data() {
     return {

+ 103 - 8
src/views/room/modules/scheduleTeam/EdiBatchScheduleRoomForm.vue

@@ -83,6 +83,7 @@
                     :default-value="moment('12:00', 'HH:mm')"
                     format="HH:mm"
                     :allowClear="false"
+                    @change="arrivalTimeSpanChange"
                   />
                 </a-form-model-item>
               </a-col>
@@ -94,16 +95,16 @@
                   prop="orderInfo.dueOutTime2"
                 >
                   <j-date
-                    :disabled="disabled"
+                    :disabled="disabled || model.orderInfo.bookingType === 2"
                     placeholder="预离时间"
                     v-model="model.orderInfo.dueOutTime2"
                     style="width: 180px"
                     :allowClear="false"
                     :disabled-date="disabledDate"
-                    @change="arrivalTimeChange"
+                    @change="arrivalTimeChange2"
                   />
                   <a-time-picker
-                    :disabled="disabled"
+                    :disabled="disabled || model.orderInfo.bookingType === 2"
                     style="width: 80px; margin-left: 2px"
                     v-model="model.orderInfo.dueOutTimeSpan"
                     format="HH:mm"
@@ -144,6 +145,7 @@
                     :disabled="disabled"
                     placeholder="时长"
                     v-model="model.orderInfo.hourRoomId"
+                    @change="hourRoomIdChange"
                   >
                     <a-select-option
                       :value="item.id"
@@ -1016,6 +1018,27 @@ export default {
           this.model.orderInfo.hourRoomId = hourRoomRule.id;
         }
       }
+      if (this.model.orderInfo.bookingType === 2) {
+        var find = this.hourRoomRuleList.find(
+          (t) => t.id === this.model.orderInfo.hourRoomId
+        );
+        if (find) {
+          var mDate = moment(
+            this.model.orderInfo.arrivalTime2 +
+              " " +
+              moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm")
+          ).add(find.afterOpenRoom, "minutes");
+          this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
+
+          this.model.orderInfo.dueOutTimeSpan = moment(
+            mDate.format("HH:mm"),
+            "HH:mm"
+          );
+        }
+      } 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");
+      }
       this.loadRooms();
     },
     dayCountChange(e) {
@@ -1030,18 +1053,90 @@ export default {
       return current && current < moment().add(-1, "days").endOf("day");
     },
     arrivalTimeChange(e) {
-      this.model.orderInfo.dayCount = Math.abs(
-        parseInt(
-          (new Date(this.model.orderInfo.arrivalTime2).getTime() -
-            new Date(this.model.orderInfo.dueOutTime2).getTime()) /
-            (1000 * 60 * 60 * 24)
+      var v = parseInt(
+        (new Date(this.model.orderInfo.dueOutTime2).getTime() -
+          new Date(this.model.orderInfo.arrivalTime2).getTime()) /
+          (1000 * 60 * 60 * 24)
+      );
+      if (v <= 0) {
+        this.model.orderInfo.dueOutTime2 = moment(
+          this.model.orderInfo.arrivalTime2
         )
+          .add(1, "days")
+          .format("YYYY-MM-DD");
+      }
+      v = parseInt(
+        (new Date(this.model.orderInfo.dueOutTime2).getTime() -
+          new Date(this.model.orderInfo.arrivalTime2).getTime()) /
+          (1000 * 60 * 60 * 24)
+      );
+      this.model.orderInfo.dayCount = Math.abs(v);
+      this.loadRooms();
+    },
+    arrivalTimeChange2(e) {
+      var v = parseInt(
+        (new Date(this.model.orderInfo.dueOutTime2).getTime() -
+          new Date(this.model.orderInfo.arrivalTime2).getTime()) /
+          (1000 * 60 * 60 * 24)
+      );
+      if (v <= 0) {
+        this.model.orderInfo.arrivalTime2 = moment(
+          this.model.orderInfo.dueOutTime2
+        )
+          .add(-1, "days")
+          .format("YYYY-MM-DD");
+      }
+      v = parseInt(
+        (new Date(this.model.orderInfo.dueOutTime2).getTime() -
+          new Date(this.model.orderInfo.arrivalTime2).getTime()) /
+          (1000 * 60 * 60 * 24)
       );
+      this.model.orderInfo.dayCount = Math.abs(v);
       this.loadRooms();
     },
     arrivalTimeSpanChange(m, time) {
       console.log(time);
       console.log(moment(m).format("HH:mm"));
+      if (this.model.orderInfo.bookingType === 2) {
+        var find = this.hourRoomRuleList.find(
+          (t) => t.id === this.model.orderInfo.hourRoomId
+        );
+        if (find) {
+          var mDate = moment(
+            this.model.orderInfo.arrivalTime2 +
+              " " +
+              moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm")
+          ).add(find.afterOpenRoom, "minutes");
+          this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
+
+          this.model.orderInfo.dueOutTimeSpan = moment(
+            mDate.format("HH:mm"),
+            "HH:mm"
+          );
+        }
+      }
+      this.loadRooms();
+    },
+    hourRoomIdChange() {
+      if (this.model.orderInfo.bookingType === 2) {
+        var find = this.hourRoomRuleList.find(
+          (t) => t.id === this.model.orderInfo.hourRoomId
+        );
+        if (find) {
+          var mDate = moment(
+            this.model.orderInfo.arrivalTime2 +
+              " " +
+              moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm")
+          ).add(find.afterOpenRoom, "minutes");
+          this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
+
+          this.model.orderInfo.dueOutTimeSpan = moment(
+            mDate.format("HH:mm"),
+            "HH:mm"
+          );
+        }
+      }
+      this.loadRooms();
     },
     tagClose2(rindex, bindex, index) {
       // console.log(rindex, index);

+ 4 - 2
src/views/room/modules/scheduleTeam/ScheduleRoomForm.vue

@@ -148,6 +148,7 @@
                   <a-select
                     placeholder="时长"
                     v-model="model.orderInfo.hourRoomId"
+                    :disabled="batchRoomsTypeList.length > 0"
                   >
                     <a-select-option
                       :value="item.id"
@@ -229,7 +230,7 @@
                     @search="handleSearch"
                     @select="(e) => handleSelectMember(e)"
                   >
-                  <template slot="dataSource">
+                    <template slot="dataSource">
                       <a-select-option
                         v-for="item in customerList"
                         :key="item.id"
@@ -456,6 +457,7 @@
       @ok="modalBatchSelectRoomTypeFormOk"
       :orderInfo="model.orderInfo"
       :batchRoomsTypeList="batchRoomsTypeList"
+      :hourRoomRuleList="hourRoomRuleList"
     ></batch-select-room-type-form-modal>
     <edit-batch-select-room-type-form-modal
       ref="modalEditBatchSelectRoomTypeForm"
@@ -1019,7 +1021,7 @@ export default {
             .then((res) => {
               if (res.success) {
                 that.$message.success(res.message);
-                that.$emit("ok");
+                that.$emit("ok", res.result);
               } else {
                 that.$message.warning(res.message);
               }

+ 51 - 47
src/views/room/modules/scheduleTeam/ScheduleRoomModal.vue

@@ -5,64 +5,68 @@
     :visible="visible"
     switchFullscreen
     @ok="handleOk"
-    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
+    :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
     @cancel="handleCancel"
-    cancelText="关闭">
-    <schedule-room-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></schedule-room-form>
+    cancelText="关闭"
+  >
+    <schedule-room-form
+      ref="realForm"
+      @ok="submitCallback"
+      :disabled="disableSubmit"
+    ></schedule-room-form>
   </j-modal>
 </template>
 
 <script>
-
-  import ScheduleRoomForm from './ScheduleRoomForm'
-  export default {
-    name: 'ScheduleRoomModal',
-    components: {
-      ScheduleRoomForm
-    },
-    data () {
-      return {
-        title:'',
-        width:1300,
-        visible: false,
-        disableSubmit: false
-      }
+import ScheduleRoomForm from "./ScheduleRoomForm";
+export default {
+  name: "ScheduleRoomModal",
+  components: {
+    ScheduleRoomForm,
+  },
+  data() {
+    return {
+      title: "",
+      width: 1300,
+      visible: false,
+      disableSubmit: false,
+    };
+  },
+  methods: {
+    add() {
+      this.visible = true;
+      this.$nextTick(() => {
+        this.$refs.realForm.add();
+      });
     },
-    methods: {
-      add () {
-        this.visible=true
-        this.$nextTick(()=>{
-          this.$refs.realForm.add();
-        })
-      },
-      addList(record) {
+    addList(record) {
       this.visible = true;
       this.$nextTick(() => {
         this.$refs.realForm.addList(record);
       });
     },
-      edit (record) {
-        this.visible=true
-        this.$nextTick(()=>{
-          this.$refs.realForm.edit(record);
-        })
-      },
-      close () {
-        this.$emit('close');
-        this.visible = false;
-      },
-      handleOk () {
-        this.$refs.realForm.submitForm();
-      },
-      submitCallback(){
-        this.$emit('ok');
-        this.visible = false;
-      },
-      handleCancel () {
-        this.close()
-      }
-    }
-  }
+    edit(record) {
+      this.visible = true;
+      this.$nextTick(() => {
+        this.$refs.realForm.edit(record);
+      });
+    },
+    close() {
+      this.$emit("close");
+      this.visible = false;
+    },
+    handleOk() {
+      this.$refs.realForm.submitForm();
+    },
+    submitCallback(e) {
+      this.$emit("ok", e);
+      this.visible = false;
+    },
+    handleCancel() {
+      this.close();
+    },
+  },
+};
 </script>
 <style scoped>
 /deep/.ant-modal-body {

+ 2 - 2
src/views/room/scheduleteamdetail.vue

@@ -187,7 +187,7 @@ export default {
     };
   },
   created() {
-    this.id = this.$route.query.id;
+    this.id = this.$route.params.id;
     console.log("created", this.id);
     this.getbusCustomer();
   },
@@ -200,7 +200,7 @@ export default {
   // },
   activated() {
     //重新进入界面可能参数id不一样,需要重新加载数据,使用钩子方式
-    this.id = this.$route.query.id;
+    this.id = this.$route.params.id;
     this.selectMain = true;
     // try {
     //   this.$refs.EditScheduleRoomFormMain.load(this.id);