diff --git a/App.jsx b/App.jsx index 05b8a7d..4a2d60c 100644 --- a/App.jsx +++ b/App.jsx @@ -281,6 +281,7 @@ const blankProduct = () => ({ function isUpsCategory(cat) { return !!cat && (cat.id === 'ups' || cat.name === 'UPS不间断电源'); } +function spaceToAsterisk(v) { return (v || '').replace(/ /g, '*'); } function computeMaxPowerKW(ratedPower, ratedPowerUnit, powerFactor) { const rp = parseFloat(ratedPower); const pf = parseFloat(powerFactor); @@ -3055,7 +3056,15 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage } 产品大类 * onManage('category')}>大类管理 - set({ category: e.target.value, brand: '', type: '', machineVariant: '' })}> + { + const newCatId = e.target.value; + const newCat = (categories || []).find(c => c.id === newCatId); + const defaultBrand = (newCat && newCat.brands && newCat.brands.length) ? newCat.brands[0] : ''; + set({ category: newCatId, brand: defaultBrand, type: '', machineVariant: '' }); + }} + > 请选择 {(categories || []).map(c => {c.name})} @@ -3164,7 +3173,7 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage } 电池数量和容量 - set({ batterySpec: e.target.value })} placeholder="如:5000mAh*4" /> + set({ batterySpec: spaceToAsterisk(e.target.value) })} placeholder="如:5000mAh*4" /> @@ -3190,7 +3199,7 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage } )} - 尺寸(mm) set({ dimensions: e.target.value })} placeholder="如:210*130*40" /> + 尺寸(mm) set({ dimensions: spaceToAsterisk(e.target.value) })} placeholder="如:210*130*40" /> 净重(kg) set({ netWeight: e.target.value })} placeholder="如:0.73" /> >