perf: 日历选择时间添加任务

This commit is contained in:
kuaifan 2022-01-06 23:15:04 +08:00
parent b870f5f4d1
commit 1975b8af1d
2 changed files with 18 additions and 9 deletions

View File

@ -31,6 +31,7 @@
:calendars="calendarList"
:schedules="list"
:taskView="false"
:useCreationPopup="false"
@beforeCreateSchedule="onBeforeCreateSchedule"
@beforeClickSchedule="onBeforeClickSchedule"
@beforeUpdateSchedule="onBeforeUpdateSchedule"
@ -47,6 +48,7 @@ import 'tui-calendar-hi/dist/tui-calendar-hi.css'
import {mapState, mapGetters} from "vuex";
import Calendar from "./components/Calendar";
import moment from "moment";
import {Store} from "le5le-store";
export default {
components: {Calendar},
@ -254,16 +256,13 @@ export default {
return currentDate.format(format);
},
onBeforeCreateSchedule(res) {
this.$store.dispatch("taskAdd", {
project_id: res.calendarId,
times: [res.start.toDate(), res.end.toDate()],
name: res.title,
onBeforeCreateSchedule({start, end, guide}) {
Store.set('addTask', {
times: [start.toDate(), end.toDate()],
owner: this.userId,
}).then(({msg}) => {
$A.messageSuccess(msg);
}).catch(({msg}) => {
$A.modalError(msg);
beforeClose: () => {
guide.clearGuideElement();
}
});
},

View File

@ -216,6 +216,8 @@ export default {
},
loadIng: 0,
beforeClose: [],
}
},
mounted() {
@ -246,6 +248,10 @@ export default {
this.$refs.input.focus()
})
} else {
this.beforeClose.some(func => {
typeof func === "function" && func()
})
this.beforeClose = [];
this.taskTimeOpen = false;
}
},
@ -479,6 +485,10 @@ export default {
},
setData(data) {
if (typeof data.beforeClose !== "undefined") {
this.beforeClose.push(data.beforeClose)
delete data.beforeClose;
}
this.addData = Object.assign({}, this.addData, data);
},