From 1fe4e80f820828b33f68b82edd1903e5ca94755f Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sun, 9 Jan 2022 12:54:04 +0800 Subject: [PATCH] no msg --- package.json | 2 +- resources/assets/js/pages/manage/calendar.vue | 60 ++++++++++++++----- .../js/pages/manage/components/TaskMenu.vue | 11 +++- resources/assets/sass/element.scss | 6 ++ .../assets/sass/pages/page-calendar.scss | 7 +++ 5 files changed, 69 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 0cf07b5f..6367c706 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "stylus": "^0.56.0", "stylus-loader": "^6.2.0", "tinymce": "^5.10.2", - "tui-calendar-hi": "^1.15.1-1", + "tui-calendar-hi": "^1.15.1-5", "view-design-hi": "^4.7.0-5", "vue": "^2.6.14", "vue-clipboard2": "^0.3.3", diff --git a/resources/assets/js/pages/manage/calendar.vue b/resources/assets/js/pages/manage/calendar.vue index ac02e25b..b0e30fd7 100644 --- a/resources/assets/js/pages/manage/calendar.vue +++ b/resources/assets/js/pages/manage/calendar.vue @@ -36,6 +36,9 @@ @beforeUpdateSchedule="onBeforeUpdateSchedule" disable-click/> +
+ +
@@ -48,9 +51,10 @@ import {mapState, mapGetters} from "vuex"; import Calendar from "./components/Calendar"; import moment from "moment"; import {Store} from "le5le-store"; +import TaskMenu from "./components/TaskMenu"; export default { - components: {Calendar}, + components: {TaskMenu, Calendar}, data() { return { lists: [], @@ -63,6 +67,11 @@ export default { calendarMonth: {}, calendarTheme: {}, calendarTemplate: {}, + calendarTask: {}, + calendarMenuStyles: { + top: 0, + left: 0 + }, loadIng: 0, loadTimeout: null, @@ -94,15 +103,17 @@ 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, complete_at: data.complete_at, priority: '', preventClick: true, + preventCheckHide: true, isChecked: false, + // + start_at: data.start_at, + end_at: data.end_at, _time: data._time, }; if (data.p_name) { @@ -117,7 +128,7 @@ export default { if (data.overdue) { task.title = `[${this.$L('超期')}] ${task.title}` task.color = "#f56c6c" - task.bgColor = "#fef0f0" + task.bgColor = data.color || "#fef0f0" task.priority+= '' + this.$L('超期未完成') + ''; } if (!task.borderColor) { @@ -281,23 +292,20 @@ export default { }); }, - onBeforeClickSchedule({type, schedule}) { + onBeforeClickSchedule(event) { + const {type, schedule} = event; let data = this.cacheTasks.find(({id}) => id === schedule.id); if (!data) { return; } switch (type) { case "check": - this.$set(data, 'complete_at', $A.formatDate("Y-m-d H:i:s")) - this.$store.dispatch("taskUpdate", { - task_id: data.id, - complete_at: $A.formatDate("Y-m-d H:i:s"), - }).then(({msg}) => { - $A.messageSuccess(msg); - }).catch(({msg}) => { - this.$set(data, 'complete_at', null) - $A.modalError(msg); - }); + this.calendarMenuStyles = { + left: `${this.getElementLeft(event.target)}px`, + top: `${this.getElementTop(event.target) - 8}px` + } + this.calendarTask = data; + this.$nextTick(this.$refs.calendarTaskMenu.show); break; case "edit": @@ -346,6 +354,28 @@ export default { $A.modalError(msg); }); } + }, + + getElementLeft(element) { + let actualLeft = element.offsetLeft; + let current = element.offsetParent; + while (current !== null) { + if (current == this.$el) break; + actualLeft += (current.offsetLeft + current.clientLeft); + current = current.offsetParent; + } + return actualLeft; + }, + + getElementTop(element) { + let actualTop = element.offsetTop; + let current = element.offsetParent; + while (current !== null) { + if (current == this.$el) break; + actualTop += (current.offsetTop + current.clientTop); + current = current.offsetParent; + } + return actualTop; } } } diff --git a/resources/assets/js/pages/manage/components/TaskMenu.vue b/resources/assets/js/pages/manage/components/TaskMenu.vue index 3d9b981a..8ce5d6ff 100644 --- a/resources/assets/js/pages/manage/components/TaskMenu.vue +++ b/resources/assets/js/pages/manage/components/TaskMenu.vue @@ -1,5 +1,6 @@