diff --git a/App.jsx b/App.jsx index 31a0555..e7e51c9 100644 --- a/App.jsx +++ b/App.jsx @@ -5210,6 +5210,12 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage, const maxKW = computeMaxPowerKW(draft.ratedPower, draft.ratedPowerUnit, draft.powerFactor); const extraNames = draft.extraNames || []; const [imageUploading, setImageUploading] = useState(false); + const [dragExtraSpecIdx, setDragExtraSpecIdx] = useState(null); + function handleExtraSpecDrop(dropIdx) { + if (dragExtraSpecIdx === null || dragExtraSpecIdx === dropIdx) { setDragExtraSpecIdx(null); return; } + set({ extraSpecs: reorderArray(draft.extraSpecs || [], dragExtraSpecIdx, dropIdx) }); + setDragExtraSpecIdx(null); + } async function handleImagePick(file) { if (!file) return; setImageUploading(true); @@ -5263,18 +5269,27 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage, }); } } - function updateOutputPort(t, patch) { - set({ outputPorts: (draft.outputPorts || []).map(p => (p.type === t ? { ...p, ...patch } : p)) }); + // 各输出口那份列表按数组下标操作(不再靠type字段去重定位),这样同一个type(比如多个"DC"口, + // 电压不同)可以并存多行,用户可以自由增加/删除/改类型名,不受"输出口类型"勾选框数量限制。 + function updateOutputPortAt(idx, patch) { + set({ outputPorts: (draft.outputPorts || []).map((p, i) => (i === idx ? { ...p, ...patch } : p)) }); + } + function addOutputPort() { + const lastType = (draft.outputPorts && draft.outputPorts.length) ? draft.outputPorts[draft.outputPorts.length - 1].type : 'DC'; + set({ outputPorts: [...(draft.outputPorts || []), { type: lastType, voltage: '', current: '' }] }); + } + function removeOutputPortAt(idx) { + set({ outputPorts: (draft.outputPorts || []).filter((_, i) => i !== idx) }); } // 失焦时自动补单位:纯数字才补(比如"5"变"5Vdc"、"2.4"变"2.4A"), // 如果用户已经手动填了完整格式(比如POE常见的"24Vdc/48Vdc"),保持原样不动,避免破坏。 - function normalizeOutputVoltageOnBlur(t, rawValue) { + function normalizeOutputVoltageOnBlur(idx, rawValue) { const trimmed = (rawValue || '').trim(); - if (/^\d+(\.\d+)?$/.test(trimmed)) updateOutputPort(t, { voltage: trimmed + 'Vdc' }); + if (/^\d+(\.\d+)?$/.test(trimmed)) updateOutputPortAt(idx, { voltage: trimmed + 'Vdc' }); } - function normalizeOutputCurrentOnBlur(t, rawValue) { + function normalizeOutputCurrentOnBlur(idx, rawValue) { const trimmed = (rawValue || '').trim(); - if (/^\d+(\.\d+)?$/.test(trimmed)) updateOutputPort(t, { current: trimmed + 'A' }); + if (/^\d+(\.\d+)?$/.test(trimmed)) updateOutputPortAt(idx, { current: trimmed + 'A' }); } return (