Update App.jsx via upload script - 2026-08-07 17:04:16
This commit is contained in:
parent
b1e889dbe2
commit
2d22bd47d5
48
App.jsx
48
App.jsx
|
|
@ -458,6 +458,25 @@ async function resolveExportTranslations(terms, lang) {
|
||||||
|
|
||||||
// 把某个产品需要展示的规格行整理出来(和ProductDetail的powerInfoItems逻辑对齐,但拆分出
|
// 把某个产品需要展示的规格行整理出来(和ProductDetail的powerInfoItems逻辑对齐,但拆分出
|
||||||
// 独立的label/value结构,方便多语言渲染时分别处理"字段名要翻译"和"数值一般不用翻译")
|
// 独立的label/value结构,方便多语言渲染时分别处理"字段名要翻译"和"数值一般不用翻译")
|
||||||
|
// 把AI识别到但没有具名字段的参数(extraSpecs)插入到已经组装好的规格行列表里——如果这一条
|
||||||
|
// 标注了afterLabel(应该跟在哪个已知字段后面显示),就插到那个字段紧后面;找不到匹配的就
|
||||||
|
// 兜底追加到列表最后,不会丢数据,只是位置不够准确。labelProp传'labelKey'(productExportRows
|
||||||
|
// 用)或'label'(powerInfoItems用),因为两边字段名不一样。
|
||||||
|
function insertExtraSpecs(list, extraSpecs, labelProp) {
|
||||||
|
(extraSpecs || []).forEach((item, i) => {
|
||||||
|
if (!item || !item.label || !item.value) return;
|
||||||
|
const entry = labelProp === 'labelKey'
|
||||||
|
? { labelKey: item.label, value: item.value }
|
||||||
|
: { key: 'extra_' + i + '_' + item.label, label: item.label, value: item.value };
|
||||||
|
if (item.afterLabel) {
|
||||||
|
const idx = list.findIndex(r => r[labelProp] === item.afterLabel);
|
||||||
|
if (idx !== -1) { list.splice(idx + 1, 0, entry); return; }
|
||||||
|
}
|
||||||
|
list.push(entry);
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
function productExportRows(p, categories) {
|
function productExportRows(p, categories) {
|
||||||
const cat = (categories || []).find(c => c.id === p.category);
|
const cat = (categories || []).find(c => c.id === p.category);
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
@ -600,9 +619,7 @@ function productExportRows(p, categories) {
|
||||||
if (p.container20ft) rows.push({ labelKey: '20尺柜装箱数量', value: p.container20ft });
|
if (p.container20ft) rows.push({ labelKey: '20尺柜装箱数量', value: p.container20ft });
|
||||||
if (p.container40ft) rows.push({ labelKey: '40尺柜装箱数量', value: p.container40ft });
|
if (p.container40ft) rows.push({ labelKey: '40尺柜装箱数量', value: p.container40ft });
|
||||||
if (p.container40hq) rows.push({ labelKey: '40高柜装箱数量', value: p.container40hq });
|
if (p.container40hq) rows.push({ labelKey: '40高柜装箱数量', value: p.container40hq });
|
||||||
(p.extraSpecs || []).forEach(item => {
|
insertExtraSpecs(rows, p.extraSpecs, 'labelKey');
|
||||||
if (item && item.label && item.value) rows.push({ labelKey: item.label, value: item.value });
|
|
||||||
});
|
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -847,7 +864,7 @@ function powerInfoItems(p, categories) {
|
||||||
if (p.safetyStandard) items.push({ key: 'safetystd', label: '安规/EMC标准', value: p.safetyStandard });
|
if (p.safetyStandard) items.push({ key: 'safetystd', label: '安规/EMC标准', value: p.safetyStandard });
|
||||||
if (p.gridStandard) items.push({ key: 'gridstd', label: '并网标准', value: p.gridStandard });
|
if (p.gridStandard) items.push({ key: 'gridstd', label: '并网标准', value: p.gridStandard });
|
||||||
if (p.otherStandard) items.push({ key: 'otherstd', label: '其他标准', value: p.otherStandard });
|
if (p.otherStandard) items.push({ key: 'otherstd', label: '其他标准', value: p.otherStandard });
|
||||||
(p.extraSpecs || []).forEach((item, i) => { if (item && item.label && item.value) items.push({ key: 'extra_' + i, label: item.label, value: item.value }); });
|
insertExtraSpecs(items, p.extraSpecs, 'label');
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
if (isBatteryCategory(cat) && p.type === 'UPS配套锂电池系统') {
|
if (isBatteryCategory(cat) && p.type === 'UPS配套锂电池系统') {
|
||||||
|
|
@ -874,7 +891,7 @@ function powerInfoItems(p, categories) {
|
||||||
if (p.cabinetWeight) items.push({ key: 'cabinetweight', label: '系统柜重量(kg)', value: p.cabinetWeight });
|
if (p.cabinetWeight) items.push({ key: 'cabinetweight', label: '系统柜重量(kg)', value: p.cabinetWeight });
|
||||||
if (p.altitude) items.push({ key: 'altitude', label: '海拔(m)', value: p.altitude });
|
if (p.altitude) items.push({ key: 'altitude', label: '海拔(m)', value: p.altitude });
|
||||||
if (p.selfDischargeRate) items.push({ key: 'selfdischarge', label: '自放电率', value: p.selfDischargeRate });
|
if (p.selfDischargeRate) items.push({ key: 'selfdischarge', label: '自放电率', value: p.selfDischargeRate });
|
||||||
(p.extraSpecs || []).forEach((item, i) => { if (item && item.label && item.value) items.push({ key: 'extra_' + i, label: item.label, value: item.value }); });
|
insertExtraSpecs(items, p.extraSpecs, 'label');
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
if (isUpsCategory(cat) && (p.type === '离线式UPS' || p.type === '在线互动式UPS')) {
|
if (isUpsCategory(cat) && (p.type === '离线式UPS' || p.type === '在线互动式UPS')) {
|
||||||
|
|
@ -905,7 +922,7 @@ function powerInfoItems(p, categories) {
|
||||||
if (p.container20ft) items.push({ key: 'container20', label: '20尺柜装箱数量', value: p.container20ft });
|
if (p.container20ft) items.push({ key: 'container20', label: '20尺柜装箱数量', value: p.container20ft });
|
||||||
if (p.container40ft) items.push({ key: 'container40', label: '40尺柜装箱数量', value: p.container40ft });
|
if (p.container40ft) items.push({ key: 'container40', label: '40尺柜装箱数量', value: p.container40ft });
|
||||||
if (p.container40hq) items.push({ key: 'container40hq', label: '40高柜装箱数量', value: p.container40hq });
|
if (p.container40hq) items.push({ key: 'container40hq', label: '40高柜装箱数量', value: p.container40hq });
|
||||||
(p.extraSpecs || []).forEach((item, i) => { if (item && item.label && item.value) items.push({ key: 'extra_' + i, label: item.label, value: item.value }); });
|
insertExtraSpecs(items, p.extraSpecs, 'label');
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
if (isUpsCategory(cat) && (p.type === '机架式UPS' || p.type === '在线式高频UPS')) {
|
if (isUpsCategory(cat) && (p.type === '机架式UPS' || p.type === '在线式高频UPS')) {
|
||||||
|
|
@ -945,7 +962,7 @@ function powerInfoItems(p, categories) {
|
||||||
if (p.container20ft) items.push({ key: 'container20', label: '20尺柜装箱数量', value: p.container20ft });
|
if (p.container20ft) items.push({ key: 'container20', label: '20尺柜装箱数量', value: p.container20ft });
|
||||||
if (p.container40ft) items.push({ key: 'container40', label: '40尺柜装箱数量', value: p.container40ft });
|
if (p.container40ft) items.push({ key: 'container40', label: '40尺柜装箱数量', value: p.container40ft });
|
||||||
if (p.container40hq) items.push({ key: 'container40hq', label: '40高柜装箱数量', value: p.container40hq });
|
if (p.container40hq) items.push({ key: 'container40hq', label: '40高柜装箱数量', value: p.container40hq });
|
||||||
(p.extraSpecs || []).forEach((item, i) => { if (item && item.label && item.value) items.push({ key: 'extra_' + i, label: item.label, value: item.value }); });
|
insertExtraSpecs(items, p.extraSpecs, 'label');
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
if (isUpsCategory(cat) && p.type !== '迷你UPS') {
|
if (isUpsCategory(cat) && p.type !== '迷你UPS') {
|
||||||
|
|
@ -955,7 +972,7 @@ function powerInfoItems(p, categories) {
|
||||||
{ key: 'pf', label: '功率因数', value: p.powerFactor || '—' },
|
{ key: 'pf', label: '功率因数', value: p.powerFactor || '—' },
|
||||||
{ key: 'maxkw', label: '最大功率', value: maxKW !== null ? `${maxKW} kW` : '—' },
|
{ key: 'maxkw', label: '最大功率', value: maxKW !== null ? `${maxKW} kW` : '—' },
|
||||||
];
|
];
|
||||||
(p.extraSpecs || []).forEach((item, i) => { if (item && item.label && item.value) rackFallbackItems.push({ key: 'extra_' + i, label: item.label, value: item.value }); });
|
insertExtraSpecs(rackFallbackItems, p.extraSpecs, 'label');
|
||||||
return rackFallbackItems;
|
return rackFallbackItems;
|
||||||
}
|
}
|
||||||
if (isUpsCategory(cat) && p.type === '迷你UPS') {
|
if (isUpsCategory(cat) && p.type === '迷你UPS') {
|
||||||
|
|
@ -975,11 +992,11 @@ function powerInfoItems(p, categories) {
|
||||||
if (p.container20ft) items.push({ key: 'container20', label: '20尺柜装箱数量', value: p.container20ft });
|
if (p.container20ft) items.push({ key: 'container20', label: '20尺柜装箱数量', value: p.container20ft });
|
||||||
if (p.container40ft) items.push({ key: 'container40', label: '40尺柜装箱数量', value: p.container40ft });
|
if (p.container40ft) items.push({ key: 'container40', label: '40尺柜装箱数量', value: p.container40ft });
|
||||||
if (p.container40hq) items.push({ key: 'container40hq', label: '40高柜装箱数量', value: p.container40hq });
|
if (p.container40hq) items.push({ key: 'container40hq', label: '40高柜装箱数量', value: p.container40hq });
|
||||||
(p.extraSpecs || []).forEach((item, i) => { if (item && item.label && item.value) items.push({ key: 'extra_' + i, label: item.label, value: item.value }); });
|
insertExtraSpecs(items, p.extraSpecs, 'label');
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
const fallbackItems = [{ key: 'power', label: '功率 / 容量', value: p.powerOrCapacity || '—' }];
|
const fallbackItems = [{ key: 'power', label: '功率 / 容量', value: p.powerOrCapacity || '—' }];
|
||||||
(p.extraSpecs || []).forEach((item, i) => { if (item && item.label && item.value) fallbackItems.push({ key: 'extra_' + i, label: item.label, value: item.value }); });
|
insertExtraSpecs(fallbackItems, p.extraSpecs, 'label');
|
||||||
return fallbackItems;
|
return fallbackItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5098,6 +5115,15 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage,
|
||||||
set({ extraSpecs: next });
|
set({ extraSpecs: next });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<input
|
||||||
|
className="input" style={{ flex: 1 }} value={item.afterLabel || ''}
|
||||||
|
placeholder="显示在哪个字段后面(可选),如:充电时间"
|
||||||
|
onChange={e => {
|
||||||
|
const next = (draft.extraSpecs || []).slice();
|
||||||
|
next[idx] = { ...next[idx], afterLabel: e.target.value };
|
||||||
|
set({ extraSpecs: next });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-ghost btn-danger"
|
className="btn btn-sm btn-ghost btn-danger"
|
||||||
onClick={() => set({ extraSpecs: (draft.extraSpecs || []).filter((_, i) => i !== idx) })}
|
onClick={() => set({ extraSpecs: (draft.extraSpecs || []).filter((_, i) => i !== idx) })}
|
||||||
|
|
@ -5106,7 +5132,7 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage,
|
||||||
))}
|
))}
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-ghost"
|
className="btn btn-sm btn-ghost"
|
||||||
onClick={() => set({ extraSpecs: [...(draft.extraSpecs || []), { label: '', value: '' }] })}
|
onClick={() => set({ extraSpecs: [...(draft.extraSpecs || []), { label: '', value: '', afterLabel: '' }] })}
|
||||||
><Plus size={12} style={{ verticalAlign: -2, marginRight: 4 }} />添加一条</button>
|
><Plus size={12} style={{ verticalAlign: -2, marginRight: 4 }} />添加一条</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue