任务排序优化
Signed-off-by: vilson <545522390@qq.com>
This commit is contained in:
parent
0096371a47
commit
5cf8c2f490
@ -281,7 +281,7 @@ class Task extends CommonModel
|
|||||||
'create_by' => $memberCode,
|
'create_by' => $memberCode,
|
||||||
'assign_to' => $assignTo,
|
'assign_to' => $assignTo,
|
||||||
'id_num' => $maxNum + 1,
|
'id_num' => $maxNum + 1,
|
||||||
'sort' => $maxSort + 500,
|
'sort' => $maxSort + 65536,
|
||||||
'project_code' => $projectCode,
|
'project_code' => $projectCode,
|
||||||
'pcode' => $parentCode,
|
'pcode' => $parentCode,
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
@ -484,7 +484,7 @@ class Task extends CommonModel
|
|||||||
$newSort = (int)($nextTask['sort'] + $nextPreTaskSort) / 2;
|
$newSort = (int)($nextTask['sort'] + $nextPreTaskSort) / 2;
|
||||||
} else {
|
} else {
|
||||||
$maxSort = self::where('stage_code', '=', $toStageCode)->where('done', $done)->max('sort');
|
$maxSort = self::where('stage_code', '=', $toStageCode)->where('done', $done)->max('sort');
|
||||||
$newSort = $maxSort + 500;
|
$newSort = $maxSort + 65536;
|
||||||
}
|
}
|
||||||
if ($newSort and $newSort > 50) {
|
if ($newSort and $newSort > 50) {
|
||||||
$preTask->stage_code = $toStageCode;
|
$preTask->stage_code = $toStageCode;
|
||||||
@ -505,11 +505,11 @@ class Task extends CommonModel
|
|||||||
{
|
{
|
||||||
$taskList = self::where('stage_code', $stageCode)->order('sort asc, id asc')->where('done', $done)->select();
|
$taskList = self::where('stage_code', $stageCode)->order('sort asc, id asc')->where('done', $done)->select();
|
||||||
if ($taskList) {
|
if ($taskList) {
|
||||||
$sort = 500;
|
$sort = 65536;
|
||||||
foreach ($taskList as $task) {
|
foreach ($taskList as $task) {
|
||||||
$task->sort = $sort;
|
$task->sort = $sort;
|
||||||
$task->save();
|
$task->save();
|
||||||
$sort += 500;
|
$sort += 65536;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,7 +534,7 @@ class Task extends CommonModel
|
|||||||
foreach ($codes as $key => $code) {
|
foreach ($codes as $key => $code) {
|
||||||
$task = self::where(['code' => $code])->find();
|
$task = self::where(['code' => $code])->find();
|
||||||
self::update(['sort' => $sort, 'stage_code' => $stageCode], ['code' => $code]);
|
self::update(['sort' => $sort, 'stage_code' => $stageCode], ['code' => $code]);
|
||||||
$sort += 500;
|
$sort += 65536;
|
||||||
if ($task['stage_code'] != $stageCode) {
|
if ($task['stage_code'] != $stageCode) {
|
||||||
self::taskHook(getCurrentMember()['code'], $code, 'move', '', '', '', '', '', ['stageName' => $stage['name']]);
|
self::taskHook(getCurrentMember()['code'], $code, 'move', '', '', '', '', '', ['stageName' => $stage['name']]);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ class TaskStages extends CommonModel
|
|||||||
'create_time' => nowTime(),
|
'create_time' => nowTime(),
|
||||||
'code' => createUniqueCode('taskStages'),
|
'code' => createUniqueCode('taskStages'),
|
||||||
'project_code' => $projectCode,
|
'project_code' => $projectCode,
|
||||||
'sort' => $maxSort + 500,
|
'sort' => $maxSort + 65536,
|
||||||
'name' => trim($name),
|
'name' => trim($name),
|
||||||
];
|
];
|
||||||
$result = self::create($data)->toArray();
|
$result = self::create($data)->toArray();
|
||||||
@ -193,7 +193,7 @@ class TaskStages extends CommonModel
|
|||||||
$newSort = (int)($nextStage['sort'] + $nextPreStageSort) / 2;
|
$newSort = (int)($nextStage['sort'] + $nextPreStageSort) / 2;
|
||||||
} else {
|
} else {
|
||||||
$maxSort = self::where('project_code', $projectCode)->max('sort');
|
$maxSort = self::where('project_code', $projectCode)->max('sort');
|
||||||
$newSort = $maxSort + 500;
|
$newSort = $maxSort + 65536;
|
||||||
}
|
}
|
||||||
if ($newSort and $newSort > 50) {
|
if ($newSort and $newSort > 50) {
|
||||||
self::update(['sort' => $newSort], ['code' => $preCode]);
|
self::update(['sort' => $newSort], ['code' => $preCode]);
|
||||||
@ -211,11 +211,11 @@ class TaskStages extends CommonModel
|
|||||||
{
|
{
|
||||||
$taskStagesList = self::where('project_code', $projectCode)->order('sort asc, id asc')->select();
|
$taskStagesList = self::where('project_code', $projectCode)->order('sort asc, id asc')->select();
|
||||||
if ($taskStagesList) {
|
if ($taskStagesList) {
|
||||||
$sort = 500;
|
$sort = 65536;
|
||||||
foreach ($taskStagesList as $taskStage) {
|
foreach ($taskStagesList as $taskStage) {
|
||||||
$taskStage->sort = $sort;
|
$taskStage->sort = $sort;
|
||||||
$res = $taskStage->save();
|
$taskStage->save();
|
||||||
$sort += 500;
|
$sort += 65536;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user