|
@@ -13,7 +13,8 @@ export default defineComponent({
|
|
|
data() {
|
|
|
return {
|
|
|
selectStatus: false,
|
|
|
- calendarList: {}
|
|
|
+ calendarList: {},
|
|
|
+ calendarDate: new Date() as Date // 日历当前时间
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -76,6 +77,7 @@ export default defineComponent({
|
|
|
onSelectDay(obj: any) {
|
|
|
const result = obj || []
|
|
|
let list = [...createState.selectCourseList]
|
|
|
+ console.log(obj, list)
|
|
|
result.forEach((item: any) => {
|
|
|
const isExist = list.some(
|
|
|
(course: any) => course.startTime === item.startTime
|
|
@@ -87,7 +89,10 @@ export default defineComponent({
|
|
|
const isExist = result.some(
|
|
|
(course: any) => course.startTime === item.startTime
|
|
|
)
|
|
|
- !isExist && list.splice(list.indexOf(item), 1)
|
|
|
+ const index = result.findIndex(
|
|
|
+ (course: any) => course.startTime === item.startTime
|
|
|
+ )
|
|
|
+ !isExist && list.splice(index, 1)
|
|
|
})
|
|
|
// 对数组进行排序
|
|
|
list.sort((first: any, second: any) => {
|
|
@@ -155,7 +160,10 @@ export default defineComponent({
|
|
|
createState.coursePlanStatus = true
|
|
|
this.selectStatus = true
|
|
|
callBack && callBack()
|
|
|
- } catch {}
|
|
|
+ } catch {
|
|
|
+ // 报错时需要重置日历表的数据
|
|
|
+ this.getList(this.calendarDate || new Date())
|
|
|
+ }
|
|
|
},
|
|
|
async _unLookCourse() {
|
|
|
try {
|
|
@@ -200,6 +208,7 @@ export default defineComponent({
|
|
|
nextMonth={(date: Date) => this.getList(date)}
|
|
|
prevMonth={(date: Date) => this.getList(date)}
|
|
|
selectDay={this.onSelectDay}
|
|
|
+ v-model:calendarDate={this.calendarDate}
|
|
|
/>
|
|
|
|
|
|
<Cell
|