import {renderTemplate} from '@/components/print/tools'; export function template60_40(model = {}, title = '') { const template = renderTemplate.bind(this, model); const width = 227; const height = 151; const margin = 6; this.PRINT_INITA(0, 0, width, height, title); // 宽度按纸张的整宽缩放 this.SET_PRINT_MODE('PRINT_PAGE_PERCENT', 'Full-Width'); this.SET_PRINT_MODE('FULL_WIDTH_FOR_OVERFLOW', true); this.SET_PRINT_MODE('FULL_HEIGHT_OVERFLOW', true); // 设置输出位置以纸张边缘为基点 this.SET_PRINT_MODE('POS_BASEON_PAPER', true); let x = margin, y = margin; let w = 0, h = 0; this.SET_PRINT_STYLE('Alignment', 2); w = 215; h = 20; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{record.title}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); y += h; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{record.no}}`)); y += h; w = 115; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{patient.name}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); x += w; w = 30; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{recipe.count}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); x += w; w = 20; this.ADD_PRINT_TEXT(y, x, w, h, '帖'); x += w; w = 30; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{recipe.total}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); x += w; w = 20; this.ADD_PRINT_TEXT(y, x, w, h, '包'); this.SET_PRINT_STYLE('Alignment', 1); y += h; x = margin; w = 60; this.ADD_PRINT_TEXT(y, x, w, h, '备注:'); this.SET_PRINT_STYLE('Alignment', 2); x += w - 2; w = 60; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{recipe.volume}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); x += w; w = 50; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{recipe.method}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); x += w; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{recipe.decoction}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); this.SET_PRINT_STYLE('Alignment', 1); this.ADD_PRINT_TEXT(86, margin, 170, 44, template(`{{record.remark}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 8); if (model.record.no) this.ADD_PRINT_BARCODE(99, 175, 46, 46, 'QRCode', model.record.no); y = 130; x = margin; w = 70; h = 20; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{recipe.delivery}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); x += w; w = 100; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{record.date}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); } export function template80_50(model = {}, title = '') { const template = renderTemplate.bind(this, model); const width = 302; const height = 189; const margin = 12; this.PRINT_INITA(0, 0, width, height, title); // 宽度按纸张的整宽缩放 this.SET_PRINT_MODE('PRINT_PAGE_PERCENT', 'Full-Width'); this.SET_PRINT_MODE('FULL_WIDTH_FOR_OVERFLOW', true); this.SET_PRINT_MODE('FULL_HEIGHT_OVERFLOW', true); // 设置输出位置以纸张边缘为基点 this.SET_PRINT_MODE('POS_BASEON_PAPER', true); let x = margin, y = margin; let w = 0, h = 0; w = 290; h = 20; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{record.title}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); y += h; w = 196; this.ADD_PRINT_TEXT(y, x, w, h, '中药煎药取药凭证'); y += h; w = 50; this.ADD_PRINT_TEXT(y, x, w, h, '病历号'); x += w - 1; w = 100; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{record.medicalRecordNumber}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); x += w - 3; w = 50; this.ADD_PRINT_TEXT(y, x, w, h, '处方号'); x += w - 6; w = 94 + 6; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{record.no}}`)); this.SET_PRINT_STYLEA(0, 'Bold', 1); y += h; x = margin; w = 50; this.ADD_PRINT_TEXT(y, x, w, h, '姓名:'); x += w; w = 146 + 6; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{patient.name}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 12); this.SET_PRINT_STYLEA(0, 'Bold', 1); x += w; w = 44; this.ADD_PRINT_TEXT(y, x, w, h, '贴数'); this.SET_PRINT_STYLEA(0, 'Alignment', 2); x += w; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{recipe.count}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 12); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Bold', 1); y += h; x = margin; h = 44; this.ADD_PRINT_TEXT(y, x, 230, h, template(`地址:{{recipe.address}}`)); y += h; x = margin; h = 20; w = 50; this.ADD_PRINT_TEXT(y, x, w, h, '取药:'); x += w; this.ADD_PRINT_TEXT(y, x, 130, h, template(`{{department}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 10); this.SET_PRINT_STYLEA(0, 'Bold', 1); y += h; x = margin; this.ADD_PRINT_TEXT(y, x, 180, h, template(`{{record.remark}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 8); y += h - 4; x = margin; this.ADD_PRINT_TEXT(y, x, 180, h, template(`{{recipe.method}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 10); this.SET_PRINT_STYLEA(0, 'Bold', 1); this.ADD_PRINT_TEXT(98, 236, 60, 20, template(`{{recipe.delivery}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 12); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Bold', 1); if (model.record.no) this.ADD_PRINT_BARCODE(133, 189, 107, 50, '128Auto', model.record.no); } /** * A5 纸 96 PPI (559px * 794px) * * @param model * @param title */ export function templateA5(model = {}, title = '') { const template = renderTemplate.bind(this, model); const size = 40; const width = 559; const height = 794; const margin = 12; this.PRINT_INITA(0, 0, width, height, title); // 宽度按纸张的整宽缩放 this.SET_PRINT_MODE('PRINT_PAGE_PERCENT', 'Full-Width'); // 设置输出位置以纸张边缘为基点 this.SET_PRINT_MODE('POS_BASEON_PAPER', true); const chunks = (function (array, size = 32) { let result = []; for (let i = 0; i < array.length; i += size) {result.push(array.slice(i, i + size));} return result; })(model.recipe['medicines'], size); if (!chunks.length) chunks.push([]); const single = chunks.length === 1; for (const chunk of chunks) { let x = margin, y = margin; let w = 0, h = 0, offset = 0; // 绘制头部 this.ADD_PRINT_TEXT(y, x, 310, 26, template(`{{record.title}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 12); this.SET_PRINT_STYLEA(0, 'Bold', 1); y = 37; this.ADD_PRINT_TEXT(y, 117, 100, 20, template(`{{recipe.type}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.ADD_PRINT_TEXT(y, 12, 100, 20, template(`{{recipe.decoction}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 12); this.SET_PRINT_STYLEA(0, 'Bold', 1); this.ADD_PRINT_TEXT(y, 222, 100, 20, template(`{{record.serialNumber}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Bold', 1); if (model.record.no) this.ADD_PRINT_BARCODE(12, 331, 216, 50, '128Auto', model.record.no); // 绘制顶部信息 y = 66; h = 20; offset = 2; this.ADD_PRINT_TEXT(y, 12, 45, h, '姓名:'); this.ADD_PRINT_TEXT(y, 151, 60, h, template(`性别:{{patient.gender}}`)); this.ADD_PRINT_TEXT(y, 211, 80, h, template(`年龄:{{patient.age}}`)); this.ADD_PRINT_TEXT(y, 291, 100, h, template(`床号:{{record.bedNo}}`)); this.ADD_PRINT_TEXT(y - 6, 56, 96, h + 6, template(`{{patient.name}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 12); this.SET_PRINT_STYLEA(0, 'Bold', 1); y += h + offset; this.ADD_PRINT_TEXT(y, 12, 200, h, template(`科室:{{department}}`)); this.ADD_PRINT_TEXT(y, 211, 150, h, template(`病历号:{{record.recordNo}}`)); this.ADD_PRINT_TEXT(y, 360, 185, h, template(`开方日期:{{record.date}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); y += h + offset; h = 34; this.ADD_PRINT_TEXT(y, 12, 418, h, template(`地址:{{recipe.address}}`)); this.ADD_PRINT_TEXT(y, 430, 120, h, template(`电话:{{patient.phone}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); y += h; this.ADD_PRINT_TEXT(y, 12, 418, h, template(`临床诊断:{{diagnosis}}`)); this.ADD_PRINT_TEXT(y, 430, 120, h, template(`{{recipe.delivery}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 12); this.SET_PRINT_STYLEA(0, 'Bold', 1); this.SET_PRINT_STYLEA(0, 'Alignment', 3); // 分割线 this.ADD_PRINT_SHAPE(4, 178, 12, 535, 1, 0, 1, '#000000'); y = 188; this.ADD_PRINT_TEXT(y, 48, 120, 20, '药品名'); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Bold', 1); this.ADD_PRINT_TEXT(y, 168, 50, 20, '单帖量'); this.SET_PRINT_STYLEA(0, 'Alignment', 3); this.SET_PRINT_STYLEA(0, 'Bold', 1); this.ADD_PRINT_TEXT(y, 220, 48, 20, '用法'); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Bold', 1); if (chunk.length > 1) { this.ADD_PRINT_TEXT(y, 291, 120, 20, '药品名'); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Bold', 1); this.ADD_PRINT_TEXT(y, 411, 50, 20, '单贴量'); this.SET_PRINT_STYLEA(0, 'Alignment', 3); this.SET_PRINT_STYLEA(0, 'Bold', 1); this.ADD_PRINT_TEXT(y, 463, 48, 20, '用法'); this.SET_PRINT_STYLEA(0, 'Bold', 1); } // 绘制药品 chunk.forEach((medicine, i) => { const template = renderTemplate.bind(this, medicine); if (i % 2) { x = 291; } else { y += 20 + 2; x = 48; } this.ADD_PRINT_TEXT(y, x, 120, 20, template(`{{name}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); x += 120; this.ADD_PRINT_TEXT(y, x, 50, 20, template(`{{dosage}}{{unit}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); x += 50 + 2; this.ADD_PRINT_TEXT(y, x, 48, 16, template(`{{usage}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 6); this.SET_PRINT_STYLEA(0, 'Alignment', 2); }); y += 20 + 2 + 12; this.ADD_PRINT_TEXT(y, 12, 536, 40, template(`{{record.remark}}`)); y += 40; x = margin; h = 20; w = 130; this.ADD_PRINT_TEXT(y, x, w, h, template(`用法:{{recipe.method}}`)); this.ADD_PRINT_TEXT(y, width - margin - w, w, 40, template(`{{recipe.volume}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 12); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Bold', 1); y += h; x = margin; h = 20; w = 130; offset = 5; this.ADD_PRINT_TEXT(y, x, w, h, template(`金额:{{recipe.totalFees}} 元`)); x += w + offset; this.ADD_PRINT_TEXT(y, x, w, h, template(`共 {{recipe.count}} 剂`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); x += w + offset; this.ADD_PRINT_TEXT(y, x, w, h, template(`煎 {{recipe.count}} 剂`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); y += h; x = margin; this.ADD_PRINT_TEXT(y, x, w, h, template(`医生:{{sign.field1}}`)); x += w + offset; this.ADD_PRINT_TEXT(y, x, w, h, template(`单剂重量:{{recipe.unitWeight}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); x += w + offset; this.ADD_PRINT_TEXT(y, x, w, h, template(`总重量:{{recipe.totalWeight}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); y += h; x = margin; this.ADD_PRINT_TEXT(y, x, w, h, template(`审方人:{{sign.field2}}`)); x += w + offset; this.ADD_PRINT_TEXT(y, x, w, h, template(`配药人:{{sign.field3}}`)); x += w + offset; this.ADD_PRINT_TEXT(y, x, w, h, template(`复核人:{{sign.field4}}`)); x += w + offset; this.ADD_PRINT_TEXT(y, x, w, h, template(`煎药人:{{sign.field6}}`)); if (!single) this.NEWPAGEA(); } } /** * 药品明细清单 * @param model * @param title */ export function template72(model, title) { const template = renderTemplate.bind(this, model); const width = 272; const height = 794; const margin = 0; this.PRINT_INITA(0, 0, width, height, title); // 宽度按纸张的整宽缩放 this.SET_PRINT_MODE('PRINT_PAGE_PERCENT', 'Full-Width'); // 设置输出位置以纸张边缘为基点 this.SET_PRINT_MODE('POS_BASEON_PAPER', true); let x = margin, y = margin; let w = 0, h = 0; w = 60; h = 20; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{recipe.delivery}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Bold', 1); x += w; h = 30; this.ADD_PRINT_TEXT(y, x, width - x - margin, h, template(`{{record.title}}`)); this.SET_PRINT_STYLEA(0, 'FontSize', 12); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Bold', 1); x = margin; y += h; h = 36; this.ADD_PRINT_TEXT(y, x, width - x - margin, h, template(`{{recipe.address}}`)); this.SET_PRINT_STYLEA(0, 'Underline', 1); x = margin; y += h; w = 118; h = 20; this.ADD_PRINT_TEXT(y, x, w, h, template(`序号:{{bedNo}}`)); x += w; this.ADD_PRINT_TEXT(y, x, width - x - margin, h, template(`处方号:{{record.no}}`)); y += h; x = margin; this.ADD_PRINT_TEXT(y, x, 118, h, template(`姓名:{{patient.name}}`)); this.ADD_PRINT_TEXT(y, 118, 75, 20, template(`{{recipe.method}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Underline', 1); this.ADD_PRINT_TEXT(y, 197, 75, 20, template(`{{recipe.decoction}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.SET_PRINT_STYLEA(0, 'Underline', 1); y += h; x = margin; h = 96; if (model.record.no) this.ADD_PRINT_BARCODE(y, x, h, h, 'QRCode', model.record.no); x = 94; h = 45; this.ADD_PRINT_TEXT(y, x, 178, h, template(`备注:{{record.remark}}`)); y += h; this.ADD_PRINT_TEXT(y, x, 178, h, template(`另包:`)); x = margin; y += h; w = 72; h = 20; this.ADD_PRINT_TEXT(y, x, w, h, `药味:${model.recipe.medicines.length}`); x += w; w = 100; this.ADD_PRINT_TEXT(y, x, w, h, template(`帖重:{{recipe.unitWeight}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); x += w; this.ADD_PRINT_TEXT(y, x, w, h, template(`总重:{{recipe.totalWeight}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); x = margin; y += h; w = 100; this.ADD_PRINT_TEXT(y, x, w, h, template(`开单:{{doctor}}`)); x += w; this.ADD_PRINT_TEXT(y, x, width - x - margin, h, template(`共 {{recipe.count}} 帖 煎 {{recipe.total}} 包`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); y += h; this.ADD_PRINT_SHAPE(4, y, 0, 278, 1, 0, 1, '#000000'); x = margin; y += 8; w = 178; h = 20; this.ADD_PRINT_TEXT(y, x, w, h, [ template(`{{recipe.frequency}}`), template(`{{recipe.frequencyTime}}`), ].filter(Boolean).join(',')); w = 100; this.ADD_PRINT_TEXT(y, width - w - margin, w, h, template(`装量:{{recipe.totalVolume}} ML`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); y += h - 2; this.ADD_PRINT_SHAPE(4, y, 0, 278, 1, 0, 1, '#000000'); y += 10; this.ADD_PRINT_TEXT(y, 0, 60, 20, '斗号'); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.ADD_PRINT_TEXT(y, 53, 86, 20, '品名'); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.ADD_PRINT_TEXT(y, 136, 36, 20, '单帖'); this.SET_PRINT_STYLEA(0, 'Alignment', 3); this.ADD_PRINT_TEXT(y, 166, 36, 20, '总量'); this.SET_PRINT_STYLEA(0, 'Alignment', 3); this.ADD_PRINT_TEXT(y, 196, 36, 20, '单位'); this.SET_PRINT_STYLEA(0, 'Alignment', 3); this.ADD_PRINT_TEXT(y, 228, 44, 20, '特煎'); this.SET_PRINT_STYLEA(0, 'Alignment', 3); y += 20; this.ADD_PRINT_SHAPE(4, y, 0, 278, 1, 0, 1, '#000000'); y = 285 + h; this.SET_PRINT_STYLE('FontSize', 8); model.recipe.medicines.forEach((medicine, i) => { const template = renderTemplate.bind(this, medicine); x = margin; w = 54; h = 30; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{mark}}`)); x += w - 1; w = 86; this.ADD_PRINT_TEXT(y, x, w, h, template(`{{name}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 2); this.ADD_PRINT_TEXT(y, 132, 40, h, template(`{{dosage}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); this.ADD_PRINT_TEXT(y, 164, 40, h, template(`{{total}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); this.ADD_PRINT_TEXT(y, 200, 22, h, template(`{{unit}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); this.ADD_PRINT_TEXT(y, 222, 50, h, template(`{{usage}}`)); this.SET_PRINT_STYLEA(0, 'Alignment', 3); y += h + 2; }); this.SET_PRINT_STYLE('FontSize', 9); // y += 2; this.ADD_PRINT_SHAPE(4, y, 0, 278, 1, 0, 1, '#000000'); }