From eebcec34e533069ae2c487727460ee112f3ef274 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Fri, 26 Jul 2024 15:22:17 +0800 Subject: [PATCH] * The plus sign will not be displayed when the dropdown exceeds the number under the product. --- lib/zin/wg/productsbox/js/v1.js | 10 ++++++++++ lib/zin/wg/productsbox/v1.php | 9 ++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/zin/wg/productsbox/js/v1.js b/lib/zin/wg/productsbox/js/v1.js index a01353d3df..ba0642dc11 100644 --- a/lib/zin/wg/productsbox/js/v1.js +++ b/lib/zin/wg/productsbox/js/v1.js @@ -127,6 +127,11 @@ window.addNewLine = function(e) new zui.Picker(`.linkProduct #products${index}`, options); new zui.Picker(`#branch${index}`, {name: `branch[${index}]`, multiple: true, items: []}); new zui.Picker(`#${objectType}s${index}`, {items:[], multiple: true, name: `${objectType}s[${index}]`}); + + if($('[name="charter"]').length && $('[name="charter"]').val()) + { + if(options.items.length == $('.productBox').length) $('.addLine').addClass('hidden'); + } } window.removeLine = function(e) @@ -145,6 +150,11 @@ window.removeLine = function(e) $(obj).closest('.productBox').remove(); if(typeof toggleStageBy == 'function') toggleStageBy(); + + if($('[name="charter"]').length && $('[name="charter"]').val()) + { + $('.addLine').removeClass('hidden'); + } } window.loadPlans = function(product, branch) diff --git a/lib/zin/wg/productsbox/v1.php b/lib/zin/wg/productsbox/v1.php index 37f0f0c289..ebaf1e9283 100644 --- a/lib/zin/wg/productsbox/v1.php +++ b/lib/zin/wg/productsbox/v1.php @@ -28,7 +28,7 @@ class productsBox extends wg 'errorSameProducts?: string', // 选择同一个产品的提示。 'required?: bool=false', // 是否是必填。 'from?: string=project', // 来源类型。 - 'type?: string=plan', // 类型。 plan|roadmap + 'type?: string="plan"', // 类型。 plan|roadmap 'selectTip?: string=""' // 产品下拉提示。 ); @@ -44,7 +44,7 @@ class productsBox extends wg protected function build() { - list($project, $productItems, $linkedProducts, $errorSameProducts) = $this->prop(array('project', 'productItems', 'linkedProducts', 'errorSameProducts')); + list($project, $productItems, $linkedProducts, $errorSameProducts, $type) = $this->prop(array('project', 'productItems', 'linkedProducts', 'errorSameProducts', 'type')); $productsBox = array(); if((!empty($project->hasProduct) || is_null($project)) && $linkedProducts) @@ -74,7 +74,6 @@ class productsBox extends wg { global $lang, $app; list($productItems, $project, $isStage, $hasNewProduct, $type) = $this->prop(array('productItems', 'project', 'isStage', 'hasNewProduct', 'type')); - $type = empty($type) ? 'plan' : $type; $typeLang = $type == 'plan' ? $lang->project->associatePlan : $lang->project->manageRoadmap; $typeClass = $type == 'plan' ? 'planBox' : 'roadmapBox'; @@ -216,7 +215,6 @@ class productsBox extends wg global $lang; list($productItems, $branchGroups, $planGroups, $productPlans, $type, $roadmapGroups) = $this->prop(array('productItems', 'branchGroups', 'planGroups', 'productPlans', 'type', 'roadmapGroups')); list($linkedBranches, $currentProduct, $currentPlan, $project, $isStage) = $this->prop(array('linkedBranches', 'currentProduct', 'currentPlan', 'project', 'isStage')); - $type = empty($type) ? 'plan' : $type; $unmodifiableProducts = data('unmodifiableProducts') ? data('unmodifiableProducts') : array(); @@ -224,6 +222,7 @@ class productsBox extends wg $typeClass = $type == 'plan' ? 'planBox' : 'roadmapBox'; $linkedProductsBox = array(); + $hiddenPlusBtn = $type == 'roadmap' && count($productItems) == count(array_keys($linkedProducts)) ? ' hidden' : ''; foreach(array_values($linkedProducts) as $i => $product) { $hasBranch = $product->type != 'normal' && isset($branchGroups[$product->id]); @@ -381,7 +380,7 @@ class productsBox extends wg btn ( bind::click('addNewLine(event)'), - setClass('btn btn-link text-gray addLine'), + setClass("btn btn-link text-gray addLine $hiddenPlusBtn"), icon('plus') ), btn