|
@@ -45,7 +45,16 @@ export default defineComponent({
|
|
|
return {
|
|
|
timerList: [],
|
|
|
list: [] as any,
|
|
|
- weekList: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
|
|
+ weekList: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
|
|
+ weekType: [
|
|
|
+ 'monday',
|
|
|
+ 'tuesday',
|
|
|
+ 'wednesday',
|
|
|
+ 'thursday',
|
|
|
+ 'friday',
|
|
|
+ 'saturday',
|
|
|
+ 'sunday'
|
|
|
+ ]
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
@@ -61,6 +70,7 @@ export default defineComponent({
|
|
|
const end = dayjs(endTime, 'HH:mm')
|
|
|
|
|
|
const timerList: any = []
|
|
|
+ // 生成一天的时间段
|
|
|
while (start.add(space, 'minute').isSameOrBefore(dayjs(end))) {
|
|
|
const item = {
|
|
|
startTime: start.format('HH:mm'),
|
|
@@ -73,6 +83,7 @@ export default defineComponent({
|
|
|
start = start.add(space, 'minute')
|
|
|
}
|
|
|
const list: any = []
|
|
|
+ // 生成一周的时间段
|
|
|
timerList.forEach((item: any) => {
|
|
|
const weekList: any = []
|
|
|
for (let i = 0; i < 7; i++) {
|
|
@@ -82,6 +93,24 @@ export default defineComponent({
|
|
|
}
|
|
|
list.push(weekList)
|
|
|
})
|
|
|
+
|
|
|
+ const tempList = this._initData(list)
|
|
|
+ return tempList
|
|
|
+ },
|
|
|
+ _initData(list: Array<any>) {
|
|
|
+ // 回显数据
|
|
|
+ const weekType = this.weekType
|
|
|
+ const timerObject = this.timerObject
|
|
|
+ list.forEach((item: any) => {
|
|
|
+ item.forEach((slot: any, slotIndex: number) => {
|
|
|
+ const dayList = timerObject[weekType[slotIndex]]
|
|
|
+ const startTime = dayjs(slot.startTime, 'HH:mm').format('HH:mm:ss')
|
|
|
+ const isExist = dayList?.some(
|
|
|
+ (course: any) => course.startTime === startTime
|
|
|
+ )
|
|
|
+ isExist && (slot.status = true)
|
|
|
+ })
|
|
|
+ })
|
|
|
return list
|
|
|
},
|
|
|
btnStatus(index: number, type: 'row' | 'col') {
|
|
@@ -121,15 +150,7 @@ export default defineComponent({
|
|
|
saturday: [],
|
|
|
sunday: []
|
|
|
}
|
|
|
- const weekType = [
|
|
|
- 'monday',
|
|
|
- 'tuesday',
|
|
|
- 'wednesday',
|
|
|
- 'thursday',
|
|
|
- 'friday',
|
|
|
- 'saturday',
|
|
|
- 'sunday'
|
|
|
- ]
|
|
|
+ const weekType = this.weekType
|
|
|
let status = false
|
|
|
list.forEach((item: any, i: number) => {
|
|
|
item.forEach((times: any, j: number) => {
|