| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <script>
- import { getSchedule } from '@/api/calendar'
- import ScheduleCalendar from './ScheduleCalendar'
- import ScheduleSwiper from './ScheduleSwiper'
- export default {
- name: 'Schedule',
- components: {
- ScheduleCalendar,
- ScheduleSwiper
- },
- props: {
- schedule: {
- type: String,
- default: null
- }
- },
- data () {
- return {
- options: null
- }
- },
- watch: {
- schedule: {
- handler () {
- this.getSchedule()
- },
- immediate: true
- }
- },
- methods: {
- getSchedule () {
- const options = {
- loading: true,
- error: false,
- detail: null
- }
- this.options = options
- getSchedule(this.schedule).then(
- schedule => {
- options.detail = schedule
- },
- () => {
- options.error = true
- }
- ).finally(() => {
- options.loading = false
- })
- }
- },
- render (h) {
- if (this.options.loading) {
- return h('div', {
- directives: [
- {
- name: 'loading',
- value: true
- }
- ]
- })
- }
- if (this.options.error) {
- return h('Warning', {
- props: {
- error: true
- },
- on: {
- click: this.getSchedule
- }
- })
- }
- const { detail } = this.options
- return h([null, 'ScheduleSwiper', 'ScheduleCalendar'][detail.type - 1], {
- props: {
- detail,
- ...this.$attrs
- },
- on: this.$listeners
- })
- }
- }
- </script>
|