Update App.jsx via upload script - 2026-10-27 14:59:18
This commit is contained in:
parent
0ba71ceaaf
commit
47bbfd9f62
47
App.jsx
47
App.jsx
|
|
@ -2366,6 +2366,7 @@ function MainApp({ username, onLogout }) {
|
||||||
const [aiImportHintCategory, setAiImportHintCategory] = useState('');
|
const [aiImportHintCategory, setAiImportHintCategory] = useState('');
|
||||||
const [aiImportHintBrand, setAiImportHintBrand] = useState('');
|
const [aiImportHintBrand, setAiImportHintBrand] = useState('');
|
||||||
const [aiImportHintType, setAiImportHintType] = useState('');
|
const [aiImportHintType, setAiImportHintType] = useState('');
|
||||||
|
const [aiImportHintExtraTypes, setAiImportHintExtraTypes] = useState([]); // 这批产品同时属于的其他细分品类(多选)
|
||||||
const [aiImportTruncatedWarning, setAiImportTruncatedWarning] = useState(false);
|
const [aiImportTruncatedWarning, setAiImportTruncatedWarning] = useState(false);
|
||||||
|
|
||||||
const [exportOpen, setExportOpen] = useState(false);
|
const [exportOpen, setExportOpen] = useState(false);
|
||||||
|
|
@ -3089,7 +3090,7 @@ function MainApp({ username, onLogout }) {
|
||||||
|
|
||||||
function openAiImport() {
|
function openAiImport() {
|
||||||
setAiImportOpen(true); setAiImportDrafts(null); setAiImportError('');
|
setAiImportOpen(true); setAiImportDrafts(null); setAiImportError('');
|
||||||
setAiImportHintCategory(''); setAiImportHintBrand(''); setAiImportHintType('');
|
setAiImportHintCategory(''); setAiImportHintBrand(''); setAiImportHintType(''); setAiImportHintExtraTypes([]);
|
||||||
setAiImportTruncatedWarning(false);
|
setAiImportTruncatedWarning(false);
|
||||||
}
|
}
|
||||||
function closeAiImport() { setAiImportOpen(false); setAiImportDrafts(null); setAiImportError(''); setAiImportBusy(false); }
|
function closeAiImport() { setAiImportOpen(false); setAiImportDrafts(null); setAiImportError(''); setAiImportBusy(false); }
|
||||||
|
|
@ -3111,6 +3112,7 @@ function MainApp({ username, onLogout }) {
|
||||||
_localId: 'aidraft_' + i + '_' + Math.random().toString(36).slice(2, 6),
|
_localId: 'aidraft_' + i + '_' + Math.random().toString(36).slice(2, 6),
|
||||||
include: true,
|
include: true,
|
||||||
name: p.name || '', brand: p.brand || '', category: p.category || '', type: p.type || '',
|
name: p.name || '', brand: p.brand || '', category: p.category || '', type: p.type || '',
|
||||||
|
extraTypes: aiImportHintExtraTypes.filter(t => t && t !== (p.type || '')),
|
||||||
machineVariant: p.machineVariant || '', powerOrCapacity: p.powerOrCapacity || '', voltage: p.voltage || '',
|
machineVariant: p.machineVariant || '', powerOrCapacity: p.powerOrCapacity || '', voltage: p.voltage || '',
|
||||||
ratedPower: p.ratedPower || '', ratedPowerUnit: p.ratedPowerUnit || 'VA', powerFactor: p.powerFactor || '',
|
ratedPower: p.ratedPower || '', ratedPowerUnit: p.ratedPowerUnit || 'VA', powerFactor: p.powerFactor || '',
|
||||||
outputPortCount: p.outputPortCount || '',
|
outputPortCount: p.outputPortCount || '',
|
||||||
|
|
@ -3191,6 +3193,7 @@ function MainApp({ username, onLogout }) {
|
||||||
if (cat) {
|
if (cat) {
|
||||||
if (d.brand && !cat.brands.includes(d.brand)) cat.brands.push(d.brand);
|
if (d.brand && !cat.brands.includes(d.brand)) cat.brands.push(d.brand);
|
||||||
if (d.type && !cat.types.includes(d.type)) cat.types.push(d.type);
|
if (d.type && !cat.types.includes(d.type)) cat.types.push(d.type);
|
||||||
|
for (const t of d.extraTypes || []) if (t && !cat.types.includes(t)) cat.types.push(t);
|
||||||
}
|
}
|
||||||
return { ...d, categoryId: cat ? cat.id : '' };
|
return { ...d, categoryId: cat ? cat.id : '' };
|
||||||
});
|
});
|
||||||
|
|
@ -3201,6 +3204,7 @@ function MainApp({ username, onLogout }) {
|
||||||
...blankProduct(),
|
...blankProduct(),
|
||||||
id: 'p_' + Date.now() + '_' + idx + '_' + Math.random().toString(36).slice(2, 7),
|
id: 'p_' + Date.now() + '_' + idx + '_' + Math.random().toString(36).slice(2, 7),
|
||||||
name: d.name.trim(), brand: d.brand || '', category: d.categoryId || '', type: d.type || '',
|
name: d.name.trim(), brand: d.brand || '', category: d.categoryId || '', type: d.type || '',
|
||||||
|
extraTypes: (d.extraTypes || []).filter(t => t && t !== d.type),
|
||||||
machineVariant: d.machineVariant || '', powerOrCapacity: d.powerOrCapacity || '', voltage: d.voltage || '',
|
machineVariant: d.machineVariant || '', powerOrCapacity: d.powerOrCapacity || '', voltage: d.voltage || '',
|
||||||
ratedPower: d.ratedPower || '', ratedPowerUnit: d.ratedPowerUnit || 'VA', powerFactor: d.powerFactor || '',
|
ratedPower: d.ratedPower || '', ratedPowerUnit: d.ratedPowerUnit || 'VA', powerFactor: d.powerFactor || '',
|
||||||
outputPortCount: d.outputPortCount || '', outputPortTypes: d.outputPortTypes || [], outputPorts: d.outputPorts || [],
|
outputPortCount: d.outputPortCount || '', outputPortTypes: d.outputPortTypes || [], outputPorts: d.outputPorts || [],
|
||||||
|
|
@ -4578,6 +4582,27 @@ function MainApp({ username, onLogout }) {
|
||||||
{(productCategories.find(c => c.name === aiImportHintCategory.trim())?.types || []).map(t => <option key={t} value={t} />)}
|
{(productCategories.find(c => c.name === aiImportHintCategory.trim())?.types || []).map(t => <option key={t} value={t} />)}
|
||||||
</datalist>
|
</datalist>
|
||||||
</div>
|
</div>
|
||||||
|
{(() => {
|
||||||
|
const opts = (productCategories.find(c => c.name === aiImportHintCategory.trim())?.types || []).filter(t => t !== aiImportHintType.trim());
|
||||||
|
if (!aiImportHintType.trim() || !opts.length) return null;
|
||||||
|
return (
|
||||||
|
<div className="field">
|
||||||
|
<span className="field-label">同时属于(可选,可多选)</span>
|
||||||
|
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6 }}>
|
||||||
|
{opts.map(t => {
|
||||||
|
const on = aiImportHintExtraTypes.includes(t);
|
||||||
|
return (
|
||||||
|
<button key={t} type="button" className={`btn btn-sm${on ? ' btn-primary' : ''}`} disabled={aiImportBusy}
|
||||||
|
onClick={() => setAiImportHintExtraTypes(on ? aiImportHintExtraTypes.filter(x => x !== t) : [...aiImportHintExtraTypes, t])}>
|
||||||
|
{on ? '✓ ' : ''}{t}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: 12, color: 'var(--ink-soft)', marginTop: 4 }}>这批产品导入后会同时出现在勾选的品类栏目里,预览里还可以逐个调整。</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
<label className="tax-add-category" style={{ display: 'block', cursor: aiImportBusy ? 'default' : 'pointer' }}>
|
<label className="tax-add-category" style={{ display: 'block', cursor: aiImportBusy ? 'default' : 'pointer' }}>
|
||||||
<input
|
<input
|
||||||
type="file" accept="application/pdf,image/*,.html,.htm,text/html" multiple style={{ display: 'none' }}
|
type="file" accept="application/pdf,image/*,.html,.htm,text/html" multiple style={{ display: 'none' }}
|
||||||
|
|
@ -4628,6 +4653,26 @@ function MainApp({ username, onLogout }) {
|
||||||
</div>
|
</div>
|
||||||
<button className="btn btn-sm btn-ghost btn-danger" onClick={() => removeAiImportDraft(d._localId)}><Trash2 size={12} /></button>
|
<button className="btn btn-sm btn-ghost btn-danger" onClick={() => removeAiImportDraft(d._localId)}><Trash2 size={12} /></button>
|
||||||
</div>
|
</div>
|
||||||
|
{(() => {
|
||||||
|
const opts = (productCategories.find(c => c.name === (d.category || '').trim())?.types || []).filter(t => t !== d.type);
|
||||||
|
const extra = d.extraTypes || [];
|
||||||
|
const all = [...new Set([...opts, ...extra.filter(t => t !== d.type)])];
|
||||||
|
if (!all.length) return null;
|
||||||
|
return (
|
||||||
|
<div style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 5, paddingLeft: 26 }}>
|
||||||
|
<span style={{ fontSize: 11.5, color: 'var(--ink-soft)', marginRight: 2 }}>同时属于:</span>
|
||||||
|
{all.map(t => {
|
||||||
|
const on = extra.includes(t);
|
||||||
|
return (
|
||||||
|
<button key={t} type="button" className={`btn btn-sm${on ? ' btn-primary' : ' btn-ghost'}`} style={{ padding: '2px 8px', fontSize: 11.5 }}
|
||||||
|
onClick={() => updateAiImportDraft(d._localId, { extraTypes: on ? extra.filter(x => x !== t) : [...extra, t] })}>
|
||||||
|
{on ? '✓ ' : ''}{t}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
{needsCapacity && (
|
{needsCapacity && (
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, paddingLeft: 26 }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8, paddingLeft: 26 }}>
|
||||||
<span style={{ fontSize: 11.5, color: 'var(--led-red)', fontWeight: 600, flexShrink: 0 }}>⚠️ 没识别到容量,请手动填一下:</span>
|
<span style={{ fontSize: 11.5, color: 'var(--led-red)', fontWeight: 600, flexShrink: 0 }}>⚠️ 没识别到容量,请手动填一下:</span>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue