放大销售单据字号并收紧内部留白

This commit is contained in:
summer committed 2026-10-22 13:51:39 +08:00
1 parent 5265a2e568
commit 7269945bc1
3 files changed
+4 -3

No files matched your search

+2 -2
View File
@@ -2,7 +2,7 @@
const escape=s=>String(s??'').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
const yuan=n=>(n/100).toFixed(2);
const STATUS_NOTICE={draft:'草稿 · 未确认',returned:'退货单 · 已退货',cancelled:'取消单 · 已取消'};
const PAPER_WIDTH=241,PAPER_HEIGHT=140;
const PAPER_WIDTH=241,PAPER_HEIGHT=140,CONTENT_SCALE=1.2;
const defaults={store:'麦麦珠宝',subtitle:'珠宝销售单',contact:'',width:PAPER_WIDTH,height:PAPER_HEIGHT,offsetX:0,offsetY:0,rows:3,contentTop:12,rowHeight:10};
// 按麦麦提供的纸质单据及后续修改保留条款,不由系统追加交易承诺。
const notices=[
@@ -66,7 +66,7 @@ function receipt(order,rawSettings={},mode='full'){
<div class="signatures">${s.contact?`<span>联系电话:${escape(s.contact)}</span>`:''}<span class="salesperson">经办人:${escape(order.salesperson||'')} ________________</span></div>
</div><svg class="print-canvas" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" aria-hidden="true"><foreignObject x="0" y="0"></foreignObject></svg></div></section>`;
return `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escape(paper)} · 客户单据</title><style>
*{box-sizing:border-box}body{margin:0;background:#e8e7e4;color:#181818;font-family:"Microsoft YaHei","PingFang SC",sans-serif;font-size:12px}.toolbar{padding:12px 20px;background:white;position:sticky;top:0;z-index:2;display:flex;gap:12px;align-items:center;flex-wrap:wrap;box-shadow:0 1px 5px #aaa}.toolbar button,.toolbar a{padding:9px 16px;border:1px solid #444;border-radius:5px;background:white;color:#222;text-decoration:none;cursor:pointer}.toolbar button{background:#254d42;color:#fff}.toolbar button:disabled{opacity:.5}.toolbar small{color:#555}.sheet{width:${s.width}mm;height:${s.height}mm;background:white;margin:12px auto;position:relative;box-shadow:0 3px 16px #bbb}.print-frame{position:absolute;left:${Math.max(3,12+s.offsetX)}mm;right:${Math.max(3,12-s.offsetX)}mm;top:${Math.max(3,s.contentTop+s.offsetY)}mm;bottom:8mm}.content{width:100%;transform-origin:top left}.print-canvas{display:none}header{text-align:center;padding:0 0 6mm}h1{font-size:25px;letter-spacing:5px;margin:0 0 5px;overflow-wrap:anywhere}.subtitle{letter-spacing:3px;font-size:16px;overflow-wrap:anywhere}.meta{display:flex;justify-content:space-between;gap:10px;margin:5px 0;overflow-wrap:anywhere}.meta span,.meta strong{max-width:65%}.secondary{font-size:11px;margin-bottom:8px}table{border-collapse:collapse;width:100%;table-layout:fixed}th,td{border:1px solid #333;padding:4px;overflow-wrap:anywhere;text-align:center}th{height:9mm;font-size:11px}td{height:${s.rowHeight}mm;font-size:12px}td:nth-child(2){text-align:left}.totals{display:flex;justify-content:space-between;gap:10px;padding:10px 6px;border:1px solid #333;border-top:0;line-height:1.6;overflow-wrap:anywhere}.amount{flex-shrink:0}.amount strong{font-size:16px}.notices{border:1px solid #333;border-top:0;padding:6px 8px;font-family:"SimSun","Songti SC",serif;font-size:12px;line-height:1.65}.notices h2{font-size:13px;margin:0;font-weight:700}.notices ol{padding-left:20px;margin:0 0 2px}.notices li{padding-left:0}.promise{margin:2px 0 0;font-weight:600}.note{padding:8px 0;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.6}.signatures{display:flex;justify-content:space-between;gap:12px;padding-top:8px;overflow-wrap:anywhere}.signatures .salesperson{margin-left:auto}.overlay .preprinted{visibility:hidden}.overlay th,.overlay td,.overlay .totals,.overlay .notices{border-color:transparent}.compact .blank-row{display:none}.compact td{height:7mm;padding:2px 3px}.compact header{padding-bottom:3mm}.compact .note,.compact .signatures{padding-top:4px;padding-bottom:4px}
*{box-sizing:border-box}body{margin:0;background:#e8e7e4;color:#181818;font-family:"Microsoft YaHei","PingFang SC",sans-serif;font-size:12px}.toolbar{padding:12px 20px;background:white;position:sticky;top:0;z-index:2;display:flex;gap:12px;align-items:center;flex-wrap:wrap;box-shadow:0 1px 5px #aaa}.toolbar button,.toolbar a{padding:9px 16px;border:1px solid #444;border-radius:5px;background:white;color:#222;text-decoration:none;cursor:pointer}.toolbar button{background:#254d42;color:#fff}.toolbar button:disabled{opacity:.5}.toolbar small{color:#555}.sheet{width:${s.width}mm;height:${s.height}mm;background:white;margin:12px auto;position:relative;box-shadow:0 3px 16px #bbb}.print-frame{position:absolute;left:${Math.max(3,12+s.offsetX)}mm;right:${Math.max(3,12-s.offsetX)}mm;top:${Math.max(3,s.contentTop+s.offsetY)}mm;bottom:8mm}.content{width:100%;transform-origin:top left;font-size:${12*CONTENT_SCALE}px}.print-canvas{display:none}header{text-align:center;padding:0 0 6mm}h1{font-size:${25*CONTENT_SCALE}px;letter-spacing:5px;margin:0 0 3px;overflow-wrap:anywhere}.subtitle{letter-spacing:3px;font-size:${16*CONTENT_SCALE}px;overflow-wrap:anywhere}.meta{display:flex;justify-content:space-between;gap:10px;margin:5px 0;overflow-wrap:anywhere}.meta span,.meta strong{max-width:65%}.secondary{font-size:${11*CONTENT_SCALE}px;margin-bottom:8px}table{border-collapse:collapse;width:100%;table-layout:fixed}th,td{border:1px solid #333;padding:4px;overflow-wrap:anywhere;text-align:center}th{height:9mm;font-size:${11*CONTENT_SCALE}px}td{height:${s.rowHeight}mm;font-size:${12*CONTENT_SCALE}px}td:nth-child(2){text-align:left}.totals{display:flex;justify-content:space-between;gap:10px;padding:4px 5px;border:1px solid #333;border-top:0;line-height:1.4;overflow-wrap:anywhere}.amount{flex-shrink:0}.amount strong{font-size:${16*CONTENT_SCALE}px}.notices{border:1px solid #333;border-top:0;padding:3px 6px;font-family:"SimSun","Songti SC",serif;font-size:${12*CONTENT_SCALE}px;line-height:1.35}.notices h2{font-size:${13*CONTENT_SCALE}px;margin:0;font-weight:700}.notices ol{padding-left:20px;margin:0 0 2px}.notices li{padding-left:0}.promise{margin:2px 0 0;font-weight:600}.note{padding:8px 0;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.6}.signatures{display:flex;justify-content:space-between;gap:12px;padding-top:8px;overflow-wrap:anywhere}.signatures .salesperson{margin-left:auto}.overlay .preprinted{visibility:hidden}.overlay th,.overlay td,.overlay .totals,.overlay .notices{border-color:transparent}.compact .blank-row{display:none}.compact td{height:7mm;padding:2px 3px}.compact header{padding-bottom:1mm}.compact .note,.compact .signatures{padding-top:1px;padding-bottom:1px;line-height:1.4}
@page{size:${PAPER_WIDTH}mm ${PAPER_HEIGHT}mm;margin:0}@media print{html,body{width:auto;height:auto;margin:0;padding:0;background:white}.toolbar{display:none}.sheet{width:${PAPER_WIDTH}mm;height:calc(${PAPER_HEIGHT}mm - 1px);max-width:${PAPER_WIDTH}mm;max-height:${PAPER_HEIGHT}mm;box-shadow:none;margin:0;break-inside:avoid;page-break-inside:avoid}.print-frame>.content{display:none}.print-canvas{display:block;width:100%;height:100%;position:absolute;inset:0}body.fit-error .sheet{visibility:hidden}}
</style></head><body><div class="toolbar"><button id="print" disabled>打印/保存 PDF</button><a href="?mode=${overlay?'full':'overlay'}">切换${overlay?'完整单据':'预印纸套打'}模板</a><small>固定241×140mm横版;打印窗口也选241×140mm,关闭页眉页脚。${overlay?'套打位置仍需按实物纸样校准。':''}</small><small id="fit-status" role="status">正在调整为一页…</small></div>${body}<script src="/print.js"></script></body></html>`;
}
+1 -1
View File
@@ -23,7 +23,7 @@
}finally{measure.remove();}
}
function failed(){document.body.classList.add('fit-error');button.disabled=true;status.textContent='页面暂未排好,请刷新后再打印。';return false;}
// 屏幕与打印统一使用固定纸型;明细较多时保留全部商品、附加项和尾部内容。
// 屏幕与打印统一使用模板的放大字号和紧凑留白;仍完整保留全部商品、附加项和尾部内容。
function fit(){
if(printing||printMedia.matches)return true;
try{
+1
View File
@@ -154,6 +154,7 @@
- 「完整单据」有店名、表格、金额大写、经办人栏和麦麦提供纸单中的注意事项、珠宝首饰保养须知及公司承诺;已按最新要求删除免费维修/清洗/抛光及人为损坏只收配件费的整条承诺。可用普通纸试印或在Chrome/Edge中保存PDF。
- 「预印纸套打」隐藏已印标题和表格线,保留填写内容。目前是可调初稿,没有纸样和机器,不能保证与旧单格线对齐。
- 单据固定为241×140mm横版,设置中不再提供纸宽高。旧设置和旧客户端传入的尺寸均不会改变这一纸型。全部明细、长备注、注意事项和经办人统一排为一页,行数多时自动缩小;表格最少行数只用于补空行。
- 普通单的整体字号按原来的约1.2倍放大,同时收紧标题、合计、注意事项和签名之间的空隙。屏幕预览和打印使用同一套字号与间距;明细或备注较多时仍会缩小,以完整保留所有内容为先。
- 店名、标题、联系信息、上下左右偏移、内容距顶部和行高仍可调整,套打按实物纸样校准。
- 打印窗口也选241×140mm,打印比例100%,关闭页眉页脚。先保存PDF核对完整性,再用店内纸张和打印机试打;若驱动只提供A4,仍需先配置支持实际纸型的驱动。软件排成一页不等于打印机已经按一张连续纸走纸,实体打印须以现场结果验收。
- 打印、取消打印或补打不会改变库存或收入。日志只记录“打开打印页”,不会冒充打印成功。