From 7dcbd6ef61f8864d0afa535baff2b8b8581c4139 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 17 Nov 2026 14:32:40 +0800 Subject: [PATCH] Update App.jsx via upload script - 2026-11-17 14:32:20 --- App.jsx | 264 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 226 insertions(+), 38 deletions(-) diff --git a/App.jsx b/App.jsx index 23e2490..9097419 100644 --- a/App.jsx +++ b/App.jsx @@ -2252,6 +2252,10 @@ const Styles = () => ( .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-hs-row { grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr) auto; } + .cd-req { color: #d92d20; } + .cd-missing { border-color: #f04438 !important; background: #fff6f5; } + .cd-prev-box { overflow: hidden; display: flex; justify-content: center; } + .cd-prev-box iframe { border: 0; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.12); transform-origin: top center; flex: none; } .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); } @@ -6046,44 +6050,208 @@ function cdSums(d) { } const cdProducer = (d) => (d.producerSame ? { name: d.shipper, code: d.shipperCode } : { name: d.producer, code: d.producerCode }); -// 打印:按海关出口报关单的样子排一份草单(仅供核对) -function printCustomsDecl(d, customers) { - const esc = (s) => String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])).replace(/\n/g, '
'); +// ===== 预报关单:同一份内容用于编辑页底部的实时预览、下载 PDF、下载 Excel ===== +const CD_PREPARER = { name: 'Mike', phone: '15201273157' }; +const cdEsc = (s) => String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])).replace(/\n/g, '
'); +const cdQty2 = (it) => (String(it.qty2 ?? '').trim() || String(it.qty ?? '').trim()); // 发票数量没单独填就等于成交数量 +const cdFileBase = (d) => `预报关单_${String(d.contractNo || d.date || '').replace(/[\\/:*?"<>|\s]+/g, '_')}`; +// 整理成一份结构化数据,HTML 和 Excel 都从这里取 +function cdDocData(d, customers, defs) { const cust = customers.find((c) => c.id === d.customerId); const pr = cdProducer(d); const term = CD_TERMS.find((t) => t[0] === d.terms); - const cell = (label, code, val) => `
${esc(label)}${code ? ` (${esc(code)})` : ''}
${esc(val) || ' '}
`; - const rows = (d.items || []).filter((it) => it.name || it.hsCode || it.qty).map((it, i) => ` - ${i + 1}${esc(it.hsCode)} - ${esc(it.name)}
${esc(it.spec)}
- ${it.qty ? `${esc(it.qty)}${esc(it.unit)}` : ''}${it.kg ? `
${esc(it.kg)}千克` : ''}${it.qty2 ? `
${esc(it.qty2)}${esc(it.unit2)}` : ''} - ${it.unitPrice ? cdFmt(cdNum(it.unitPrice), 4) : ''}
${it.qty && it.unitPrice ? cdFmt(cdTotal(it)) : ''}
${esc(cdCurLabel(it.currency))} - ${esc(it.origin)}${esc(it.dest || d.tradeCountry)}${esc(it.source)}`).join(''); + const items = (d.items || []).filter((it) => it.name || it.hsCode || it.qty).map((it, i) => { + const def = cdElemDef(defs, it.hsCode); + const vals = cdSplit(it.spec); + const elems = def ? def.elements.map((e, k) => { + const v = vals[k] || ''; const bi = CD_ELEM_BUILTIN[e.name]; const hit = bi && bi.find(([c]) => c === v); + return [e.name, hit ? `${v}(${hit[1]})` : v]; + }) : (it.spec ? vals.map((v, k) => [`第 ${k + 1} 项`, v]) : []); + return { + no: i + 1, it, elems, + qtyLines: [it.qty ? `${it.qty}${it.unit || ''}` : '', it.kg ? `${it.kg}千克` : '', cdQty2(it) ? `${cdQty2(it)}${it.unit2 || ''}` : ''], + priceLines: [it.unitPrice ? cdFmt(cdNum(it.unitPrice), 4) : '', it.qty && it.unitPrice ? cdFmt(cdTotal(it)) : '', cdCurLabel(it.currency)], + dest: it.dest || d.tradeCountry, + }; + }); const s = cdSums(d); - const html = `报关草单 ${esc(d.contractNo)} -

中华人民共和国海关出口货物报关单

草单 · 仅供核对用 · ${esc(d.date)}
- - ${cell('境内发货人', d.shipperCode, d.shipper)}${cell('境外收货人', '', cust ? (cust.company || cust.contact) : '')}${cell('生产销售单位', pr.code, pr.name)} - ${cell('合同协议号', '', d.contractNo)}${cell('贸易国(地区)', '', d.tradeCountry)}${cell('成交方式', term ? term[1] : '', d.terms)} - ${cell('件数', '', d.packages)}${cell('毛重(千克)', '', d.grossWeight)}${cell('净重(千克)', '', d.netWeight)} - ${d.notes ? `` : ''} -
标记唛码及备注
${esc(d.notes)}
- - ${rows}
项号商品编号商品名称及规格型号数量及单位单价/总价/币制原产国(地区)最终目的国(地区)境内货源地
-
${Object.entries(s.by).map(([c, v]) => `合计 ${cdFmt(v)} ${esc(cdCurLabel(c))}`).join(' ')}${s.kg ? ` · 法定数量合计 ${cdFmt(s.kg, 1)} 千克` : ''}
-
本草单由客户档案系统生成,仅供与报关行核对,以海关正式报关单为准。
-