From f5fedf9ffd8c3317af25ff74b4cb4d5fafae2e6a Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Tue, 4 Jul 2023 09:46:29 +0800 Subject: [PATCH] * Change execution name output use render cell. --- module/execution/config/dtable.php | 17 ++++++++--------- module/execution/js/all.ui.js | 17 +++++++++++++++++ module/execution/model.php | 4 +--- module/execution/ui/all.html.php | 4 ++++ 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/module/execution/config/dtable.php b/module/execution/config/dtable.php index b2a3008b0b..2f27041b3c 100644 --- a/module/execution/config/dtable.php +++ b/module/execution/config/dtable.php @@ -11,15 +11,14 @@ $config->execution->dtable->fieldList['rawID']['checkbox'] = true; $config->execution->dtable->fieldList['rawID']['width'] = '80'; $config->execution->dtable->fieldList['rawID']['required'] = true; -$config->execution->dtable->fieldList['name']['title'] = $lang->execution->name; -$config->execution->dtable->fieldList['name']['name'] = 'name'; -$config->execution->dtable->fieldList['name']['fixed'] = 'left'; -$config->execution->dtable->fieldList['name']['flex'] = 1; -$config->execution->dtable->fieldList['name']['type'] = 'html'; -$config->execution->dtable->fieldList['name']['nestedToggle'] = true; -$config->execution->dtable->fieldList['name']['sortType'] = true; -$config->execution->dtable->fieldList['name']['minWidth'] = '356'; -$config->execution->dtable->fieldList['name']['required'] = true; +$config->execution->dtable->fieldList['name']['title'] = $lang->execution->name; +$config->execution->dtable->fieldList['name']['name'] = 'name'; +$config->execution->dtable->fieldList['name']['fixed'] = 'left'; +$config->execution->dtable->fieldList['name']['flex'] = 1; +$config->execution->dtable->fieldList['name']['type'] = 'nestedTitle'; +$config->execution->dtable->fieldList['name']['sortType'] = true; +$config->execution->dtable->fieldList['name']['minWidth'] = '356'; +$config->execution->dtable->fieldList['name']['required'] = true; if(isset($config->setCode) and $config->setCode == 1) { diff --git a/module/execution/js/all.ui.js b/module/execution/js/all.ui.js index 6488cb19cb..8f47655fec 100644 --- a/module/execution/js/all.ui.js +++ b/module/execution/js/all.ui.js @@ -24,3 +24,20 @@ $(document).off('click','.batch-btn').on('click', '.batch-btn', function() $.cookie.set('checkedItem', checkedList); }); + +const today = zui.formatDate(new Date(), 'yyyy-MM-dd'); +window.onRenderCell = function(result, {col, row}) +{ + if(col.name == 'name') + { + const executionLink = $.createLink('execution', 'task', `executionID=${row.data.rawID}`); + const executionType = typeList[row.data.type]; + let executionName = `${executionType} `; + executionName += (!row.data.isParent) ? `${row.data.name}` : row.data.name; + executionName += (today > row.data.end) ? `${delayed}` : ''; + result[0] = {html: executionName}; + return result; + } + + return result; +} diff --git a/module/execution/model.php b/module/execution/model.php index 92045f4e8f..5b53760ab5 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -5379,15 +5379,13 @@ class executionModel extends model */ public function generateRow(array $executions, array $users, array $avatarList): array { - $today = helper::today(); - $rows = array(); + $rows = array(); foreach($executions as $execution) { $link = $execution->type == 'kanban' ? helper::createLink('execution', 'kanban', "id=$execution->id") : helper::createLink('execution', 'task', "id=$execution->id"); $execution->rawID = $execution->id; $execution->isExecution = 1; $execution->id = 'pid' . (string)$execution->id; - $execution->name = "{$this->lang->execution->typeList[$execution->type]} " . (empty($execution->isParent) ? html::a($link, $execution->name, '_self', 'class="text-primary"') : $execution->name) . (strtotime($today) > strtotime($execution->end) ? '' . $this->lang->execution->delayed . '' : ''); $execution->project = $execution->projectName; $execution->parent = ($execution->parent and $execution->grade > 1) ? 'pid' . (string)$execution->parent : ''; $execution->isParent = !empty($execution->isParent) or !empty($execution->tasks); diff --git a/module/execution/ui/all.html.php b/module/execution/ui/all.html.php index 1c0a3129c3..8df643a7aa 100644 --- a/module/execution/ui/all.html.php +++ b/module/execution/ui/all.html.php @@ -12,6 +12,9 @@ declare(strict_types=1); namespace zin; +jsVar('typeList', $lang->execution->typeList); +jsVar('delayed', $lang->execution->delayed); + $footToolbar = array(); $canBatchEdit = common::hasPriv('execution', 'batchEdit'); $canBatchChangeStatus = common::hasPriv('execution', 'batchChangeStatus'); @@ -86,6 +89,7 @@ dtable set::fixedLeftWidth('44%'), set::customCols(true), set::footToolbar($footToolbar), + set::onRenderCell(jsRaw('window.onRenderCell')), set::footPager( usePager(), set::recPerPage($recPerPage),