From 9c59dbfb89fd9f4629f16d294818fa9f307dcfe5 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Tue, 29 Apr 2025 03:27:04 +0000 Subject: [PATCH] * [task#142088,done,2h] finish task. --- module/execution/control.php | 6 +++++- module/execution/model.php | 10 +++++++++- module/programplan/model.php | 12 ++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 58f1a51463..1ed6776aca 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1656,7 +1656,11 @@ class execution extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $project = $this->loadModel('project')->getById($execution->project); - if(in_array($project->model, array('waterfall', 'waterfallplus', 'ipd'))) $this->loadModel('programplan')->computeProgress($executionID, 'close'); + if(in_array($project->model, array('waterfall', 'waterfallplus', 'ipd'))) + { + $result = $this->loadModel('programplan')->computeProgress($executionID, 'close'); + if(is_array($result)) return $this->send($result); + } $this->executeHooks($executionID); diff --git a/module/execution/model.php b/module/execution/model.php index 2118973a36..8f70a74b60 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1488,6 +1488,7 @@ class executionModel extends model $today = helper::today(); $burns = $this->getBurnData($executions); $parentExecutions = $this->dao->select('parent,parent')->from(TABLE_EXECUTION)->where('parent')->ne(0)->andWhere('deleted')->eq(0)->fetchPairs(); + $statusGroup = $this->dao->select('parent,status')->from(TABLE_EXECUTION)->where('parent')->in(array_keys($executions))->fetchGroup('parent', 'status'); /* Get workingDays. */ $earliestEnd = $today; @@ -1509,6 +1510,13 @@ class executionModel extends model if(isset($parentExecutions[$execution->id])) $executions[$execution->id]->isParent = 1; if(empty($productID) && !empty($productList[$execution->id])) $execution->product = trim($productList[$execution->id]->product, ','); + /** 如果子执行都关闭了,则父执行可以手动关闭。 */ + if(isset($statusGroup[$execution->id])) + { + $childStatus = array_keys($statusGroup[$execution->id]); + if(count($childStatus) == 1 && $childStatus[0] == 'closed') $execution->parentCanClose = true; + } + /* Judge whether the execution is delayed. */ if($execution->status != 'done' && $execution->status != 'closed' && $execution->status != 'suspended' && !empty($workingDays)) { @@ -3829,7 +3837,7 @@ class executionModel extends model $action = strtolower($action); if($action == 'start') return $execution->status == 'wait'; - if($action == 'close') return $execution->status != 'closed' && (!isset($execution->isParent) || (isset($execution->isParent) && !$execution->isParent)); + if($action == 'close') return $execution->status != 'closed' && (empty($execution->isParent) || !empty($execution->parentCanClose)); if($action == 'suspend') return $execution->status == 'wait' || $execution->status == 'doing'; if($action == 'putoff') return $execution->status == 'wait' || $execution->status == 'doing'; if($action == 'activate') return $execution->status == 'suspended' || $execution->status == 'closed'; diff --git a/module/programplan/model.php b/module/programplan/model.php index 04baa84e51..483747b149 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -602,9 +602,9 @@ class programplanModel extends model * @param string $action * @param bool $isParent * @access public - * @return bool + * @return bool|array */ - public function computeProgress(int $stageID, string $action = '', bool $isParent = false): bool + public function computeProgress(int $stageID, string $action = '', bool $isParent = false): bool|array { $stage = $this->loadModel('execution')->getByID($stageID); if(empty($stage) || empty($stage->path)) return false; @@ -618,6 +618,14 @@ class programplanModel extends model foreach($parentIdList as $id) { $parent = $this->execution->getByID((int)$id); + + /* 如果当前是顶级阶段,并且由于交付物不能关闭,则跳转到顶级阶段的关闭页面。 */ + if(in_array($this->config->edition, array('max', 'ipd')) && $parent->grade == 1 && $parent->type != 'project' && $stageID != $id && !$this->execution->canCloseByDeliverable($parent)) + { + $url = helper::createLink('execution', 'close', "executionID={$parent->id}"); + return array('result' => 'fail', 'callback' => "zui.Modal.confirm('{$this->lang->execution->cannotAutoCloseParent}').then((res) => {if(res) {loadModal('$url', '.modal-dialog');} else {loadPage();}});"); + } + if(empty($this->lang->execution->typeList[$parent->type]) || (!$isParent && $id == $stageID)) continue; /** 获取子阶段关联开始任务数以及状态下子阶段数量。 */