From 13dd73069e004adfe6045ea26ba0babff0b8c590 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Fri, 4 Sep 2026 10:28:58 +0800 Subject: [PATCH] fix: align sofia certificate print fields --- .../barcodePrintCertificate.test.ts | 46 +++++++++++++++++++ .../barcode-print/barcodePrintCertificate.ts | 5 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.test.ts b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.test.ts index 4b85070a..523d11c6 100644 --- a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.test.ts +++ b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.test.ts @@ -1,6 +1,52 @@ import { __barcodePrintCertificateTestUtils } from "./barcodePrintCertificate"; import { SOFIA_CARTON_BARCODE_QR_LAYOUT } from "./barcodePrintSofiaCartonLayout"; +describe("Sofia certificate field positioning", () => { + afterEach(() => { + jest.useRealTimers(); + }); + + it("moves all six values upward by three rows without changing their data or horizontal layout", () => { + jest.useFakeTimers().setSystemTime(new Date("2026-09-04T12:00:00.000Z")); + const element = __barcodePrintCertificateTestUtils.renderSofiaCertificate( + { + barcode: "GBSFY-SJ038036N1410V01", + productCategory: "书架", + color: "经典北美黑胡桃色", + procode: "SFY-001", + brandProcode: "SFY-BRAND-001", + size: "100*40*180", + productSpec: "100*40*180", + hangtagMaterial: "人造板", + qualifiedCertMainMaterial: "人造板", + executionStandard: "GB/T 3324-2017", + }, + "", + {}, + "data:image/png;base64,background", + ); + const values = Array.from(element.querySelectorAll(".item")); + + expect(values.map((value) => value.style.top)).toEqual([ + "200px", + "266px", + "332px", + "398px", + "464px", + "530px", + ]); + expect(values.map((value) => value.style.left)).toEqual(Array(6).fill("310px")); + expect(values.map((value) => value.textContent)).toEqual([ + "书架-经典北美黑胡桃色", + "SFY-001", + "100*40*180", + "GB/T 3324-2017", + "QC01", + "2026-08-25", + ]); + }); +}); + describe("Sofia carton certificate rendering", () => { it("renders the current barcode QR code to the left of the fixed official-account QR code", () => { const qrCodeDataUrl = "data:image/png;base64,barcode-qr"; diff --git a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.ts b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.ts index 60f24249..07e5f46b 100644 --- a/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.ts +++ b/furniture-3d-system/src/app/intake/barcode-print/barcodePrintCertificate.ts @@ -110,6 +110,8 @@ const PORTRAIT_FIELD_TOP = 883; const PORTRAIT_FIELD_ROW_GAP = 68; const PORTRAIT_RIGHT_FIRST_ROW_TOP_OFFSET = 0; const PORTRAIT_VALUE_VISUAL_OFFSET = -8; +const SOFIA_CERTIFICATE_FIELD_TOP = 200; +const SOFIA_CERTIFICATE_FIELD_ROW_GAP = 66; function trimText(value: unknown) { return String(value ?? "").trim(); @@ -524,7 +526,7 @@ function renderSofiaCertificate( color: "#000000", lineHeight: "32px", left: "310px", - top: `${398 + index * 66}px`, + top: `${SOFIA_CERTIFICATE_FIELD_TOP + index * SOFIA_CERTIFICATE_FIELD_ROW_GAP}px`, }); }); @@ -641,6 +643,7 @@ export const __barcodePrintCertificateTestUtils = { getLandscapeProductNameFontSize, renderCommonWithMaker, renderCommonWithoutMaker, + renderSofiaCertificate, renderSofiaCarton, };