mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-08 23:45:35 +00:00
perf: 完成任务时任务暂时继续显示,直到路由发生改变
This commit is contained in:
parent
e969b5b7e4
commit
b3e9b1c2be
@ -107,10 +107,12 @@ export default {
|
||||
return task.owner;
|
||||
}
|
||||
let array = cacheTasks.filter(task => filterTask(task));
|
||||
let tmps = taskCompleteTemps.filter(task => filterTask(task, false));
|
||||
if (tmps.length > 0) {
|
||||
array = $A.cloneJSON(array)
|
||||
array.push(...tmps);
|
||||
if (taskCompleteTemps.length > 0) {
|
||||
let tmps = cacheTasks.filter(task => taskCompleteTemps.includes(task.id) && filterTask(task, false));
|
||||
if (tmps.length > 0) {
|
||||
array = $A.cloneJSON(array)
|
||||
array.push(...tmps);
|
||||
}
|
||||
}
|
||||
return this.transforTasks(array).map(data => {
|
||||
const isAllday = $A.rightExists(data.start_at, "00:00:00") && $A.rightExists(data.end_at, "23:59:59")
|
||||
|
||||
@ -640,10 +640,12 @@ export default {
|
||||
myList() {
|
||||
const {allTask, taskCompleteTemps, sortField, sortType} = this;
|
||||
let array = allTask.filter(task => this.myFilter(task));
|
||||
let tmps = taskCompleteTemps.filter(task => this.myFilter(task, false));
|
||||
if (tmps.length > 0) {
|
||||
array = $A.cloneJSON(array)
|
||||
array.push(...tmps);
|
||||
if (taskCompleteTemps.length > 0) {
|
||||
let tmps = allTask.filter(task => taskCompleteTemps.includes(task.id) && this.myFilter(task, false));
|
||||
if (tmps.length > 0) {
|
||||
array = $A.cloneJSON(array)
|
||||
array.push(...tmps);
|
||||
}
|
||||
}
|
||||
return array.sort((a, b) => {
|
||||
if (sortType == 'asc') {
|
||||
@ -663,10 +665,12 @@ export default {
|
||||
helpList() {
|
||||
const {allTask, taskCompleteTemps, sortField, sortType} = this;
|
||||
let array = allTask.filter(task => this.helpFilter(task));
|
||||
let tmps = taskCompleteTemps.filter(task => this.helpFilter(task, false));
|
||||
if (tmps.length > 0) {
|
||||
array = $A.cloneJSON(array)
|
||||
array.push(...tmps);
|
||||
if (taskCompleteTemps.length > 0) {
|
||||
let tmps = allTask.filter(task => taskCompleteTemps.includes(task.id) && this.helpFilter(task, false));
|
||||
if (tmps.length > 0) {
|
||||
array = $A.cloneJSON(array)
|
||||
array.push(...tmps);
|
||||
}
|
||||
}
|
||||
return array.sort((a, b) => {
|
||||
if (sortType == 'asc') {
|
||||
|
||||
@ -157,39 +157,71 @@ export default {
|
||||
},
|
||||
|
||||
dropTask(command) {
|
||||
const cacheTask = this.task;
|
||||
const completeTemp = (save) => {
|
||||
if (save) {
|
||||
this.$store.dispatch("saveTaskCompleteTemp", cacheTask.id)
|
||||
} else {
|
||||
this.$store.dispatch("forgetTaskCompleteTemp", cacheTask.id)
|
||||
}
|
||||
}
|
||||
// 修改背景色
|
||||
if ($A.isJson(command)) {
|
||||
if (command.name) {
|
||||
// 修改背景色
|
||||
this.updateTask({
|
||||
color: command.color
|
||||
}).catch(() => {})
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 修改工作流状态
|
||||
if ($A.leftExists(command, 'turn::')) {
|
||||
// 修改工作流状态
|
||||
let flow_item_id = $A.leftDelete(command, 'turn::');
|
||||
if (flow_item_id == this.task.flow_item_id) return;
|
||||
//
|
||||
let currentFlow = this.taskFlowItems.find(({id}) => id == this.flow.flow_item_id) || {};
|
||||
let updateFlow = this.taskFlowItems.find(({id}) => id == flow_item_id) || {};
|
||||
let isComplete = currentFlow.status !== 'end' && updateFlow.status === 'end';
|
||||
let isUnComplete = currentFlow.status === 'end' && updateFlow.status !== 'end';
|
||||
if (this.updateBefore) {
|
||||
if (isComplete) {
|
||||
completeTemp(true)
|
||||
} else if (isUnComplete) {
|
||||
completeTemp(false)
|
||||
}
|
||||
}
|
||||
this.updateTask({
|
||||
flow_item_id
|
||||
}).catch(() => {})
|
||||
}).then(() => {
|
||||
if (isComplete) {
|
||||
completeTemp(true)
|
||||
} else if (isUnComplete) {
|
||||
completeTemp(false)
|
||||
}
|
||||
}).catch(() => {
|
||||
if (isComplete) {
|
||||
completeTemp(false)
|
||||
} else if (isUnComplete) {
|
||||
completeTemp(true)
|
||||
}
|
||||
})
|
||||
return;
|
||||
}
|
||||
const cacheTask = this.task;
|
||||
// 其他操作
|
||||
switch (command) {
|
||||
case 'complete':
|
||||
if (this.task.complete_at) {
|
||||
return;
|
||||
}
|
||||
if (this.updateBefore) {
|
||||
this.$store.dispatch("saveTaskCompleteTemp", cacheTask)
|
||||
completeTemp(true)
|
||||
}
|
||||
this.updateTask({
|
||||
complete_at: $A.formatDate("Y-m-d H:i:s")
|
||||
}).then(() => {
|
||||
this.$store.dispatch("saveTaskCompleteTemp", cacheTask)
|
||||
completeTemp(true)
|
||||
}).catch(() => {
|
||||
this.$store.dispatch("forgetTaskCompleteTemp", cacheTask.id)
|
||||
completeTemp(false)
|
||||
})
|
||||
break;
|
||||
|
||||
@ -198,14 +230,14 @@ export default {
|
||||
return;
|
||||
}
|
||||
if (this.updateBefore) {
|
||||
this.$store.dispatch("forgetTaskCompleteTemp", cacheTask.id)
|
||||
completeTemp(false)
|
||||
}
|
||||
this.updateTask({
|
||||
complete_at: false
|
||||
}).then(() => {
|
||||
this.$store.dispatch("forgetTaskCompleteTemp", cacheTask.id)
|
||||
completeTemp(false)
|
||||
}).catch(() => {
|
||||
this.$store.dispatch("saveTaskCompleteTemp", cacheTask)
|
||||
completeTemp(true)
|
||||
})
|
||||
break;
|
||||
|
||||
|
||||
20
resources/assets/js/store/actions.js
vendored
20
resources/assets/js/store/actions.js
vendored
@ -1737,16 +1737,11 @@ export default {
|
||||
/**
|
||||
* 保存完成任务临时表
|
||||
* @param state
|
||||
* @param data
|
||||
* @param task_id
|
||||
*/
|
||||
saveTaskCompleteTemp({state}, data) {
|
||||
if ($A.isJson(data)) {
|
||||
let index = state.taskCompleteTemps.findIndex(({id}) => id == data.id);
|
||||
if (index > -1) {
|
||||
state.taskCompleteTemps.splice(index, 1, data);
|
||||
} else {
|
||||
state.taskCompleteTemps.push(data);
|
||||
}
|
||||
saveTaskCompleteTemp({state}, task_id) {
|
||||
if (/^\d+$/.test(task_id) && !state.taskCompleteTemps.includes(task_id)) {
|
||||
state.taskCompleteTemps.push(task_id)
|
||||
}
|
||||
},
|
||||
|
||||
@ -1758,11 +1753,8 @@ export default {
|
||||
forgetTaskCompleteTemp({state}, task_id) {
|
||||
if (task_id === true) {
|
||||
state.taskCompleteTemps = [];
|
||||
return;
|
||||
}
|
||||
let index = state.taskCompleteTemps.findIndex(({id}) => id == task_id);
|
||||
if (index > -1) {
|
||||
state.taskCompleteTemps.splice(index, 1);
|
||||
} else if (/^\d+$/.test(task_id)) {
|
||||
state.taskCompleteTemps = state.taskCompleteTemps.filter(id => id != task_id);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
10
resources/assets/js/store/getters.js
vendored
10
resources/assets/js/store/getters.js
vendored
@ -128,10 +128,12 @@ export default {
|
||||
return task.owner;
|
||||
}
|
||||
let array = state.cacheTasks.filter(task => filterTask(task));
|
||||
let tmps = state.taskCompleteTemps.filter(task => filterTask(task, false));
|
||||
if (tmps.length > 0) {
|
||||
array = $A.cloneJSON(array)
|
||||
array.push(...tmps);
|
||||
if (state.taskCompleteTemps.length > 0) {
|
||||
let tmps = state.cacheTasks.filter(task => state.taskCompleteTemps.includes(task.id) && filterTask(task, false));
|
||||
if (tmps.length > 0) {
|
||||
array = $A.cloneJSON(array)
|
||||
array.push(...tmps);
|
||||
}
|
||||
}
|
||||
const todayTasks = array.filter(task => {
|
||||
const start = $A.Date(task.start_at),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user