Merge branch 'sprint/199_mayue_task56550,56553' into 'master'

* Finish task #56550,56553.

See merge request easycorp/zentaopms!3840
This commit is contained in:
孙广明
2022-06-10 01:02:07 +00:00
3 changed files with 120 additions and 8 deletions
+23 -4
View File
@@ -647,8 +647,8 @@ EOF;
$cases = array();
if($type == 'assigntome') $cases = $this->testcase->getByAssignedTo($this->app->user->account, $sort, $pager, 'skip');
if($type == 'openedbyme') $cases = $this->testcase->getByOpenedBy($this->app->user->account, $sort, $pager, 'skip');
if($type == 'bysearch' and $this->app->rawMethod == 'contribute') $cases = $this->my->getTestcasesBySearch($queryID, 'openedbyme', $orderBy, $pager);
if($type == 'bysearch' and $this->app->rawMethod == 'work') $cases = $this->my->getTestcasesBySearch($queryID, 'assigntome', $orderBy, $pager);
if($type == 'bysearch' and $this->app->rawMethod == 'contribute') $cases = $this->my->getTestcasesBySearch($queryID, 'contribute', $orderBy, $pager);
if($type == 'bysearch' and $this->app->rawMethod == 'work') $cases = $this->my->getTestcasesBySearch($queryID, 'work', $orderBy, $pager);
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', $type == 'assigntome' ? false : true);
@@ -836,18 +836,37 @@ EOF;
* @param int $pageID
* @return void
*/
public function risk($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function risk($type = 'assignedTo', $param = 0,$orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
/* Set the pager. */
$this->loadModel('risk');
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
/* Build the search form. */
$currentMethod = $this->app->rawMethod;
$queryID = ($type == 'bysearch') ? (int)$param : 0;
$actionURL = $this->createLink('my', $currentMethod, "mode=risk&type=bysearch&param=myQueryID");
$this->my->buildRiskSearchForm($queryID, $actionURL, $currentMethod);
/* Get risks by type*/
if($type == 'assignedBy')
{
$risks = $this->my->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'risk');
}
else
{
if($type != 'bysearch') $risks = $this->risk->getUserRisks($type, $this->app->user->account, $orderBy, $pager);
}
if($type == 'bysearch' and $currentMethod == 'contribute') $risks = $this->my->getRisksBySearch($queryID, $currentMethod, $orderBy, $pager);
if($type == 'bysearch' and $currentMethod == 'work') $risks = $this->my->getRisksBySearch($queryID, $currentMethod, $orderBy, $pager);
$this->app->session->set('riskList', $this->app->getURI(true), 'project');
$this->view->title = $this->lang->my->risk;
$this->view->position[] = $this->lang->my->risk;
$this->view->risks = $type == 'assignedBy' ? $this->loadModel('my')->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'risk') : $this->loadModel('risk')->getUserRisks($type, $this->app->user->account, $orderBy, $pager);
$this->view->risks = $risks;
$this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter');
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
+96 -3
View File
@@ -376,7 +376,7 @@ class myModel extends model
}
/**
* Build search form.
* Build case search form.
*
* @param int $queryID
* @param string $actionURL
@@ -417,7 +417,7 @@ class myModel extends model
*/
public function getTestcasesBySearch($queryID, $type, $orderBy, $pager)
{
$queryName = $type == 'openedbyme' ? 'contributeTestcaseQuery' : 'workTestcaseQuery';
$queryName = $type == 'contribute' ? 'contributeTestcaseQuery' : 'workTestcaseQuery';
if($queryID)
{
$query = $this->loadModel('search')->getQuery($queryID);
@@ -439,7 +439,7 @@ class myModel extends model
$myTestcaseQuery = $this->session->$queryName;
$myTestcaseQuery = preg_replace('/`(\w+)`/', 't1.`$1`', $myTestcaseQuery);
if($type == 'openedbyme')
if($type == 'contribute')
{
$cases = $this->dao->select('*')->from(TABLE_CASE)->alias('t1')
->where($myTestcaseQuery)
@@ -622,4 +622,97 @@ class myModel extends model
$this->loadModel('search')->setSearchParams($this->config->bug->search);
}
/*
* Build risk search form.
*
* @param int $queryID
* @param string $actionURL
* @param string $type risk|contribute
* @access public
* @return void
*/
public function buildRiskSearchForm($queryID, $actionURL, $type)
{
$projects = $this->loadModel('project')->getPairsByProgram();
$queryName = $type == 'contribute' ? 'contributeRisk' : 'workRisk';
$this->app->loadConfig('risk');
$this->config->risk->search['module'] = $queryName;
$this->config->risk->search['actionURL'] = $actionURL;
$this->config->risk->search['queryID'] = $queryID;
$this->config->risk->search['params']['project']['value'] = array('') + $projects;
if($this->config->systemMode == 'classic') unset($this->config->risk->search['fields']['project']);
unset($this->config->risk->search['fields']['module']);
$this->loadModel('search')->setSearchParams($this->config->risk->search);
}
/**
* Get risks by search.
*
* @param int $queryID
* @param string $type
* @param string $orderBy
* @param int $pager
* @access public
* @return array
*/
public function getRisksBySearch($queryID, $type, $orderBy, $pager)
{
$queryName = $type == 'contribute' ? 'contributeRiskQuery' : 'workRiskQuery';
if($queryID && $queryID != 'myQueryID')
{
$query = $this->loadModel('search')->getQuery($queryID);
if($query)
{
$this->session->set($queryName, $query->sql);
$this->session->set($queryName . 'Form', $query->form);
}
else
{
$this->session->set($queryName, ' 1 = 1');
}
}
else
{
if($this->session->$queryName == false) $this->session->set($queryName, ' 1 = 1');
}
$riskQuery = $this->session->$queryName;
if($type == 'contribute')
{
$riskIDList = array();
$AssignedByMe = $this->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'risk');
foreach($AssignedByMe as $riskID => $risk)
{
$riskIDList[$riskID] = $riskID;
}
$risks = $this->dao->select('*')->from(TABLE_RISK)
->where($riskQuery)
->andWhere('deleted')->eq('0')
->orWhere('createdBy',1)->eq($this->app->user->account)
->orWhere('id')->in($riskIDList)
->orWhere('closedBy')->eq($this->app->user->account)
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
}
elseif($type == 'work')
{
$risks = $this->dao->select('*')->from(TABLE_RISK)
->where($riskQuery)
->andWhere('deleted')->eq('0')
->andWhere('assignedTo')->eq($this->app->user->account)
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
}
return $risks;
}
}
+1 -1
View File
@@ -32,7 +32,7 @@
</div>
</div>
<div id="mainContent">
<div class="cell<?php if($type == 'bysearch') echo ' show';?>" id="queryBox" data-module=<?php echo ($app->rawMethod == 'contribute' ? 'contributeTestcase' : 'workTestcase');?>></div>
<div class="cell<?php if($type == 'bysearch') echo ' show';?>" id="queryBox" data-module=<?php echo ($app->rawMethod == 'contribute' ? 'contributeTestcase' : 'workTestcase');?>></div>
<?php if(empty($cases)):?>
<div class="table-empty-tip">
<p><span class="text-muted"><?php echo $lang->testcase->noCase;?></span></p>