tiny-vue/examples/sites/demos/mobile-first/app/calendar-bar/workday.vue

45 lines
1.3 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<tiny-calendar-bar v-model="value" :config="config"></tiny-calendar-bar>
</template>
<script>
import { CalendarBar } from '@opentiny/vue'
export default {
components: {
TinyCalendarBar: CalendarBar
},
data() {
return {
value: '2022-10-18',
config: {
workday: this.workday,
holiday: this.holiday,
workdayColorClass: 'text-color-text-primary',
holidayColorClass: 'text-color-none-hover'
}
}
},
methods: {
workday(date) {
const year = date.getFullYear()
const month = date.getMonth() + 1
const dat = date.getDate()
// 把10月1号到10月7号之间的所有当前月工作日判断为假期10月1号、2号是周末不会调用到此方法
if (year === 2022 && month === 10 && dat >= 1 && dat <= 7) return false
// 其他当前月工作日 默认返回true
return true
},
holiday(date) {
const year = date.getFullYear()
const month = date.getMonth() + 1
const dat = date.getDate()
// 把10月8号、9号和29号月末周六判断为工作日
if (year === 2022 && month === 10 && ~[8, 9, 29].indexOf(dat)) return false
// 其他当前月周末 默认返回true
return true
}
}
}
</script>