- {[['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]) => (
))}
);
if (tab === 'shippers') return <>{tabs}
-
+
@@ -6244,12 +6269,27 @@ function CustomsEditor({ d, update, onBack, onDelete, onDuplicate, customers, or
);
}
// 商品编号(HS)+ 商品名称 + 申报要素:从编码库选,或手动填;同一个 HS 编码可以对应多个品名(各自的申报要素)
+// 每个 HS 编码可以设置"要素名称"(品牌类型、出口享惠情况、用途……):选了编码就逐项填写,自动用"|"拼成规格型号(申报要素)
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 sameHs = hsList.filter((x) => x.hsCode === it.hsCode.trim());
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 parts = cdSplit(it.spec);
function onHs(v) {
v = v.replace(/[^\d.]/g, '');
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()));
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() {
const rec = { hsCode: it.hsCode.trim(), name: it.name.trim(), spec: it.spec || '' };
if (entry) {
@@ -6279,20 +6333,77 @@ function HsPicker({ it, hsList, setHsList, setItem, notify }) {
{canSave &&
}