diff --git a/web-admin/src/components/business/pl-plan-arrange-dialog/index.vue b/web-admin/src/components/business/pl-plan-arrange-dialog/index.vue index df5e971cb..6a1b7aa17 100644 --- a/web-admin/src/components/business/pl-plan-arrange-dialog/index.vue +++ b/web-admin/src/components/business/pl-plan-arrange-dialog/index.vue @@ -273,24 +273,38 @@ > 复制磅单二维码 - - 入库单 - - - 送(提)货单 - - - 分装单 - + + 打印单据 + + + + diff --git a/web-admin/src/utils/pl-delivery-slip-template.ts b/web-admin/src/utils/pl-delivery-slip-template.ts index f978afb56..01c956a97 100644 --- a/web-admin/src/utils/pl-delivery-slip-template.ts +++ b/web-admin/src/utils/pl-delivery-slip-template.ts @@ -29,17 +29,18 @@ const INFO_COLGROUP = ` ` /** - * 物料表列宽:加宽编号/名称,收窄规格/单位;前 5 列合计供条款区使用。 - * 物料编号 / 物料名称 / 规格 / 单位 / 数量 / 产品规格 / 实收数量 + * 物料表列宽:单据编号 + 加宽编号/名称,收窄规格/单位;前 5 列合计供条款区使用。 + * 单据编号 / 物料编号 / 物料名称 / 规格 / 单位 / 数量 / 产品规格 / 实收数量 */ const PRODUCT_COLGROUP = ` - - + + + - - - + + + ` /** 物料网格 padding(编辑器预览) */ @@ -87,9 +88,9 @@ const INFO_VALUE_INLINE_LEFT = `flex:1;min-width:0;box-sizing:border-box;border- const INFO_VALUE_INLINE_CENTER = `flex:1;min-width:0;box-sizing:border-box;border-bottom:${INFO_UNDERLINE} !important;padding:0 2px 2px;text-align:center;min-height:1.3em;` const INFO_CELL_LEFT = `${NO_BORDER}text-align:left;` const INFO_CELL_RIGHT = `${NO_BORDER}text-align:left;` -const INFO_GAP_BEFORE_PRODUCT = 24 +const INFO_GAP_BEFORE_PRODUCT = 12 const GAP_BEFORE_PRODUCT_CELL = `border:none !important;padding:0 !important;line-height:0 !important;font-size:0 !important;background:transparent !important;height:${INFO_GAP_BEFORE_PRODUCT}px !important;min-height:${INFO_GAP_BEFORE_PRODUCT}px !important;` -const INFO_GAP_BEFORE_SIGN = 24 +const INFO_GAP_BEFORE_SIGN = 12 const GAP_BEFORE_SIGN_CELL = `border:none !important;padding:0 !important;line-height:0 !important;font-size:0 !important;background:transparent !important;height:${INFO_GAP_BEFORE_SIGN}px !important;min-height:${INFO_GAP_BEFORE_SIGN}px !important;` const SIDE_LABELS_COL_WIDTH = 36 @@ -99,7 +100,7 @@ function buildDeliverySlipSignItem(label: string, valueContent: string, minWidth function buildDeliverySlipSignRowHtml(): string { return ` - +
${buildDeliverySlipSignItem('仓库:', ' ', '80px')} ${buildDeliverySlipSignItem('审核:', ' ', '80px')} @@ -165,15 +166,22 @@ function formatDeliverySlipProductGridCellContent(content: string): string { return plain || ' ' } -function buildProductRows(products: PlanProduct[] = [], ctx?: DeliverySlipRenderContext): string { +function buildProductRows( + products: PlanProduct[] = [], + planNo = '', + ctx?: DeliverySlipRenderContext +): string { if (!products.length) { - return `暂无产品信息` + return `暂无产品信息` } + const planNoText = formatDeliverySlipProductGridCellContent(planNo) + const dataRows = products .map((product) => { const qty = product.outboundQty ?? product.outboundEstimateQty ?? product.quantity ?? '' return ` + ${planNoText} ${formatDeliverySlipProductGridCellContent(resolveSlipProductCode(product, ctx))} ${formatDeliverySlipProductGridCellContent(product.productName || '')} ${formatDeliverySlipProductGridCellContent(product.model || '')} @@ -220,13 +228,14 @@ export const DELIVERY_SLIP_PRINT_CSS = ` flex: 1 !important; min-width: 0 !important; display: flex !important; - flex-wrap: wrap !important; + flex-wrap: nowrap !important; justify-content: flex-start !important; align-items: center !important; - gap: 14px 18px !important; + gap: 10px 12px !important; box-sizing: border-box !important; font-size: 20px !important; line-height: 1.35 !important; + white-space: nowrap !important; } .delivery-slip-doc .delivery-slip-type-check-item { display: inline-flex !important; @@ -577,17 +586,44 @@ const SIDE_LABEL_CELL = `border:none !important;padding:0 !important;vertical-al const DELIVERY_SLIP_TYPE_CHECK_WRAP_STYLE = `${INFO_ROW}margin-top:-8px;margin-bottom:20px;` const DELIVERY_SLIP_TYPE_CHECK_INNER_STYLE = - 'flex:1;min-width:0;display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;gap:14px 18px;box-sizing:border-box;font-size:20px;line-height:1.35;' + 'flex:1;min-width:0;display:flex;flex-wrap:nowrap;justify-content:flex-start;align-items:center;gap:10px 12px;box-sizing:border-box;font-size:20px;line-height:1.35;white-space:nowrap;' function buildDeliverySlipTypeCheckboxesHtml(): string { const item = (label: string) => `` return `
- 单据编号: + 日 期:
${item('自提')}${item('出库')}${item('直销')}
` } +function buildDeliverySlipInfoTableHtml(): string { + return ` + ${INFO_COLGROUP} + + + + + +
+
+ 收货单位: + {{receivingUnit}}  +
+
+
+ 收货联系方式: + {{receiveContact}}  +
+
+ ${buildDeliverySlipTypeCheckboxesHtml()} +
+ 日 期: + {{planDateChinese}}  +
+
` +} + function buildDeliverySlipTermsHtml(): string { return `
1.本送货单如购销双方未签订合同,视为有效;
@@ -622,38 +658,7 @@ export function generateDeliverySlipTemplate(_plan?: Plan): string { - - ${INFO_COLGROUP} - - - - - - - - -
-
- 收货单位: - {{receivingUnit}}  -
-
- ${buildDeliverySlipTypeCheckboxesHtml()} -
- 单据编号: - {{planNo}}  -
-
-
- 收货联系方式: - {{receiveContact}}  -
-
-
- 日 期: - {{planDateChinese}}  -
-
+ ${buildDeliverySlipInfoTableHtml()}
 
@@ -661,6 +666,7 @@ export function generateDeliverySlipTemplate(_plan?: Plan): string { ${PRODUCT_COLGROUP} + @@ -671,7 +677,7 @@ export function generateDeliverySlipTemplate(_plan?: Plan): string { {{productTable}} - @@ -679,7 +685,7 @@ export function generateDeliverySlipTemplate(_plan?: Plan): string { - @@ -781,7 +787,7 @@ function patchDeliverySlipProductGridCellAttrs(attrs: string): string { function normalizeDeliverySlipProductGridCell(html: string): string { if (!html.includes('delivery-slip-doc') || !html.includes('delivery-slip-product-cell')) return html - let result = html.replace(/]*)>\s*(\s*){7}\s*<\/tr>/g, (rowMatch) => { + let result = html.replace(/]*)>\s*(\s*){8}\s*<\/tr>/g, (rowMatch) => { if (!rowMatch.includes('物料编号') || rowMatch.includes('colspan')) return rowMatch let row = rowMatch.includes('delivery-slip-product-header') ? rowMatch @@ -791,7 +797,7 @@ function normalizeDeliverySlipProductGridCell(html: string): string { }) }) - result = result.replace(/]*)>\s*(]*colspan)[^>]*>[\s\S]*?<\/td>\s*){7}\s*<\/tr>/g, (rowMatch) => { + result = result.replace(/]*)>\s*(]*colspan)[^>]*>[\s\S]*?<\/td>\s*){8}\s*<\/tr>/g, (rowMatch) => { if ( rowMatch.includes('备注') || rowMatch.includes('1.本送货单') || @@ -1120,9 +1126,10 @@ function normalizeDeliverySlipProductTableFooter(html: string): string { let result = html - result = result.replace(/]*colspan="7"[^>]*)>(\s*)备注:/g, (_match, attrs, space) => { + result = result.replace(/]*colspan="[78]"[^>]*)>(\s*)备注:/g, (_match, attrs, space) => { + const withSpan = String(attrs).replace(/colspan="[78]"/, 'colspan="8"') const patched = patchProductFooterCellAttrs( - attrs, + withSpan, 'delivery-slip-product-cell', PRODUCT_TABLE_CELL_LEFT ) @@ -1130,9 +1137,9 @@ function normalizeDeliverySlipProductTableFooter(html: string): string { }) result = result.replace( - /]*colspan="[45]"[^>]*)>\s*(
]*colspan="[456]"[^>]*)>\s*(
{ - const withSpan = String(attrs).replace(/colspan="[45]"/, 'colspan="5"') + const withSpan = String(attrs).replace(/colspan="[456]"/, 'colspan="5"') const patched = patchProductFooterCellAttrs( withSpan, 'delivery-slip-product-cell delivery-slip-terms-cell', @@ -1145,7 +1152,7 @@ function normalizeDeliverySlipProductTableFooter(html: string): string { result = result.replace( /]*colspan="[23]"[^>]*)>\s*
{ - const withSpan = String(attrs).replace(/colspan="[23]"/, 'colspan="2"') + const withSpan = String(attrs).replace(/colspan="[23]"/, 'colspan="3"') const patched = patchProductFooterCellAttrs(withSpan, 'delivery-slip-product-cell', PRODUCT_TABLE_CELL_LEFT) return `\n
]*)>\s*
]*)>\s*
{ if (attrs.includes('delivery-slip-terms-cell') && attrs.includes('border:0.3px solid #000') && /colspan="5"/.test(match)) { return match @@ -1227,10 +1234,15 @@ function normalizeDeliverySlipTermsText(html: string): string { /** 刷新已有间距行的 inline 样式(TinyMCE 保存后可能丢失) */ function refreshDeliverySlipGapBeforeProduct(html: string): string { - return html.replace( - /
[\s\S]*?<\/tr>/, - `\n \n ` - ) + return html + .replace( + /[\s\S]*?<\/tr>/, + `\n \n ` + ) + .replace( + /
]*>[\s\S]*?<\/div>/, + `
 
` + ) } /** 在收货联系方式行与物料表之间插入间距行(兼容已保存模板) */ @@ -1243,32 +1255,42 @@ function normalizeDeliverySlipGapBeforeProduct(html: string): string { return refreshDeliverySlipGapBeforeProduct(html) } - const gapRow = `
\n ` + const gapRow = `\n ` + const productHeader = `(?:单据编号|物料编号)` const withComment = html.replace( - /(]*>日(?: )?期:<\/span>[\s\S]*?<\/tr>\s*)(
单据编号 物料编号 物料名称 规格
+ 备注:{{remark}}
${buildDeliverySlipTermsHtml()} + ${SEAL_BLOCK}