From 03a980e013359fafd76c56c77e2b7fe0a97e10d3 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Thu, 7 Nov 2024 05:05:09 +0000 Subject: [PATCH] * [task#131936,done,0.5h] finish task. --- module/task/config/dtable.php | 2 +- module/task/model.php | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/module/task/config/dtable.php b/module/task/config/dtable.php index c9d65436c5..9d50785fcf 100644 --- a/module/task/config/dtable.php +++ b/module/task/config/dtable.php @@ -330,7 +330,7 @@ $config->task->dtable->children->fieldList['name'] = $config->ta $config->task->dtable->children->fieldList['name']['title'] = $lang->task->name; $config->task->dtable->children->fieldList['name']['sortType'] = false; $config->task->dtable->children->fieldList['name']['name'] = 'name'; -$config->task->dtable->children->fieldList['name']['nestedToggle'] = false; +$config->task->dtable->children->fieldList['name']['nestedToggle'] = true; $config->task->dtable->children->fieldList['name']['data-toggle'] = 'modal'; $config->task->dtable->children->fieldList['name']['data-size'] = 'lg'; diff --git a/module/task/model.php b/module/task/model.php index 51dff74cc6..df822ea877 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -1299,7 +1299,8 @@ class taskModel extends model $task->realStarted = !empty($task->realStarted) ? substr($task->realStarted, 0, 19) : null; /* Get the child tasks of the parent task. */ - $children = $this->dao->select('*')->from(TABLE_TASK)->where('parent')->eq($taskID)->andWhere('deleted')->eq(0)->fetchAll('id'); + $childIdList = $this->getAllChildId($taskID, false); + $children = $this->getByIdList($childIdList); foreach($children as $child) { $child->team = array(); @@ -1329,7 +1330,7 @@ class taskModel extends model if($task->story) $task->cases = $this->dao->select('id, title')->from(TABLE_CASE)->where('story')->eq($task->story)->andWhere('storyVersion')->eq($task->storyVersion)->andWhere('deleted')->eq('0')->fetchPairs(); /* Process a task, compute its progress and get its related information. */ - return $this->processTask($task); + return $this->processTask($task, false); } /** @@ -1944,18 +1945,20 @@ class taskModel extends model } /** - * 获取任务所有子任务id,包括任务它自己。 - * Get all child task id, including the task itself. + * 获取任务所有子任务id。 + * Get all child task id. * * @param int $taskID + * @param bool $includeSelf * @access public * @return array */ - public function getAllChildId(int $taskID): array + public function getAllChildId(int $taskID, bool $includeSelf = true): array { return $this->dao->select('id')->from(TABLE_TASK) ->where('path')->like("%,$taskID,%") ->andWhere('deleted')->eq(0) + ->beginIF(!$includeSelf)->andWhere('id')->ne($taskID)->fi() ->fetchPairs('id'); } @@ -2600,10 +2603,11 @@ class taskModel extends model * Process a task, compute its progress and get its relates. * * @param object $task + * @param bool $convertParent * @access public * @return object */ - public function processTask(object $task): object + public function processTask(object $task, bool $convertParent = true): object { $today = helper::today(); @@ -2653,12 +2657,15 @@ class taskModel extends model if(in_array($field, $this->config->task->dateFields) && helper::isZeroDate($value)) $task->$field = ''; } - $task->parent = array(); - foreach(explode(',', trim((string)$task->path, ',')) as $parentID) + if($convertParent) { - if(!$parentID) continue; - if($parentID == $task->id) continue; - $task->parent[] = (int)$parentID; + $task->parent = array(); + foreach(explode(',', trim((string)$task->path, ',')) as $parentID) + { + if(!$parentID) continue; + if($parentID == $task->id) continue; + $task->parent[] = (int)$parentID; + } } return $task;