From e037349cecd2e779bd106b23f0d9beb8399c8fb5 Mon Sep 17 00:00:00 2001 From: chaideqing Date: Wed, 10 Jan 2024 13:47:38 +0800 Subject: [PATCH] * Finish task #110593. --- module/product/control.php | 8 ++++---- module/product/js/create.js | 2 -- module/product/js/edit.js | 6 ------ module/product/model.php | 10 +++------- module/product/view/create.html.php | 2 +- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index 04b3fc7098..ec2ba1fc83 100755 --- a/module/product/control.php +++ b/module/product/control.php @@ -454,7 +454,7 @@ class product extends control if(!empty($this->config->user->moreLink)) $this->config->moreLinks["RD"] = $this->config->user->moreLink; $lines = array(); - if($programID and in_array($this->config->systemMode, array('ALM', 'PLM'))) $lines = array('') + $this->product->getLinePairs($programID); + if(in_array($this->config->systemMode, array('ALM', 'PLM'))) $lines = array('') + $this->product->getLinePairs($programID, true); if($this->app->tab == 'doc') unset($this->lang->doc->menu->product['subMenu']); @@ -541,7 +541,7 @@ class product extends control if(!empty($this->config->user->moreLink)) $this->config->moreLinks["RD"] = $this->config->user->moreLink; $lines = array(); - if($product->program and in_array($this->config->systemMode, array('ALM', 'PLM'))) $lines = array('') + $this->product->getLinePairs($product->program); + if(in_array($this->config->systemMode, array('ALM', 'PLM'))) $lines = array('') + $this->product->getLinePairs($product->program, true); /* Get programs. */ $programs = $this->loadModel('program')->getTopPairs('', 'noclosed'); @@ -1123,7 +1123,7 @@ class product extends control public function ajaxGetLine($programID, $productID = 0) { $lines = array(); - if(empty($productID) or $programID) $lines = $this->product->getLinePairs($programID); + if(empty($productID) or $programID) $lines = $this->product->getLinePairs($programID, true); if($productID) return print(html::select("lines[$productID]", array('' => '') + $lines, '', "class='form-control picker-select'")); if(!$productID) return print(html::select('line', array('' => '') + $lines, '', "class='form-control picker-select'")); @@ -1430,7 +1430,7 @@ class product extends control $this->view->title = $this->lang->product->line; $this->view->position[] = $this->lang->product->line; - $this->view->programs = array('null' => $this->lang->null) + $this->loadModel('program')->getTopPairs('', 'withDeleted', true); + $this->view->programs = array(0 => $this->lang->null) + $this->loadModel('program')->getTopPairs('', 'withDeleted', true); $this->view->lines = $this->product->getLines(); $this->display(); } diff --git a/module/product/js/create.js b/module/product/js/create.js index 3234cfe452..57c97c8893 100644 --- a/module/product/js/create.js +++ b/module/product/js/create.js @@ -2,8 +2,6 @@ $(function() { $('#lineName').css('border-left-color', ''); $('[name=newLine]').change(); - - if(programID == 0) $("#line").closest('tr').addClass('hidden'); }) /** * Load product Lines. diff --git a/module/product/js/edit.js b/module/product/js/edit.js index 78c8f46ed5..d6cb0a812a 100644 --- a/module/product/js/edit.js +++ b/module/product/js/edit.js @@ -1,12 +1,6 @@ -$(function() -{ - if(programID == 0) $("#line").closest('tr').addClass('hidden'); -}); - $('#program').change(function() { var programID = $(this).val(); - programID > 0 ? $("#line").closest('tr').removeClass('hidden') : $("#line").closest('tr').addClass('hidden'); $.get(createLink('product', 'ajaxGetLine', 'programID=' + programID), function(data) { diff --git a/module/product/model.php b/module/product/model.php index 5e80606c2c..2dc2c6632a 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -1035,11 +1035,6 @@ class productModel extends model foreach($data->modules as $id => $name) { if(empty($name)) continue; - if(in_array($this->config->systemMode, array('ALM', 'PLM')) and empty($data->programs[$id])) - { - dao::$errors[] = $this->lang->product->programEmpty; - return false; - } $programID = $data->programs[$id]; if(!isset($lines[$programID])) $lines[$programID] = array(); @@ -2091,14 +2086,15 @@ class productModel extends model * Get product line pairs. * * @param int $programID + * @param bool $withZero * @access public * @return array */ - public function getLinePairs($programID = 0) + public function getLinePairs($programID = 0, $withZero = false) { return $this->dao->select('id,name')->from(TABLE_MODULE) ->where('type')->eq('line') - ->beginIF($programID)->andWhere('root')->eq($programID)->fi() + ->beginIF($withZero || $programID)->andWhere('root')->eq($programID)->fi() ->andWhere('deleted')->eq(0) ->fetchPairs(); } diff --git a/module/product/view/create.html.php b/module/product/view/create.html.php index 6c8d666229..a5a108ffac 100644 --- a/module/product/view/create.html.php +++ b/module/product/view/create.html.php @@ -31,7 +31,7 @@ product->line;?> - +
1 ? '' : 'checked';?>