From bd9700212c4d153be1d7adb2be7159d287ca860d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Tue, 12 Jul 2022 22:48:07 +0800 Subject: [PATCH] * Finish task #59706. --- module/project/control.php | 1 - module/project/js/execution.js | 46 +++-- module/project/model.php | 94 +++++++++++ module/project/view/execution.html.php | 222 +------------------------ module/task/control.php | 47 +----- module/task/model.php | 55 ++++++ 6 files changed, 175 insertions(+), 290 deletions(-) diff --git a/module/project/control.php b/module/project/control.php index 7dce65d6f1..6845d7966c 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -980,7 +980,6 @@ class project extends control $this->view->productID = $productID; $this->view->projectID = $projectID; $this->view->project = $project; - $this->view->projects = array('') + $this->project->getPairsByProgram(); $this->view->pager = $pager; $this->view->orderBy = $orderBy; $this->view->users = $this->loadModel('user')->getPairs('noletter'); diff --git a/module/project/js/execution.js b/module/project/js/execution.js index 1a6ea3f77d..f131f1d854 100644 --- a/module/project/js/execution.js +++ b/module/project/js/execution.js @@ -11,32 +11,33 @@ $(function() window.addEventListener('scroll', this.handleScroll) function handleScroll(e) { - var relative = 500; // 相对距离 - if(getScrollTop() + getWindowHeight() >= getScrollHeight() - relative) - { - throttle(loadData(), 250) - } -} - -function loadData() -{ + var relative = 200; // 相对距离 $('tr.showmore').each(function() { - var offsetTop = $(this)[0].offsetTop; + var $showmore = $(this); + var offsetTop = $showmore[0].offsetTop; if(offsetTop == 0) return true; - $(this).removeClass('showmore'); - var showmoreTr = this; - var executionID = $(this).attr('data-parent'); - var maxTaskID = $(this).attr('data-id'); - var link = createLink('task', 'ajaxGetTasks', 'executionID=' + executionID + '&maxTaskID=' + maxTaskID); - $.get(link, function(data) + if(getScrollTop() + getWindowHeight() >= offsetTop - relative) { - $(showmoreTr).before(data); - $(".iframe").modalTrigger({type:'iframe'}); + throttle(loadData($showmore), 150) + } + }) +} - $('#executionForm').table('initNestedList'); - }) +function loadData($showmore) +{ + $showmore.removeClass('showmore'); + + var executionID = $showmore.attr('data-parent'); + var maxTaskID = $showmore.attr('data-id'); + var link = createLink('task', 'ajaxGetTasks', 'executionID=' + executionID + '&maxTaskID=' + maxTaskID); + $.get(link, function(data) + { + $showmore.before(data); + $(".iframe").modalTrigger({type:'iframe'}); + + $('#executionForm').table('initNestedList'); }) } @@ -75,11 +76,6 @@ function getScrollTop() return scrollTop = document.body.scrollTop + document.documentElement.scrollTop } -function getScrollHeight() -{ - return scrollHeight = document.documentElement.scrollHeight -} - function getWindowHeight() { return document.compatMode == "CSS1Compat" ? windowHeight = document.documentElement.clientHeight : windowHeight = document.body.clientHeight diff --git a/module/project/model.php b/module/project/model.php index 1e02b1f3ac..3af953650f 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -2091,6 +2091,100 @@ class projectModel extends model } } + /** + * Print execution list. + * + * @param object $execution + * @param int $isChild + * @param array $users + * @access public + * @return void + */ + public function printExecutionList($execution, $isChild = false, $users, $productID) + { + $this->loadModel('task'); + $this->loadModel('execution'); + $this->loadModel('programplan'); + + if(!$isChild) + { + $trClass = 'is-top-level table-nest-child-hide'; + $trAttrs = "data-id='$execution->id' data-order='$execution->order' data-nested='true'"; + } + else + { + $trClass = 'is-nest-child'; + $trAttrs = "data-id={$execution->id} data-parent={$execution->parent}"; + $trAttrs .= " data-nest-parent='$execution->parent' data-order='$execution->order' data-nest-path=',$execution->parent,$execution->id,'"; + } + + $burns = join(',', $execution->burns); + echo ""; + echo "id class='table-nest-icon icon table-nest-toggle'>"; + if($this->config->systemMode == 'new') + { + $spanClass = $execution->type == 'stage' ? 'label-warning' : 'label-info'; + echo "{$this->lang->execution->typeList[$execution->type]}"; + } + echo html::a(helper::createLink('execution', 'view', "executionID=$execution->id"), $execution->name); + echo '' . zget($users, $execution->PM) . ''; + echo '' . zget($this->lang->project->statusList, $execution->status) . ''; + echo '' . html::ring($execution->hours->progress) . ''; + echo '' . $execution->begin . ''; + echo '' . $execution->end . ''; + echo "" . $execution->hours->totalEstimate . $this->lang->execution->workHourUnit . ''; + echo "" . $execution->hours->totalConsumed . $this->lang->execution->workHourUnit . ''; + echo "" . $execution->hours->totalLeft . $this->lang->execution->workHourUnit . ''; + echo ""; + echo ''; + common::printIcon('execution', 'start', "executionID={$execution->id}", $execution, 'list', '', '', 'iframe', true); + $class = !empty($execution->children) ? 'disabled' : ''; + common::printIcon('task', 'create', "executionID={$execution->id}", $execution, 'list', '', '', $class, false, "data-app='execution'"); + + if($execution->grade == 1 && $this->loadModel('programplan')->isCreateTask($execution->id)) + { + common::printIcon('programplan', 'create', "program={$execution->parent}&productID=$productID&planID=$execution->id", $execution, 'list', 'split', '', '', '', '', $this->lang->programplan->createSubPlan); + } + else + { + $disabled = ($execution->grade == 2) ? ' disabled' : ''; + echo common::hasPriv('programplan', 'create') ? html::a('javascript:alert("' . $this->lang->programplan->error->createdTask . '");', '', '', 'class="btn ' . $disabled . '"') : ''; + } + + common::printIcon('programplan', 'edit', "stageID=$execution->id&projectID=$execution->project", $execution, 'list', '', '', 'iframe', true); + + $disabled = !empty($execution->children) ? ' disabled' : ''; + if($execution->status != 'closed' and common::hasPriv('execution', 'close', $execution)) + { + common::printIcon('execution', 'close', "stageID=$execution->id", $execution, 'list', 'off', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->close); + } + elseif($execution->status == 'closed' and common::hasPriv('execution', 'activate', $execution)) + { + common::printIcon('execution', 'activate', "stageID=$execution->id", $execution, 'list', 'magic', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->activate); + } + + if(common::hasPriv('execution', 'delete', $execution)) + { + common::printIcon('execution', 'delete', "stageID=$execution->id&confirm=no", $execution, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete); + echo ''; + echo ''; + + if(!empty($execution->children)) + { + foreach($execution->children as $child) $this->printExecutionList($child, true, $users, $productID); + } + + if(!empty($execution->tasks)) + { + foreach($execution->tasks as $task) + { + $showmore = (count($execution->tasks) == 50) && ($task == end($execution->tasks)); + echo $this->task->buildNestedList($execution, $task, false, $showmore, $users); + } + } + } + } + /** * Convert budget unit. * diff --git a/module/project/view/execution.html.php b/module/project/view/execution.html.php index 64bf75d7f9..5feacef27b 100644 --- a/module/project/view/execution.html.php +++ b/module/project/view/execution.html.php @@ -75,227 +75,7 @@ - id' data-order='$execution->order' data-nested='true'"; - $trClass .= ' is-top-level table-nest-child-hide'; - ?> - class=""> - - id;?> class="table-nest-icon icon table-nest-toggle"> - systemMode == 'new'):?> - '>execution->typeList[$execution->type]?> - - createLink('execution', 'view', "executionID=$execution->id"), $execution->name);?> - - PM);?> - project->statusList, $execution->status);?> - hours->progress); ?> - begin;?> - end;?> - lang->execution->workHour;?>'>hours->totalEstimate . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>hours->totalConsumed . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>hours->totalLeft . $this->lang->execution->workHourUnit;?> - burns);?>'> - - id}", $execution, 'list', '', '', 'iframe', true); - $class = !empty($execution->children) ? 'disabled' : ''; - common::printIcon('task', 'create', "executionID={$execution->id}", $execution, 'list', '', '', $class, false, "data-app='execution'"); - - if($execution->grade == 1 && $this->loadModel('programplan')->isCreateTask($execution->id)) - { - common::printIcon('programplan', 'create', "program={$execution->parent}&productID=$productID&planID=$execution->id", $execution, 'list', 'split', '', '', '', '', $this->lang->programplan->createSubPlan); - } - else - { - $disabled = ($execution->grade == 2) ? ' disabled' : ''; - echo common::hasPriv('programplan', 'create') ? html::a('javascript:alert("' . $this->lang->programplan->error->createdTask . '");', '', '', 'class="btn ' . $disabled . '"') : ''; - } - - common::printIcon('programplan', 'edit', "stageID=$execution->id&projectID=$execution->project", $execution, 'list', '', '', 'iframe', true); - - $disabled = !empty($execution->children) ? ' disabled' : ''; - if($execution->status != 'closed' and common::hasPriv('execution', 'close', $execution)) - { - common::printIcon('execution', 'close', "stageID=$execution->id", $execution, 'list', 'off', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->close); - } - elseif($execution->status == 'closed' and common::hasPriv('execution', 'activate', $execution)) - { - common::printIcon('execution', 'activate', "stageID=$execution->id", $execution, 'list', 'magic', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->activate); - } - - if(common::hasPriv('execution', 'delete', $execution)) - { - common::printIcon('execution', 'delete', "stageID=$execution->id&confirm=no", $execution, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete); - } - ?> - - - - tasks)):?> - tasks as $task):?> - id} data-parent={$task->execution}"; - $trClass .= " is-nest-child no-nest"; - $trAttrs .= " data-nest-parent='$task->execution' data-nest-path=',$execution->id,$task->id,'"; - if(empty($task->children)) $trAttrs .= " data-nested='false'"; - if($task == end($child->tasks) and count($execution->tasks) == 50) $trClass .= ' showmore'; - ?> - class=''> - createLink('task', 'view', "id=$task->id"), $task->name, '', "data-app={$this->app->tab}");?> - assignedTo);?> - task->statusList, $task->status);?> - - estStarted;?> - deadline;?> - lang->execution->workHour;?>'>estimate . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>consumed . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>left . $this->lang->execution->workHourUnit;?> - - task->buildOperateMenu($task, 'browse');?> - - - children)):?> - children as $childTask):?> - id} data-parent={$child->parent}"; - $trClass .= " is-nest-child no-nest"; - $trAttrs .= " data-nest-parent='$childTask->parent' data-nest-path=',$execution->id,$childTask->parent,$childTask->id,'"; - ?> - class=''> - createLink('task', 'view', "id=$childTask->id"), $childTask->name);?> - assignedTo);?> - task->statusList, $childTask->status);?> - - estStarted;?> - deadline;?> - lang->execution->workHour;?>'>estimate . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>consumed . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>left . $this->lang->execution->workHourUnit;?> - - task->buildOperateMenu($childTask, 'browse');?> - - - - - - - children)):?> - children as $child):?> - id} data-parent={$child->parent}"; - $trClass .= " is-nest-child"; - $trAttrs .= " data-nest-parent='$child->parent' data-order='$child->order' data-nest-path=',$execution->id,$child->id,'"; - ?> - class=''> - - systemMode == 'new'):?> - '>execution->typeList[$child->type]?> - - createLink('execution', 'view', "executionID=$child->id"), $child->name);?> - - PM);?> - project->statusList, $child->status);?> - hours->progress); ?> - begin;?> - end;?> - lang->execution->workHour;?>'>hours->totalEstimate . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>hours->totalConsumed . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>hours->totalLeft . $this->lang->execution->workHourUnit;?> - burns);?>'> - - id}", $child, 'list', '', '', 'iframe', true); - $class = !empty($child->children) ? 'disabled' : ''; - common::printIcon('task', 'create', "executionID={$child->id}", $child, 'list', '', '', $class, false, "data-app='execution'"); - - if($child->grade == 1 && $this->loadModel('programplan')->isCreateTask($child->id)) - { - common::printIcon('programplan', 'create', "program={$child->parent}&productID=$productID&planID=$child->id", $child, 'list', 'split', '', '', '', '', $this->lang->programplan->createSubPlan); - } - else - { - $disabled = ($child->grade == 2) ? ' disabled' : ''; - echo common::hasPriv('programplan', 'create') ? html::a('javascript:alert("' . $this->lang->programplan->error->createdTask . '");', '', '', 'class="btn ' . $disabled . '"') : ''; - } - - common::printIcon('programplan', 'edit', "stageID=$child->id&projectID=$child->project", $child, 'list', '', '', 'iframe', true); - - $disabled = !empty($child->children) ? ' disabled' : ''; - if($child->status != 'closed' and common::hasPriv('execution', 'close', $child)) - { - common::printIcon('execution', 'close', "stageID=$child->id", $child, 'list', 'off', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->close); - } - elseif($child->status == 'closed' and common::hasPriv('execution', 'activate', $child)) - { - common::printIcon('execution', 'activate', "stageID=$child->id", $child, 'list', 'magic', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->activate); - } - - if(common::hasPriv('execution', 'delete', $child)) - { - common::printIcon('execution', 'delete', "stageID=$child->id&confirm=no", $child, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete); - } - ?> - - - - tasks)):?> - tasks as $task):?> - id} data-parent={$task->execution}"; - $trClass .= " is-nest-child no-nest"; - $trAttrs .= " data-nest-parent='$task->execution' data-nest-path=',$execution->id,$child->id,$task->id,'"; - if(empty($task->children)) $trAttrs .= " data-nested='false'"; - if($task == end($child->tasks) and count($child->tasks) == 50) $trClass .= ' showmore'; - ?> - class=''> - createLink('task', 'view', "id=$task->id"), $task->name, '', "data-app={$this->app->tab}");?> - assignedTo);?> - task->statusList, $task->status);?> - - estStarted;?> - deadline;?> - lang->execution->workHour;?>'>estimate . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>consumed . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>left . $this->lang->execution->workHourUnit;?> - - task->buildOperateMenu($task, 'browse');?> - - - children)):?> - children as $childTask):?> - id} data-parent={$child->parent}"; - $trClass .= " is-nest-child no-nest"; - $trAttrs .= " data-nest-parent='$childTask->parent' data-nest-path=',$execution->id,$child->id,$childTask->parent,$childTask->id,' data-nested='false'"; - ?> - class=''> - createLink('task', 'view', "id=$childTask->id"), $childTask->name);?> - assignedTo);?> - task->statusList, $childTask->status);?> - - estStarted;?> - deadline;?> - lang->execution->workHour;?>'>estimate . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>consumed . $this->lang->execution->workHourUnit;?> - lang->execution->workHour;?>'>left . $this->lang->execution->workHourUnit;?> - - task->buildOperateMenu($childTask, 'browse');?> - - - - - - - - - + project->printExecutionList($execution, false, $users, $productID);?> diff --git a/module/task/control.php b/module/task/control.php index c5c99a9b52..ee33dfb2e7 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -1798,56 +1798,17 @@ class task extends control } } - $body = ''; + $list = ''; $tasks = array_chunk($tasks, 50, true); $tasks = $tasks[0]; $count = count($tasks); foreach($tasks as $task) { - $path = $execution->grade == 2 ? "$execution->parent,$execution->id,$task->id," : ",$execution->id,$task->id,"; - $showmore = ($count == 50 and $task == end($tasks)) ? 'showmore' : ''; - $trAttrs = empty($task->children) ? " data-nested='false'" : ''; - - $body .= "id data-nest-path='$path' $trAttrs data-nest-parent=$executionID class=' $showmore'>"; - $body .= '' . html::a($this->createLink('task', 'view', "id=$task->id"), $task->name, '', "data-app='project'") . ''; - $body .= '' . zget($users, $task->assignedTo, '') . ''; - $body .= '' . zget($this->lang->task->statusList, $task->status, '') . ''; - $body .= ''; - $body .= '' . $task->estStarted . ''; - $body .= '' . $task->deadline . ''; - $body .= '' . $task->estimate . $this->lang->execution->workHourUnit . ''; - $body .= '' . $task->consumed . $this->lang->execution->workHourUnit . ''; - $body .= '' . $task->left . $this->lang->execution->workHourUnit . ''; - $body .= ''; - $body .= ''; - $body .= $this->task->buildOperateMenu($task, 'browse'); - $body .= ''; - - if(!empty($task->children)) - { - foreach($task->children as $childTask) - { - $path = $execution->grade == 2 ? "$execution->parent,$execution->id,$childTask->parent,$childTask->id," : ",$execution->id,$childTask->parent,$childTask->id,"; - - $body .= "id data-nest-path=$path data-nested='false' data-nest-parent=$executionID class='is-nest-child no-nest'>"; - $body .= '' . html::a($this->createLink('task', 'view', "id=$childTask->id"), $childTask->name, '', "data-app='project'") . ''; - $body .= '' . zget($users, $childTask->assignedTo, '') . ''; - $body .= '' . zget($this->lang->task->statusList, $childTask->status, '') . ''; - $body .= ''; - $body .= '' . $childTask->estStarted . ''; - $body .= '' . $childTask->deadline . ''; - $body .= '' . $childTask->estimate . $this->lang->execution->workHourUnit . ''; - $body .= '' . $childTask->consumed . $this->lang->execution->workHourUnit . ''; - $body .= '' . $childTask->left . $this->lang->execution->workHourUnit . ''; - $body .= ''; - $body .= ''; - $body .= $this->task->buildOperateMenu($childTask, 'browse'); - $body .= ''; - } - } + $showmore = ($count == 50) && ($task == end($tasks)); + $list .= $this->task->buildNestedList($execution, $task, false, $showmore, $users); } - die($body); + die($list); } /** diff --git a/module/task/model.php b/module/task/model.php index ffc675aa33..3f373914e4 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -3734,6 +3734,61 @@ class taskModel extends model ->fetchPairs('actor'); } + /** + * Build nested list. + * + * @param objecct $execution + * @param object $task + * @param bool $isChild + * @param bool $showmore + * @access public + * @return string + */ + public function buildNestedList($execution, $task, $isChild = false, $showmore = false, $users) + { + $showmore = $showmore ? 'showmore' : ''; + $trAttrs = "data-id=$task->id"; + if(!$isChild) + { + $path = $execution->grade == 2 ? "$execution->parent,$execution->id,$task->id," : ",$execution->id,$task->id,"; + $trAttrs .= " data-parent=$execution->id data-nest-parent=$execution->id data-nest-path=$path"; + if(empty($task->children)) $trAttrs .= " data-nested='false'"; + $trClass = empty($task->children) ? '' : " has-nest-child"; + } + else + { + $path = $execution->grade == 2 ? "$execution->parent,$execution->id,$task->parent,$task->id," : ",$execution->id,$task->parent,$task->id,"; + $trClass = 'is-nest-child no-nest'; + $trAttrs .= " data-nested='false' data-parent=$task->parent data-nest-parent=$task->parent data-nest-path=$path"; + } + + $list = ""; + $list .= '' . html::a(helper::createLink('task', 'view', "id=$task->id"), $task->name, '', "data-app='project'") . ''; + $list .= '' . zget($users, $task->assignedTo, '') . ''; + $list .= '' . zget($this->lang->task->statusList, $task->status, '') . ''; + $list .= ''; + $list .= '' . $task->estStarted . ''; + $list .= '' . $task->deadline . ''; + $list .= '' . $task->estimate . $this->lang->execution->workHourUnit . ''; + $list .= '' . $task->consumed . $this->lang->execution->workHourUnit . ''; + $list .= '' . $task->left . $this->lang->execution->workHourUnit . ''; + $list .= ''; + $list .= ''; + $list .= $this->buildOperateMenu($task, 'browse'); + $list .= ''; + + if(!empty($task->children)) + { + foreach($task->children as $child) + { + $showmore = (count($task->children) == 50) && ($child == end($task->children)); + $list .= $this->buildNestedList($execution, $child, true, $showmore, $users); + } + } + + return $list; + } + /** * Build task menu. *