From 5c81a133eadb9ff5cc7917d8f930263ec38ffc15 Mon Sep 17 00:00:00 2001 From: Default User Date: Fri, 9 Jan 2026 15:54:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=99=90=E5=88=B6=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E5=AF=B9=E6=9C=80=E5=A4=9A=E5=8F=AA=E8=83=BD?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=B8=89=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supply.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/supply.html b/supply.html index 28006ab..5446fcb 100644 --- a/supply.html +++ b/supply.html @@ -2939,6 +2939,14 @@ // 添加规格和件数对 function addSpecQuantityPair() { const container = document.getElementById('specQuantityPairs'); + const pairs = container.querySelectorAll('.spec-quantity-pair'); + + // 限制最多只能创建三个规格对 + if (pairs.length >= 3) { + alert('最多只能创建三个规格对'); + return; + } + const existingSpecs = []; container.querySelectorAll('.spec-value').forEach(input => { if (input.value) existingSpecs.push(input.value); @@ -2953,6 +2961,16 @@ `; container.appendChild(pair); + + // 检查是否已达到最大数量,如果是则禁用添加按钮 + const newPairCount = container.querySelectorAll('.spec-quantity-pair').length; + if (newPairCount >= 3) { + const addButton = document.querySelector('.add-spec-quantity-btn'); + if (addButton) { + addButton.disabled = true; + addButton.className = 'add-spec-quantity-btn btn-disabled'; + } + } } // 删除规格和件数对 @@ -2973,6 +2991,16 @@ if (quantityInput) quantityInput.value = ''; if (costpriceInput) costpriceInput.value = ''; } + + // 检查当前数量,如果少于三个则启用添加按钮 + const newPairCount = container.querySelectorAll('.spec-quantity-pair').length; + if (newPairCount < 3) { + const addButton = document.querySelector('.add-spec-quantity-btn'); + if (addButton) { + addButton.disabled = false; + addButton.className = 'add-spec-quantity-btn'; + } + } } // 为规格和件数对显示规格选择弹窗