* [perf story #72331] get child stages for programplan create page.
This commit is contained in:
@@ -1798,14 +1798,19 @@ class executionModel extends model
|
||||
*
|
||||
* @param int $executionID
|
||||
* @param string $orderBy
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getChildExecutions(int $executionID, string $orderBy = 'id_desc'): array
|
||||
public function getChildExecutions(int $executionID, string $orderBy = 'id_desc', string $type = 'child'): array
|
||||
{
|
||||
$executionID = (int)$executionID;
|
||||
$path = '';
|
||||
if($type != 'child') $path = $this->dao->select('id,parent,path')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetch('path');
|
||||
return $this->dao->select('*')->from(TABLE_EXECUTION)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('parent')->eq((int)$executionID)
|
||||
->beginIF($type == 'child')->andWhere('parent')->eq($executionID)->fi()
|
||||
->beginIF($type != 'child' && $path)->andWhere('path')->like("{$path}%")->andWhere('id')->ne($executionID)->fi()
|
||||
->orderBy($orderBy)
|
||||
->fetchAll('id', false);
|
||||
}
|
||||
|
||||
@@ -113,9 +113,9 @@ class programplan extends control
|
||||
$project = $this->project->getById($projectID);
|
||||
$programPlan = $this->project->getById($planID);
|
||||
$productList = $this->session->hasProduct ? $this->product->getProductPairsByProject($projectID) : array();
|
||||
$executions = !empty($planID) ? $this->loadModel('execution')->getChildExecutions($planID, 'order_asc') : array();
|
||||
$executions = !empty($planID) ? $this->loadModel('execution')->getChildExecutions($planID, 'order_asc,grade_asc', 'all') : array();
|
||||
|
||||
$plans = $this->programplan->getStage($planID ?: $projectID, $this->productID, 'parent', 'order_asc');
|
||||
$plans = $this->programplan->getStage($planID ?: $projectID, $this->productID, 'all', 'order_asc,grade_asc');
|
||||
if(!empty($planID) and in_array($project->model, array('ipd', 'waterfallplus')))
|
||||
{
|
||||
if(!empty($plans))
|
||||
@@ -129,6 +129,8 @@ class programplan extends control
|
||||
unset($this->lang->programplan->typeList['stage']);
|
||||
}
|
||||
}
|
||||
if(!empty($executions)) $plans = $executions;
|
||||
$plans = $this->programplanZen->sortPlans($plans);
|
||||
|
||||
/* Set programplan typeList. */
|
||||
if($executionType != 'stage') unset($this->lang->execution->typeList[''], $this->lang->execution->typeList['stage']);
|
||||
@@ -143,7 +145,7 @@ class programplan extends control
|
||||
$viewData->programPlan = $programPlan;
|
||||
$viewData->productList = $productList;
|
||||
$viewData->project = $project;
|
||||
$viewData->plans = !empty($executions) ? $executions : $plans;
|
||||
$viewData->plans = $plans;
|
||||
$viewData->syncData = $syncData;
|
||||
|
||||
$this->programplanZen->buildCreateView($viewData);
|
||||
|
||||
@@ -43,6 +43,7 @@ window.handleRenderRow = function($row, index, data)
|
||||
|
||||
/* 获取当前行的层级,下面可能会根据上一行层级修改当前行层级: */
|
||||
let level = this.nestedLevelMap[$row.attr('data-gid')] || 0;
|
||||
if(typeof data != 'undefined' && typeof data.grade != 'undefined') level = data.grade - planGrade;
|
||||
|
||||
/* 当前行层级信息文本: */
|
||||
let text = '1';
|
||||
@@ -115,11 +116,6 @@ window.handleRenderRow = function($row, index, data)
|
||||
|
||||
$('thead [data-name="ACTIONS"]').css('display', 'none');
|
||||
$row.find('[data-name="ACTIONS"]').css('display', 'none');
|
||||
$row.find('[data-name="attribute"]').find('.picker-box').on('inited', function(e, info)
|
||||
{
|
||||
let $attributePicker = info[0];
|
||||
$attributePicker.render({disabled: true});
|
||||
});
|
||||
|
||||
if(data.hasOwnProperty('status') && data.status != 'wait')
|
||||
{
|
||||
@@ -150,6 +146,16 @@ window.handleRenderRow = function($row, index, data)
|
||||
});
|
||||
}
|
||||
|
||||
if(level > 0 || planGrade > 1)
|
||||
{
|
||||
$row.find('[data-name="attribute"]').find('.picker-box').on('inited', function(e, info)
|
||||
{
|
||||
let $attributePicker = info[0];
|
||||
$attributePicker.render({disabled: true});
|
||||
if($prevRow) $attributePicker.$.setValue($prevRow.find('[name^=attribute]').val());
|
||||
});
|
||||
}
|
||||
|
||||
if(data != undefined)
|
||||
{
|
||||
if(data.hasOwnProperty('type'))
|
||||
@@ -343,4 +349,21 @@ window.changeEnabled = function(obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.changeAttribute = function(obj)
|
||||
{
|
||||
const attribute = obj.value;
|
||||
const $target = $(obj);
|
||||
|
||||
let $tr = $target.closest('tr');
|
||||
while(true)
|
||||
{
|
||||
$nextTr = $tr.next();
|
||||
if($nextTr.length == 0) break;
|
||||
if($nextTr.attr('data-level') == '0') break;
|
||||
|
||||
$nextTr.find('.picker-box[data-name="attribute"]').zui('picker').$.setValue(attribute);
|
||||
$tr = $nextTr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,6 +274,7 @@ jsVar('planID', $planID);
|
||||
jsVar('type', $executionType);
|
||||
jsVar('project', $project);
|
||||
jsVar('plans', $plans);
|
||||
jsVar('planGrade', $programPlan ? $programPlan->grade + 1 : 1);
|
||||
jsVar('syncData', $syncData);
|
||||
jsVar('cropStageTip', $lang->programplan->cropStageTip);
|
||||
jsVar('ipdStagePoint', $project->model == 'ipd' ? $config->review->ipdReviewPoint : array());
|
||||
@@ -316,5 +317,6 @@ formBatchPanel
|
||||
set::data($fnGenerateDefaultData()),
|
||||
$app->session->projectPlanList ? set::actions(array('submit', array('text' => $lang->cancel, 'url' => $app->session->projectPlanList))) : null,
|
||||
on::change('[name^="enabled"]', 'changeEnabled(e.target)'),
|
||||
on::change('[name^="attribute"]', 'changeAttribute(e.target)'),
|
||||
($project->model == 'ipd' && !$planID) ? set::maxRows(count($fnGenerateDefaultData())) : null,
|
||||
);
|
||||
|
||||
@@ -57,9 +57,9 @@ class programplanZen extends programplan
|
||||
}
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$project = $this->loadModel('project')->getByID($projectID);
|
||||
$project = $this->loadModel('project')->getByID($projectID);
|
||||
$oldPlans = $this->programplan->getStage($projectID);
|
||||
if($parentID) $parentStage = $this->programplan->getByID($parentID);
|
||||
if(!$parentID) $oldPlans = $this->programplan->getStage($projectID);
|
||||
|
||||
$fields = $this->config->programplan->form->create;
|
||||
foreach(explode(',', $this->config->programplan->create->requiredFields) as $field)
|
||||
@@ -77,9 +77,10 @@ class programplanZen extends programplan
|
||||
if(empty($parentID) and empty($oldPlans)) $plan->id = '';
|
||||
$plan->days = isset($plan->enabled) && $plan->enabled == 'on' ? $this->calcDaysForStage($plan->begin, $plan->end) : 0;
|
||||
$plan->project = $projectID;
|
||||
$plan->parent = $parentID ? $parentID : $projectID;
|
||||
$plan->order = (int)array_shift($orders);
|
||||
$plan->hasProduct = $project->hasProduct;
|
||||
$plan->parent = $parentID ? $parentID : $projectID;
|
||||
if($plan->id && isset($oldPlans[$plan->id])) $plan->parent = $oldPlans[$plan->id]->parent;
|
||||
|
||||
if(empty($plan->days)) $plan->days = helper::diffDate($plan->end, $plan->begin) + 1;
|
||||
if(!empty($parentID) && !empty($parentStage) && $parentStage->attribute != 'mix') $plan->attribute = $parentStage->attribute;;
|
||||
@@ -449,4 +450,43 @@ class programplanZen extends programplan
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新排序阶段,将子阶段放在父阶段之后。
|
||||
* Reorder stage, put sub stage after parent stage.
|
||||
*
|
||||
* @param array $plans
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function sortPlans(array $plans): array
|
||||
{
|
||||
$parents = array();
|
||||
foreach($plans as $plan) $parents[$plan->parent][$plan->id] = $plan->id;
|
||||
|
||||
$getChildren = function($planID) use($parents, &$getChildren)
|
||||
{
|
||||
if(!isset($parents[$planID])) return array();
|
||||
|
||||
$children = array();
|
||||
foreach($parents[$planID] as $childPlanID)
|
||||
{
|
||||
$children[$childPlanID] = $childPlanID;
|
||||
$children = arrayUnion($children, $getChildren($childPlanID));
|
||||
}
|
||||
return $children;
|
||||
};
|
||||
|
||||
$sortedPlans = array();
|
||||
foreach($plans as $plan)
|
||||
{
|
||||
if($sortedPlans[$plan->id]) continue;
|
||||
|
||||
$sortedPlans[$plan->id] = $plan;
|
||||
$children = $getChildren($plan->id);
|
||||
foreach($children as $childID) $sortedPlans[$childID] = $plans[$childID];
|
||||
}
|
||||
|
||||
return $sortedPlans;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user