This commit is contained in:
kuaifan 2022-01-09 12:54:04 +08:00
parent eb1f5f2632
commit 1fe4e80f82
5 changed files with 69 additions and 17 deletions

View File

@ -58,7 +58,7 @@
"stylus": "^0.56.0", "stylus": "^0.56.0",
"stylus-loader": "^6.2.0", "stylus-loader": "^6.2.0",
"tinymce": "^5.10.2", "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", "view-design-hi": "^4.7.0-5",
"vue": "^2.6.14", "vue": "^2.6.14",
"vue-clipboard2": "^0.3.3", "vue-clipboard2": "^0.3.3",

View File

@ -36,6 +36,9 @@
@beforeUpdateSchedule="onBeforeUpdateSchedule" @beforeUpdateSchedule="onBeforeUpdateSchedule"
disable-click/> disable-click/>
</div> </div>
<div class="calendar-menu" :style="calendarMenuStyles">
<TaskMenu ref="calendarTaskMenu" :task="calendarTask"/>
</div>
</div> </div>
</template> </template>
@ -48,9 +51,10 @@ import {mapState, mapGetters} from "vuex";
import Calendar from "./components/Calendar"; import Calendar from "./components/Calendar";
import moment from "moment"; import moment from "moment";
import {Store} from "le5le-store"; import {Store} from "le5le-store";
import TaskMenu from "./components/TaskMenu";
export default { export default {
components: {Calendar}, components: {TaskMenu, Calendar},
data() { data() {
return { return {
lists: [], lists: [],
@ -63,6 +67,11 @@ export default {
calendarMonth: {}, calendarMonth: {},
calendarTheme: {}, calendarTheme: {},
calendarTemplate: {}, calendarTemplate: {},
calendarTask: {},
calendarMenuStyles: {
top: 0,
left: 0
},
loadIng: 0, loadIng: 0,
loadTimeout: null, loadTimeout: null,
@ -94,15 +103,17 @@ export default {
category: isAllday ? 'allday' : 'time', category: isAllday ? 'allday' : 'time',
start: $A.Date(data.start_at).toISOString(), start: $A.Date(data.start_at).toISOString(),
end: $A.Date(data.end_at).toISOString(), end: $A.Date(data.end_at).toISOString(),
start_at: data.start_at,
end_at: data.end_at,
color: "#515a6e", color: "#515a6e",
bgColor: data.color || '#E3EAFD', bgColor: data.color || '#E3EAFD',
borderColor: data.p_color, borderColor: data.p_color,
complete_at: data.complete_at, complete_at: data.complete_at,
priority: '', priority: '',
preventClick: true, preventClick: true,
preventCheckHide: true,
isChecked: false, isChecked: false,
//
start_at: data.start_at,
end_at: data.end_at,
_time: data._time, _time: data._time,
}; };
if (data.p_name) { if (data.p_name) {
@ -117,7 +128,7 @@ export default {
if (data.overdue) { if (data.overdue) {
task.title = `[${this.$L('超期')}] ${task.title}` task.title = `[${this.$L('超期')}] ${task.title}`
task.color = "#f56c6c" task.color = "#f56c6c"
task.bgColor = "#fef0f0" task.bgColor = data.color || "#fef0f0"
task.priority+= '<span class="overdue">' + this.$L('超期未完成') + '</span>'; task.priority+= '<span class="overdue">' + this.$L('超期未完成') + '</span>';
} }
if (!task.borderColor) { 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); let data = this.cacheTasks.find(({id}) => id === schedule.id);
if (!data) { if (!data) {
return; return;
} }
switch (type) { switch (type) {
case "check": case "check":
this.$set(data, 'complete_at', $A.formatDate("Y-m-d H:i:s")) this.calendarMenuStyles = {
this.$store.dispatch("taskUpdate", { left: `${this.getElementLeft(event.target)}px`,
task_id: data.id, top: `${this.getElementTop(event.target) - 8}px`
complete_at: $A.formatDate("Y-m-d H:i:s"), }
}).then(({msg}) => { this.calendarTask = data;
$A.messageSuccess(msg); this.$nextTick(this.$refs.calendarTaskMenu.show);
}).catch(({msg}) => {
this.$set(data, 'complete_at', null)
$A.modalError(msg);
});
break; break;
case "edit": case "edit":
@ -346,6 +354,28 @@ export default {
$A.modalError(msg); $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;
} }
} }
} }

View File

@ -1,5 +1,6 @@
<template> <template>
<EDropdown <EDropdown
ref="dropdown"
trigger="click" trigger="click"
:size="size" :size="size"
placement="bottom" placement="bottom"
@ -30,7 +31,7 @@
</div> </div>
</EDropdownItem> </EDropdownItem>
<EDropdownItem command="remove"> <EDropdownItem command="remove">
<div class="item"> <div class="item hover-del">
<Icon type="md-trash" />{{$L('删除')}} <Icon type="md-trash" />{{$L('删除')}}
</div> </div>
</EDropdownItem> </EDropdownItem>
@ -99,6 +100,14 @@ export default {
} }
}, },
methods: { methods: {
show() {
this.$refs.dropdown.show()
},
hide() {
this.$refs.dropdown.hide()
},
dropTask(command) { dropTask(command) {
if ($A.isJson(command)) { if ($A.isJson(command)) {
if (command.name) { if (command.name) {

View File

@ -31,6 +31,12 @@ $--dropdown-menuItem-hover-color: #606266;
color: #f00; color: #f00;
} }
} }
&.hover-del {
color: #f00;
> i {
color: #f00;
}
}
} }
} }
} }

View File

@ -177,6 +177,13 @@
} }
} }
} }
.calendar-menu {
position: absolute;
top: 2px;
right: 2px;
z-index: -1;
opacity: 0;
}
} }
@media (max-width: 768px) { @media (max-width: 768px) {