浏览代码

fix: the schedule can not be displayed

Casper Dai 3 年之前
父节点
当前提交
f9cb2cb35f

+ 2 - 2
src/api/calendar.js

@@ -29,8 +29,8 @@ export function getSchedule (id, options) {
     method: 'GET',
     method: 'GET',
     ...options
     ...options
   }).then(({ data }) => {
   }).then(({ data }) => {
-    const { id, type, name, resolutionRatio, eventDetail } = data
-    return { id, type, name, resolutionRatio, events: __SUPPORT_COMPLEX__ ? JSON.parse(eventDetail) : eventDetail }
+    const { id, type, status, name, resolutionRatio, eventDetail } = data
+    return { id, type, status, name, resolutionRatio, events: __SUPPORT_COMPLEX__ ? JSON.parse(eventDetail) : eventDetail }
   })
   })
 }
 }
 
 

+ 1 - 1
src/components/Schedule/ScheduleCalendar/index.vue

@@ -2,11 +2,11 @@
   <schedule-wrapper
   <schedule-wrapper
     class="c-schedule-calendar"
     class="c-schedule-calendar"
     v-bind="scheduleOptions"
     v-bind="scheduleOptions"
+    :editable="editable"
     :dirty="dirty"
     :dirty="dirty"
     @add="addProgram"
     @add="addProgram"
     @submit="submit"
     @submit="submit"
     @save="onSave"
     @save="onSave"
-    @click.stop
   >
   >
     <div class="l-flex__none l-flex--row">
     <div class="l-flex__none l-flex--row">
       <button
       <button

+ 3 - 3
src/components/Schedule/ScheduleComplex/index.vue

@@ -2,11 +2,11 @@
   <schedule-wrapper
   <schedule-wrapper
     class="c-schedule-calendar"
     class="c-schedule-calendar"
     v-bind="scheduleOptions"
     v-bind="scheduleOptions"
+    :editable="editable"
     :dirty="dirty"
     :dirty="dirty"
     @add="onAdd"
     @add="onAdd"
     @submit="submit"
     @submit="submit"
     @save="onSave"
     @save="onSave"
-    @click.stop
   >
   >
     <div class="l-flex__none l-flex--row">
     <div class="l-flex__none l-flex--row">
       <button
       <button
@@ -273,7 +273,6 @@ export default {
       return this.events.map(({ origin }) => origin)
       return this.events.map(({ origin }) => origin)
     },
     },
     init () {
     init () {
-      this.$cache = {}
       const events = this.events
       const events = this.events
       const length = events.length
       const length = events.length
       const today = new Date()
       const today = new Date()
@@ -294,13 +293,14 @@ export default {
               maxDate = until
               maxDate = until
             }
             }
           }
           }
+          maxDate = toDate(maxDate)
         } else {
         } else {
           minDate = today
           minDate = today
           maxDate = today
           maxDate = today
         }
         }
       }
       }
       this.minDate = toZeroPoint(minDate)
       this.minDate = toZeroPoint(minDate)
-      this.maxDate = toDate(maxDate)
+      this.maxDate = maxDate
       this.toDay(maxDate ? toZeroPoint(pickMax(minDate, pickMin(today, maxDate))) : toZeroPoint(pickMax(minDate, today)))
       this.toDay(maxDate ? toZeroPoint(pickMax(minDate, pickMin(today, maxDate))) : toZeroPoint(pickMax(minDate, today)))
     },
     },
     calculate () {
     calculate () {

+ 1 - 1
src/components/Schedule/ScheduleSwiper/index.vue

@@ -2,11 +2,11 @@
   <schedule-wrapper
   <schedule-wrapper
     class="c-schedule-swiper"
     class="c-schedule-swiper"
     v-bind="scheduleOptions"
     v-bind="scheduleOptions"
+    :editable="editable"
     :dirty="dirty"
     :dirty="dirty"
     @add="onAdd"
     @add="onAdd"
     @submit="submit"
     @submit="submit"
     @save="onSave"
     @save="onSave"
-    @click.stop
   >
   >
     <el-empty
     <el-empty
       v-if="isEmpty"
       v-if="isEmpty"

+ 7 - 5
src/components/Schedule/mixins/schedule.js

@@ -21,20 +21,22 @@ export default {
     }
     }
   },
   },
   computed: {
   computed: {
-    isEmpty () {
-      return this.scheduleOptions?.events?.length === 0
-    },
     events () {
     events () {
-      return this.scheduleOptions?.events ?? []
+      return this.scheduleOptions?.events || []
+    },
+    isEmpty () {
+      return this.events.length === 0
     },
     },
     ratio () {
     ratio () {
       return this.scheduleOptions?.resolutionRatio
       return this.scheduleOptions?.resolutionRatio
+    },
+    editable () {
+      return this.scheduleOptions?.status === State.READY
     }
     }
   },
   },
   created () {
   created () {
     this.scheduleOptions = {
     this.scheduleOptions = {
       ...this.detail,
       ...this.detail,
-      editable: this.detail.status === State.READY,
       hideHeader: this.hideHeader,
       hideHeader: this.hideHeader,
       events: this._transformEvents(this.detail.events || []).map(this._transformEvent)
       events: this._transformEvents(this.detail.events || []).map(this._transformEvent)
     }
     }