From 95ec7512546b9924d8ce6590e6874bccd3d30b2c Mon Sep 17 00:00:00 2001 From: wangyuting Date: Thu, 8 Jun 2023 16:00:41 +0800 Subject: [PATCH] * Finsih my task page. --- module/my/config/table.php | 115 ++++++++++++++++++++++++++++++++++++- module/my/control.php | 6 +- module/my/js/task.ui.js | 47 +++++++++++++++ module/my/ui/task.html.php | 43 ++++++++++++++ 4 files changed, 208 insertions(+), 3 deletions(-) create mode 100644 module/my/js/task.ui.js create mode 100644 module/my/ui/task.html.php diff --git a/module/my/config/table.php b/module/my/config/table.php index be551f286e..895e09e72f 100644 --- a/module/my/config/table.php +++ b/module/my/config/table.php @@ -2,6 +2,7 @@ global $lang,$config, $app; $app->loadLang('todo'); $app->loadLang('score'); +$app->loadLang('task'); $app->loadLang('story'); $config->my->todo = new stdclass(); @@ -133,6 +134,116 @@ $config->my->score->dtable->fieldList['desc']['name'] = 'desc'; $config->my->score->dtable->fieldList['desc']['title'] = $lang->score->desc; $config->my->score->dtable->fieldList['desc']['type'] = 'desc'; +$config->my->task = new stdclass(); +$config->my->task->actionList = array(); +$config->my->task->actionList['confirmStoryChange']['icon'] = 'search'; +$config->my->task->actionList['confirmStoryChange']['text'] = $lang->task->confirmStoryChange; +$config->my->task->actionList['confirmStoryChange']['hint'] = $lang->task->confirmStoryChange; +$config->my->task->actionList['confirmStoryChange']['url'] = helper::createLink('task', 'confirmStoryChange', 'taskID={id}'); + +$config->my->task->actionList['start']['icon'] = 'play'; +$config->my->task->actionList['start']['text'] = $lang->task->start; +$config->my->task->actionList['start']['hint'] = $lang->task->start; +$config->my->task->actionList['start']['url'] = helper::createLink('task', 'start', 'taskID={id}'); +$config->my->task->actionList['start']['data-toggle'] = 'modal'; + +$config->my->task->actionList['restart']['icon'] = 'play'; +$config->my->task->actionList['restart']['text'] = $lang->task->restart; +$config->my->task->actionList['restart']['hint'] = $lang->task->restart; +$config->my->task->actionList['restart']['url'] = helper::createLink('task', 'restart', 'taskID={id}'); +$config->my->task->actionList['restart']['data-toggle'] = 'modal'; + +$config->my->task->actionList['finish']['icon'] = 'checked'; +$config->my->task->actionList['finish']['text'] = $lang->task->finish; +$config->my->task->actionList['finish']['hint'] = $lang->task->finish; +$config->my->task->actionList['finish']['url'] = helper::createLink('task', 'finish', 'taskID={id}'); +$config->my->task->actionList['finish']['data-toggle'] = 'modal'; + +$config->my->task->actionList['close']['icon'] = 'off'; +$config->my->task->actionList['close']['text'] = $lang->task->close; +$config->my->task->actionList['close']['hint'] = $lang->task->close; +$config->my->task->actionList['close']['url'] = helper::createLink('task', 'close', 'taskID={id}'); +$config->my->task->actionList['close']['data-toggle'] = 'modal'; + +$config->my->task->actionList['record']['icon'] = 'time'; +$config->my->task->actionList['record']['text'] = $lang->task->logEfforts; +$config->my->task->actionList['record']['hint'] = $lang->task->logEfforts; +$config->my->task->actionList['record']['url'] = helper::createLink('task', 'recordEstimate', 'taskID={id}'); +$config->my->task->actionList['record']['data-toggle'] = 'modal'; + +$config->my->task->actionList['edit']['icon'] = 'edit'; +$config->my->task->actionList['edit']['text'] = $lang->task->edit; +$config->my->task->actionList['edit']['hint'] = $lang->task->edit; +$config->my->task->actionList['edit']['url'] = helper::createLink('task', 'edit', 'taskID={id}'); +$config->my->task->actionList['edit']['data-toggle'] = 'modal'; + +$config->my->task->actionList['batchCreate']['icon'] = 'split'; +$config->my->task->actionList['batchCreate']['text'] = $lang->task->batchCreate; +$config->my->task->actionList['batchCreate']['hint'] = $lang->task->batchCreate; +$config->my->task->actionList['batchCreate']['url'] = helper::createLink('task', 'batchCreate', 'executionID={execution}&storyID={story}&moduleID={module}&taskID={id}iframe=true'); +$config->my->task->actionList['batchCreate']['data-toggle'] = 'modal'; + +$config->my->task->dtable = new stdclass(); +$config->my->task->dtable->fieldList['id']['name'] = 'id'; +$config->my->task->dtable->fieldList['id']['title'] = $lang->idAB; +$config->my->task->dtable->fieldList['id']['type'] = 'checkID'; +$config->my->task->dtable->fieldList['id']['fixed'] = 'left'; + +$config->my->task->dtable->fieldList['name']['name'] = 'name'; +$config->my->task->dtable->fieldList['name']['title'] = $lang->task->name; +$config->my->task->dtable->fieldList['name']['type'] = 'title'; +$config->my->task->dtable->fieldList['name']['link'] = helper::createLink('task', 'view', 'taskID={id}'); +$config->my->task->dtable->fieldList['name']['fixed'] = 'left'; + +$config->my->task->dtable->fieldList['pri']['name'] = 'pri'; +$config->my->task->dtable->fieldList['pri']['title'] = $lang->priAB; +$config->my->task->dtable->fieldList['pri']['type'] = 'pri'; +$config->my->task->dtable->fieldList['pri']['map'] = $lang->task->priList; +$config->my->task->dtable->fieldList['pri']['group'] = 'pri'; + +$config->my->task->dtable->fieldList['status']['name'] = 'status'; +$config->my->task->dtable->fieldList['status']['title'] = $lang->statusAB; +$config->my->task->dtable->fieldList['status']['type'] = 'status'; +$config->my->task->dtable->fieldList['status']['statusMap'] = $lang->task->statusList; +$config->my->task->dtable->fieldList['status']['group'] = 'pri'; + +$config->my->task->dtable->fieldList['openedBy']['name'] = 'openedBy'; +$config->my->task->dtable->fieldList['openedBy']['title'] = $lang->task->openedByAB; +$config->my->task->dtable->fieldList['openedBy']['type'] = 'user'; +$config->my->task->dtable->fieldList['openedBy']['group'] = 'user'; + +$config->my->task->dtable->fieldList['finishedBy']['name'] = 'finishedBy'; +$config->my->task->dtable->fieldList['finishedBy']['title'] = $lang->task->finishedByAB; +$config->my->task->dtable->fieldList['finishedBy']['type'] = 'user'; +$config->my->task->dtable->fieldList['finishedBy']['group'] = 'user'; + +$config->my->task->dtable->fieldList['deadline']['name'] = 'deadline'; +$config->my->task->dtable->fieldList['deadline']['title'] = $lang->task->deadlineAB; +$config->my->task->dtable->fieldList['deadline']['type'] = 'date'; +$config->my->task->dtable->fieldList['deadline']['group'] = 'number'; + +$config->my->task->dtable->fieldList['estimate']['name'] = 'estimateLabel'; +$config->my->task->dtable->fieldList['estimate']['title'] = $lang->task->estimateAB; +$config->my->task->dtable->fieldList['estimate']['type'] = 'number'; +$config->my->task->dtable->fieldList['estimate']['group'] = 'number'; + +$config->my->task->dtable->fieldList['consumed']['name'] = 'consumedLabel'; +$config->my->task->dtable->fieldList['consumed']['title'] = $lang->task->consumedAB; +$config->my->task->dtable->fieldList['consumed']['type'] = 'number'; +$config->my->task->dtable->fieldList['consumed']['group'] = 'number'; + +$config->my->task->dtable->fieldList['left']['name'] = 'leftLabel'; +$config->my->task->dtable->fieldList['left']['title'] = $lang->task->leftAB; +$config->my->task->dtable->fieldList['left']['type'] = 'number'; +$config->my->task->dtable->fieldList['left']['group'] = 'number'; + +$config->my->task->dtable->fieldList['actions']['name'] = 'actions'; +$config->my->task->dtable->fieldList['actions']['title'] = $lang->actions; +$config->my->task->dtable->fieldList['actions']['type'] = 'actions'; +$config->my->task->dtable->fieldList['actions']['sortType'] = false; +$config->my->task->dtable->fieldList['actions']['list'] = $config->my->task->actionList; +$config->my->task->dtable->fieldList['actions']['menu'] = array(array('confirmStoryChange'), array('start|restart', 'finish', 'close', 'record', 'edit', 'batchCreate')); + $config->my->requirement = new stdclass(); $config->my->requirement->actionList = array(); $config->my->requirement->actionList['change']['icon'] = 'alter'; @@ -320,7 +431,7 @@ $config->my->audit->dtable->fieldList['id']['fixed'] = 'left'; $config->my->audit->dtable->fieldList['title']['name'] = 'title'; $config->my->audit->dtable->fieldList['title']['title'] = $lang->my->auditField->title; $config->my->audit->dtable->fieldList['title']['type'] = 'title'; -$config->my->audit->dtable->fieldList['title']['link'] = helper::createLink('story', 'view', "id={id}"); +$config->my->audit->dtable->fieldList['title']['link'] = helper::createLink('story', 'view', 'id={id}'); $config->my->audit->dtable->fieldList['title']['fixed'] = 'left'; $config->my->audit->dtable->fieldList['title']['data-toggle'] = 'modal'; @@ -352,7 +463,7 @@ $config->my->project->dtable = new stdclass(); $config->my->project->dtable->fieldList['name']['name'] = 'name'; $config->my->project->dtable->fieldList['name']['title'] = $lang->project->name; $config->my->project->dtable->fieldList['name']['type'] = 'title'; -$config->my->project->dtable->fieldList['name']['link'] = helper::createLink('project', 'index', "id={id}"); +$config->my->project->dtable->fieldList['name']['link'] = helper::createLink('project', 'index', 'id={id}'); $config->my->project->dtable->fieldList['name']['fixed'] = 'left'; $config->my->project->dtable->fieldList['name']['group'] = '1'; $config->my->project->dtable->fieldList['name']['iconRender'] = 'RAWJSRAWJS'; diff --git a/module/my/control.php b/module/my/control.php index 9b6a3dafc9..e191f90b46 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -500,9 +500,13 @@ EOF; } $parents = array(); + $summary = $this->loadModel('execution')->summary($tasks); foreach($tasks as $task) { if($task->parent > 0) $parents[$task->parent] = $task->parent; + $task->estimateLabel = $task->estimate . $this->lang->execution->workHourUnit; + $task->consumedLabel = $task->consumed . $this->lang->execution->workHourUnit; + $task->leftLabel = $task->left . $this->lang->execution->workHourUnit; } $parents = $this->dao->select('*')->from(TABLE_TASK)->where('id')->in($parents)->fetchAll('id'); @@ -533,7 +537,7 @@ EOF; $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->task; $this->view->tabID = 'task'; $this->view->tasks = $tasks; - $this->view->summary = $this->loadModel('execution')->summary($tasks); + $this->view->summary = $summary; $this->view->type = $type; $this->view->kanbanList = $this->execution->getPairs(0, 'kanban'); $this->view->recTotal = $recTotal; diff --git a/module/my/js/task.ui.js b/module/my/js/task.ui.js new file mode 100644 index 0000000000..00da891752 --- /dev/null +++ b/module/my/js/task.ui.js @@ -0,0 +1,47 @@ +$(document).on('click', '.batch-btn', function() +{ + const dtable = zui.DTable.query($(this).target); + const checkedList = dtable.$.getChecks(); + if(!checkedList.length) return; + + const url = $(this).data('url'); + const form = new FormData(); + checkedList.forEach((id) => form.append('taskIdList[]', id)); + + if($(this).hasClass('ajax-btn')) + { + $.ajaxSubmit({url, data: form}); + } + else + { + postAndLoadPage(url, form); + } +}); + +/** + * 计算表格任务信息的统计。 + * Set todo summary for table footer. + * + * @param element element + * @param array checkedIDList + * @access public + * @return object + */ +window.setStatistics = function(element, checks) +{ + let waitCount = 0; + let doingCount = 0; + let estimate = 0; + let consumed = 0; + let left = 0; + checks.forEach((checkID) => { + const task = element.getRowInfo(checkID).data; + if(task.status == 'wait') waitCount ++; + if(task.status == 'doing') doingCount ++; + estimate += task.estimate; + consumed += task.consumed; + left += task.left; + }) + if(checks.length) return {html: element.options.checkedSummary.replaceAll('%total%', `${checks.length}`).replaceAll('%wait%', waitCount).replaceAll('%doing%', doingCount).replaceAll('%estimate%', estimate).replaceAll('%consumed%', consumed).replaceAll('%left%', left)}; + return zui.formatString(element.options.defaultSummary); +} diff --git a/module/my/ui/task.html.php b/module/my/ui/task.html.php new file mode 100644 index 0000000000..48f7eb465d --- /dev/null +++ b/module/my/ui/task.html.php @@ -0,0 +1,43 @@ + + * @package my + * @link https://www.zentao.net + */ +namespace zin; + +featureBar +( + set::current($type), + set::linkParams("mode={$mode}&type={key}"), + li(searchToggle()) +); + +$footToolbar = array('items' => array +( + array('text' => $lang->edit, 'className' => 'batch-btn ' . (common::hasPriv('task', 'batchEdit') ? '' : 'hidden'), 'data-url' => helper::createLink('task', 'batchEdit')), + array('text' => $lang->close, 'className' => 'batch-btn ajax-btn ' . (common::hasPriv('task', 'batchClose') ? '' : 'hidden'), 'data-url' => helper::createLink('task', 'batchClose')), +), 'btnProps' => array('size' => 'sm', 'btnType' => 'secondary')); + +$tasks = initTableData($tasks, $config->my->task->dtable->fieldList, $this->task); +$cols = array_values($config->my->task->dtable->fieldList); +$data = array_values($tasks); +dtable +( + set::cols($cols), + set::data($data), + set::userMap($users), + set::fixedLeftWidth('44%'), + set::checkable(true), + set::defaultSummary(array('html' => $summary)), + set::checkedSummary($lang->execution->checkedSummary), + set::checkInfo(jsRaw('function(checkedIDList){return window.setStatistics(this, checkedIDList);}')), + set::footToolbar($footToolbar), + set::footPager(usePager()), +); + +render();