mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-17 23:02:49 +00:00
perf: 优化任务排序
This commit is contained in:
parent
b9e435c0e2
commit
7c952822db
@ -604,13 +604,14 @@ class ProjectController extends AbstractController
|
|||||||
if (!is_array($item['task'])) continue;
|
if (!is_array($item['task'])) continue;
|
||||||
$index = 0;
|
$index = 0;
|
||||||
foreach ($item['task'] as $task_id) {
|
foreach ($item['task'] as $task_id) {
|
||||||
ProjectTask::whereId($task_id)->whereProjectId($project->id)->update([
|
if (ProjectTask::whereId($task_id)->whereProjectId($project->id)->whereCompleteAt(null)->update([
|
||||||
'column_id' => $item['id'],
|
'column_id' => $item['id'],
|
||||||
'sort' => $index
|
'sort' => $index
|
||||||
]);
|
])) {
|
||||||
ProjectTask::whereParentId($task_id)->whereProjectId($project->id)->update([
|
ProjectTask::whereParentId($task_id)->whereProjectId($project->id)->update([
|
||||||
'column_id' => $item['id'],
|
'column_id' => $item['id'],
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -623,10 +623,8 @@ export default {
|
|||||||
column.tasks = this.transforTasks(allTask.filter(task => {
|
column.tasks = this.transforTasks(allTask.filter(task => {
|
||||||
return task.column_id == column.id;
|
return task.column_id == column.id;
|
||||||
})).sort((a, b) => {
|
})).sort((a, b) => {
|
||||||
let at1 = $A.Date(a.complete_at),
|
if (a.complete_at || b.complete_at) {
|
||||||
at2 = $A.Date(b.complete_at);
|
return $A.Date(a.complete_at) - $A.Date(b.complete_at);
|
||||||
if (at1 || at2) {
|
|
||||||
return at1 - at2;
|
|
||||||
}
|
}
|
||||||
if (a.sort != b.sort) {
|
if (a.sort != b.sort) {
|
||||||
return a.sort - b.sort;
|
return a.sort - b.sort;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user