diff --git a/App.jsx b/App.jsx index dcc9a7f..3997d4f 100644 --- a/App.jsx +++ b/App.jsx @@ -259,13 +259,23 @@ const blankCustomer = () => ({ attachments: [], }); +const OUTPUT_PORT_TYPES = ['USB', 'DC', 'DC1', 'DC2', 'DC3', 'POE', 'Type-C', 'DC interface', 'POE interface']; +const DEFAULT_MINI_UPS_OUTPUT_TYPES = ['USB', 'DC1', 'DC2', 'DC3', 'POE']; + const blankProduct = () => ({ id: 'p_' + Date.now() + '_' + Math.random().toString(36).slice(2, 7), name: '', extraNames: [], brand: '', category: '', type: '', - machineVariant: '', // 标机 / 长机,仅UPS大类适用,独立于细分品类 - powerOrCapacity: '', // 非UPS大类的功率/容量,或UPS大类下"迷你UPS"的最大输出功率 + machineVariant: '', // 标机 / 长机,仅UPS大类适用,独立于细分品类(迷你UPS固定为标机) + powerOrCapacity: '', // 非UPS大类的功率/容量,或UPS大类下"迷你UPS"的输出功率 ratedPower: '', ratedPowerUnit: 'VA', powerFactor: '', // UPS大类下除"迷你UPS"外的三段式功率 - voltage: '', costPrice: '', notes: '', + voltage: '', // 非迷你UPS:电压;迷你UPS:输入电压(默认 100~240Vac/50-60Hz,可修改) + outputPortCount: '', // 迷你UPS专属:输出口数量 1-6 + outputPortTypes: [], // 迷你UPS专属:输出口类型(多选) + outputPorts: [], // 迷你UPS专属:每个已选输出口类型对应的输出电压/电流,如 [{type:'USB', voltage:'5Vdc', current:'3.0A'}] + batterySpec: '', // 迷你UPS专属:电池数量和容量,如 "5000mAh*4" + dimensions: '', // 迷你UPS专属:尺寸(mm),如 "210*130*40" + netWeight: '', // 迷你UPS专属:净重(kg) + costPrice: '', notes: '', }); function isUpsCategory(cat) { @@ -290,7 +300,19 @@ function powerInfoItems(p, categories) { ]; } if (isUpsCategory(cat) && p.type === '迷你UPS') { - return [{ key: 'maxout', label: '最大输出功率', value: p.powerOrCapacity || '—' }]; + const items = [{ key: 'maxout', label: '输出功率', value: p.powerOrCapacity || '—' }]; + items.push({ key: 'inputvoltage', label: '输入电压', value: p.voltage || '—' }); + if (p.outputPortCount) items.push({ key: 'portcount', label: '输出口数量', value: p.outputPortCount }); + if (p.outputPortTypes && p.outputPortTypes.length) items.push({ key: 'porttypes', label: '输出口类型', value: p.outputPortTypes.join(' / ') }); + (p.outputPorts || []).forEach(port => { + if (port.voltage || port.current) { + items.push({ key: 'port_' + port.type, label: `${port.type} 输出`, value: [port.voltage, port.current].filter(Boolean).join(' ') }); + } + }); + if (p.batterySpec) items.push({ key: 'battery', label: '电池数量和容量', value: p.batterySpec }); + if (p.dimensions) items.push({ key: 'dim', label: '尺寸(mm)', value: p.dimensions }); + if (p.netWeight) items.push({ key: 'weight', label: '净重(kg)', value: p.netWeight }); + return items; } return [{ key: 'power', label: '功率 / 容量', value: p.powerOrCapacity || '—' }]; } @@ -2995,6 +3017,23 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage } function addExtraName() { set({ extraNames: [...extraNames, ''] }); } function updateExtraName(idx, val) { const arr = [...extraNames]; arr[idx] = val; set({ extraNames: arr }); } function removeExtraName(idx) { set({ extraNames: extraNames.filter((_, i) => i !== idx) }); } + function toggleOutputPortType(t) { + const list = draft.outputPortTypes || []; + if (list.includes(t)) { + set({ + outputPortTypes: list.filter(x => x !== t), + outputPorts: (draft.outputPorts || []).filter(p => p.type !== t), + }); + } else { + set({ + outputPortTypes: [...list, t], + outputPorts: [...(draft.outputPorts || []), { type: t, voltage: '', current: '' }], + }); + } + } + function updateOutputPort(t, patch) { + set({ outputPorts: (draft.outputPorts || []).map(p => (p.type === t ? { ...p, ...patch } : p)) }); + } return (
{draft.name ? '编辑产品' : '新建产品'}
@@ -3044,7 +3083,24 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage } 细分品类 onManage('type')}>品类管理
- { + const newType = e.target.value; + if (newType === '迷你UPS') { + set({ + type: newType, + machineVariant: '标机', + voltage: draft.voltage || '100~240Vac/50-60Hz', + outputPortCount: draft.outputPortCount || '5', + outputPortTypes: (draft.outputPortTypes && draft.outputPortTypes.length) ? draft.outputPortTypes : [...DEFAULT_MINI_UPS_OUTPUT_TYPES], + outputPorts: (draft.outputPorts && draft.outputPorts.length) ? draft.outputPorts : DEFAULT_MINI_UPS_OUTPUT_TYPES.map(t => ({ type: t, voltage: '', current: '' })), + }); + } else { + set({ type: newType }); + } + }} + > {typeOptions.map(t => )} @@ -3054,11 +3110,15 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage } {isUps && (
机型 - + {isMiniUps ? ( + + ) : ( + + )}
)} @@ -3079,10 +3139,51 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage }
电压 set({ voltage: e.target.value })} placeholder="如:48V / 192V / 220V" />
) : isUps && isMiniUps ? ( -
-
最大输出功率 set({ powerOrCapacity: e.target.value })} placeholder="如:600W" />
-
电压 set({ voltage: e.target.value })} placeholder="如:48V / 192V / 220V" />
-
+ <> +
+
输出功率 set({ powerOrCapacity: e.target.value })} placeholder="如:36W" />
+
输入电压 set({ voltage: e.target.value })} placeholder="如:100~240Vac/50-60Hz" />
+
+
+
+ 输出口数量 + +
+
+ 电池数量和容量 + set({ batterySpec: e.target.value })} placeholder="如:5000mAh*4" /> +
+
+
+ 输出口类型 +
+ {OUTPUT_PORT_TYPES.map(t => ( +
toggleOutputPortType(t)}> + {(draft.outputPortTypes || []).includes(t) && } {t} +
+ ))} +
+
+ {(draft.outputPorts || []).length > 0 && ( +
+ 各输出口的输出电压 / 电流 + {draft.outputPorts.map(p => ( +
+
{p.type}
+ updateOutputPort(p.type, { voltage: e.target.value })} /> + updateOutputPort(p.type, { current: e.target.value })} /> +
+ ))} +
+ )} +
+
尺寸(mm) set({ dimensions: e.target.value })} placeholder="如:210*130*40" />
+
净重(kg) set({ netWeight: e.target.value })} placeholder="如:0.73" />
+
+ ) : (
功率 / 容量 set({ powerOrCapacity: e.target.value })} placeholder="如:10kVA / 100Ah / 5kWh" />