diff --git a/module/testcase/model.php b/module/testcase/model.php index a2a8eb24a6..60b6cab0ee 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -1303,63 +1303,6 @@ class testcaseModel extends model return $module->id; } - /** - * Build search form. - * - * @param int $productID - * @param array $products - * @param int $queryID - * @param string $actionURL - * @param string $projectID - * @access public - * @return void - */ - public function buildSearchForm($productID, $products, $queryID, $actionURL, $projectID = 0, $moduleID = 0, $branch = 0) - { - $productList = array(); - if($this->app->tab == 'project' and empty($productID)) - { - $productList = $products; - } - else - { - $productList = array('all' => $this->lang->all); - if(isset($products[$productID])) $productList = array($productID => $products[$productID]) + $productList; - } - $this->config->testcase->search['params']['product']['values'] = array('') + $productList; - - $module = $this->loadModel('tree')->getOptionMenu($productID, 'case', 0, $branch); - $scene = $this->getSceneMenu($productID, $moduleID, $viewType = 'case', $startSceneID = 0, $branch, 0, true); - if(!$productID) - { - $module = array(); - foreach($products as $id => $name) $module += $this->loadModel('tree')->getOptionMenu($id, 'case', 0); - } - $this->config->testcase->search['params']['module']['values'] = $module; - $this->config->testcase->search['params']['scene']['values'] = $scene; - - $this->config->testcase->search['params']['lib']['values'] = $this->loadModel('caselib')->getLibraries(); - - if($this->session->currentProductType == 'normal') - { - unset($this->config->testcase->search['fields']['branch']); - unset($this->config->testcase->search['params']['branch']); - } - else - { - $this->app->loadLang('branch'); - $product = $this->loadModel('product')->getByID($productID); - $this->config->testcase->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); - $this->config->testcase->search['params']['branch']['values'] = array('' => '', '0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($productID, '', $projectID) + array('all' => $this->lang->branch->all); - } - if(!$this->config->testcase->needReview) unset($this->config->testcase->search['params']['status']['values']['wait']); - $this->config->testcase->search['actionURL'] = $actionURL; - $this->config->testcase->search['queryID'] = $queryID; - $this->config->testcase->search['module'] = $this->app->rawModule; - - $this->loadModel('search')->setSearchParams($this->config->testcase->search); - } - /** * Print cell data * diff --git a/module/testcase/zen.php b/module/testcase/zen.php index 2e24f5463a..8f426a44e6 100644 --- a/module/testcase/zen.php +++ b/module/testcase/zen.php @@ -136,7 +136,7 @@ class testcaseZen extends testcase $actionURL = $this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID"); $searchProducts = $this->product->getPairs('', 0, '', 'all'); - $this->testcase->buildSearchForm($productID, $searchProducts, $queryID, $actionURL, $projectID); + $this->buildSearchForm($productID, $searchProducts, $queryID, $actionURL, $projectID); } /** @@ -2259,7 +2259,7 @@ class testcaseZen extends testcase if($this->app->tab == 'execution') $objectID = $case->execution; unset($this->config->testcase->search['fields']['product']); - $this->testcase->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID); + $this->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID); } /** @@ -2290,6 +2290,75 @@ class testcaseZen extends testcase $this->bug->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID); } + /** + * Build search form. + * + * @param int $productID + * @param array $products + * @param int $queryID + * @param string $actionURL + * @param string $projectID + * @access public + * @return void + */ + private function buildSearchForm(int $productID, array $products, int $queryID, string $actionURL, int $projectID = 0, int $moduleID = 0, int|string $branch = 0): void + { + /* 获取产品列表。*/ + /* Get productList. */ + if($this->app->tab == 'project' && !$productID) + { + $productList = $products; + } + else + { + $productList = array(); + $productList['all'] = $this->lang->all; + if(isset($products[$productID])) $productList[$productID] = $products[$productID]; + } + + /* 获取模块列表。*/ + /* Get moduleList. */ + if($productID) + { + $modules = $this->loadModel('tree')->getOptionMenu($productID, 'case', 0, $branch); + } + else + { + $modules = array(); + foreach($products as $id => $name) $modules += $this->loadModel('tree')->getOptionMenu($id, 'case', 0); + } + + $this->config->testcase->search['params']['product']['values'] = array('') + $productList; + $this->config->testcase->search['params']['module']['values'] = $modules; + $this->config->testcase->search['params']['scene']['values'] = $this->testcase->getSceneMenu($productID, $moduleID, $viewType = 'case', $startSceneID = 0, $branch, 0, true); + $this->config->testcase->search['params']['lib']['values'] = $this->loadModel('caselib')->getLibraries(); + + if($this->session->currentProductType == 'normal') + { + unset($this->config->testcase->search['fields']['branch']); + unset($this->config->testcase->search['params']['branch']); + } + else + { + $this->app->loadLang('branch'); + $product = $this->loadModel('product')->getByID($productID); + + $branches = $this->loadModel('branch')->getPairs($productID, '', $projectID); + $branches = array('') + array('0' => $this->lang->branch->main) + $branches + array('all' => $this->lang->branch->all); + + $this->config->testcase->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); + $this->config->testcase->search['params']['branch']['values'] = $branches; + } + + if(!$this->config->testcase->needReview) unset($this->config->testcase->search['params']['status']['values']['wait']); + + $this->config->testcase->search['actionURL'] = $actionURL; + $this->config->testcase->search['queryID'] = $queryID; + $this->config->testcase->search['module'] = $this->app->rawModule; + + $this->loadModel('search')->setSearchParams($this->config->testcase->search); + } + /** * 获取导出的字段列表。 * Get the export fields.