perf: 优化任务时间范围选择

This commit is contained in:
kuaifan 2025-03-31 23:49:11 +08:00
parent 0c8517667f
commit 52babf82ae
4 changed files with 15 additions and 22 deletions

View File

@ -297,7 +297,7 @@ export default {
return currentDate.format(format);
},
onBeforeCreateSchedule({start, end, isAllDay, guide}) {
async onBeforeCreateSchedule({start, end, isAllDay, guide}) {
if (isAllDay || this.calendarView == 'month') {
start = $A.dayjs(start.toDate()).startOf('day')
end = $A.dayjs(end.toDate()).endOf('day')
@ -305,16 +305,12 @@ export default {
start = $A.dayjs(start.toDate())
end = $A.dayjs(end.toDate())
}
this.$store.dispatch("taskDefaultTime", [
start.format('YYYY-MM-DD HH:mm:ss'),
end.format('YYYY-MM-DD HH:mm:ss')
]).then(times => {
emitter.emit('addTask', {
times,
owner: [this.userId],
beforeClose: () => guide.clearGuideElement()
});
})
const times = await this.$store.dispatch("taskDefaultTime", $A.newDateString([start, end], "YYYY-MM-DD HH:mm"))
emitter.emit('addTask', {
times,
owner: [this.userId],
beforeClose: () => guide.clearGuideElement()
});
},
onBeforeClickSchedule(event) {

View File

@ -416,9 +416,7 @@ export default {
async taskTimeChange(data) {
const times = $A.newDateString(data.times, "YYYY-MM-DD HH:mm");
if (/\s+(00:00|23:59)$/.test(times[0]) && /\s+(00:00|23:59)$/.test(times[1])) {
this.$set(data, 'times', await this.$store.dispatch("taskDefaultTime", times))
}
this.$set(data, 'times', await this.$store.dispatch("taskDefaultTime", times))
},
taskTimeOpenChange(val) {
@ -463,7 +461,7 @@ export default {
const days = $A.runNum(item.days);
if (days > 0) {
const end = start.clone().add(days, 'day');
this.$set(this.addData, 'times', await this.$store.dispatch("taskDefaultTime", $A.newDateString([start, end])))
this.$set(this.addData, 'times', await this.$store.dispatch("taskDefaultTime", $A.newDateString([start, end], 'YYYY-MM-DD 00:00')))
} else {
this.$set(this.addData, 'times', [])
}

View File

@ -1357,10 +1357,7 @@ export default {
},
async taskTimeChange() {
const times = $A.newDateString(this.timeValue, "YYYY-MM-DD HH:mm");
if (/\s+(00:00|23:59)$/.test(times[0]) && /\s+(00:00|23:59)$/.test(times[1])) {
this.timeValue = await this.$store.dispatch("taskDefaultTime", times)
}
this.timeValue = await this.$store.dispatch("taskDefaultTime", $A.newDateString(this.timeValue, "YYYY-MM-DD HH:mm"))
},
async onOwner(pick) {

View File

@ -2662,9 +2662,11 @@ export default {
*/
taskDefaultTime({state, dispatch}, array) {
return new Promise(async resolve => {
if ($A.isArray(array)) {
array[0] = await dispatch("taskDefaultStartTime", array[0])
array[1] = await dispatch("taskDefaultEndTime", array[1])
if ($A.isArray(array) && array.length === 2) {
if (/\s+(00:00|23:59)$/.test(array[0]) && /\s+(00:00|23:59)$/.test(array[1])) {
array[0] = await dispatch("taskDefaultStartTime", array[0])
array[1] = await dispatch("taskDefaultEndTime", array[1])
}
}
resolve(array)
});