diff --git a/Review b/Review index aa49899..785502c 160000 --- a/Review +++ b/Review @@ -1 +1 @@ -Subproject commit aa49899ed3d632727d2b51c0affca59643d2ee19 +Subproject commit 785502c7a13bf341be514c9a73cbd7df2d5c5d40 diff --git a/supply.html b/supply.html index bf33266..1863e4f 100644 --- a/supply.html +++ b/supply.html @@ -1301,13 +1301,13 @@
- +
- +
@@ -1706,13 +1706,13 @@
- +
- +
@@ -2417,6 +2417,7 @@ let allSpecOptions = ['净重47+', '净重46-47', '净重45-46', '净重44-45', '净重43-44', '净重42-43', '净重41-42', '净重40-41', '净重39-40', '净重38-39', '净重37-39', '净重37-38', '净重36-38', '净重36-37', '净重35-36', '净重34-35', '净重33-34', '净重32-33', '净重32-34', '净重31-32', '净重30-35', '净重30-34', '净重30-32', '净重30-31', '净重29-31', '净重29-30', '净重28-29', '净重28以下', '毛重52以上', '毛重50-51', '毛重48-49', '毛重47-48', '毛重46-47', '毛重45-47', '毛重45-46', '毛重44-45', '毛重43-44', '毛重42-43', '毛重41-42', '毛重40-41', '毛重38-39', '毛重36-37', '毛重34-35', '毛重32-33', '毛重30-31', '毛重30以下']; let filteredSpecOptions = [...allSpecOptions]; let selectedSpec = []; + let excludedSpecOptions = []; // 产品包装选择功能 let allProductingOptions = ['1*360枚新包装', '1*360枚旧包新拖', '1*360枚旧包旧拖', '1*420枚新包装', '1*480枚新包装', '30枚蛋托散装', '360枚散托']; @@ -2448,12 +2449,12 @@ let selectedContactId = ''; // 显示规格选择弹窗 - function showSpecSelectModal() { + function showSpecSelectModal(excludeSpecs = []) { const specSelectModal = document.getElementById('specSelectModal'); specSelectModal.classList.add('active'); - // 重置搜索输入 document.getElementById('specSearchInput').value = ''; - filteredSpecOptions = [...allSpecOptions]; + excludedSpecOptions = excludeSpecs; + filteredSpecOptions = allSpecOptions.filter(spec => !excludeSpecs.includes(spec)); generateSpecOptions(); } @@ -2522,7 +2523,7 @@ const searchKeyword = searchInput.value.toLowerCase(); filteredSpecOptions = allSpecOptions.filter(spec => { - return spec.toLowerCase().includes(searchKeyword); + return spec.toLowerCase().includes(searchKeyword) && !excludedSpecOptions.includes(spec); }); generateSpecOptions(); @@ -2591,11 +2592,16 @@ // 添加规格和件数对 function addSpecQuantityPair() { const container = document.getElementById('specQuantityPairs'); + const existingSpecs = []; + container.querySelectorAll('.spec-value').forEach(input => { + if (input.value) existingSpecs.push(input.value); + }); + const pair = document.createElement('div'); pair.className = 'spec-quantity-pair'; pair.innerHTML = ` - - + + `; container.appendChild(pair); @@ -2620,10 +2626,15 @@ } // 为规格和件数对显示规格选择弹窗 - function showSpecSelectModalForPair(input) { - // 保存当前点击的输入框 + function showSpecSelectModalForPair(input, mode) { currentSpecInput = input; - showSpecSelectModal(); + currentSpecMode = mode || 'pair'; + const container = document.getElementById('specQuantityPairs'); + const existingSpecs = []; + container.querySelectorAll('.spec-value').forEach(inp => { + if (inp.value && inp !== input) existingSpecs.push(inp.value); + }); + showSpecSelectModal(existingSpecs); } // 保存当前点击的规格输入框 @@ -4275,60 +4286,108 @@ // 重置表单 resetForm(); - // 填充表单字段 - document.getElementById('price').value = supply.price || ''; - document.getElementById('quantity').value = supply.quantity || ''; - document.getElementById('grossWeight').value = supply.grossWeight || ''; - document.getElementById('description').value = supply.description || ''; + // 填充表单字段 - 为所有元素添加null检查 + const priceInput = document.getElementById('price'); + if (priceInput) priceInput.value = supply.price || ''; + + const quantityInput = document.getElementById('quantity'); + if (quantityInput) quantityInput.value = supply.quantity || ''; + + const grossWeightInput = document.getElementById('grossWeight'); + if (grossWeightInput) grossWeightInput.value = supply.grossWeight || ''; + + const descriptionInput = document.getElementById('description'); + if (descriptionInput) descriptionInput.value = supply.description || ''; // 填充选择字段 // 商品名称 - document.getElementById('productName').value = supply.productName || ''; - document.getElementById('productNameDisplayText').textContent = supply.productName || '请选择商品名称'; + const productNameInput = document.getElementById('productName'); + if (productNameInput) productNameInput.value = supply.productName || ''; + + const productNameDisplay = document.getElementById('productNameDisplayText'); + if (productNameDisplay) productNameDisplay.textContent = supply.productName || '请选择商品名称'; selectedProductName = supply.productName || ''; // 货源类型 - document.getElementById('sourceType').value = supply.sourceType || ''; - document.getElementById('sourceTypeDisplayText').textContent = supply.sourceType || '请选择货源类型'; + const sourceTypeInput = document.getElementById('sourceType'); + if (sourceTypeInput) sourceTypeInput.value = supply.sourceType || ''; + + const sourceTypeDisplay = document.getElementById('sourceTypeDisplayText'); + if (sourceTypeDisplay) sourceTypeDisplay.textContent = supply.sourceType || '请选择货源类型'; selectedSourceType = supply.sourceType || ''; // 蛋黄类型 - document.getElementById('yolk').value = supply.yolk || ''; - document.getElementById('yolkDisplayText').textContent = supply.yolk || '请选择蛋黄类型'; + const yolkInput = document.getElementById('yolk'); + if (yolkInput) yolkInput.value = supply.yolk || ''; + + const yolkDisplay = document.getElementById('yolkDisplayText'); + if (yolkDisplay) yolkDisplay.textContent = supply.yolk || '请选择蛋黄类型'; selectedYolk = supply.yolk || ''; // 地区 - document.getElementById('regionValue').value = supply.region || ''; - document.getElementById('regionDisplayText').textContent = supply.region || '请选择地区'; - - // 规格 - document.getElementById('specValue').value = supply.specification || supply.spec || ''; - document.getElementById('specDisplayText').textContent = (supply.specification || supply.spec) || '请选择规格'; - selectedSpec = supply.specification || supply.spec || ''; + const regionValueInput = document.getElementById('regionValue'); + if (regionValueInput) regionValueInput.value = supply.region || ''; + + const regionDisplay = document.getElementById('regionDisplayText'); + if (regionDisplay) regionDisplay.textContent = supply.region || '请选择地区'; + + // 规格 - 确保selectedSpec是数组类型 + const specValue = supply.specification || supply.spec || ''; + const specDisplay = document.getElementById('specDisplayText'); + if (specDisplay) specDisplay.textContent = specValue || '请选择规格'; + + const specValueInput = document.getElementById('specValue'); + if (specValueInput) { + if (Array.isArray(specValue)) { + selectedSpec = specValue; + specValueInput.value = JSON.stringify(specValue); + } else if (specValue) { + selectedSpec = [specValue]; + specValueInput.value = JSON.stringify([specValue]); + } else { + selectedSpec = []; + specValueInput.value = JSON.stringify([]); + } + } // 货源状态 - document.getElementById('supplyStatus').value = supply.supplyStatus || ''; + const supplyStatusInput = document.getElementById('supplyStatus'); + if (supplyStatusInput) supplyStatusInput.value = supply.supplyStatus || ''; + + // 设置货源状态按钮 + if (supply.supplyStatus === '预售') { + setSupplyStatus('预售'); + } else if (supply.supplyStatus === '现货') { + setSupplyStatus('现货'); + } - // 联系人 - 使用contacts数组查找完整信息 - document.getElementById('contactId').value = supply.contactId || ''; + const contactIdInput = document.getElementById('contactId'); + if (contactIdInput) contactIdInput.value = supply.contactId || ''; selectedContactId = supply.contactId || ''; - if (supply.contactId) { - // 从contacts数组(可能包含本地缓存数据)中查找联系人 - const contact = contacts.find(c => String(c.id) === String(supply.contactId)); - if (contact) { - document.getElementById('contactIdDisplayText').textContent = `${contact.name} (${contact.phoneNumber})`; + + const contactIdDisplay = document.getElementById('contactIdDisplayText'); + if (contactIdDisplay) { + if (supply.contactId) { + // 从contacts数组(可能包含本地缓存数据)中查找联系人 + const contact = contacts.find(c => String(c.id) === String(supply.contactId)); + if (contact) { + contactIdDisplay.textContent = `${contact.name} (${contact.phoneNumber})`; + } else { + // 如果找不到联系人,使用supply中的数据或默认值 + contactIdDisplay.textContent = supply.product_contact || `联系人ID: ${supply.contactId}` || '请选择联系人'; + } } else { - // 如果找不到联系人,使用supply中的数据或默认值 - document.getElementById('contactIdDisplayText').textContent = supply.product_contact || `联系人ID: ${supply.contactId}` || '请选择联系人'; + contactIdDisplay.textContent = '请选择联系人'; } - } else { - document.getElementById('contactIdDisplayText').textContent = '请选择联系人'; } // 产品包装 - document.getElementById('productingValue').value = supply.producting || ''; - document.getElementById('productingDisplayText').textContent = supply.producting || '请选择产品包装'; + const productingValueInput = document.getElementById('productingValue'); + if (productingValueInput) productingValueInput.value = supply.producting || ''; + + const productingDisplay = document.getElementById('productingDisplayText'); + if (productingDisplay) productingDisplay.textContent = supply.producting || '请选择产品包装'; selectedProducting = supply.producting || ''; // 不复制图片,保持图片列表为空 @@ -4423,18 +4482,31 @@ // 设置货源状态(预售/现货) function setSupplyStatus(status) { - document.getElementById('supplyStatus').value = status; + const supplyStatusInput = document.getElementById('supplyStatus'); + if (supplyStatusInput) supplyStatusInput.value = status; + // 更新按钮样式 + const preSaleBtn = document.getElementById('preSaleBtn'); + const inStockBtn = document.getElementById('inStockBtn'); + if (status === '预售') { - document.getElementById('preSaleBtn').style.borderColor = '#1677ff'; - document.getElementById('preSaleBtn').style.color = '#1677ff'; - document.getElementById('inStockBtn').style.borderColor = '#d9d9d9'; - document.getElementById('inStockBtn').style.color = '#666'; + if (preSaleBtn) { + preSaleBtn.style.borderColor = '#1677ff'; + preSaleBtn.style.color = '#1677ff'; + } + if (inStockBtn) { + inStockBtn.style.borderColor = '#d9d9d9'; + inStockBtn.style.color = '#666'; + } } else if (status === '现货') { - document.getElementById('inStockBtn').style.borderColor = '#1677ff'; - document.getElementById('inStockBtn').style.color = '#1677ff'; - document.getElementById('preSaleBtn').style.borderColor = '#d9d9d9'; - document.getElementById('preSaleBtn').style.color = '#666'; + if (inStockBtn) { + inStockBtn.style.borderColor = '#1677ff'; + inStockBtn.style.color = '#1677ff'; + } + if (preSaleBtn) { + preSaleBtn.style.borderColor = '#d9d9d9'; + preSaleBtn.style.color = '#666'; + } } // 自动保存表单数据 saveFormData(); @@ -5884,8 +5956,8 @@ const pair = document.createElement('div'); pair.className = 'spec-quantity-pair'; pair.innerHTML = ` - - + + `; specQuantityPairs.appendChild(pair); @@ -5989,14 +6061,15 @@ // 编辑规格选择功能 let editFilteredSpecOptions = [...allSpecOptions]; + let editExcludedSpecOptions = []; // 显示编辑规格选择弹窗 - function showEditSpecSelectModal() { + function showEditSpecSelectModal(excludeSpecs = []) { const specSelectModal = document.getElementById('editSpecSelectModal'); specSelectModal.classList.add('active'); - // 重置搜索输入 document.getElementById('editSpecSearchInput').value = ''; - editFilteredSpecOptions = [...allSpecOptions]; + editExcludedSpecOptions = excludeSpecs; + editFilteredSpecOptions = allSpecOptions.filter(spec => !excludeSpecs.includes(spec)); generateEditSpecOptions(); } @@ -6065,7 +6138,7 @@ const searchKeyword = searchInput.value.toLowerCase(); editFilteredSpecOptions = allSpecOptions.filter(spec => { - return spec.toLowerCase().includes(searchKeyword); + return spec.toLowerCase().includes(searchKeyword) && !editExcludedSpecOptions.includes(spec); }); generateEditSpecOptions(); @@ -6139,11 +6212,16 @@ // 添加编辑规格和件数对 function addEditSpecQuantityPair() { const container = document.getElementById('editSpecQuantityPairs'); + const existingSpecs = []; + container.querySelectorAll('.spec-value').forEach(input => { + if (input.value) existingSpecs.push(input.value); + }); + const pair = document.createElement('div'); pair.className = 'spec-quantity-pair'; pair.innerHTML = ` - - + + `; container.appendChild(pair); @@ -6168,10 +6246,14 @@ } // 为编辑规格和件数对显示规格选择弹窗 - function showEditSpecSelectModalForPair(input) { - // 保存当前点击的输入框 + function showEditSpecSelectModalForPair(input, mode) { currentEditSpecInput = input; - showEditSpecSelectModal(); + const container = document.getElementById('editSpecQuantityPairs'); + const existingSpecs = []; + container.querySelectorAll('.spec-value').forEach(inp => { + if (inp.value && inp !== input) existingSpecs.push(inp.value); + }); + showEditSpecSelectModal(existingSpecs); } // 保存当前点击的编辑规格输入框