|
|
@@ -5,7 +5,7 @@
|
|
|
:hide-header="hideHeader"
|
|
|
:editable="editable"
|
|
|
:dirty="dirty"
|
|
|
- @add="addProgram"
|
|
|
+ @add="onAdd"
|
|
|
@submit="submit"
|
|
|
@save="onSave"
|
|
|
>
|
|
|
@@ -13,561 +13,137 @@
|
|
|
<button
|
|
|
class="l-flex__none o-button c-schedule-calendar__toggle"
|
|
|
:class="{ show: canToToday }"
|
|
|
- @click="today"
|
|
|
+ @click="onToday"
|
|
|
>
|
|
|
今日
|
|
|
</button>
|
|
|
<div class="l-flex__fill l-flex--row center">
|
|
|
<i
|
|
|
class="c-schedule-calendar__toggle c-schedule-calendar__btn el-icon-arrow-left c-sibling-item u-pointer"
|
|
|
- :class="{ show: canToPresent }"
|
|
|
- @click="toPresent"
|
|
|
+ :class="{ show: canToPrevious }"
|
|
|
+ @click="onPrevious"
|
|
|
/>
|
|
|
<span class="c-schedule-calendar__time u-readonly">{{ date }}</span>
|
|
|
<i
|
|
|
class="c-schedule-calendar__toggle c-schedule-calendar__btn el-icon-arrow-right u-pointer"
|
|
|
:class="{ show: canToNext }"
|
|
|
- @click="toNext"
|
|
|
+ @click="onNext"
|
|
|
/>
|
|
|
</div>
|
|
|
+ <div class="l-flex__none l-flex--row c-schedule-calendar__mode u-pointer">
|
|
|
+ <div
|
|
|
+ class="c-schedule-calendar__type"
|
|
|
+ :class="{ active: mode === 0 }"
|
|
|
+ @click="onChangeToWeek"
|
|
|
+ >
|
|
|
+ 周
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class="c-schedule-calendar__type"
|
|
|
+ :class="{ active: mode === 1 }"
|
|
|
+ @click="onChangeToMonth"
|
|
|
+ >
|
|
|
+ 月
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <schedule-calendar-month
|
|
|
- class="l-flex__auto c-schedule-calendar__main"
|
|
|
- :weeks="weeks"
|
|
|
+ <component
|
|
|
+ :is="activeComponent"
|
|
|
+ class="c-schedule-calendar__main"
|
|
|
:editable="editable"
|
|
|
- @add="addProgramByDay"
|
|
|
- @edit="editProgram"
|
|
|
- @remove="removeProgram"
|
|
|
+ :weeks="weeks"
|
|
|
+ :cursor="weekIndex"
|
|
|
+ @add="onAdd"
|
|
|
+ @edit="onEditProxy"
|
|
|
+ @remove="onRemove"
|
|
|
+ @switch="toDay"
|
|
|
/>
|
|
|
- <el-dialog
|
|
|
- title="排期设置"
|
|
|
- :visible.sync="editing"
|
|
|
- custom-class="c-dialog"
|
|
|
- :close-on-click-modal="false"
|
|
|
- :before-close="onCloseEditDialog"
|
|
|
+ <confirm-dialog
|
|
|
+ ref="editDialog"
|
|
|
+ title="事件设置"
|
|
|
+ @confirm="onSaveEvent"
|
|
|
>
|
|
|
<schedule-edit
|
|
|
- v-if="program"
|
|
|
+ v-if="event"
|
|
|
ref="editor"
|
|
|
- :program="program"
|
|
|
+ :event="event"
|
|
|
:ratio="ratio"
|
|
|
- :min-date="min"
|
|
|
- :max-date="max"
|
|
|
/>
|
|
|
- <template #footer>
|
|
|
- <button
|
|
|
- class="o-button"
|
|
|
- @click="saveProgram"
|
|
|
- >
|
|
|
- 确定
|
|
|
- </button>
|
|
|
- <button
|
|
|
- class="o-button cancel"
|
|
|
- @click="onCloseEditDialog"
|
|
|
- >
|
|
|
- 取消
|
|
|
- </button>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
- <el-dialog
|
|
|
+ </confirm-dialog>
|
|
|
+ <confirm-dialog
|
|
|
+ ref="conflictDialog"
|
|
|
title="冲突提醒"
|
|
|
- :visible.sync="conflicting"
|
|
|
- custom-class="c-dialog"
|
|
|
- :close-on-click-modal="false"
|
|
|
append-to-body
|
|
|
+ @confirm="onCover"
|
|
|
>
|
|
|
- <div class="has-bottom-padding u-bold">
|
|
|
- <div>局部覆盖:被冲突的节目的时间段将被切割</div>
|
|
|
- <div>覆盖:被冲突的节目将被移除</div>
|
|
|
- </div>
|
|
|
<div
|
|
|
v-for="conflict in conflicts"
|
|
|
:key="conflict.key"
|
|
|
+ class="o-conflict"
|
|
|
>
|
|
|
- 与 {{ conflict.target.name }} 于 {{ conflict.start }} ~ {{ conflict.end }} 冲突
|
|
|
+ {{ conflict.info }}
|
|
|
+ <div class="o-conflict__desc">{{ conflict.desc }}</div>
|
|
|
</div>
|
|
|
- <template #footer>
|
|
|
- <button
|
|
|
- class="o-button"
|
|
|
- @click="_coverConflicts"
|
|
|
- >
|
|
|
- 局部覆盖
|
|
|
- </button>
|
|
|
- <button
|
|
|
- class="o-button"
|
|
|
- @click="_coverConflictsFull"
|
|
|
- >
|
|
|
- 覆盖
|
|
|
- </button>
|
|
|
- <button
|
|
|
- class="o-button cancel"
|
|
|
- @click="conflicting = false"
|
|
|
- >
|
|
|
- 取消
|
|
|
- </button>
|
|
|
- </template>
|
|
|
+ </confirm-dialog>
|
|
|
+ <el-dialog
|
|
|
+ :visible.sync="isPreviewing"
|
|
|
+ custom-class="c-preview schedule"
|
|
|
+ :before-close="onClosePreviewDialog"
|
|
|
+ append-to-body
|
|
|
+ >
|
|
|
+ <schedule
|
|
|
+ v-if="scheduleId"
|
|
|
+ class="l-flex__auto has-padding"
|
|
|
+ :schedule="scheduleId"
|
|
|
+ />
|
|
|
</el-dialog>
|
|
|
</schedule-wrapper>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { parseTime } from '@/utils'
|
|
|
-import scheduleMixin from '../mixins/schedule'
|
|
|
+import { ScheduleType } from '@/constant'
|
|
|
+import {
|
|
|
+ toEvent,
|
|
|
+ toDate
|
|
|
+} from '@/utils/event'
|
|
|
+import calendarMixin from '../mixins/calendar'
|
|
|
import ScheduleWrapper from '../components/ScheduleWrapper'
|
|
|
+import ScheduleCalendarWeek from './ScheduleCalendarWeek'
|
|
|
import ScheduleCalendarMonth from './ScheduleCalendarMonth'
|
|
|
-import ScheduleEdit from './ScheduleEdit'
|
|
|
+import ScheduleEdit from './ScheduleComplexEdit'
|
|
|
|
|
|
export default {
|
|
|
- name: 'ScheduleCalendar',
|
|
|
+ name: 'ScheduleComplex',
|
|
|
components: {
|
|
|
ScheduleWrapper,
|
|
|
+ ScheduleCalendarWeek,
|
|
|
ScheduleCalendarMonth,
|
|
|
ScheduleEdit
|
|
|
},
|
|
|
- mixins: [scheduleMixin],
|
|
|
- data () {
|
|
|
- return {
|
|
|
- weeks: [],
|
|
|
- min: null,
|
|
|
- max: null,
|
|
|
- current: null,
|
|
|
- editing: false,
|
|
|
- program: null,
|
|
|
- dirty: false,
|
|
|
- conflicting: false,
|
|
|
- conflicts: []
|
|
|
- }
|
|
|
- },
|
|
|
- computed: {
|
|
|
- date () {
|
|
|
- return this.current ? `${this.current.year}.${this.current.month + 1}` : ''
|
|
|
- },
|
|
|
- canToPresent () {
|
|
|
- return this.current ? this._compare(this.current, this.min, false) > 0 : false
|
|
|
- },
|
|
|
- canToNext () {
|
|
|
- return this.current && this.max ? this._compare(this.current, this.max, false) < 0 : !!this.current
|
|
|
- },
|
|
|
- canToToday () {
|
|
|
- if (!this.current) {
|
|
|
- return false
|
|
|
- }
|
|
|
- if (this.editable) {
|
|
|
- return this._compare(this.current, this._transform(Date.now()), false) !== 0
|
|
|
- }
|
|
|
- if (this.min && this.max) {
|
|
|
- const today = this._transform(Date.now())
|
|
|
- return this._compare(this.min, today, false) <= 0 && this._compare(this.max, today, false) >= 0
|
|
|
- }
|
|
|
- return false
|
|
|
- }
|
|
|
- },
|
|
|
+ mixins: [calendarMixin],
|
|
|
methods: {
|
|
|
- init () {
|
|
|
- const now = this._transform(Date.now())
|
|
|
- let current = {
|
|
|
- year: now.year,
|
|
|
- month: now.month
|
|
|
- }
|
|
|
- if (this.editable) {
|
|
|
- this._setMinDate()
|
|
|
- if (this.events.length) {
|
|
|
- const minDate = this._transform(this.events[0].startDateTime)
|
|
|
- if (this._compare(now, minDate, false) < 0) {
|
|
|
- current = {
|
|
|
- year: minDate.year,
|
|
|
- month: minDate.month
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (this.events.length) {
|
|
|
- this.min = this._transform(this.events[0].startDateTime)
|
|
|
- this.max = this.events.reduce((curr, { endDateTime }) => {
|
|
|
- const date = this._transform(endDateTime)
|
|
|
- if (curr) {
|
|
|
- return this._compare(curr, date) < 0 ? date : curr
|
|
|
- }
|
|
|
- return date
|
|
|
- }, null)
|
|
|
- } else {
|
|
|
- this.max = this.min = now
|
|
|
- }
|
|
|
- if (this._compare(now, this.max, false) > 0) {
|
|
|
- current = {
|
|
|
- year: this.min.year,
|
|
|
- month: this.min.month
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- this.current = current
|
|
|
- this._calculate()
|
|
|
- },
|
|
|
- fix () {
|
|
|
- let endTime = Date.now() + 60000
|
|
|
- if (this.events.some(({ endDateTime }) => new Date(endDateTime).getTime() <= endTime)) {
|
|
|
- return this.$confirm(
|
|
|
- '存在过期或将要过期(<=60s)节目,是否移除?',
|
|
|
- {
|
|
|
- type: 'warning',
|
|
|
- distinguishCancelAndClose: true,
|
|
|
- confirmButtonText: '移除',
|
|
|
- cancelButtonText: '保留'
|
|
|
- }
|
|
|
- ).then(
|
|
|
- () => {
|
|
|
- endTime = Date.now() + 60000
|
|
|
- this.scheduleOptions.events = this.events.filter(({ endDateTime }) => new Date(endDateTime).getTime() > endTime)
|
|
|
- if (this._compare(this.current, this._transform(endTime), false) <= 0) {
|
|
|
- this._calculate()
|
|
|
+ transformEvents (events, type) {
|
|
|
+ switch (type) {
|
|
|
+ case ScheduleType.CALENDAR:
|
|
|
+ return events.map(event => this.createEventProxy(toEvent(event))).sort((a, b) => toDate(a.origin.start) - toDate(b.origin.start))
|
|
|
+ default:
|
|
|
+ return events.sort((a, b) => toDate(a.start) - toDate(b.start)).map(this.createEventProxy)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getEvents () {
|
|
|
+ switch (this.scheduleOptions.type) {
|
|
|
+ case ScheduleType.CALENDAR:
|
|
|
+ return this.events.map(({ origin: event }) => {
|
|
|
+ const { start, until, target: { id, name } } = event
|
|
|
+ return {
|
|
|
+ programId: id,
|
|
|
+ programName: name,
|
|
|
+ startDateTime: start,
|
|
|
+ endDateTime: until
|
|
|
}
|
|
|
- },
|
|
|
- action => {
|
|
|
- if (action === 'cancel') {
|
|
|
- return Promise.reject()
|
|
|
- }
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- return Promise.resolve()
|
|
|
- },
|
|
|
- onSave () {
|
|
|
- this.fix().then(this.save).then(() => { this.dirty = false })
|
|
|
- },
|
|
|
- _transformEvents (events) {
|
|
|
- return events.sort(this._sortEvents)
|
|
|
- },
|
|
|
- _sortEvents (a, b) {
|
|
|
- return new Date(a.startDateTime).getTime() - new Date(b.startDateTime).getTime()
|
|
|
- },
|
|
|
- _transformEvent ({ programId, programName, startDateTime, endDateTime }) {
|
|
|
- // 服务器保存的时间采用左闭右开原则
|
|
|
- return this._createEvent(programId, programName, startDateTime, this._offsetDateTime(endDateTime, -1))
|
|
|
- },
|
|
|
- _getEvents () {
|
|
|
- return this.events.map(({ id, name, startDateTime, endDateTime }) => {
|
|
|
- endDateTime = this._offsetDateTime(endDateTime, 1)
|
|
|
- return {
|
|
|
- programId: id,
|
|
|
- programName: name,
|
|
|
- startDateTime, endDateTime
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- _createEvent (id, name, startDateTime, endDateTime) {
|
|
|
- return {
|
|
|
- id, name, startDateTime, endDateTime,
|
|
|
- key: Math.random().toString(16).slice(2),
|
|
|
- days: this._getDays(startDateTime, endDateTime)
|
|
|
- }
|
|
|
- },
|
|
|
- _offsetDateTime (dateTime, val) {
|
|
|
- return parseTime(new Date(dateTime).getTime() + val * 1000, '{y}-{m}-{d} {h}:{i}:{s}')
|
|
|
- },
|
|
|
- _getDays (startDateTime, endDateTime) {
|
|
|
- const days = {}
|
|
|
- const { year: endYear, month: endMonth, day: endDay } = this._transform(endDateTime)
|
|
|
- const end = `${endYear}-${endMonth + 1}-${endDay}`
|
|
|
- let { year, month, day } = this._transform(startDateTime)
|
|
|
- let start = `${year}-${month + 1}-${day}`
|
|
|
- while (start !== end) {
|
|
|
- days[start] = 1
|
|
|
- ;({ year, month, day } = this._transform(new Date(year, month, day + 1)))
|
|
|
- start = `${year}-${month + 1}-${day}`
|
|
|
- }
|
|
|
- days[start] = 1
|
|
|
- return days
|
|
|
- },
|
|
|
- removeProgram ({ key, name }) {
|
|
|
- this.$confirm(
|
|
|
- `确定移除节目 ${name}`,
|
|
|
- { type: 'warning' }
|
|
|
- ).then(() => {
|
|
|
- this.dirty = true
|
|
|
- this._removeProgram(key)
|
|
|
- this._calculate()
|
|
|
- })
|
|
|
- },
|
|
|
- _removeProgram (key) {
|
|
|
- if (!key) {
|
|
|
- return
|
|
|
- }
|
|
|
- const index = this.events.findIndex(event => event.key === key)
|
|
|
- this.events.splice(index, 1)
|
|
|
- if (index === 0) {
|
|
|
- this._setMinDate()
|
|
|
- if (this._compare(this.current, this.min, false) < 0) {
|
|
|
- this.current = {
|
|
|
- year: this.min.year,
|
|
|
- month: this.min.month
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- _setMinDate () {
|
|
|
- let minDate = this._transform(Date.now())
|
|
|
- if (this.events.length) {
|
|
|
- const minProgramDate = this._transform(this.events[0].startDateTime)
|
|
|
- if (this._compare(minDate, minProgramDate, false) > 0) {
|
|
|
- minDate = minProgramDate
|
|
|
- }
|
|
|
- }
|
|
|
- if (!this.min || this._compare(this.min, minDate) < 0) {
|
|
|
- this.min = minDate
|
|
|
- }
|
|
|
- },
|
|
|
- addProgram () {
|
|
|
- this.editProgram({})
|
|
|
- },
|
|
|
- addProgramByDay (day) {
|
|
|
- if (day.editable) {
|
|
|
- const { year, month } = this.current
|
|
|
- const date = day.value
|
|
|
- this.editProgram({
|
|
|
- startDateTime: `${year}-${(month + 1).toString().padStart(2, '0')}-${(date).toString().padStart(2, '0')} ${this._compare({ year, month, day: date }, this._transform(Date.now())) === 0 ? parseTime(new Date(), '{h}:{i}:{s}') : '00:00:00'}`,
|
|
|
- endDateTime: `${year}-${(month + 1).toString().padStart(2, '0')}-${(date).toString().padStart(2, '0')} 23:59:59`
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- editProgram (program) {
|
|
|
- if (this.editable) {
|
|
|
- this.program = program
|
|
|
- this.editing = true
|
|
|
- }
|
|
|
- },
|
|
|
- saveProgram () {
|
|
|
- const { id, name, startDateTime, endDateTime } = this.$refs.editor.getValue()
|
|
|
- if (!startDateTime || !endDateTime) {
|
|
|
- this.$message({
|
|
|
- type: 'warning',
|
|
|
- message: '请选择生效时间'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (!id) {
|
|
|
- this.$message({
|
|
|
- type: 'warning',
|
|
|
- message: '请选择节目'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.program.id &&
|
|
|
- id === this.program.id &&
|
|
|
- startDateTime === this.program.startDateTime &&
|
|
|
- endDateTime === this.program.endDateTime
|
|
|
- ) {
|
|
|
- this.onCloseEditDialog()
|
|
|
- return
|
|
|
- }
|
|
|
- this._program = { id, name, startDateTime, endDateTime }
|
|
|
- if (this._checkConflict(this._program, this.program.key)) {
|
|
|
- this._saveProgram()
|
|
|
- }
|
|
|
- },
|
|
|
- _saveProgram () {
|
|
|
- this._removeProgram(this.program.key)
|
|
|
- this._mergeOrAdd()
|
|
|
- this.dirty = true
|
|
|
- this._calculate()
|
|
|
- this.onCloseEditDialog()
|
|
|
- },
|
|
|
- _mergeOrAdd () {
|
|
|
- let program = this._program
|
|
|
- const timestamp = new Date(program.startDateTime).getTime()
|
|
|
- const insertIndex = this.events.findIndex(item => new Date(item.startDateTime).getTime() > timestamp)
|
|
|
- let pre = null
|
|
|
- let next = null
|
|
|
- let add = true
|
|
|
- if (~insertIndex) {
|
|
|
- pre = this.events[insertIndex - 1]
|
|
|
- next = this.events[insertIndex]
|
|
|
- } else {
|
|
|
- pre = this.events[this.events.length - 1]
|
|
|
- }
|
|
|
- if (next && program.id === next.id && new Date(program.endDateTime).getTime() + 1000 === new Date(next.startDateTime).getTime()) {
|
|
|
- next.startDateTime = program.startDateTime
|
|
|
- program = next
|
|
|
- add = false
|
|
|
- }
|
|
|
- if (pre && program.id === pre.id && new Date(pre.endDateTime).getTime() + 1000 === new Date(program.startDateTime).getTime()) {
|
|
|
- pre.endDateTime = program.endDateTime
|
|
|
- this._removeProgram(program.key)
|
|
|
- program = pre
|
|
|
- add = false
|
|
|
- }
|
|
|
- program.key = Math.random().toString(16).slice(2)
|
|
|
- program.days = this._getDays(program.startDateTime, program.endDateTime)
|
|
|
- if (add) {
|
|
|
- if (next) {
|
|
|
- this.events.splice(insertIndex, 0, program)
|
|
|
- } else {
|
|
|
- this.events.push(program)
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- _checkConflict (program, key) {
|
|
|
- if (this.events.length) {
|
|
|
- const cstartDateTime = new Date(program.startDateTime)
|
|
|
- const cendDateTime = new Date(program.endDateTime)
|
|
|
- this.conflicts = this.events.filter(item => {
|
|
|
- const startDateTime = new Date(item.startDateTime)
|
|
|
- const endDateTime = new Date(item.endDateTime)
|
|
|
- return item.key !== key && !(cstartDateTime > endDateTime || cendDateTime < startDateTime)
|
|
|
- }).map(item => {
|
|
|
- const startDateTime = new Date(item.startDateTime)
|
|
|
- const endDateTime = new Date(item.endDateTime)
|
|
|
- return {
|
|
|
- target: item,
|
|
|
- key: item.key,
|
|
|
- start: cstartDateTime > startDateTime ? program.startDateTime : item.startDateTime,
|
|
|
- end: cendDateTime > endDateTime ? item.endDateTime : program.endDateTime
|
|
|
- }
|
|
|
- })
|
|
|
- if (this.conflicts.length) {
|
|
|
- this.conflicting = true
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
- return true
|
|
|
- },
|
|
|
- _coverConflicts () {
|
|
|
- const now = Date.now()
|
|
|
- this.conflicts.forEach(({ target, key, start, end }) => {
|
|
|
- const { startDateTime, endDateTime } = target
|
|
|
- if (new Date(endDateTime).getTime() <= now || startDateTime === start && endDateTime === end) {
|
|
|
- this._removeProgram(key)
|
|
|
- return
|
|
|
- }
|
|
|
- if (startDateTime === start) {
|
|
|
- target.startDateTime = this._offsetDateTime(end, 1)
|
|
|
- } else {
|
|
|
- if (endDateTime !== end) {
|
|
|
- const index = this.events.findIndex(({ key }) => key === target.key)
|
|
|
- this.events.splice(index + 1, 0, this._createEvent(target.id, target.name, this._offsetDateTime(end, 1), target.endDateTime))
|
|
|
- }
|
|
|
- target.endDateTime = this._offsetDateTime(start, -1)
|
|
|
- }
|
|
|
- target.days = this._getDays(target.startDateTime, target.endDateTime)
|
|
|
- })
|
|
|
- this.conflicting = false
|
|
|
- this._saveProgram()
|
|
|
- },
|
|
|
- _coverConflictsFull () {
|
|
|
- this.conflicts.forEach(({ key }) => this._removeProgram(key))
|
|
|
- this.conflicting = false
|
|
|
- this._saveProgram()
|
|
|
- },
|
|
|
- onCloseEditDialog () {
|
|
|
- this.program = null
|
|
|
- this.editing = false
|
|
|
- },
|
|
|
- today () {
|
|
|
- const { year, month } = this._transform(Date.now())
|
|
|
- this.current = { year, month }
|
|
|
- this._calculate()
|
|
|
- },
|
|
|
- _transform (timestamp) {
|
|
|
- const date = new Date(timestamp)
|
|
|
- return {
|
|
|
- year: date.getFullYear(),
|
|
|
- month: date.getMonth(),
|
|
|
- day: date.getDate()
|
|
|
- }
|
|
|
- },
|
|
|
- _compare (a, b, full = true) {
|
|
|
- if (a.year === b.year) {
|
|
|
- if (full && a.month === b.month) {
|
|
|
- return a.day - b.day
|
|
|
- }
|
|
|
- return a.month - b.month
|
|
|
- }
|
|
|
- return a.year - b.year
|
|
|
- },
|
|
|
- _createItem (date, disabled) {
|
|
|
- const dateObj = this._transform(date)
|
|
|
- const invalid = this._compare(dateObj, this._transform(Date.now())) < 0
|
|
|
- const day = `${dateObj.year}-${dateObj.month + 1}-${dateObj.day}`
|
|
|
- return {
|
|
|
- value: dateObj.day,
|
|
|
- editable: this.editable && !disabled && !invalid,
|
|
|
- invalid,
|
|
|
- disabled,
|
|
|
- events: this.events.length ? this.events.filter(program => {
|
|
|
- return program.days[day]
|
|
|
- }) : []
|
|
|
- }
|
|
|
- },
|
|
|
- _calculate () {
|
|
|
- const { year, month } = this.current
|
|
|
- const monthDays = this._getPresentMonthDays(year, month).concat(this._currentMonthDays(year, month))
|
|
|
- const diff = 42 - monthDays.length
|
|
|
- const dates = diff === 0 ? monthDays : monthDays.concat(this._getNextMonthDays(year, month, diff))
|
|
|
- const weeks = []
|
|
|
- let row
|
|
|
- for (let i = 0; i < dates.length; i++) {
|
|
|
- if (i % 7 === 0) {
|
|
|
- row = weeks.length
|
|
|
- weeks[row] = []
|
|
|
- }
|
|
|
- weeks[row][i % 7] = dates[i]
|
|
|
- }
|
|
|
- this.weeks = weeks
|
|
|
- },
|
|
|
- _currentMonthDays (year, month) {
|
|
|
- const dateArr = []
|
|
|
- const lastDay = new Date(year, month + 1, 0).getDate()
|
|
|
-
|
|
|
- for (let i = 1; i <= lastDay; i++) {
|
|
|
- dateArr.push(this._createItem(new Date(year, month, i)))
|
|
|
- }
|
|
|
- return dateArr
|
|
|
- },
|
|
|
- _getPresentMonthDays (year, month) {
|
|
|
- const dateArr = []
|
|
|
- const week = new Date(year, month, 1).getDay()
|
|
|
- const fill = week === 0 ? 7 : week
|
|
|
-
|
|
|
- for (let i = fill; i > 0; i--) {
|
|
|
- dateArr.push(this._createItem(new Date(year, month, 1 - i), true))
|
|
|
- }
|
|
|
-
|
|
|
- return dateArr
|
|
|
- },
|
|
|
- _getNextMonthDays (year, month, count) {
|
|
|
- const dateArr = []
|
|
|
-
|
|
|
- for (let i = 0; i < count; i++) {
|
|
|
- dateArr.push(this._createItem(new Date(year, month + 1, 1 + i), true))
|
|
|
- }
|
|
|
-
|
|
|
- return dateArr
|
|
|
- },
|
|
|
- _offsetMonth (offset) {
|
|
|
- if (offset < 0) {
|
|
|
- if (this.current.month === 0) {
|
|
|
- this.current.year -= 1
|
|
|
- this.current.month = 11
|
|
|
- } else {
|
|
|
- this.current.month -= 1
|
|
|
- }
|
|
|
- } else if (offset > 0) {
|
|
|
- if (this.current.month === 11) {
|
|
|
- this.current.year += 1
|
|
|
- this.current.month = 0
|
|
|
- } else {
|
|
|
- this.current.month += 1
|
|
|
- }
|
|
|
- }
|
|
|
- this._calculate()
|
|
|
- },
|
|
|
- toPresent () {
|
|
|
- if (this.canToPresent) {
|
|
|
- this._offsetMonth(-1)
|
|
|
- }
|
|
|
- },
|
|
|
- toNext () {
|
|
|
- if (this.canToNext) {
|
|
|
- this._offsetMonth(1)
|
|
|
+ })
|
|
|
+ default:
|
|
|
+ return this.events.map(({ origin }) => origin)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -604,8 +180,14 @@ export default {
|
|
|
}
|
|
|
|
|
|
&__main {
|
|
|
- color: $black;
|
|
|
- font-size: 16px;
|
|
|
+ flex: 0 1 auto;
|
|
|
+ min-height: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__mode {
|
|
|
+ border-radius: 4px;
|
|
|
+ background-color: #f4f7f8;
|
|
|
+ overflow: hidden;
|
|
|
}
|
|
|
|
|
|
&__type {
|
|
|
@@ -618,4 +200,12 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.o-conflict {
|
|
|
+ &__desc {
|
|
|
+ padding: 4px 0;
|
|
|
+ color: $info;
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|