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';
+ }
+ }
}
// 为规格和件数对显示规格选择弹窗