diff --git a/module/execution/js/task.ui.js b/module/execution/js/task.ui.js index 59ba2611d1..2a610c4edd 100644 --- a/module/execution/js/task.ui.js +++ b/module/execution/js/task.ui.js @@ -9,3 +9,57 @@ $(document).on('click', '.batch-btn', function() checkedList.forEach((id) => form.append('taskIdList[]', id)); postAndLoadPage(url, form); }); + + +/** + * 计算表格任务信息的统计。 + * Set task summary for table footer. + * + * @param element element + * @param array checkedIDList + * @access public + * @return object + */ +window.setStatistics = function(element, checkedIDList) +{ + let totalLeft = 0; + let totalEstimate = 0; + let totalConsumed = 0; + + let waitCount = 0; + let doingCount = 0; + let totalCount = 0; + + const rows = element.layout.allRows; + rows.forEach((row) => { + if(checkedIDList.length == 0 || checkedIDList.includes(row.id)) + { + const task = row.data; + + totalEstimate += Number(task.estimate); + totalConsumed += Number(task.consumed); + if(task.status != 'cancel' && task.status != 'closed') totalLeft += Number(task.left); + + if(task.status == 'wait') + { + waitCount ++; + } + else if(task.status == 'doing') + { + doingCount ++; + } + + totalCount ++; + } + }) + + const summary = checkedIDList.length > 0 ? checkedSummary : pageSummary; + return { + html: summary.replace('%total%', totalCount) + .replace('%wait%', waitCount) + .replace('%doing%', doingCount) + .replace('%estimate%', totalEstimate.toFixed(1)) + .replace('%consumed%', totalConsumed.toFixed(1)) + .replace('%left%', totalLeft.toFixed(1)) + }; +} diff --git a/module/execution/ui/task.html.php b/module/execution/ui/task.html.php index 5b7979696a..ade78ce2a2 100644 --- a/module/execution/ui/task.html.php +++ b/module/execution/ui/task.html.php @@ -195,6 +195,10 @@ if($canBatchAction) if($canBatchAssignTo) $footToolbar['items'][] = array('caret' => 'up', 'text' => $lang->task->assignedTo, 'btnType' => 'primary', 'url' => '#navAssignedTo','data-toggle' => 'dropdown'); } +jsVar('taskSummary', $lang->execution->taskSummary); +jsVar('pageSummary', $lang->execution->pageSummary); +jsVar('checkedSummary', $lang->execution->checkedSummary); + dtable ( set::userMap($memberPairs), @@ -205,11 +209,11 @@ dtable set::footToolbar($footToolbar), set::footPager( usePager(), - set::page($pageID), set::recPerPage($recPerPage), set::recTotal($recTotal), set::linkCreator(helper::createLink('execution', 'task', "executionID={$execution->id}&status={$status}¶m={$param}&orderBy=$orderBy&recTotal={$recTotal}&recPerPage={recPerPage}&page={page}")) ), + set::checkInfo(jsRaw('function(checkedIDList){return window.setStatistics(this, checkedIDList); }')) ); render();