This commit is contained in:
zlwu committed 2026-09-02 08:20:52 +08:00
1 parent 506cc7991a
commit 1dfcc66d2c
269 files changed
+1413333 -55990

No files matched your search

@@ -1345,7 +1345,7 @@ const handleDetailCopy = () => {
const handleDetailEdit = async () => {
if (!detailContract.value?.id) return
if (!isContractEditableStatus(detailContract.value.status)) {
$modal.msgWarning('仅草稿、审批中或已审批(未执行)的合同才能修改')
$modal.msgWarning('已完成的合同不能修改')
return
}
const confirmMsg = getContractReeditConfirmMessage(detailContract.value.status)
@@ -2042,18 +2042,19 @@ const replacePlaceholders = (htmlContent: string, contractData: ContractVO | und
}
// 合计区(12 列):第 1 行左右对半运费/桶押金;第 2 行合计;第 3 行提示
// 合计区(12 列):运费/桶押金 → 不含税/税额 → 含税金额合计 → 提示
const freightRaw = Number(contractData.freight);
const freightAmount = Number.isFinite(freightRaw) && freightRaw > 0 ? freightRaw : 0;
const depositRaw = Number(contractData.barrelDeposit);
const barrelDepositAmount = Number.isFinite(depositRaw) && depositRaw > 0 ? depositRaw : 0;
const totalWithExtras = productTotal + freightAmount + barrelDepositAmount;
const totalWithExtrasChinese = numberToChinese(totalWithExtras);
const freightText = freightAmount > 0 ? `¥${formatNumber(freightAmount)}` : '-';
const barrelDepositText = barrelDepositAmount > 0 ? `¥${formatNumber(barrelDepositAmount)}` : '-';
const totalWithExtrasText = isFrameworkContract
? '随行就市'
: `${totalWithExtrasChinese}(¥${formatNumber(totalWithExtras)})`;
const formatRmbAmountText = (amount: number) =>
isFrameworkContract ? '随行就市' : `${numberToChinese(amount)}(¥${formatNumber(amount)})`;
const beforeTaxTotalText = formatRmbAmountText(productTotalBeforeTax);
const taxTotalText = formatRmbAmountText(totalTax);
const totalWithExtrasText = formatRmbAmountText(totalWithExtras);
const tipRowText = hasSelfPickupProduct(contractData.products)
? '含税、客户自提结算以实际到货吨位为准'
: '含税、含运费、装卸费(一票制)    结算以实际到货吨位为准';
@@ -2065,7 +2066,13 @@ const replacePlaceholders = (htmlContent: string, contractData: ContractVO | und
<td colspan="4" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">${barrelDepositText}</td>
</tr>
<tr style="background-color: #fff; font-weight: bold;">
<td colspan="2" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">合计(人民币)</td>
<td colspan="2" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">不含税金额合计(人民币)</td>
<td colspan="4" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">${beforeTaxTotalText}</td>
<td colspan="2" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">税额合计(人民币)</td>
<td colspan="4" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">${taxTotalText}</td>
</tr>
<tr style="background-color: #fff; font-weight: bold;">
<td colspan="2" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">含税金额合计(人民币)</td>
<td colspan="10" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">${totalWithExtrasText}</td>
</tr>
<tr>
@@ -2074,7 +2081,16 @@ const replacePlaceholders = (htmlContent: string, contractData: ContractVO | und
</td>
</tr>
`;
result = result.replace(/\{\{productTotalRow\}\}/gi, productTotalRow);
// 优先替换占位符;否则替换已展开的「运费~提示」合计块(兼容旧模板,打印/PDF 共用)
if (/\{\{productTotalRow\}\}/i.test(result)) {
result = result.replace(/\{\{productTotalRow\}\}/gi, productTotalRow);
} else {
const summaryBlockPattern =
/(?:<tr[^>]*font-weight:\s*bold[^>]*>[\s\S]*?<\/tr>\s*){1,3}<tr>[\s\S]*?结算以实际到货吨位为准[\s\S]*?<\/tr>/i;
if (summaryBlockPattern.test(result)) {
result = result.replace(summaryBlockPattern, productTotalRow.trim());
}
}
// 特殊处理:印章图片
// 从合同编号中提取供方编码
@@ -2421,7 +2437,7 @@ const generateContractTemplate = (contractData: ContractVO | undefined): string
</thead>
<tbody>
{{productTable}}
<!-- 合计行+提示行(由 {{productTotalRow}} 一并输出,此处不再重复) -->
<!-- 运费/桶押金 + 不含税/税额 + 含税合计 + 提示(由 {{productTotalRow}} 一并输出) -->
{{productTotalRow}}
</tbody>
</table>
@@ -2562,9 +2578,9 @@ const handleSaveTemplate = async () => {
const productTableMatch = templateWithPlaceholders.match(/<tbody>[\s\S]*?<\/tbody>/);
const productTableHtml = productTableMatch ? productTableMatch[0] : '';
// 2. 提取运费/桶押金行 + 合计行(连续两行加粗)
// 2. 提取运费/桶押金 + 不含税/税额 + 含税合计(连续 2~3 行加粗,兼容旧版)
const totalRowMatch = templateWithPlaceholders.match(
/(?:<tr style="background-color: #fff; font-weight: bold;">[\s\S]*?<\/tr>\s*){2}/
/(?:<tr style="background-color: #fff; font-weight: bold;">[\s\S]*?<\/tr>\s*){2,3}/
);
const totalRowHtml = totalRowMatch ? totalRowMatch[0] : '';
@@ -2583,10 +2599,10 @@ const handleSaveTemplate = async () => {
);
}
// 替换运费/桶押金行 + 合计行(兼容旧版单行合计)
// 替换运费/桶押金行 + 合计相关行(兼容旧版 1~2 行、新版 3 行)
if (totalRowHtml) {
const totalRowPattern =
/(?:<tr style="background-color: #fff; font-weight: bold;">[\s\S]*?<\/tr>\s*){1,2}/;
/(?:<tr style="background-color: #fff; font-weight: bold;">[\s\S]*?<\/tr>\s*){1,3}/;
if (totalRowPattern.test(finalTemplate)) {
finalTemplate = finalTemplate.replace(totalRowPattern, totalRowHtml);
}
@@ -2956,13 +2972,12 @@ const handleGeneratePdfFromDialog = async () => {
// 判断是否为SX供方编码
const isSXSupplier = supplierCode === 'SX';
// 获取合同内容并替换占位符(使用最新的合同数据)
// 获取合同内容并用最新数据刷新合计区(打印弹窗与 PDF 同源)
let htmlContent = contractContent.value;
// 如果内容中包含占位符,需要替换
if (htmlContent.includes('{{') || htmlContent.includes('SETTLEMENT_METHOD_CONTENT')) {
// 重新获取最新合同数据来替换占位符
const res = await getContractDetail(detailContract.value.id);
const res = await getContractDetail(detailContract.value.id);
if (res?.data) {
htmlContent = replacePlaceholders(htmlContent, res.data);
contractContent.value = htmlContent;
}
// 1. 创建临时容器(border-box:794 含 padding)