From db6114a4eea18cc60b84a9e31dfe03aeed90a50b Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 7 Jan 2022 00:56:03 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E6=97=A5=E5=8E=86=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/pages/manage/calendar.vue | 29 +++++++++++++++++-- resources/assets/js/store/actions.js | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/resources/assets/js/pages/manage/calendar.vue b/resources/assets/js/pages/manage/calendar.vue index fffeef87..d982700e 100644 --- a/resources/assets/js/pages/manage/calendar.vue +++ b/resources/assets/js/pages/manage/calendar.vue @@ -67,6 +67,7 @@ export default { calendarList: [], loadIng: 0, + loadTimeout: null, } }, @@ -95,6 +96,8 @@ export default { category: isAllday ? 'allday' : 'time', start: $A.Date(data.start_at).toISOString(), end: $A.Date(data.end_at).toISOString(), + start_at: data.start_at, + end_at: data.end_at, color: "#515a6e", bgColor: data.color || '#E3EAFD', borderColor: data.p_color, @@ -102,6 +105,7 @@ export default { priority: '', preventClick: true, isChecked: false, + _time: data._time, }; if (data.p_name) { task.priority = '' + data.p_name + ''; @@ -193,19 +197,40 @@ export default { getTask(time) { if (this.loadIng > 0) { - setTimeout(() => { + clearTimeout(this.loadTimeout) + this.loadTimeout = setTimeout(() => { this.getTask(time) }, 100) return; } + // + const timeStart = $A.Date($A.formatDate(time[0] + " 00:00:00")), + timeEnd = $A.Date($A.formatDate(time[1] + " 23:59:59")), + now = $A.Time(); + const find = (item, n) => { + if (n === true && item._time < now) { + return false + } + const start = $A.Date(item.start_at), + end = $A.Date(item.end_at); + return (start <= timeStart && timeStart <= end) || (start <= timeEnd && timeEnd <= end) || (start > timeStart && timeEnd > end); + } + const currentIds = this.list.filter(item => find(item)).map(({id}) => id); + const call = () => { + const newIds = this.list.filter(item => find(item, true)).map(({id}) => id); + this.$store.dispatch("forgetTask", currentIds.filter(v => newIds.indexOf(v) == -1)) + } + // this.loadIng++; this.$store.dispatch("getTasks", { - time: time, + time, complete: "no" }).then(() => { this.loadIng--; + call() }).catch(() => { this.loadIng--; + call() }) }, diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 4e44a626..10a7127c 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -1085,7 +1085,7 @@ export default { const time = $A.Time() const currentIds = state.tasks.filter(task => task.project_id == project_id).map(({id}) => id) // - let call = () => { + const call = () => { const newIds = state.tasks.filter(task => task.project_id == project_id && task._time >= time).map(({id}) => id) dispatch("forgetTask", currentIds.filter(v => newIds.indexOf(v) == -1)) }