From 74bb6d7ea1e7d7ffee6443122f9244fa81e5d7a5 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 18 Oct 2023 13:56:59 +0800 Subject: [PATCH] * Fixed an error in batch edit task to be processed. --- module/task/js/batchedit.ui.js | 17 ++++++++++++++--- module/task/ui/batchedit.html.php | 1 + module/task/zen.php | 22 ++++++++++++++++++---- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/module/task/js/batchedit.ui.js b/module/task/js/batchedit.ui.js index 8b27e68c39..713c883db5 100644 --- a/module/task/js/batchedit.ui.js +++ b/module/task/js/batchedit.ui.js @@ -23,9 +23,9 @@ window.renderRowData = function($row, index, row) taskMembers = members; } - const taskUsers = []; - let disabled = false; - let $assignedTo = $row.find('.form-batch-input[data-name="assignedTo"]').empty(); + const taskUsers = []; + let disabled = false; + let $assignedTo = $row.find('.form-batch-input[data-name="assignedTo"]').empty(); if(teams[row.id] != undefined && ((row.assignedTo != currentUser && row.mode == 'linear') || taskMembers[currentUser] == undefined)) { disabled = true; @@ -46,4 +46,15 @@ window.renderRowData = function($row, index, row) $row.find('.form-batch-input[data-name="consumed"]').attr('disabled', 'disabled'); $row.find('.form-batch-input[data-name="left"]').attr('disabled', 'disabled'); } + + if(moduleGroup[executionID] != undefined) + { + $row.find('[data-name="module"]').find('.picker-box').on('inited', function(e, info) + { + let $module = info[0]; + let modules = moduleGroup[executionID]; + $module.render({items: modules}); + $module.$.setValue(row.module); + }); + } } diff --git a/module/task/ui/batchedit.html.php b/module/task/ui/batchedit.html.php index cad84afb0b..299dcbcd13 100644 --- a/module/task/ui/batchedit.html.php +++ b/module/task/ui/batchedit.html.php @@ -16,6 +16,7 @@ jsVar('executionTeams', $executionTeams); jsVar('users', $users); jsVar('teams', $teams); jsVar('currentUser', $app->user->account); +jsVar('moduleGroup', $moduleGroup); /* ====== Define the page structure with zin widgets ====== */ formBatchPanel diff --git a/module/task/zen.php b/module/task/zen.php index 84e9bd6647..671e5d5b38 100644 --- a/module/task/zen.php +++ b/module/task/zen.php @@ -169,6 +169,8 @@ class taskZen extends task */ protected function assignBatchEditVars(int $executionID): void { + $this->loadModel('tree'); + /* Set menu and related variables. */ if($executionID) { @@ -184,8 +186,9 @@ class taskZen extends task $this->loadModel('my'); $this->lang->my->menu->work['subModule'] = 'task'; - $this->view->title = $this->lang->task->batchEdit; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->view->title = $this->lang->task->batchEdit; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->view->modules = array(); } /* Check if the request data size exceeds the PHP limit. */ @@ -207,14 +210,25 @@ class taskZen extends task $executionTeamList = $this->execution->getMembersByIdList($executionIdList); foreach($executionIdList as $id) $executionTeams[$id] = array_column($executionTeamList[$id], 'account'); + $moduleGroup = array(); + if(!$executionID) + { + foreach($tasks as $task) + { + if(isset($moduleGroup[$task->execution])) continue; + $executionInfo = $this->execution->getByID($task->execution); + $executionModules = $this->tree->getTaskOptionMenu($task->execution, 0, 'allModule'); + foreach($executionModules as $moduleID => $moduleName) $moduleGroup[$task->execution][] = array('text' => $executionInfo->name. $moduleName, 'value' => $moduleID); + } + } + /* Assign. */ $this->view->executionID = $executionID; $this->view->tasks = $tasks; $this->view->teams = $this->task->getTeamMembersByIdList($this->post->taskIdList); $this->view->executionTeams = $executionTeams; - $this->view->executionName = zget($execution, 'name', ''); - $this->view->executionType = zget($execution, 'type', ''); $this->view->users = $this->loadModel('user')->getPairs('nodeleted'); + $this->view->moduleGroup = $moduleGroup; $this->display(); }