Update App.jsx via upload script - 2026-11-17 11:22:52
This commit is contained in:
parent
0e552923de
commit
09e664369c
224
App.jsx
224
App.jsx
|
|
@ -253,8 +253,8 @@ const COUNTRIES = [
|
||||||
|
|
||||||
const COUNTRY_BY_NAME = Object.fromEntries(COUNTRIES.map(c => [c.name, c]));
|
const COUNTRY_BY_NAME = Object.fromEntries(COUNTRIES.map(c => [c.name, c]));
|
||||||
|
|
||||||
const SAVE_KEY_LABEL = { 'crm:customers': '客户', 'crm:products': '产品', 'crm:quotes': '报价单', 'crm:sellerProfiles': '卖方信息', 'crm:certifications': '授权', 'crm:productCategories': '产品分组', 'crm:packingLists': '箱单', 'crm:catalogDocs': '产品目录', 'crm:jmsLines': 'Just My Socks', 'crm:backPanelTemplates': '后板图模板', 'crm:suppliers': '供应商', 'crm:webDetailTemplates': '模板', 'crm:webAssets': '网站图片', 'crm:webNews': '新闻 / 动态', 'crm:webPackSpecs': 'Packing List', 'crm:customsDecls': '报关', 'crm:customsShippers': '境内发货人', 'crm:customsHs': '商品编码库' };
|
const SAVE_KEY_LABEL = { 'crm:customers': '客户', 'crm:products': '产品', 'crm:quotes': '报价单', 'crm:sellerProfiles': '卖方信息', 'crm:certifications': '授权', 'crm:productCategories': '产品分组', 'crm:packingLists': '箱单', 'crm:catalogDocs': '产品目录', 'crm:jmsLines': 'Just My Socks', 'crm:backPanelTemplates': '后板图模板', 'crm:suppliers': '供应商', 'crm:webDetailTemplates': '模板', 'crm:webAssets': '网站图片', 'crm:webNews': '新闻 / 动态', 'crm:webPackSpecs': 'Packing List', 'crm:customsDecls': '报关', 'crm:customsShippers': '境内发货人', 'crm:customsHs': '商品编码库', 'crm:customsHsDefs': '申报要素名称' };
|
||||||
const STORAGE_KEYS = { customers: 'crm:customers', products: 'crm:products', quotes: 'crm:quotes', sellerProfiles: 'crm:sellerProfiles', certifications: 'crm:certifications', productCategories: 'crm:productCategories', packingLists: 'crm:packingLists', catalogDocs: 'crm:catalogDocs', jmsLines: 'crm:jmsLines', backPanelTemplates: 'crm:backPanelTemplates', suppliers: 'crm:suppliers', webDetailTemplates: 'crm:webDetailTemplates', webAssets: 'crm:webAssets', webNews: 'crm:webNews', webPackSpecs: 'crm:webPackSpecs', orders: 'crm:orders', customsDecls: 'crm:customsDecls', customsShippers: 'crm:customsShippers', customsHs: 'crm:customsHs' };
|
const STORAGE_KEYS = { customers: 'crm:customers', products: 'crm:products', quotes: 'crm:quotes', sellerProfiles: 'crm:sellerProfiles', certifications: 'crm:certifications', productCategories: 'crm:productCategories', packingLists: 'crm:packingLists', catalogDocs: 'crm:catalogDocs', jmsLines: 'crm:jmsLines', backPanelTemplates: 'crm:backPanelTemplates', suppliers: 'crm:suppliers', webDetailTemplates: 'crm:webDetailTemplates', webAssets: 'crm:webAssets', webNews: 'crm:webNews', webPackSpecs: 'crm:webPackSpecs', orders: 'crm:orders', customsDecls: 'crm:customsDecls', customsShippers: 'crm:customsShippers', customsHs: 'crm:customsHs', customsHsDefs: 'crm:customsHsDefs' };
|
||||||
|
|
||||||
const blankCustomer = () => ({
|
const blankCustomer = () => ({
|
||||||
id: 'c_' + Date.now() + '_' + Math.random().toString(36).slice(2, 7),
|
id: 'c_' + Date.now() + '_' + Math.random().toString(36).slice(2, 7),
|
||||||
|
|
@ -1706,8 +1706,13 @@ async function loadAll() {
|
||||||
const v = await storageGet(STORAGE_KEYS.customsHs);
|
const v = await storageGet(STORAGE_KEYS.customsHs);
|
||||||
if (v && v.value) customsHs = JSON.parse(v.value) || [];
|
if (v && v.value) customsHs = JSON.parse(v.value) || [];
|
||||||
} catch (e) { if (!e.notFound) failed.push(e.message); }
|
} catch (e) { if (!e.notFound) failed.push(e.message); }
|
||||||
|
let customsHsDefs = CD_DEFAULT_HS_DEFS;
|
||||||
|
try {
|
||||||
|
const v = await storageGet(STORAGE_KEYS.customsHsDefs);
|
||||||
|
if (v && v.value) customsHsDefs = JSON.parse(v.value) || CD_DEFAULT_HS_DEFS;
|
||||||
|
} catch (e) { if (!e.notFound) failed.push(e.message); }
|
||||||
if (failed.length) { const err = new Error(failed[0]); err.loadFailed = true; throw err; }
|
if (failed.length) { const err = new Error(failed[0]); err.loadFailed = true; throw err; }
|
||||||
return { orders, customsDecls, customsShippers, customsHs, customers, products, quotes, sellerProfiles, certifications, productCategories, packingLists, catalogDocs, jmsLines, backPanelTemplates, suppliers, webDetailTemplates, tplPendingIds: tplPending.map(x => x.id), webAssets, webNews, webPackSpecs };
|
return { orders, customsDecls, customsShippers, customsHs, customsHsDefs, customers, products, quotes, sellerProfiles, certifications, productCategories, packingLists, catalogDocs, jmsLines, backPanelTemplates, suppliers, webDetailTemplates, tplPendingIds: tplPending.map(x => x.id), webAssets, webNews, webPackSpecs };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------- styles -------------------------------- */
|
/* -------------------------------- styles -------------------------------- */
|
||||||
|
|
@ -2246,7 +2251,24 @@ const Styles = () => (
|
||||||
.cd-note { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; }
|
.cd-note { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; }
|
||||||
.cd-lib-row { display: grid; gap: 8px; align-items: start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
|
.cd-lib-row { display: grid; gap: 8px; align-items: start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
|
||||||
.cd-ship-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto auto; align-items: center; }
|
.cd-ship-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto auto; align-items: center; }
|
||||||
.cd-hs-row { grid-template-columns: 130px minmax(0, 1fr) minmax(0, 2.2fr) auto; }
|
.cd-hs-row { grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr) auto; }
|
||||||
|
.cd-link { border: 0; background: none; color: #2563eb; cursor: pointer; font-size: 12px; margin-left: 10px; padding: 0; font-weight: 500; }
|
||||||
|
.cd-elems { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--panel); }
|
||||||
|
.cd-elem { display: grid; grid-template-columns: minmax(150px, 46%) 1fr; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--line); }
|
||||||
|
.cd-elem:nth-child(odd) { border-right: 1px solid var(--line); }
|
||||||
|
.cd-elem .input { height: 32px; }
|
||||||
|
.cd-elem.empty .cd-elem-n { color: #b54708; }
|
||||||
|
.cd-elem-n { font-size: 12.5px; display: flex; gap: 6px; align-items: baseline; line-height: 1.35; }
|
||||||
|
.cd-elem-n i { font-style: normal; font-size: 11px; font-weight: 700; color: var(--ink-soft); min-width: 14px; }
|
||||||
|
.cd-names { border: 1px dashed var(--line); border-radius: 9px; padding: 10px 12px; background: var(--panel); }
|
||||||
|
.cd-code { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; background: var(--bg); }
|
||||||
|
.cd-code-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); }
|
||||||
|
.cd-code-h b { font-size: 15px; color: var(--ink); }
|
||||||
|
.cd-def { display: grid; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
|
||||||
|
.cd-def-r { display: grid; grid-template-columns: minmax(180px, 34%) 1fr; gap: 10px; align-items: center; min-height: 30px; }
|
||||||
|
.cd-def-r .input { height: 30px; font-size: 12.5px; }
|
||||||
|
@media (max-width: 860px) { .cd-elems { grid-template-columns: 1fr; } .cd-elem:nth-child(odd) { border-right: 0; } }
|
||||||
|
|
||||||
@media (max-width: 860px) { .cd-ship-row, .cd-hs-row { grid-template-columns: 1fr; } }
|
@media (max-width: 860px) { .cd-ship-row, .cd-hs-row { grid-template-columns: 1fr; } }
|
||||||
.cd-search { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--panel); color: var(--ink-soft); height: 34px; min-width: 300px; }
|
.cd-search { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--panel); color: var(--ink-soft); height: 34px; min-width: 300px; }
|
||||||
.cd-search input { border: 0; outline: 0; background: transparent; flex: 1; font-size: 13px; color: var(--ink); }
|
.cd-search input { border: 0; outline: 0; background: transparent; flex: 1; font-size: 13px; color: var(--ink); }
|
||||||
|
|
@ -2896,6 +2918,7 @@ function MainApp({ username, onLogout }) {
|
||||||
const [customsDecls, setCustomsDecls] = useState([]);
|
const [customsDecls, setCustomsDecls] = useState([]);
|
||||||
const [customsShippers, setCustomsShippers] = useState(CD_DEFAULT_SHIPPERS);
|
const [customsShippers, setCustomsShippers] = useState(CD_DEFAULT_SHIPPERS);
|
||||||
const [customsHs, setCustomsHs] = useState([]);
|
const [customsHs, setCustomsHs] = useState([]);
|
||||||
|
const [customsHsDefs, setCustomsHsDefs] = useState(CD_DEFAULT_HS_DEFS);
|
||||||
const [selectedOrderId, setSelectedOrderId] = useState(null);
|
const [selectedOrderId, setSelectedOrderId] = useState(null);
|
||||||
const [packingSubView, setPackingSubView] = useState('list'); // 'list' | 'editor'
|
const [packingSubView, setPackingSubView] = useState('list'); // 'list' | 'editor'
|
||||||
const [packingDraft, setPackingDraft] = useState(null);
|
const [packingDraft, setPackingDraft] = useState(null);
|
||||||
|
|
@ -2969,6 +2992,7 @@ function MainApp({ username, onLogout }) {
|
||||||
setCustomsDecls(Array.isArray(data.customsDecls) ? data.customsDecls : []);
|
setCustomsDecls(Array.isArray(data.customsDecls) ? data.customsDecls : []);
|
||||||
setCustomsShippers(Array.isArray(data.customsShippers) ? data.customsShippers : CD_DEFAULT_SHIPPERS);
|
setCustomsShippers(Array.isArray(data.customsShippers) ? data.customsShippers : CD_DEFAULT_SHIPPERS);
|
||||||
setCustomsHs(Array.isArray(data.customsHs) ? data.customsHs : []);
|
setCustomsHs(Array.isArray(data.customsHs) ? data.customsHs : []);
|
||||||
|
setCustomsHsDefs(Array.isArray(data.customsHsDefs) ? data.customsHsDefs : CD_DEFAULT_HS_DEFS);
|
||||||
setCatalogDocs((data.catalogDocs || []).filter(d => d.fileName));
|
setCatalogDocs((data.catalogDocs || []).filter(d => d.fileName));
|
||||||
setJmsLines(data.jmsLines || []);
|
setJmsLines(data.jmsLines || []);
|
||||||
setBackPanelTemplates(data.backPanelTemplates || []);
|
setBackPanelTemplates(data.backPanelTemplates || []);
|
||||||
|
|
@ -3020,6 +3044,7 @@ function MainApp({ username, onLogout }) {
|
||||||
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.webNews, JSON.stringify(webNews)).then(() => clearSaveIssue(STORAGE_KEYS.webNews)).catch(reportSaveError); }, [webNews, loaded]);
|
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.webNews, JSON.stringify(webNews)).then(() => clearSaveIssue(STORAGE_KEYS.webNews)).catch(reportSaveError); }, [webNews, loaded]);
|
||||||
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.orders, JSON.stringify(orders)).then(() => clearSaveIssue(STORAGE_KEYS.orders)).catch(reportSaveError); }, [orders, loaded]);
|
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.orders, JSON.stringify(orders)).then(() => clearSaveIssue(STORAGE_KEYS.orders)).catch(reportSaveError); }, [orders, loaded]);
|
||||||
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.customsShippers, JSON.stringify(customsShippers)).then(() => clearSaveIssue(STORAGE_KEYS.customsShippers)).catch(reportSaveError); }, [customsShippers, loaded]);
|
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.customsShippers, JSON.stringify(customsShippers)).then(() => clearSaveIssue(STORAGE_KEYS.customsShippers)).catch(reportSaveError); }, [customsShippers, loaded]);
|
||||||
|
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.customsHsDefs, JSON.stringify(customsHsDefs)).then(() => clearSaveIssue(STORAGE_KEYS.customsHsDefs)).catch(reportSaveError); }, [customsHsDefs, loaded]);
|
||||||
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.customsHs, JSON.stringify(customsHs)).then(() => clearSaveIssue(STORAGE_KEYS.customsHs)).catch(reportSaveError); }, [customsHs, loaded]);
|
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.customsHs, JSON.stringify(customsHs)).then(() => clearSaveIssue(STORAGE_KEYS.customsHs)).catch(reportSaveError); }, [customsHs, loaded]);
|
||||||
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.customsDecls, JSON.stringify(customsDecls)).then(() => clearSaveIssue(STORAGE_KEYS.customsDecls)).catch(reportSaveError); }, [customsDecls, loaded]);
|
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.customsDecls, JSON.stringify(customsDecls)).then(() => clearSaveIssue(STORAGE_KEYS.customsDecls)).catch(reportSaveError); }, [customsDecls, loaded]);
|
||||||
// 侧栏“订单管理”上的数字:到期未处理的订单提醒(每分钟刷新一次)
|
// 侧栏“订单管理”上的数字:到期未处理的订单提醒(每分钟刷新一次)
|
||||||
|
|
@ -4942,7 +4967,7 @@ function MainApp({ username, onLogout }) {
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{view === 'customs' && (
|
{view === 'customs' && (
|
||||||
<CustomsPage decls={customsDecls} setDecls={setCustomsDecls} shipperList={customsShippers} setShipperList={setCustomsShippers} hsList={customsHs} setHsList={setCustomsHs} customers={customers} orders={orders} notify={notify} />
|
<CustomsPage decls={customsDecls} setDecls={setCustomsDecls} shipperList={customsShippers} setShipperList={setCustomsShippers} hsList={customsHs} setHsList={setCustomsHs} hsDefs={customsHsDefs} setHsDefs={setCustomsHsDefs} customers={customers} orders={orders} notify={notify} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{view === 'settings' && (
|
{view === 'settings' && (
|
||||||
|
|
@ -6061,7 +6086,7 @@ function printCustomsDecl(d, customers) {
|
||||||
w.document.open(); w.document.write(html); w.document.close();
|
w.document.open(); w.document.write(html); w.document.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function CustomsPage({ decls, setDecls, shipperList, setShipperList, hsList, setHsList, customers, orders, notify }) {
|
function CustomsPage({ decls, setDecls, shipperList, setShipperList, hsList, setHsList, hsDefs, setHsDefs, customers, orders, notify }) {
|
||||||
const [selId, setSelId] = useState(null);
|
const [selId, setSelId] = useState(null);
|
||||||
const [tab, setTab] = useState('decls');
|
const [tab, setTab] = useState('decls');
|
||||||
const [q, setQ] = useState('');
|
const [q, setQ] = useState('');
|
||||||
|
|
@ -6084,16 +6109,16 @@ function CustomsPage({ decls, setDecls, shipperList, setShipperList, hsList, set
|
||||||
setDecls((prev) => prev.filter((x) => x.id !== d.id)); setSelId(null); notify('已删除');
|
setDecls((prev) => prev.filter((x) => x.id !== d.id)); setSelId(null); notify('已删除');
|
||||||
}
|
}
|
||||||
if (sel) return <CustomsEditor d={sel} update={(p) => update(sel.id, p)} onBack={() => setSelId(null)} onDelete={() => remove(sel)} onDuplicate={() => duplicate(sel)}
|
if (sel) return <CustomsEditor d={sel} update={(p) => update(sel.id, p)} onBack={() => setSelId(null)} onDelete={() => remove(sel)} onDuplicate={() => duplicate(sel)}
|
||||||
customers={customers} orders={orders} shippers={shippers} shipperList={shipperList} hsList={hsList} setHsList={setHsList} notify={notify} />;
|
customers={customers} orders={orders} shippers={shippers} shipperList={shipperList} hsList={hsList} setHsList={setHsList} hsDefs={hsDefs} setHsDefs={setHsDefs} notify={notify} />;
|
||||||
const tabs = (
|
const tabs = (
|
||||||
<div className="cd-tabs">
|
<div className="cd-tabs">
|
||||||
{[['decls', `报关单(${decls.length})`], ['shippers', `境内发货人(${shipperList.length})`], ['hs', `商品编码库(${hsList.length})`]].map(([k, l]) => (
|
{[['decls', `报关单(${decls.length})`], ['shippers', `境内发货人(${shipperList.length})`], ['hs', `商品编码库(${new Set([...hsList.map((x) => x.hsCode), ...hsDefs.map((x) => x.hsCode)]).size})`]].map(([k, l]) => (
|
||||||
<button key={k} className={tab === k ? 'on' : ''} onClick={() => setTab(k)}>{l}</button>
|
<button key={k} className={tab === k ? 'on' : ''} onClick={() => setTab(k)}>{l}</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
if (tab === 'shippers') return <>{tabs}<ShipperManager list={shipperList} setList={setShipperList} notify={notify} /></>;
|
if (tab === 'shippers') return <>{tabs}<ShipperManager list={shipperList} setList={setShipperList} notify={notify} /></>;
|
||||||
if (tab === 'hs') return <>{tabs}<HsManager list={hsList} setList={setHsList} notify={notify} /></>;
|
if (tab === 'hs') return <>{tabs}<HsManager list={hsList} setList={setHsList} defs={hsDefs} setDefs={setHsDefs} notify={notify} /></>;
|
||||||
|
|
||||||
const s0 = q.trim().toLowerCase();
|
const s0 = q.trim().toLowerCase();
|
||||||
const list = decls.filter((d) => !s0 || [d.contractNo, d.shipper, d.tradeCountry, custName(d.customerId), ...(d.items || []).flatMap((it) => [it.name, it.hsCode, it.spec])].some((x) => String(x || '').toLowerCase().includes(s0)))
|
const list = decls.filter((d) => !s0 || [d.contractNo, d.shipper, d.tradeCountry, custName(d.customerId), ...(d.items || []).flatMap((it) => [it.name, it.hsCode, it.spec])].some((x) => String(x || '').toLowerCase().includes(s0)))
|
||||||
|
|
@ -6130,7 +6155,7 @@ function CustomsPage({ decls, setDecls, shipperList, setShipperList, hsList, set
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CustomsEditor({ d, update, onBack, onDelete, onDuplicate, customers, orders, shippers, shipperList, hsList, setHsList, notify }) {
|
function CustomsEditor({ d, update, onBack, onDelete, onDuplicate, customers, orders, shippers, shipperList, hsList, setHsList, hsDefs, setHsDefs, notify }) {
|
||||||
const set = (p) => update(p);
|
const set = (p) => update(p);
|
||||||
const setItem = (id, p) => update((x) => ({ items: x.items.map((it) => (it.id === id ? { ...it, ...p } : it)) }));
|
const setItem = (id, p) => update((x) => ({ items: x.items.map((it) => (it.id === id ? { ...it, ...p } : it)) }));
|
||||||
const addItem = () => update((x) => ({ items: [...x.items, blankCdItem({ ...x.items[x.items.length - 1], dest: (x.items[x.items.length - 1] || {}).dest })] }));
|
const addItem = () => update((x) => ({ items: [...x.items, blankCdItem({ ...x.items[x.items.length - 1], dest: (x.items[x.items.length - 1] || {}).dest })] }));
|
||||||
|
|
@ -6222,7 +6247,7 @@ function CustomsEditor({ d, update, onBack, onDelete, onDuplicate, customers, or
|
||||||
<button className="btn btn-sm btn-ghost btn-danger" title="删除" onClick={() => delItem(it)}><Trash2 size={12} /></button>
|
<button className="btn btn-sm btn-ghost btn-danger" title="删除" onClick={() => delItem(it)}><Trash2 size={12} /></button>
|
||||||
</div>
|
</div>
|
||||||
<div className="cd-item-body">
|
<div className="cd-item-body">
|
||||||
<HsPicker it={it} hsList={hsList} setHsList={setHsList} setItem={setItem} notify={notify} />
|
<HsPicker it={it} hsList={hsList} setHsList={setHsList} defs={hsDefs} setDefs={setHsDefs} setItem={setItem} notify={notify} />
|
||||||
<div className="field"><span className="field-label">成交数量 / 单位</span><div className="cd-row2"><input className="input" inputMode="decimal" value={it.qty} onChange={(e) => setItem(it.id, { qty: e.target.value })} /><UnitInput value={it.unit} onChange={(v) => setItem(it.id, { unit: v })} /></div></div>
|
<div className="field"><span className="field-label">成交数量 / 单位</span><div className="cd-row2"><input className="input" inputMode="decimal" value={it.qty} onChange={(e) => setItem(it.id, { qty: e.target.value })} /><UnitInput value={it.unit} onChange={(v) => setItem(it.id, { unit: v })} /></div></div>
|
||||||
<label className="field"><span className="field-label">法定第一数量(千克)</span><input className="input" inputMode="decimal" value={it.kg} onChange={(e) => setItem(it.id, { kg: e.target.value })} /></label>
|
<label className="field"><span className="field-label">法定第一数量(千克)</span><input className="input" inputMode="decimal" value={it.kg} onChange={(e) => setItem(it.id, { kg: e.target.value })} /></label>
|
||||||
<div className="field"><span className="field-label">第二数量 / 单位(可选)</span><div className="cd-row2"><input className="input" inputMode="decimal" value={it.qty2} onChange={(e) => setItem(it.id, { qty2: e.target.value })} /><UnitInput value={it.unit2} onChange={(v) => setItem(it.id, { unit2: v })} /></div></div>
|
<div className="field"><span className="field-label">第二数量 / 单位(可选)</span><div className="cd-row2"><input className="input" inputMode="decimal" value={it.qty2} onChange={(e) => setItem(it.id, { qty2: e.target.value })} /><UnitInput value={it.unit2} onChange={(v) => setItem(it.id, { unit2: v })} /></div></div>
|
||||||
|
|
@ -6244,12 +6269,27 @@ function CustomsEditor({ d, update, onBack, onDelete, onDuplicate, customers, or
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// 商品编号(HS)+ 商品名称 + 申报要素:从编码库选,或手动填;同一个 HS 编码可以对应多个品名(各自的申报要素)
|
// 商品编号(HS)+ 商品名称 + 申报要素:从编码库选,或手动填;同一个 HS 编码可以对应多个品名(各自的申报要素)
|
||||||
|
// 每个 HS 编码可以设置"要素名称"(品牌类型、出口享惠情况、用途……):选了编码就逐项填写,自动用"|"拼成规格型号(申报要素)
|
||||||
const hsKey = (x) => `${String(x.hsCode || '').trim()}|${String(x.name || '').trim()}`;
|
const hsKey = (x) => `${String(x.hsCode || '').trim()}|${String(x.name || '').trim()}`;
|
||||||
function HsPicker({ it, hsList, setHsList, setItem, notify }) {
|
// 所有编码通用的前两项,海关有固定的代码
|
||||||
|
const CD_ELEM_BUILTIN = {
|
||||||
|
'品牌类型': [['0', '无品牌'], ['1', '境内自主品牌'], ['2', '境内收购品牌'], ['3', '境外品牌(贴牌生产)'], ['4', '境外品牌(其他)']],
|
||||||
|
'出口享惠情况': [['0', '出口货物在最终目的国(地区)不享受优惠关税'], ['1', '出口货物在最终目的国(地区)享受优惠关税'], ['2', '不能确定在最终目的国(地区)是否享受优惠关税']],
|
||||||
|
};
|
||||||
|
const CD_DEFAULT_HS_DEFS = [
|
||||||
|
{ id: 'hsd_8507600099', hsCode: '8507600099', elements: ['品牌类型', '出口享惠情况', '用途', '电极材质(铅酸、镍镉、镍铁、镍氢、锂离子等)', '比能量', '品牌(中文或外文名称)', '型号', '容量', '是否含汞', '额定电压'].map((name) => ({ name, opts: [] })) },
|
||||||
|
];
|
||||||
|
const cdSplit = (spec) => String(spec || '').split('|');
|
||||||
|
const cdElemDef = (defs, hs) => (defs || []).find((x) => x.hsCode === String(hs || '').trim()) || null;
|
||||||
|
|
||||||
|
function HsPicker({ it, hsList, setHsList, defs, setDefs, setItem, notify }) {
|
||||||
|
const [editNames, setEditNames] = useState(false);
|
||||||
const sorted = [...hsList].sort((a, b) => String(a.hsCode).localeCompare(String(b.hsCode)) || String(a.name).localeCompare(String(b.name), 'zh'));
|
const sorted = [...hsList].sort((a, b) => String(a.hsCode).localeCompare(String(b.hsCode)) || String(a.name).localeCompare(String(b.name), 'zh'));
|
||||||
const sameHs = hsList.filter((x) => x.hsCode === it.hsCode.trim());
|
const sameHs = hsList.filter((x) => x.hsCode === it.hsCode.trim());
|
||||||
const entry = hsList.find((x) => hsKey(x) === hsKey(it));
|
const entry = hsList.find((x) => hsKey(x) === hsKey(it));
|
||||||
|
const def = cdElemDef(defs, it.hsCode);
|
||||||
const canSave = it.hsCode.trim() && it.name.trim() && (!entry || (entry.spec || '') !== (it.spec || ''));
|
const canSave = it.hsCode.trim() && it.name.trim() && (!entry || (entry.spec || '') !== (it.spec || ''));
|
||||||
|
const parts = cdSplit(it.spec);
|
||||||
function onHs(v) {
|
function onHs(v) {
|
||||||
v = v.replace(/[^\d.]/g, '');
|
v = v.replace(/[^\d.]/g, '');
|
||||||
const m = hsList.filter((x) => x.hsCode === v);
|
const m = hsList.filter((x) => x.hsCode === v);
|
||||||
|
|
@ -6261,6 +6301,20 @@ function HsPicker({ it, hsList, setHsList, setItem, notify }) {
|
||||||
const m = hsList.find((x) => x.name === v.trim() && (!it.hsCode.trim() || x.hsCode === it.hsCode.trim()));
|
const m = hsList.find((x) => x.name === v.trim() && (!it.hsCode.trim() || x.hsCode === it.hsCode.trim()));
|
||||||
setItem(it.id, { name: v, ...(m ? { hsCode: it.hsCode.trim() || m.hsCode, ...(!it.spec.trim() || hsList.some((x) => x.spec === it.spec) ? { spec: m.spec || '' } : {}) } : {}) });
|
setItem(it.id, { name: v, ...(m ? { hsCode: it.hsCode.trim() || m.hsCode, ...(!it.spec.trim() || hsList.some((x) => x.spec === it.spec) ? { spec: m.spec || '' } : {}) } : {}) });
|
||||||
}
|
}
|
||||||
|
function setPart(i, v) {
|
||||||
|
const arr = cdSplit(it.spec);
|
||||||
|
const n = Math.max(arr.length, def.elements.length);
|
||||||
|
while (arr.length < n) arr.push('');
|
||||||
|
arr[i] = String(v).replace(/\|/g, '/');
|
||||||
|
while (arr.length > def.elements.length && arr[arr.length - 1] === '') arr.pop();
|
||||||
|
setItem(it.id, { spec: arr.every((x) => x === '') ? '' : arr.join('|') });
|
||||||
|
}
|
||||||
|
// 填过的值记下来,下次直接选
|
||||||
|
function learn(i, v) {
|
||||||
|
v = String(v || '').trim(); if (!v || !def) return;
|
||||||
|
const el = def.elements[i]; if (!el || CD_ELEM_BUILTIN[el.name] || (el.opts || []).includes(v)) return;
|
||||||
|
setDefs((prev) => prev.map((d) => (d.id === def.id ? { ...d, elements: d.elements.map((e, k) => (k === i ? { ...e, opts: [v, ...(e.opts || [])].slice(0, 40) } : e)) } : d)));
|
||||||
|
}
|
||||||
function save() {
|
function save() {
|
||||||
const rec = { hsCode: it.hsCode.trim(), name: it.name.trim(), spec: it.spec || '' };
|
const rec = { hsCode: it.hsCode.trim(), name: it.name.trim(), spec: it.spec || '' };
|
||||||
if (entry) {
|
if (entry) {
|
||||||
|
|
@ -6279,20 +6333,77 @@ function HsPicker({ it, hsList, setHsList, setItem, notify }) {
|
||||||
{canSave && <button type="button" className="btn btn-sm" onClick={save}><Save size={12} />{entry ? '更新编码库的申报要素' : '存入编码库'}</button>}
|
{canSave && <button type="button" className="btn btn-sm" onClick={save}><Save size={12} />{entry ? '更新编码库的申报要素' : '存入编码库'}</button>}
|
||||||
</div>
|
</div>
|
||||||
<label className="field"><span className="field-label">商品编号(HS)</span>
|
<label className="field"><span className="field-label">商品编号(HS)</span>
|
||||||
<input className="input crm-mono" list="cd-hs-codes" value={it.hsCode} onChange={(e) => onHs(e.target.value)} placeholder="8504401990" />
|
<input className="input crm-mono" list="cd-hs-codes" value={it.hsCode} onChange={(e) => onHs(e.target.value)} placeholder="8507600099" />
|
||||||
<datalist id="cd-hs-codes">{[...new Set(hsList.map((x) => x.hsCode))].map((c) => <option key={c} value={c}>{hsList.filter((x) => x.hsCode === c).map((x) => x.name).join(' / ')}</option>)}</datalist>
|
<datalist id="cd-hs-codes">{[...new Set([...hsList.map((x) => x.hsCode), ...defs.map((x) => x.hsCode)])].map((c) => <option key={c} value={c}>{hsList.filter((x) => x.hsCode === c).map((x) => x.name).join(' / ')}</option>)}</datalist>
|
||||||
</label>
|
</label>
|
||||||
<label className="field cd-span2"><span className="field-label">商品名称{sameHs.length > 1 && <small className="cd-soft"> 这个编码有 {sameHs.length} 个品名:{sameHs.map((x) => x.name).join('、')}</small>}</span>
|
<label className="field cd-span2"><span className="field-label">商品名称{sameHs.length > 1 && <small className="cd-soft"> 这个编码有 {sameHs.length} 个品名:{sameHs.map((x) => x.name).join('、')}</small>}</span>
|
||||||
<input className="input" list={`cd-hs-names-${it.id}`} value={it.name} onChange={(e) => onName(e.target.value)} placeholder="如:电源系统" />
|
<input className="input" list={`cd-hs-names-${it.id}`} value={it.name} onChange={(e) => onName(e.target.value)} placeholder="如:锂电池" />
|
||||||
<datalist id={`cd-hs-names-${it.id}`}>{(sameHs.length ? sameHs : hsList).map((x) => <option key={x.id} value={x.name}>{x.hsCode}</option>)}</datalist>
|
<datalist id={`cd-hs-names-${it.id}`}>{(sameHs.length ? sameHs : hsList).map((x) => <option key={x.id} value={x.name}>{x.hsCode}</option>)}</datalist>
|
||||||
</label>
|
</label>
|
||||||
<label className="field cd-span3"><span className="field-label">规格型号(申报要素){entry && (entry.spec || '') !== (it.spec || '') && <small className="cd-hint"> 和编码库里的不一样(只改这一单没关系;要以后都用,点上面"更新编码库")</small>}</span>
|
|
||||||
|
{it.hsCode.trim().length >= 8 && (def && !editNames ? (
|
||||||
|
<div className="field cd-span3">
|
||||||
|
<span className="field-label">申报要素({it.hsCode.trim()},共 {def.elements.length} 项)
|
||||||
|
<button type="button" className="cd-link" onClick={() => setEditNames(true)}>修改要素名称</button></span>
|
||||||
|
<div className="cd-elems">
|
||||||
|
{def.elements.map((el, i) => {
|
||||||
|
const bi = CD_ELEM_BUILTIN[el.name];
|
||||||
|
const v = parts[i] || '';
|
||||||
|
return (
|
||||||
|
<div key={i} className={`cd-elem${v ? '' : ' empty'}`}>
|
||||||
|
<span className="cd-elem-n"><i>{i + 1}</i>{el.name}</span>
|
||||||
|
{bi ? (
|
||||||
|
<select className="input" value={v} onChange={(e) => setPart(i, e.target.value)}>
|
||||||
|
<option value="">请选择…</option>{bi.map(([c, l]) => <option key={c} value={c}>{c} - {l}</option>)}
|
||||||
|
{v && !bi.some(([c]) => c === v) && <option value={v}>{v}</option>}
|
||||||
|
</select>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<input className="input" list={`cd-el-${def.id}-${i}`} value={v} onChange={(e) => setPart(i, e.target.value)} onBlur={(e) => learn(i, e.target.value)} placeholder={(el.opts || []).length ? '选择或填写' : '填写'} />
|
||||||
|
<datalist id={`cd-el-${def.id}-${i}`}>{(el.opts || []).map((o) => <option key={o} value={o} />)}</datalist>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<ElemNamesEditor hsCode={it.hsCode.trim()} def={def} setDefs={setDefs} onDone={() => setEditNames(false)} compact />
|
||||||
|
))}
|
||||||
|
|
||||||
|
<label className="field cd-span3"><span className="field-label">规格型号(申报要素){def ? <small className="cd-soft"> 由上面各项自动拼成,也可以直接改这里</small> : null}{entry && (entry.spec || '') !== (it.spec || '') && <small className="cd-hint"> 和编码库里的不一样(只改这一单没关系;要以后都用,点上面"更新编码库")</small>}</span>
|
||||||
<textarea className="textarea crm-mono" rows={2} value={it.spec} onChange={(e) => setItem(it.id, { spec: e.target.value })} placeholder="1|0|稳定输出电压用|直流稳压电源|2kW|+/-10%|义达牌|无型号" />
|
<textarea className="textarea crm-mono" rows={2} value={it.spec} onChange={(e) => setItem(it.id, { spec: e.target.value })} placeholder="1|0|稳定输出电压用|直流稳压电源|2kW|+/-10%|义达牌|无型号" />
|
||||||
</label>
|
</label>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置某个 HS 编码的要素名称:一行一个,按海关规定的顺序
|
||||||
|
function ElemNamesEditor({ hsCode, def, setDefs, onDone, compact }) {
|
||||||
|
const [text, setText] = useState(def ? def.elements.map((e) => e.name).join('\n') : '品牌类型\n出口享惠情况\n');
|
||||||
|
function apply() {
|
||||||
|
const names = text.split('\n').map((x) => x.trim()).filter(Boolean);
|
||||||
|
if (!names.length) { if (def && window.confirm(`删除 ${hsCode} 的要素名称设置?`)) { setDefs((prev) => prev.filter((d) => d.id !== def.id)); } onDone && onDone(); return; }
|
||||||
|
setDefs((prev) => {
|
||||||
|
const old = prev.find((d) => d.hsCode === hsCode);
|
||||||
|
const elements = names.map((name) => ({ name, opts: ((old && old.elements.find((e) => e.name === name)) || {}).opts || [] }));
|
||||||
|
return old ? prev.map((d) => (d === old ? { ...d, elements } : d)) : [...prev, { id: cdId('hsd'), hsCode, elements }];
|
||||||
|
});
|
||||||
|
onDone && onDone();
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className={`field cd-span3 cd-names${compact ? ' compact' : ''}`}>
|
||||||
|
<span className="field-label">{def ? `修改 ${hsCode} 的要素名称` : `${hsCode} 还没有设置要素名称`}<small className="cd-soft"> 一行一个,按海关申报要素的顺序;设置一次,以后选这个编码就按这些项目填写</small></span>
|
||||||
|
<textarea className="textarea" rows={Math.min(12, Math.max(4, text.split('\n').length + 1))} value={text} onChange={(e) => setText(e.target.value)} placeholder={'品牌类型\n出口享惠情况\n用途\n…'} />
|
||||||
|
<div style={{ display: 'flex', gap: 6, justifyContent: 'flex-end' }}>
|
||||||
|
{def && <button type="button" className="btn btn-sm btn-ghost" onClick={onDone}>取消</button>}
|
||||||
|
<button type="button" className="btn btn-sm btn-primary" onClick={apply}><Check size={12} />保存要素名称</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function ShipperManager({ list, setList, notify }) {
|
function ShipperManager({ list, setList, notify }) {
|
||||||
const upd = (id, p) => setList((prev) => prev.map((x) => (x.id === id ? { ...x, ...p } : x)));
|
const upd = (id, p) => setList((prev) => prev.map((x) => (x.id === id ? { ...x, ...p } : x)));
|
||||||
const setDefault = (id) => setList((prev) => prev.map((x) => ({ ...x, isDefault: x.id === id })));
|
const setDefault = (id) => setList((prev) => prev.map((x) => ({ ...x, isDefault: x.id === id })));
|
||||||
|
|
@ -6318,35 +6429,74 @@ function ShipperManager({ list, setList, notify }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function HsManager({ list, setList, notify }) {
|
function HsManager({ list, setList, defs, setDefs, notify }) {
|
||||||
const [q, setQ] = useState('');
|
const [q, setQ] = useState('');
|
||||||
|
const [editing, setEditing] = useState(null); // 正在改要素名称的编码
|
||||||
|
const [newCode, setNewCode] = useState('');
|
||||||
const upd = (id, p) => setList((prev) => prev.map((x) => (x.id === id ? { ...x, ...p, updatedAt: new Date().toISOString() } : x)));
|
const upd = (id, p) => setList((prev) => prev.map((x) => (x.id === id ? { ...x, ...p, updatedAt: new Date().toISOString() } : x)));
|
||||||
const add = () => { setQ(''); setList((prev) => [{ id: cdId('hs'), hsCode: '', name: '', spec: '', createdAt: new Date().toISOString() }, ...prev]); };
|
const addName = (hsCode) => setList((prev) => [...prev, { id: cdId('hs'), hsCode, name: '', spec: '', createdAt: new Date().toISOString() }]);
|
||||||
const del = (x) => { if (!window.confirm(`从编码库删除"${x.hsCode} · ${x.name}"?已经录好的报关单不受影响。`)) return; setList((prev) => prev.filter((y) => y.id !== x.id)); };
|
const del = (x) => { if (!window.confirm(`从编码库删除"${x.hsCode} · ${x.name || '(未填品名)'}"?已经录好的报关单不受影响。`)) return; setList((prev) => prev.filter((y) => y.id !== x.id)); };
|
||||||
|
const setOpts = (def, i, text) => setDefs((prev) => prev.map((d) => (d.id === def.id ? { ...d, elements: d.elements.map((e, k) => (k === i ? { ...e, opts: text.split(/[,,\n]/).map((x) => x.trim()).filter(Boolean) } : e)) } : d)));
|
||||||
|
function addCode() {
|
||||||
|
const c = newCode.replace(/[^\d.]/g, '');
|
||||||
|
if (c.length < 8) { notify('请输入完整的商品编号(10 位)'); return; }
|
||||||
|
if (!defs.some((d) => d.hsCode === c)) setEditing(c);
|
||||||
|
if (!list.some((x) => x.hsCode === c)) addName(c);
|
||||||
|
setNewCode('');
|
||||||
|
}
|
||||||
|
const codes = [...new Set([...defs.map((d) => d.hsCode), ...list.map((x) => x.hsCode)])].filter((c) => c !== undefined).sort();
|
||||||
const s = q.trim().toLowerCase();
|
const s = q.trim().toLowerCase();
|
||||||
const shown = list.filter((x) => !s || [x.hsCode, x.name, x.spec].some((v) => String(v || '').toLowerCase().includes(s)));
|
const shown = codes.filter((c) => !s || c.includes(s) || list.some((x) => x.hsCode === c && [x.name, x.spec].some((v) => String(v || '').toLowerCase().includes(s))) || (cdElemDef(defs, c) || { elements: [] }).elements.some((e) => e.name.toLowerCase().includes(s)));
|
||||||
const dup = new Set(); const seen = new Set();
|
|
||||||
for (const x of list) { const k = hsKey(x); if (x.hsCode && x.name && seen.has(k)) dup.add(k); seen.add(k); }
|
|
||||||
return (
|
return (
|
||||||
<div className="panel">
|
<div className="panel">
|
||||||
<div className="panel-header"><div className="panel-title">商品编码库</div>
|
<div className="panel-header"><div className="panel-title">商品编码库</div>
|
||||||
<div style={{ display: 'flex', gap: 8 }}>
|
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
|
||||||
<div className="cd-search" style={{ minWidth: 220 }}><Search size={13} /><input value={q} onChange={(e) => setQ(e.target.value)} placeholder="搜编码、品名、申报要素" /></div>
|
<div className="cd-search" style={{ minWidth: 200 }}><Search size={13} /><input value={q} onChange={(e) => setQ(e.target.value)} placeholder="搜编码、品名、要素" /></div>
|
||||||
<button className="btn btn-sm btn-primary" onClick={add}><Plus size={13} />添加</button>
|
<input className="input crm-mono" style={{ width: 150 }} value={newCode} onChange={(e) => setNewCode(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') addCode(); }} placeholder="新的 HS 编码" />
|
||||||
|
<button className="btn btn-sm btn-primary" onClick={addCode}><Plus size={13} />添加编码</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="panel-body" style={{ padding: '12px 16px', display: 'grid', gap: 8 }}>
|
<div className="panel-body" style={{ padding: '12px 16px', display: 'grid', gap: 12 }}>
|
||||||
<div className="cd-note">一条 = 商品编号(HS)+ 商品名称 + 申报要素。同一个 HS 编码可以有多个品名,各自的申报要素不同。录入报关时选一条就会自动填好这三项(申报要素在报关单里还可以再改)。录报关时填的新编码,也可以在那里点"存入编码库"。</div>
|
<div className="cd-note">每个商品编号(HS)设置一次"要素名称"(海关规定的申报要素项目,按顺序),录报关时选了这个编码就逐项填写,自动拼成规格型号。同一个编码下可以存多个品名,各自带一套常用的申报要素,录报关时选品名就整套填好。</div>
|
||||||
{list.length === 0 && <div className="empty-state">编码库还是空的,点右上角"添加",或者在录入报关时点"存入编码库"</div>}
|
{codes.length === 0 && <div className="empty-state">编码库还是空的:在右上角输入 HS 编码添加,或者在录入报关时点"存入编码库"</div>}
|
||||||
{shown.map((x) => (
|
{shown.map((code) => {
|
||||||
<div key={x.id} className="cd-lib-row cd-hs-row">
|
const def = cdElemDef(defs, code);
|
||||||
<input className="input crm-mono" value={x.hsCode} onChange={(e) => upd(x.id, { hsCode: e.target.value.replace(/[^\d.]/g, '') })} placeholder="HS 编码" />
|
const names = list.filter((x) => x.hsCode === code);
|
||||||
<input className="input" value={x.name} onChange={(e) => upd(x.id, { name: e.target.value })} placeholder="商品名称" />
|
return (
|
||||||
<textarea className="textarea crm-mono" rows={2} value={x.spec} onChange={(e) => upd(x.id, { spec: e.target.value })} placeholder="申报要素,如 1|0|稳定输出电压用|直流稳压电源|2kW|+/-10%|义达牌|无型号" />
|
<div key={code} className="cd-code">
|
||||||
<button className="btn btn-sm btn-ghost btn-danger" onClick={() => del(x)}><Trash2 size={13} /></button>
|
<div className="cd-code-h">
|
||||||
{dup.has(hsKey(x)) && <small className="cd-hint" style={{ gridColumn: '1 / -1' }}>编码和品名都相同的有多条,选的时候容易混,建议删掉一条</small>}
|
<b className="crm-mono">{code}</b>
|
||||||
</div>
|
<span>{def ? `要素名称 ${def.elements.length} 项` : '还没有设置要素名称'} · 品名 {names.length} 个</span>
|
||||||
))}
|
<div style={{ marginLeft: 'auto', display: 'flex', gap: 6 }}>
|
||||||
|
<button className="btn btn-sm" onClick={() => setEditing(editing === code ? null : code)}><Edit2 size={12} />{def ? '修改要素名称' : '设置要素名称'}</button>
|
||||||
|
<button className="btn btn-sm" onClick={() => addName(code)}><Plus size={12} />添加品名</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{editing === code ? (
|
||||||
|
<ElemNamesEditor key={code} hsCode={code} def={def} setDefs={setDefs} onDone={() => setEditing(null)} />
|
||||||
|
) : def && (
|
||||||
|
<div className="cd-def">
|
||||||
|
{def.elements.map((e, i) => (
|
||||||
|
<div key={i} className="cd-def-r">
|
||||||
|
<span className="cd-elem-n"><i>{i + 1}</i>{e.name}</span>
|
||||||
|
{CD_ELEM_BUILTIN[e.name]
|
||||||
|
? <small className="cd-soft">{CD_ELEM_BUILTIN[e.name].map(([c, l]) => `${c} ${l}`).join(';')}</small>
|
||||||
|
: <input className="input" defaultValue={(e.opts || []).join(',')} onBlur={(ev) => setOpts(def, i, ev.target.value)} placeholder="常用值(逗号分隔,可不填;录报关时填过的会自动记下)" />}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{names.map((x) => (
|
||||||
|
<div key={x.id} className="cd-lib-row cd-hs-row">
|
||||||
|
<input className="input" value={x.name} onChange={(e) => upd(x.id, { name: e.target.value })} placeholder="商品名称" />
|
||||||
|
<textarea className="textarea crm-mono" rows={2} value={x.spec} onChange={(e) => upd(x.id, { spec: e.target.value })} placeholder={def ? def.elements.map((e) => e.name.replace(/(.*)/, '')).join('|') : '申报要素,用 | 分隔'} />
|
||||||
|
<button className="btn btn-sm btn-ghost btn-danger" onClick={() => del(x)}><Trash2 size={13} /></button>
|
||||||
|
{def && x.spec && cdSplit(x.spec).length !== def.elements.length && <small className="cd-hint" style={{ gridColumn: '1 / -1' }}>这套申报要素有 {cdSplit(x.spec).length} 项,要素名称是 {def.elements.length} 项,请核对</small>}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue