任务排序优化

Signed-off-by: vilson <545522390@qq.com>
This commit is contained in:
vilson 2020-05-09 21:15:44 +08:00
parent 0208a06256
commit 54621ee79c
2 changed files with 2 additions and 2 deletions

View File

@ -481,7 +481,7 @@ class Task extends CommonModel
$nextTask = self::where(['code' => $nextCode])->field('sort')->find();
$nextPreTask = self::where('sort', '<', $nextTask['sort'])->where('code', '<>', $nextCode)->where('stage_code', '=', $toStageCode)->where('done', $done)->order('sort desc')->find();
$nextPreTaskSort = $nextPreTask ? $nextPreTask['sort'] : 0;
$newSort = (int)($nextTask['sort'] - $nextPreTaskSort) / 2;
$newSort = (int)($nextTask['sort'] + $nextPreTaskSort) / 2;
} else {
$maxSort = self::where('stage_code', '=', $toStageCode)->where('done', $done)->max('sort');
$newSort = $maxSort + 500;

View File

@ -190,7 +190,7 @@ class TaskStages extends CommonModel
if ($nextCode) {
$nextPreStage = self::where('sort', '<', $nextStage['sort'])->where('code', '<>', $nextCode)->where('project_code', '=', $projectCode)->order('sort desc')->find();
$nextPreStageSort = $nextPreStage ? $nextPreStage['sort'] : 0;
$newSort = (int)($nextStage['sort'] - $nextPreStageSort) / 2;
$newSort = (int)($nextStage['sort'] + $nextPreStageSort) / 2;
} else {
$maxSort = self::where('project_code', $projectCode)->max('sort');
$newSort = $maxSort + 500;