提交
This commit is contained in:
1 parent
8dbb816d01
commit
b74d483682
156 files changed
+258503
-10836
No files matched your search
@@ -15,7 +15,7 @@ export const DELIVERY_SLIP_DEFAULTS = {
|
||||
const DOC_FONT = "SimSun, 'Songti SC', serif"
|
||||
const FONT_TITLE = 'font-size:26px;font-weight:bold;'
|
||||
const FONT_BODY = 'font-size:20px;'
|
||||
const FONT_SIGN = 'font-size:14px;'
|
||||
const FONT_SIGN = 'font-size:18px;'
|
||||
const FONT_SIDE = 'font-size:18px;'
|
||||
const DOC_PADDING = '8px 10px 24px'
|
||||
/** 单据内容区最大宽度(编辑预览居中,略窄于 A4 像素宽) */
|
||||
@@ -26,9 +26,15 @@ const LOGO_LEFT = 50
|
||||
const TITLE_STYLE = `${FONT_TITLE}font-weight:700 !important;letter-spacing:6px;line-height:1.35;`
|
||||
const TITLE_SUB_STYLE = `${TITLE_STYLE}margin-top:2px;letter-spacing:10px;`
|
||||
const TABLE_ROW_PADDING = '4px'
|
||||
/** 信息表等宽列 */
|
||||
/** 信息表列宽:收货单位(4) / 联系方式(1,略加宽) / 日期(2) */
|
||||
const INFO_COLGROUP = `<colgroup>
|
||||
<col span="7" style="width:14.28%;" />
|
||||
<col style="width:12.75%;" />
|
||||
<col style="width:12.75%;" />
|
||||
<col style="width:12.75%;" />
|
||||
<col style="width:12.75%;" />
|
||||
<col style="width:22.5%;" />
|
||||
<col style="width:13.25%;" />
|
||||
<col style="width:13.25%;" />
|
||||
</colgroup>`
|
||||
/**
|
||||
* 物料表列宽:单据编号 + 加宽编号/名称,收窄规格/单位;前 5 列合计供条款区使用。
|
||||
@@ -421,7 +427,7 @@ export const DELIVERY_SLIP_PRINT_CSS = `
|
||||
.delivery-slip-doc .delivery-slip-sign-row-cell,
|
||||
.delivery-slip-doc .delivery-slip-sign-inner,
|
||||
.delivery-slip-doc .delivery-slip-sign-item {
|
||||
font-size: 14px !important;
|
||||
font-size: 18px !important;
|
||||
}
|
||||
.delivery-slip-doc .delivery-slip-sign-row-cell {
|
||||
overflow: hidden !important;
|
||||
@@ -614,7 +620,6 @@ function buildDeliverySlipTypeCheckboxesHtml(): string {
|
||||
const item = (label: string) =>
|
||||
`<label class="delivery-slip-type-check-item" contenteditable="false"><input type="checkbox" class="delivery-slip-type-check-input" />${label}</label>`
|
||||
return `<div class="delivery-slip-info-row delivery-slip-type-check-wrap" style="${DELIVERY_SLIP_TYPE_CHECK_WRAP_STYLE}">
|
||||
<span class="delivery-slip-info-label delivery-slip-type-check-spacer" style="${INFO_LABEL}visibility:hidden;">日 期:</span>
|
||||
<div class="delivery-slip-type-check-row" style="${DELIVERY_SLIP_TYPE_CHECK_INNER_STYLE}">${item('自提')}${item('出库')}${item('直销')}</div>
|
||||
</div>`
|
||||
}
|
||||
@@ -623,19 +628,19 @@ function buildDeliverySlipInfoTableHtml(): string {
|
||||
return `<table class="delivery-slip-info-table" style="width:100%;border-collapse:collapse;table-layout:fixed;border:none !important;">
|
||||
${INFO_COLGROUP}
|
||||
<tr>
|
||||
<td colspan="2" style="${INFO_CELL_LEFT}">
|
||||
<td colspan="4" style="${INFO_CELL_LEFT}">
|
||||
<div class="delivery-slip-info-row" style="${INFO_ROW}">
|
||||
<span class="delivery-slip-info-label" style="${INFO_LABEL}">收货单位:</span>
|
||||
<span class="delivery-slip-info-value-left" style="${INFO_VALUE_INLINE_LEFT}">{{receivingUnit}} </span>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="2" style="${INFO_CELL_LEFT}">
|
||||
<td colspan="1" style="${INFO_CELL_LEFT}">
|
||||
<div class="delivery-slip-info-row" style="${INFO_ROW}">
|
||||
<span class="delivery-slip-info-label" style="${INFO_LABEL}">收货联系方式:</span>
|
||||
<span class="delivery-slip-info-label" style="${INFO_LABEL}">联系方式:</span>
|
||||
<span class="delivery-slip-info-value-left" style="${INFO_VALUE_INLINE_LEFT}">{{receiveContact}} </span>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="3" style="${INFO_CELL_RIGHT}">
|
||||
<td colspan="2" style="${INFO_CELL_RIGHT}">
|
||||
${buildDeliverySlipTypeCheckboxesHtml()}
|
||||
<div class="delivery-slip-info-row" style="${INFO_ROW}">
|
||||
<span class="delivery-slip-info-label" style="${INFO_LABEL}">日 期:</span>
|
||||
@@ -1267,7 +1272,7 @@ function refreshDeliverySlipGapBeforeProduct(html: string): string {
|
||||
)
|
||||
}
|
||||
|
||||
/** 在收货联系方式行与物料表之间插入间距行(兼容已保存模板) */
|
||||
/** 在联系方式行与物料表之间插入间距行(兼容已保存模板) */
|
||||
function normalizeDeliverySlipGapBeforeProduct(html: string): string {
|
||||
if (!html.includes('delivery-slip-doc')) {
|
||||
return html
|
||||
@@ -1279,17 +1284,18 @@ function normalizeDeliverySlipGapBeforeProduct(html: string): string {
|
||||
|
||||
const gapRow = `<tr class="delivery-slip-gap-before-product"><td colspan="8" class="delivery-slip-gap-before-product-cell" style="${GAP_BEFORE_PRODUCT_CELL}"> </td></tr>\n `
|
||||
const productHeader = `(?:单据编号|物料编号)`
|
||||
const contactLabel = `(?:收货)?联系方式:`
|
||||
|
||||
const withComment = html.replace(
|
||||
new RegExp(
|
||||
`(收货联系方式:[\\s\\S]*?<\\/tr>\\s*)(<!--\\s*中:产品明细表[\\s\\S]*?<tr[\\s\\S]*?<th[^>]*>${productHeader})`
|
||||
`(${contactLabel}[\\s\\S]*?<\\/tr>\\s*)(<!--\\s*中:产品明细表[\\s\\S]*?<tr[\\s\\S]*?<th[^>]*>${productHeader})`
|
||||
),
|
||||
`$1${gapRow}$2`
|
||||
)
|
||||
if (withComment !== html) return withComment
|
||||
|
||||
const withHeader = html.replace(
|
||||
new RegExp(`(收货联系方式:[\\s\\S]*?<\\/tr>\\s*)(<tr[\\s\\S]*?<th[^>]*>${productHeader})`),
|
||||
new RegExp(`(${contactLabel}[\\s\\S]*?<\\/tr>\\s*)(<tr[\\s\\S]*?<th[^>]*>${productHeader})`),
|
||||
`$1${gapRow}$2`
|
||||
)
|
||||
if (withHeader !== html) return withHeader
|
||||
@@ -1390,7 +1396,9 @@ function normalizeDeliverySlipSignRow(html: string): string {
|
||||
)
|
||||
: `${trAttrs} class="delivery-slip-sign-row"`
|
||||
|
||||
let nextTdAttrs = tdAttrs.replace(/white-space:nowrap;?/g, '').replace(/font-size:16px;?/g, 'font-size:14px;')
|
||||
let nextTdAttrs = tdAttrs
|
||||
.replace(/white-space:nowrap;?/g, '')
|
||||
.replace(/font-size:(?:14|16)px;?/g, 'font-size:18px;')
|
||||
if (nextTdAttrs.includes('class="')) {
|
||||
nextTdAttrs = nextTdAttrs.replace(/class="([^"]*)"/, (_, cls: string) =>
|
||||
cls.includes('delivery-slip-sign-row-cell') ? `class="${cls}"` : `class="${cls} delivery-slip-sign-row-cell"`
|
||||
@@ -1411,28 +1419,37 @@ function normalizeDeliverySlipSignRow(html: string): string {
|
||||
return normalizeDeliverySlipSignLabelMarkup(result)
|
||||
}
|
||||
|
||||
/** 信息区:收货单位 / 收货联系方式 / 日期 同一行(兼容旧多行布局) */
|
||||
/** 信息区:收货单位 / 联系方式 / 日期 同一行(兼容旧多行布局) */
|
||||
function normalizeDeliverySlipInfoLayout(html: string): string {
|
||||
if (!html.includes('delivery-slip-info-table')) return html
|
||||
|
||||
const infoMatch = html.match(/<table class="delivery-slip-info-table"[^>]*>[\s\S]*?<\/table>/i)
|
||||
if (!infoMatch) return html
|
||||
let result = html.replace(/收货联系方式:/g, '联系方式:')
|
||||
|
||||
const infoMatch = result.match(/<table class="delivery-slip-info-table"[^>]*>[\s\S]*?<\/table>/i)
|
||||
if (!infoMatch) return result
|
||||
|
||||
const infoHtml = infoMatch[0]
|
||||
const rowCount = (infoHtml.match(/<tr[\s>]/g) || []).length
|
||||
const hasPlanNoInInfo = infoHtml.includes('单据编号:')
|
||||
const dateColWideEnough = /<td[^>]*colspan="3"[^>]*>[\s\S]*?日(?: )?期:/.test(infoHtml)
|
||||
const oneRowThreeFields =
|
||||
const layoutOk =
|
||||
rowCount === 1 &&
|
||||
infoHtml.includes('收货单位:') &&
|
||||
infoHtml.includes('收货联系方式:') &&
|
||||
infoHtml.includes('联系方式:') &&
|
||||
/日(?: )?期:/.test(infoHtml) &&
|
||||
!hasPlanNoInInfo &&
|
||||
dateColWideEnough
|
||||
/<td[^>]*colspan="4"[^>]*>[\s\S]*?收货单位:/.test(infoHtml) &&
|
||||
/<td[^>]*colspan="1"[^>]*>[\s\S]*?联系方式:/.test(infoHtml) &&
|
||||
/<td[^>]*colspan="2"[^>]*>[\s\S]*?日(?: )?期:/.test(infoHtml) &&
|
||||
!/<td[^>]*colspan="[2-5]"[^>]*>[\s\S]*?联系方式:/.test(infoHtml)
|
||||
|
||||
if (oneRowThreeFields) return html
|
||||
if (layoutOk) {
|
||||
return result.replace(
|
||||
/(<table class="delivery-slip-info-table"[^>]*>\s*)(?:<colgroup>[\s\S]*?<\/colgroup>\s*)?/i,
|
||||
`$1${INFO_COLGROUP}`
|
||||
)
|
||||
}
|
||||
|
||||
return html.replace(infoMatch[0], buildDeliverySlipInfoTableHtml())
|
||||
return result.replace(infoMatch[0], buildDeliverySlipInfoTableHtml())
|
||||
}
|
||||
|
||||
/** 物料表:表头补「单据编号」列,并把旧 7 列数据行升为 8 列(兼容已保存模板) */
|
||||
@@ -1659,7 +1676,7 @@ function refreshDeliverySlipTypeCheckRowStyle(html: string): string {
|
||||
result = result.replace(
|
||||
/<div class="delivery-slip-type-check-row"[^>]*>([\s\S]*?)<\/div>/,
|
||||
(_match, inner) =>
|
||||
`<div class="delivery-slip-info-row delivery-slip-type-check-wrap" style="${DELIVERY_SLIP_TYPE_CHECK_WRAP_STYLE}"><span class="delivery-slip-info-label delivery-slip-type-check-spacer" style="${INFO_LABEL}visibility:hidden;">日 期:</span><div class="delivery-slip-type-check-row" style="${DELIVERY_SLIP_TYPE_CHECK_INNER_STYLE}">${inner}</div></div>`
|
||||
`<div class="delivery-slip-info-row delivery-slip-type-check-wrap" style="${DELIVERY_SLIP_TYPE_CHECK_WRAP_STYLE}"><div class="delivery-slip-type-check-row" style="${DELIVERY_SLIP_TYPE_CHECK_INNER_STYLE}">${inner}</div></div>`
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1667,9 +1684,10 @@ function refreshDeliverySlipTypeCheckRowStyle(html: string): string {
|
||||
/<div class="delivery-slip-info-row delivery-slip-type-check-wrap"[^>]*>/g,
|
||||
`<div class="delivery-slip-info-row delivery-slip-type-check-wrap" style="${DELIVERY_SLIP_TYPE_CHECK_WRAP_STYLE}">`
|
||||
)
|
||||
// 去掉「日期」占位空标签,使自提/出库/直销左对齐
|
||||
result = result.replace(
|
||||
/<span class="delivery-slip-info-label delivery-slip-type-check-spacer"[^>]*>[\s\S]*?<\/span>/g,
|
||||
`<span class="delivery-slip-info-label delivery-slip-type-check-spacer" style="${INFO_LABEL}visibility:hidden;">日 期:</span>`
|
||||
/<span class="delivery-slip-info-label delivery-slip-type-check-spacer"[^>]*>[\s\S]*?<\/span>\s*/g,
|
||||
''
|
||||
)
|
||||
result = result.replace(
|
||||
/<div class="delivery-slip-type-check-row"[^>]*>/g,
|
||||
@@ -1702,13 +1720,19 @@ function normalizeDeliverySlipTypeCheckRow(html: string): string {
|
||||
`$1${checkRowHtml}\n $2`
|
||||
)
|
||||
}
|
||||
// 兼容旧模板:日期在 colspan=2 单元格时仍插多选
|
||||
// 兼容旧模板:日期在 colspan=2 / colspan=1 单元格时仍插多选
|
||||
if (!result.includes('delivery-slip-type-check-row')) {
|
||||
result = result.replace(
|
||||
/(<td colspan="2"[^>]*>\s*)(<div class="delivery-slip-info-row"[^>]*>\s*<span class="delivery-slip-info-label"[^>]*>日(?: )?期:)/,
|
||||
`$1${checkRowHtml}\n $2`
|
||||
)
|
||||
}
|
||||
if (!result.includes('delivery-slip-type-check-row')) {
|
||||
result = result.replace(
|
||||
/(<td colspan="1"[^>]*>\s*)(<div class="delivery-slip-info-row"[^>]*>\s*<span class="delivery-slip-info-label"[^>]*>日(?: )?期:)/,
|
||||
`$1${checkRowHtml}\n $2`
|
||||
)
|
||||
}
|
||||
// 兼容更旧模板:单据编号位置仍插多选,随后由 infoLayout 迁移
|
||||
if (!result.includes('delivery-slip-type-check-row')) {
|
||||
result = result.replace(
|
||||
|
||||
@@ -17,7 +17,7 @@ const LEGACY_RECEIVING_UNIT = '安庆市山峡化工有限公司'
|
||||
const DOC_FONT = "SimSun, 'Songti SC', serif"
|
||||
const FONT_TITLE = 'font-size:26px;font-weight:bold;'
|
||||
const FONT_BODY = 'font-size:20px;'
|
||||
const FONT_SIGN = 'font-size:14px;'
|
||||
const FONT_SIGN = 'font-size:18px;'
|
||||
const FONT_SIDE = 'font-size:18px;'
|
||||
const DOC_PADDING = '8px 10px 24px'
|
||||
/** 单据内容区最大宽度(编辑预览居中,略窄于 A4 像素宽) */
|
||||
@@ -310,7 +310,7 @@ export const INBOUND_SLIP_PRINT_CSS = `
|
||||
.inbound-slip-doc .inbound-slip-sign-row-cell,
|
||||
.inbound-slip-doc .inbound-slip-sign-inner,
|
||||
.inbound-slip-doc .inbound-slip-sign-item {
|
||||
font-size: 14px !important;
|
||||
font-size: 18px !important;
|
||||
}
|
||||
.inbound-slip-doc .inbound-slip-sign-row-cell {
|
||||
overflow: hidden !important;
|
||||
@@ -515,13 +515,13 @@ export function generateInboundSlipTemplate(_plan?: Plan): string {
|
||||
<table class="inbound-slip-info-table" style="width:100%;border-collapse:collapse;table-layout:fixed;border:none !important;">
|
||||
${INFO_COLGROUP}
|
||||
<tr>
|
||||
<td colspan="4" style="${INFO_CELL_LEFT}">
|
||||
<td colspan="5" style="${INFO_CELL_LEFT}">
|
||||
<div class="inbound-slip-info-row" style="${INFO_ROW}">
|
||||
<span class="inbound-slip-info-label" style="${INFO_LABEL}">送货单位:</span>
|
||||
<span class="inbound-slip-info-value-left" style="${INFO_VALUE_INLINE_LEFT}">{{receivingUnit}} </span>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="3" style="${INFO_CELL_RIGHT}">
|
||||
<td colspan="2" style="${INFO_CELL_RIGHT}">
|
||||
<div class="inbound-slip-info-row" style="${INFO_ROW}">
|
||||
<span class="inbound-slip-info-label" style="${INFO_LABEL}">日 期:</span>
|
||||
<span class="inbound-slip-info-value-center" style="${INFO_VALUE_INLINE_CENTER}">{{planDateChinese}} </span>
|
||||
@@ -1104,7 +1104,9 @@ function normalizeInboundSlipSignRow(html: string): string {
|
||||
)
|
||||
: `${trAttrs} class="inbound-slip-sign-row"`
|
||||
|
||||
let nextTdAttrs = tdAttrs.replace(/white-space:nowrap;?/g, '').replace(/font-size:16px;?/g, 'font-size:14px;')
|
||||
let nextTdAttrs = tdAttrs
|
||||
.replace(/white-space:nowrap;?/g, '')
|
||||
.replace(/font-size:(?:14|16)px;?/g, 'font-size:18px;')
|
||||
if (nextTdAttrs.includes('class="')) {
|
||||
nextTdAttrs = nextTdAttrs.replace(/class="([^"]*)"/, (_, cls: string) =>
|
||||
cls.includes('inbound-slip-sign-row-cell') ? `class="${cls}"` : `class="${cls} inbound-slip-sign-row-cell"`
|
||||
@@ -1138,20 +1140,22 @@ function normalizeInboundSlipInfoLayout(html: string): string {
|
||||
infoHtml.includes('收货联系方式:') ||
|
||||
infoHtml.includes('单据编号:') ||
|
||||
!infoHtml.includes('送货单位:') ||
|
||||
(infoHtml.match(/<tr[\s>]/g) || []).length > 1
|
||||
(infoHtml.match(/<tr[\s>]/g) || []).length > 1 ||
|
||||
!/<td[^>]*colspan="5"[^>]*>[\s\S]*?送货单位:/.test(infoHtml) ||
|
||||
!/<td[^>]*colspan="2"[^>]*>[\s\S]*?日(?: )?期:/.test(infoHtml)
|
||||
|
||||
if (!needsMigrate) return html
|
||||
|
||||
const newInfoTable = `<table class="inbound-slip-info-table" style="width:100%;border-collapse:collapse;table-layout:fixed;border:none !important;">
|
||||
${INFO_COLGROUP}
|
||||
<tr>
|
||||
<td colspan="4" style="${INFO_CELL_LEFT}">
|
||||
<td colspan="5" style="${INFO_CELL_LEFT}">
|
||||
<div class="inbound-slip-info-row" style="${INFO_ROW}">
|
||||
<span class="inbound-slip-info-label" style="${INFO_LABEL}">送货单位:</span>
|
||||
<span class="inbound-slip-info-value-left" style="${INFO_VALUE_INLINE_LEFT}">{{receivingUnit}} </span>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="3" style="${INFO_CELL_RIGHT}">
|
||||
<td colspan="2" style="${INFO_CELL_RIGHT}">
|
||||
<div class="inbound-slip-info-row" style="${INFO_ROW}">
|
||||
<span class="inbound-slip-info-label" style="${INFO_LABEL}">日 期:</span>
|
||||
<span class="inbound-slip-info-value-center" style="${INFO_VALUE_INLINE_CENTER}">{{planDateChinese}} </span>
|
||||
|
||||
@@ -14,7 +14,7 @@ export const SUBPACK_SLIP_DEFAULTS = {
|
||||
const DOC_FONT = "SimSun, 'Songti SC', serif"
|
||||
const FONT_TITLE = 'font-size:26px;font-weight:bold;'
|
||||
const FONT_BODY = 'font-size:20px;'
|
||||
const FONT_SIGN = 'font-size:14px;'
|
||||
const FONT_SIGN = 'font-size:18px;'
|
||||
const FONT_SIDE = 'font-size:18px;'
|
||||
const DOC_PADDING = '8px 10px 24px'
|
||||
/** 单据内容区最大宽度(编辑预览居中,略窄于 A4 像素宽) */
|
||||
@@ -531,7 +531,7 @@ export const SUBPACK_SLIP_PRINT_CSS = `
|
||||
.subpack-slip-doc .subpack-slip-sign-row-cell,
|
||||
.subpack-slip-doc .subpack-slip-sign-inner,
|
||||
.subpack-slip-doc .subpack-slip-sign-item {
|
||||
font-size: 14px !important;
|
||||
font-size: 18px !important;
|
||||
}
|
||||
.subpack-slip-doc .subpack-slip-sign-row-cell {
|
||||
overflow: hidden !important;
|
||||
@@ -1598,7 +1598,9 @@ function normalizeSubpackSlipSignRow(html: string): string {
|
||||
)
|
||||
: `${trAttrs} class="subpack-slip-sign-row"`
|
||||
|
||||
let nextTdAttrs = tdAttrs.replace(/white-space:nowrap;?/g, '').replace(/font-size:16px;?/g, 'font-size:14px;')
|
||||
let nextTdAttrs = tdAttrs
|
||||
.replace(/white-space:nowrap;?/g, '')
|
||||
.replace(/font-size:(?:14|16)px;?/g, 'font-size:18px;')
|
||||
if (nextTdAttrs.includes('class="')) {
|
||||
nextTdAttrs = nextTdAttrs.replace(/class="([^"]*)"/, (_, cls: string) =>
|
||||
cls.includes('subpack-slip-sign-row-cell') ? `class="${cls}"` : `class="${cls} subpack-slip-sign-row-cell"`
|
||||
|
||||
Reference in new issue
Block a user