* Code for task#77794.

This commit is contained in:
xieqiyu
2022-11-29 15:03:58 +08:00
parent 6356683483
commit 2c6e7ffa39
7 changed files with 54 additions and 16 deletions
+3 -3
View File
@@ -84,7 +84,7 @@ class productplan extends control
}
$this->commonAction($productID, $branchID);
$lastPlan = $this->productplan->getLast($productID, $branchID, $parent);
$lastPlan = $this->productplan->getLast($productID, '', $parent);
$product = $this->loadModel('product')->getById($productID);
if($lastPlan)
@@ -117,7 +117,7 @@ class productplan extends control
$this->view->branches = $branchPairs;
$this->view->defaultBranch = $defaultBranch;
$this->view->parent = $parent;
$this->view->parentPlanPairs = $this->productplan->getTopPlanPairs($productID, $branchID, 'done,closed');
$this->view->parentPlanPairs = $this->productplan->getTopPlanPairs($productID, '', 'done,closed');
$this->display();
}
@@ -973,6 +973,6 @@ class productplan extends control
public function ajaxGetTopPlan($productID, $branch = 0)
{
$parentPlanPairs = $this->productplan->getTopPlanPairs($productID, $branch);
return print(html::select('parent', array('0' => '') + $parentPlanPairs, '', 'class="form-control"'));
return print(html::select('parent', array(0 => '') + $parentPlanPairs, 0, 'class="form-control"'));
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
.table td.content div {height: 25px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; float: left; max-width: calc(100% - 20px);}
.table td.content .more {position: absolute; right: 16px;}
.table td.content .more .icon {color: #838a9d;}
td.c-branch {overflow: hidden; text-align: left !important; text-overflow: ellipsis; white-space: nowrap;}
td.c-branch {overflow: hidden; text-align: left !important; white-space: nowrap;}
.table-children {border-left: 2px solid #cbd0db; border-right: 2px solid #cbd0db;}
.table tbody > tr.table-children.table-child-top {border-top: 2px solid #cbd0db;}
+6 -3
View File
@@ -65,9 +65,12 @@ $('#future').on('change', function()
$('#branch').change(function()
{
var branchID = $(this).val();
var lastPlanLink = createLink('productplan', 'ajaxGetLast', "productID=" + productID + "&branch=" + branchID);
var topPlanLink = createLink('productplan', 'ajaxGetTopPlan', "productID=" + productID + "&branch=" + branchID);
var branchIdList = $(this).val();
if(!branchIdList) return;
var branchIdList = branchIdList.toString();
var lastPlanLink = createLink('productplan', 'ajaxGetLast', "productID=" + productID + "&branch=" + branchIdList);
var topPlanLink = createLink('productplan', 'ajaxGetTopPlan', "productID=" + productID + "&branch=" + branchIdList);
$.post(lastPlanLink, function(data)
{
+38 -5
View File
@@ -52,15 +52,28 @@ class productplanModel extends model
* @access public
* @return object
*/
public function getLast($productID, $branch = 0, $parent = 0)
public function getLast($productID, $branch = '', $parent = 0)
{
$branchQuery = '';
if($branch !== '')
{
$branchQuery .= '(';
$branchCount = count(explode(',', $branch));
foreach(explode(',', $branch) as $index => $branchID)
{
$branchQuery .= "CONCAT(',', branch, ',') LIKE '%,$branchID,%'";
if($index < $branchCount - 1) $branchQuery .= ' AND ';
}
$branchQuery .= ')';
}
return $this->dao->select('*')->from(TABLE_PRODUCTPLAN)
->where('deleted')->eq(0)
->beginIF($parent <= 0)->andWhere('parent')->le((int)$parent)->fi()
->beginIF($parent > 0)->andWhere('parent')->eq((int)$parent)->fi()
->andWhere('product')->eq((int)$productID)
->andWhere('end')->ne($this->config->productplan->future)
->andWhere('branch')->eq($branch)
->beginIF($branch !== '' and !empty($branchQuery))->andWhere($branchQuery)->fi()
->orderBy('end desc')
->limit(1)
->fetch();
@@ -216,9 +229,22 @@ class productplanModel extends model
*/
public function getTopPlanPairs($productID, $branch = '', $exclude = '')
{
$branchQuery = '';
if($branch !== '')
{
$branchQuery .= '(';
$branchCount = count(explode(',', $branch));
foreach(explode(',', $branch) as $index => $branchID)
{
$branchQuery .= "CONCAT(',', branch, ',') LIKE '%,$branchID,%'";
if($index < $branchCount - 1) $branchQuery .= ' AND ';
}
$branchQuery .= ')';
}
$planPairs = $this->dao->select("id,title")->from(TABLE_PRODUCTPLAN)
->where('product')->eq($productID)
->beginIF($branch !== '')->andWhere('branch')->eq($branch)->fi()
->beginIF($branch !== '' and !empty($branchQuery))->andWhere($branchQuery)->fi()
->andWhere('parent')->le(0)
->andWhere('deleted')->eq(0)
->beginIF($exclude)->andWhere('status')->notin($exclude)
@@ -450,6 +476,8 @@ class productplanModel extends model
->setIF($this->post->future || empty($_POST['end']), 'end', $this->config->productplan->future)
->setDefault('createdBy', $this->app->user->account)
->setDefault('createdDate', helper::now())
->setDefault('branch', 0)
->join('branch', ',')
->remove('delta,uid,future')
->get();
@@ -466,6 +494,12 @@ class productplanModel extends model
}
}
$product = $this->loadModel('product')->getByID($plan->product);
if($product->type != 'normal' and empty($plan->branch))
{
$this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
dao::$errors['branch'] = sprintf($this->lang->error->notempty, $this->lang->product->branch);
}
if(!$this->post->future and strpos($this->config->productplan->create->requiredFields, 'begin') !== false and empty($_POST['begin']))
{
dao::$errors['begin'] = sprintf($this->lang->error->notempty, $this->lang->productplan->begin);
@@ -477,8 +511,7 @@ class productplanModel extends model
if(dao::isError()) return false;
$plan = $this->loadModel('file')->processImgURL($plan, $this->config->productplan->editor->create['id'], $this->post->uid);
$this->dao->insert(TABLE_PRODUCTPLAN)
->data($plan)
$this->dao->insert(TABLE_PRODUCTPLAN)->data($plan)
->autoCheck()
->batchCheck($this->config->productplan->create->requiredFields, 'notempty')
->checkIF(!$this->post->future && !empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin)
@@ -161,7 +161,9 @@
<td><?php echo zget($statusList, $plan->status)?></td>
<?php endif;?>
<?php if($this->session->currentProductType != 'normal'):?>
<td class='c-branch' title='<?php echo $branchOption[$plan->branch];?>'><?php if($plan->parent != '-1') echo $branchOption[$plan->branch];?></td>
<?php $planBranches = '';?>
<?php foreach(explode(',', $plan->branch) as $branchID) $planBranches .= $branchOption[$branchID] . ',';?>
<td class='c-branch' title='<?php echo trim($planBranches, ',');?>'><?php if($plan->parent != '-1') echo trim($planBranches, ',');?></td>
<?php endif;?>
<td><?php echo $plan->begin == $config->productplan->future ? $lang->productplan->future : $plan->begin;?></td>
<td><?php echo $plan->end == $config->productplan->future ? $lang->productplan->future : $plan->end;?></td>
+2 -2
View File
@@ -38,7 +38,7 @@
<?php if($product->type != 'normal'):?>
<tr>
<th><?php echo $lang->product->branch;?></th>
<td><?php echo html::select('branch', $branches, $branch, "class='form-control chosen'");?></td><td></td><td></td>
<td><?php echo html::select('branch[]', $branches, '', "class='form-control chosen' multiple required");?></td><td></td><td></td>
</tr>
<?php endif;?>
<?php endif;?>
@@ -50,7 +50,7 @@
<?php if(!$parent):?>
<tr>
<th><?php echo $lang->productplan->parent;?></th>
<td><?php echo html::select('parent', array('0' => '') + $parentPlanPairs, '', "class='form-control chosen'");?>
<td><?php echo html::select('parent', array(0 => '') + $parentPlanPairs, 0, "class='form-control chosen'");?>
</tr>
<?php endif;?>
<tr>
+1 -1
View File
@@ -33,7 +33,7 @@
<?php if($product->type != 'normal' and $plan->parent != '-1'):?>
<tr>
<th><?php echo $lang->product->branch;?></th>
<td><?php echo html::select('branch', $branchTagOption, $plan->branch, "onchange='getConflictStories($plan->id, this.value); 'class='form-control'");?></td><td></td><td></td>
<td><?php echo html::select('branch[]', $branchTagOption, $plan->branch, "onchange='getConflictStories($plan->id, this.value); 'class='form-control chosen' multiple");?></td><td></td><td></td>
</tr>
<?php endif;?>
<?php endif;?>