Prechádzať zdrojové kódy

feat(web-admin): support per-row planNo and multiline remarks on slip templates

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu 3 mesiacov pred
rodič
commit
e930e583a9

+ 5 - 3
web-admin/src/utils/pl-delivery-slip-template.ts

@@ -1,4 +1,6 @@
 import type { Plan, PlanProduct } from '@/api/pl'
 import type { Plan, PlanProduct } from '@/api/pl'
+import type { SlipPlanProduct } from '@/utils/pl-batch-print'
+import { formatRemarkForSlipHtml } from '@/utils/pl-batch-print'
 import { applyPdfStableTableCellBorders } from '@/utils/pl-slip-pdf-render'
 import { applyPdfStableTableCellBorders } from '@/utils/pl-slip-pdf-render'
 
 
 /** 送(提)货单打印默认公司信息(可在富文本中修改) */
 /** 送(提)货单打印默认公司信息(可在富文本中修改) */
@@ -175,10 +177,10 @@ function buildProductRows(
     return `<tr><td class="delivery-slip-product-cell" colspan="8" style="${PRODUCT_CELL}">暂无产品信息</td></tr>`
     return `<tr><td class="delivery-slip-product-cell" colspan="8" style="${PRODUCT_CELL}">暂无产品信息</td></tr>`
   }
   }
 
 
-  const planNoText = formatDeliverySlipProductGridCellContent(planNo)
-
   const dataRows = products
   const dataRows = products
     .map((product) => {
     .map((product) => {
+      const rowPlanNo = (product as SlipPlanProduct).slipPlanNo || planNo
+      const planNoText = formatDeliverySlipProductGridCellContent(rowPlanNo)
       const qty = product.outboundQty ?? product.outboundEstimateQty ?? product.quantity ?? ''
       const qty = product.outboundQty ?? product.outboundEstimateQty ?? product.quantity ?? ''
       return `<tr>
       return `<tr>
         <td class="delivery-slip-product-cell delivery-slip-product-grid-cell" style="${PRODUCT_GRID_CELL}">${planNoText}</td>
         <td class="delivery-slip-product-cell delivery-slip-product-grid-cell" style="${PRODUCT_GRID_CELL}">${planNoText}</td>
@@ -1800,7 +1802,7 @@ export function replaceDeliverySlipPlaceholders(
     '{{driverInfo}}': '',
     '{{driverInfo}}': '',
     '{{planDateChinese}}': formatPlanDateChinese(plan.planDate),
     '{{planDateChinese}}': formatPlanDateChinese(plan.planDate),
     '{{productTable}}': buildProductRows(plan.products, plan.planNo || '', ctx),
     '{{productTable}}': buildProductRows(plan.products, plan.planNo || '', ctx),
-    '{{remark}}': plan.remark || '',
+    '{{remark}}': formatRemarkForSlipHtml(plan.remark),
     '{{companyAddress}}': DELIVERY_SLIP_DEFAULTS.companyAddress,
     '{{companyAddress}}': DELIVERY_SLIP_DEFAULTS.companyAddress,
     '{{companyPhone}}': DELIVERY_SLIP_DEFAULTS.companyPhone,
     '{{companyPhone}}': DELIVERY_SLIP_DEFAULTS.companyPhone,
     '{{contactPhone}}': DELIVERY_SLIP_DEFAULTS.contactPhone,
     '{{contactPhone}}': DELIVERY_SLIP_DEFAULTS.contactPhone,

+ 5 - 3
web-admin/src/utils/pl-inbound-slip-template.ts

@@ -1,4 +1,6 @@
 import type { Plan, PlanProduct } from '@/api/pl'
 import type { Plan, PlanProduct } from '@/api/pl'
+import type { SlipPlanProduct } from '@/utils/pl-batch-print'
+import { formatRemarkForSlipHtml } from '@/utils/pl-batch-print'
 import { applyPdfStableTableCellBorders } from '@/utils/pl-slip-pdf-render'
 import { applyPdfStableTableCellBorders } from '@/utils/pl-slip-pdf-render'
 
 
 /** 入库单打印默认公司信息(可在富文本中修改) */
 /** 入库单打印默认公司信息(可在富文本中修改) */
@@ -173,10 +175,10 @@ function buildProductRows(
     return `<tr><td class="inbound-slip-product-cell" colspan="8" style="${PRODUCT_CELL}">暂无产品信息</td></tr>`
     return `<tr><td class="inbound-slip-product-cell" colspan="8" style="${PRODUCT_CELL}">暂无产品信息</td></tr>`
   }
   }
 
 
-  const planNoText = formatInboundSlipProductGridCellContent(planNo)
-
   const dataRows = products
   const dataRows = products
     .map((product) => {
     .map((product) => {
+      const rowPlanNo = (product as SlipPlanProduct).slipPlanNo || planNo
+      const planNoText = formatInboundSlipProductGridCellContent(rowPlanNo)
       const qty = product.inboundQty ?? product.inboundEstimateQty ?? product.quantity ?? ''
       const qty = product.inboundQty ?? product.inboundEstimateQty ?? product.quantity ?? ''
       return `<tr>
       return `<tr>
         <td class="inbound-slip-product-cell inbound-slip-product-grid-cell" style="${PRODUCT_GRID_CELL}">${planNoText}</td>
         <td class="inbound-slip-product-cell inbound-slip-product-grid-cell" style="${PRODUCT_GRID_CELL}">${planNoText}</td>
@@ -1364,7 +1366,7 @@ export function replaceInboundSlipPlaceholders(
     '{{driverInfo}}': '',
     '{{driverInfo}}': '',
     '{{planDateChinese}}': formatPlanDateChinese(plan.planDate),
     '{{planDateChinese}}': formatPlanDateChinese(plan.planDate),
     '{{productTable}}': buildProductRows(plan.products, plan.planNo || '', ctx),
     '{{productTable}}': buildProductRows(plan.products, plan.planNo || '', ctx),
-    '{{remark}}': plan.remark || '',
+    '{{remark}}': formatRemarkForSlipHtml(plan.remark),
     '{{companyAddress}}': INBOUND_SLIP_DEFAULTS.companyAddress,
     '{{companyAddress}}': INBOUND_SLIP_DEFAULTS.companyAddress,
     '{{companyPhone}}': INBOUND_SLIP_DEFAULTS.companyPhone,
     '{{companyPhone}}': INBOUND_SLIP_DEFAULTS.companyPhone,
     '{{contactPhone}}': INBOUND_SLIP_DEFAULTS.contactPhone,
     '{{contactPhone}}': INBOUND_SLIP_DEFAULTS.contactPhone,

+ 2 - 1
web-admin/src/utils/pl-subpack-slip-template.ts

@@ -1,4 +1,5 @@
 import type { Plan, PlanProduct } from '@/api/pl'
 import type { Plan, PlanProduct } from '@/api/pl'
+import { formatRemarkForSlipHtml } from '@/utils/pl-batch-print'
 import { applyPdfStableTableCellBorders } from '@/utils/pl-slip-pdf-render'
 import { applyPdfStableTableCellBorders } from '@/utils/pl-slip-pdf-render'
 
 
 /** 分装单打印默认公司信息(可在富文本中修改) */
 /** 分装单打印默认公司信息(可在富文本中修改) */
@@ -2119,7 +2120,7 @@ export function replaceSubpackSlipPlaceholders(
     '{{driverInfo}}': '',
     '{{driverInfo}}': '',
     '{{planDateChinese}}': '',
     '{{planDateChinese}}': '',
     '{{productTable}}': buildProductRows(plan.products, ctx),
     '{{productTable}}': buildProductRows(plan.products, ctx),
-    '{{remark}}': plan.remark || '',
+    '{{remark}}': formatRemarkForSlipHtml(plan.remark),
     '{{remarkExtra}}': '',
     '{{remarkExtra}}': '',
     '{{companyAddress}}': '',
     '{{companyAddress}}': '',
     '{{companyPhone}}': '',
     '{{companyPhone}}': '',