diff --git a/module/testtask/control.php b/module/testtask/control.php index 0b37974c7e..a0ec595cb4 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -36,7 +36,6 @@ class testtask extends control public function __construct($moduleName = '', $methodName = '') { parent::__construct($moduleName, $methodName); - $this->loadModel('product'); /* Get product data. */ @@ -91,17 +90,11 @@ class testtask extends control $this->session->set('reportList', $uri, 'qa'); $this->session->set('buildList', $uri, 'execution'); - $scopeAndStatus = explode(',', $type); - $this->session->set('testTaskVersionScope', $scopeAndStatus[0]); - $this->session->set('testTaskVersionStatus', $scopeAndStatus[1]); - - $beginTime = $beginTime ? date('Y-m-d', strtotime($beginTime)) : ''; - $endTime = $endTime ? date('Y-m-d', strtotime($endTime)) : ''; - /* Set menu. */ - $productID = $this->product->saveState($productID, $this->products); + $products = $this->testtaskZen->getProducts(); + $productID = $this->loadModel('product')->saveState($productID, $products); $branch = ($this->cookie->preBranch !== '' and $branch === '') ? $this->cookie->preBranch : $branch; - $this->loadModel('qa')->setMenu($this->products, $productID, $branch, $type); + $this->loadModel('qa')->setMenu($products, $productID, $branch, $type); $this->session->set('branch', $branch, 'qa'); /* Load pager. */ @@ -112,17 +105,19 @@ class testtask extends control $sort = common::appendOrder($orderBy); /* Get tasks. */ - $product = $this->product->getById($productID); + $beginTime = $beginTime ? date('Y-m-d', strtotime($beginTime)) : ''; + $endTime = $endTime ? date('Y-m-d', strtotime($endTime)) : ''; + $product = $this->product->getById($productID); if($product->type == 'normal') $branch = 'all'; - $tasks = $this->testtask->getProductTasks($productID, $branch, $sort, $pager, $scopeAndStatus, $beginTime, $endTime); + $tasks = $this->testtask->getProductTasks($productID, $branch, $sort, $pager, $type, $beginTime, $endTime); + /* 获取不同状态测试单的数量,用于列表底部统计信息展示。 */ $waitCount = 0; $testingCount = 0; $blockedCount = 0; $doneCount = 0; foreach($tasks as $key => $task) { - $productTasks[$task->product][] = $task; if($task->status == 'wait') $waitCount ++; if($task->status == 'doing') $testingCount ++; if($task->status == 'blocked') $blockedCount ++; @@ -130,18 +125,17 @@ class testtask extends control if($task->build == 'trunk' || empty($task->buildName)) $task->buildName = $this->lang->trunk; } - $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->common; + $this->view->title = $products[$productID] . $this->lang->colon . $this->lang->testtask->common; $this->view->productID = $productID; - $this->view->productName = $this->products[$productID]; - $this->view->orderBy = $orderBy; + $this->view->product = $product; + $this->view->branch = $branch; $this->view->tasks = $tasks; $this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter'); $this->view->pager = $pager; - $this->view->branch = $branch; $this->view->beginTime = $beginTime; $this->view->endTime = $endTime; - $this->view->product = $product; $this->view->type = $type; + $this->view->orderBy = $orderBy; $this->view->waitCount = $waitCount; $this->view->testingCount = $testingCount; $this->view->blockedCount = $blockedCount; @@ -1617,7 +1611,7 @@ class testtask extends control public function ajaxGetDropMenu($productID, $branch, $taskID, $module, $method, $objectType = '', $objectID = 0) { $scope = empty($objectType) ? 'local' : 'all'; - $testtasks = $this->testtask->getProductTasks($productID, $branch, 'id_desc', null, array($scope, 'totalStatus')); + $testtasks = $this->testtask->getProductTasks($productID, $branch, 'id_desc', null, "$scope,totalStatus"); $namePairs = array(); foreach($testtasks as $testtaskID => $testtask) $namePairs[$testtaskID] = $testtask->name; diff --git a/module/testtask/model.php b/module/testtask/model.php index 7ac4a4f609..ea827e2505 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -60,20 +60,22 @@ class testtaskModel extends model /** * Get test tasks of a product. * - * @param int $productID - * @param int|string $branch - * @param string $orderBy - * @param object $pager - * @param array $scopeAndStatus - * @param int $beginTime - * @param int $endTime + * @param int $productID + * @param string $branch + * @param string $orderBy + * @param object $pager + * @param string $type + * @param string $beginTime + * @param string $endTime * @access public * @return array */ - public function getProductTasks($productID, $branch = 'all', $orderBy = 'id_desc', $pager = null, $scopeAndStatus = array(), $beginTime = 0, $endTime = 0) + public function getProductTasks(int $productID, string $branch = 'all', string $orderBy = 'id_desc', object $pager = null, string $type = '', string $beginTime = '', string $endTime = ''): array { - $products = $scopeAndStatus[0] == 'all' ? $this->app->user->view->products : array(); - $branch = $scopeAndStatus[0] == 'all' ? 'all' : $branch; + $scopeAndStatus = explode(',', $type); + $scope = !empty($scopeAndStatus[0]) ? $scopeAndStatus[0] : ''; + $status = !empty($scopeAndStatus[1]) ? $scopeAndStatus[1] : ''; + $branch = $scope == 'all' ? 'all' : $branch; $tasks = $this->dao->select("t1.*, t5.multiple, IF(t2.shadow = 1, t5.name, t2.name) AS productName, t3.name as executionName, t4.name AS buildName, t4.branch AS branch, t5.name AS projectName") ->from(TABLE_TESTTASK)->alias('t1') @@ -81,40 +83,40 @@ class testtaskModel extends model ->leftJoin(TABLE_EXECUTION)->alias('t3')->on('t1.execution = t3.id') ->leftJoin(TABLE_BUILD)->alias('t4')->on('t1.build = t4.id') ->leftJoin(TABLE_PROJECT)->alias('t5')->on('t3.project = t5.id') - ->where('t1.deleted')->eq(0) ->andWhere('t1.auto')->ne('unit') ->beginIF(!$this->app->user->admin)->andWhere('t3.id')->in("0,{$this->app->user->view->sprints}")->fi() - ->beginIF($scopeAndStatus[0] == 'local')->andWhere('t1.product')->eq((int)$productID)->fi() - ->beginIF($scopeAndStatus[0] == 'all')->andWhere('t1.product')->in($products)->fi() - ->beginIF(strtolower($scopeAndStatus[1]) == 'totalstatus')->andWhere('t1.status')->in('blocked,doing,wait,done')->fi() - ->beginIF(!in_array(strtolower($scopeAndStatus[1]), array('totalstatus', 'review'), true))->andWhere('t1.status')->eq($scopeAndStatus[1])->fi() + ->beginIF($scope == 'local')->andWhere('t1.product')->eq((int)$productID)->fi() + ->beginIF($scope == 'all')->andWhere('t1.product')->in($this->app->user->view->products)->fi() + ->beginIF(strtolower($status) == 'totalstatus')->andWhere('t1.status')->in('blocked,doing,wait,done')->fi() + ->beginIF(strtolower($status) == 'review') // 工作流开启审批的时候才会使用,才会新增字段。 + ->andWhere("FIND_IN_SET('{$this->app->user->account}', t1.reviewers)") + ->andWhere('t1.reviewStatus')->eq('doing') + ->fi() + ->beginIF(!in_array(strtolower($status), array('totalstatus', 'review'), true))->andWhere('t1.status')->eq($status)->fi() ->beginIF($branch !== 'all')->andWhere("CONCAT(',', t4.branch, ',')")->like("%,$branch,%")->fi() ->beginIF($beginTime)->andWhere('t1.begin')->ge($beginTime)->fi() ->beginIF($endTime)->andWhere('t1.end')->le($endTime)->fi() ->beginIF($branch == BRANCH_MAIN) ->orWhere('(t1.build')->eq('trunk') - ->andWhere('t1.product')->eq((int)$productID) + ->andWhere('t1.product')->eq($productID) ->markRight(1) ->fi() - ->beginIF($scopeAndStatus[1] == 'review') - ->andWhere("FIND_IN_SET('{$this->app->user->account}', t1.reviewers)") - ->andWhere('t1.reviewStatus')->eq('doing') - ->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); + foreach($tasks as $taskID => $task) { if($task->multiple) { if($task->projectName and $task->executionName) { - $tasks[$taskID]->executionName = $task->projectName . '/' . $task->executionName; + $task->executionName = $task->projectName . '/' . $task->executionName; } elseif(!$task->executionName) { - $tasks[$taskID]->executionName = $task->projectName; + $task->executionName = $task->projectName; } } } diff --git a/module/testtask/tao.php b/module/testtask/tao.php new file mode 100644 index 0000000000..5dd1f01970 --- /dev/null +++ b/module/testtask/tao.php @@ -0,0 +1,5 @@ +gen(100); +zdTable('project')->gen(100); +zdTable('project')->config('execution')->gen(300, false); +zdTable('build')->gen(500); +zdTable('testtask')->gen(500); + /** title=测试 testtaskModel->getProductTasks(); +timeout=0 cid=1 -pid=1 -查看产品1下的测试单的数量 >> 2 -查看系统中所有测试单的数量 >> 11 -查看系统中所有截止日期大于2023-01-01的测试单的数量 >> 0 -查看ID为11的测试单的详细信息 >> 新增测试报告,system,2022-03-05,2022-09-05 -查看ID为3的测试单的详细信息 >> 测试单3,,2022-04-08,2022-04-15 +- 查询产品ID为1的所有状态的测试单的数量 @5 + +- 查询产品ID为51的所有状态的测试单的数量 @0 + +- 查询产品ID为1的等待状态的测试单的数量 @5 + +- 查询产品ID为1的完成状态的测试单的数量 @0 + +- 查询产品ID为1的阻塞状态的测试单的数量 @0 + +- 查询有权限产品的所有状态的测试单的数量 @150 + +- 查询有权限产品的等待状态的测试单的数量 @45 + +- 查询有权限产品的完成状态的测试单的数量 @30 + +- 查询有权限产品的阻塞状态的测试单的数量 @30 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @5 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @5 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @5 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @5 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @5 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @5 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @5 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @5 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的所有状态且某时间段的测试单的数量 @0 + +- 查询产品ID为1的测试单对应的产品名称第1条的productName属性 @正常产品1 + +- 查询产品ID为2的测试单对应的产品名称第2条的productName属性 @项目12 + +- 查询产品ID为1的测试单对应的产品名称第1条的executionName属性 @迭代1 + +- 查询产品ID为1的测试单对应的产品名称第2条的executionName属性 @项目12/迭代2 */ global $tester; $tester->loadModel('testtask'); -$localScope = array('local', 'totalstatus'); -$allScope = array('all', 'totalstatus'); +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus'))) && p() && e('5'); // 查询产品ID为1的所有状态的测试单的数量 +r(count($tester->testtask->getProductTasks(51, 'all', 'id_desc', null, 'local,totalstatus'))) && p() && e('0'); // 查询产品ID为51的所有状态的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,wait'))) && p() && e('5'); // 查询产品ID为1的等待状态的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,done'))) && p() && e('0'); // 查询产品ID为1的完成状态的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,blocked'))) && p() && e('0'); // 查询产品ID为1的阻塞状态的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'all,totalstatus'))) && p() && e('150'); // 查询有权限产品的所有状态的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'all,wait'))) && p() && e('45'); // 查询有权限产品的等待状态的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'all,done'))) && p() && e('30'); // 查询有权限产品的完成状态的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'all,blocked'))) && p() && e('30'); // 查询有权限产品的阻塞状态的测试单的数量 -$tasks1 = $tester->testtask->getProductTasks(1, 'all', 'id_desc', null, $localScope); -$tasks2 = $tester->testtask->getProductTasks(2, 'all', 'id_asc', null, $allScope); -$tasks3 = $tester->testtask->getProductTasks(2, 'all', 'id_asc', null, $allScope, '2023-01-01'); +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d')))) && p() && e('5'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('-1 day'))))) && p() && e('5'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('+1 day'))))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 + +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', '', date('Y-m-d')))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', '', date('Y-m-d', strtotime('+6 day'))))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', '', date('Y-m-d', strtotime('+7 day'))))) && p() && e('5'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', '', date('Y-m-d', strtotime('+8 day'))))) && p() && e('5'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 + +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d'), date('Y-m-d')))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d'), date('Y-m-d', strtotime('+6 day'))))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d'), date('Y-m-d', strtotime('+7 day'))))) && p() && e('5'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d'), date('Y-m-d', strtotime('+8 day'))))) && p() && e('5'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 + +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('-1 day')), date('Y-m-d')))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('+6 day'))))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('+7 day'))))) && p() && e('5'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('+8 day'))))) && p() && e('5'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 + +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('+1 day')), date('Y-m-d')))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('+1 day')), date('Y-m-d', strtotime('+6 day'))))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('+1 day')), date('Y-m-d', strtotime('+7 day'))))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 +r(count($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus', date('Y-m-d', strtotime('+1 day')), date('Y-m-d', strtotime('+8 day'))))) && p() && e('0'); // 查询产品ID为1的所有状态且某时间段的测试单的数量 + +r($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus')) && p('1:productName') && e('正常产品1'); // 查询产品ID为1、测试单ID为1的测试单对应的执行名称 +r($tester->testtask->getProductTasks(2, 'all', 'id_desc', null, 'local,totalstatus')) && p('2:productName') && e('项目12'); // 查询产品ID为2、测试单ID为2的测试单对应的执行名称 +r($tester->testtask->getProductTasks(1, 'all', 'id_desc', null, 'local,totalstatus')) && p('1:executionName') && e('迭代1'); // 查询产品ID为1、测试单ID为1的测试单对应的执行名称 +r($tester->testtask->getProductTasks(2, 'all', 'id_desc', null, 'local,totalstatus')) && p('2:executionName') && e('项目12/迭代2'); // 查询产品ID为1、测试单ID为2的测试单对应的执行名称 -r(count($tasks1)) && p() && e('2'); // 查看产品1下的测试单的数量 -r(count($tasks2)) && p() && e('11'); // 查看系统中所有测试单的数量 -r(count($tasks3)) && p() && e('0'); // 查看系统中所有截止日期大于2023-01-01的测试单的数量 -r($tasks1) && p('11:name,type,begin,end') && e('新增测试报告,system,2022-03-05,2022-09-05'); // 查看ID为11的测试单的详细信息 -r($tasks2) && p('3:name,type,begin,end') && e('测试单3,,2022-04-08,2022-04-15'); // 查看ID为3的测试单的详细信息 \ No newline at end of file diff --git a/module/testtask/test/yaml/execution.yaml b/module/testtask/test/yaml/execution.yaml new file mode 100644 index 0000000000..c01c1e03cb --- /dev/null +++ b/module/testtask/test/yaml/execution.yaml @@ -0,0 +1,75 @@ +title: table zt_execution +author: Zhu Jinyong +version: "1.0" +fields: + - field: id + range: 101-700 + - field: name + note: "名称" + fields: + - field: name1 + range: 迭代{30},阶段{30},看板{30} + - field: name2 + range: 1-10000 + - field: project + range: 11-100 + - field: model + range: [] + - field: type + range: sprint{30},stage{30},kanban{30} + - field: budget + range: 800000-1:100 + - field: status + range: wait,doing + - field: percent + range: 0{30},10{30},0{30} + - field: milestone + range: 0{30},1{10},0{10},1{10},0{30} + - field: auth + range: "extend" + - field: desc + range: 1-10000 + prefix: "迭代描述" + - field: begin + range: "(-2M)-(+M):1D" + type: timestamp + format: "YY/MM/DD" + postfix: "\t" + - field: end + range: "(+1w)-(+2M):1D" + type: timestamp + format: "YY/MM/DD" + postfix: "\t" + - field: grade + range: 1 + - field: parent + range: 11-40,41-70,71-100 + - field: path + fields: + - field: path1 + prefix: "," + range: 11-100 + - field: path2 + prefix: "," + range: 101-700 + postfix: "," + - field: acl + range: open{4},private{4} + - field: openedVersion + range: "16.5" + - field: whitelist + froms: + - from: common.user.v1.yaml + use: empty{8} + - from: common.user.v1.yaml + use: empty{8} + prefix: "," + - from: common.user.v1.yaml + use: one{8} + prefix: "," + - from: common.user.v1.yaml + use: two{8} + prefix: "," + - from: common.user.v1.yaml + use: three{8} + prefix: "," diff --git a/module/testtask/ui/browse.html.php b/module/testtask/ui/browse.html.php index 9ed8a88fbd..ba540bdafa 100644 --- a/module/testtask/ui/browse.html.php +++ b/module/testtask/ui/browse.html.php @@ -9,9 +9,10 @@ declare(strict_types=1); * @link https://www.zentao.net */ namespace zin; -$scope = $this->session->testTaskVersionScope; -$status = $this->session->testTaskVersionStatus ? $this->session->testTaskVersionStatus : ''; -$viewName = $scope == 'local'? $productName : $lang->testtask->all; +$scopeAndStatus = explode(',', $type); +$scope = !empty($scopeAndStatus[0]) ? $scopeAndStatus[0] : ''; +$status = !empty($scopeAndStatus[1]) ? $scopeAndStatus[1] : ''; +$viewName = $scope == 'local'? \zget($products, $productID) : $lang->testtask->all; jsVar('condition', "productID=$productID&branch=$branch&type=$scope,$status&orderBy=$orderBy&recTotal=0&recPerPage={$pager->recPerPage}&pageID=1"); $productDropdown = productMenu @@ -20,7 +21,7 @@ $productDropdown = productMenu set::items(array ( array('text' => $lang->testtask->all, 'url' => helper::createLink('testtask', 'browse', "productID=$productID&branch=0&type=all,$status")), - array('text' => $productName, 'url' => helper::createLink('testtask', 'browse', "productID=$productID&branch=$branch&type=local,$status")) + array('text' => \zget($products, $productID), 'url' => helper::createLink('testtask', 'browse', "productID=$productID&branch=$branch&type=local,$status")) )), set::link(createLink('qa', 'index')), ); diff --git a/module/testtask/zen.php b/module/testtask/zen.php new file mode 100644 index 0000000000..ef647fead7 --- /dev/null +++ b/module/testtask/zen.php @@ -0,0 +1,47 @@ +loadModel('product'); + $products = array(); + $objectID = 0; + $tab = ($this->app->tab == 'project' or $this->app->tab == 'execution') ? $this->app->tab : 'qa'; + if(!isonlybody()) + { + if($tab == 'project') + { + /* 如果是在项目应用下打开的测试单,则获取当前项目对应的产品。 */ + $objectID = $this->session->project; + $products = $this->product->getProducts($objectID, 'all', '', false); + } + elseif($tab == 'execution') + { + /* 如果是在执行应用下打开的测试单,则获取当前执行对应的产品。 */ + $objectID = $this->session->execution; + $products = $this->product->getProducts($objectID, 'all', '', false); + } + else + { + /* 如果是在测试应用下打开的测试单,则获取所有产品。 */ + $products = $this->product->getPairs('', 0, '', 'all'); + } + if(empty($products) and !helper::isAjaxRequest()) helper::end($this->locate($this->createLink('product', 'showErrorNone', "moduleName=$tab&activeMenu=testtask&objectID=$objectID"))); + } + else + { + /* 如果是在弹窗下打开的测试单,则获取所有产品。 */ + $products = $this->product->getPairs('', 0, '', 'all'); + } + + return $products; + } +} diff --git a/test/data/product.yaml b/test/data/product.yaml index b882d31011..5a9efe4ef0 100644 --- a/test/data/product.yaml +++ b/test/data/product.yaml @@ -24,6 +24,9 @@ fields: range: code - field: code2 range: 1-300 + - field: shadow + note: "影子产品" + range: 0-1 - field: line note: "产品线" range: 0-10 diff --git a/test/data/project.yaml b/test/data/project.yaml index a859f6abfe..9b5a88d446 100644 --- a/test/data/project.yaml +++ b/test/data/project.yaml @@ -86,5 +86,7 @@ fields: type: timestamp format: "YY/MM/DD" postfix: "\t" + - field: multiple + range: 0-1 - field: deleted range: 0