From b21278dfb6fb858a9f8177f4b49fb30b04774924 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Tue, 21 Jul 2026 16:15:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=86=99=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.js | 11 ++-- .../contract/components/printPaymentForm.vue | 55 ++++++++++++------- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 7114f75..db7637a 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -287,17 +287,20 @@ export function numberToChinese(num) { for (let i = 0; i < groups.length; i++) { const section = groups[i] if (section === 0) { - if (result) needZero = true + if (groups.slice(i + 1).some(g => g > 0)) { + needZero = true + } continue } const sectionStr = convertSection(section) - let prefix = sectionStr + bigUnits[i] - if (needZero) { + const prefix = sectionStr + bigUnits[i] + if (needZero && result) { result = prefix + '零' + result needZero = false } else { const lower = groups.slice(0, i).reduce((sum, g, idx) => sum + g * Math.pow(10000, idx), 0) - const padZero = i > 0 && lower > 0 && section < 1000 + // 低位段不足千位,或高位段整百/整千结尾且低位非空时,需补「零」 + const padZero = i > 0 && lower > 0 && (lower < 1000 || (section >= 100 && section % 100 === 0)) result = prefix + (padZero ? '零' : '') + result } } diff --git a/src/views/contract/components/printPaymentForm.vue b/src/views/contract/components/printPaymentForm.vue index 08ed430..7f6b162 100644 --- a/src/views/contract/components/printPaymentForm.vue +++ b/src/views/contract/components/printPaymentForm.vue @@ -35,7 +35,7 @@
- + @@ -68,7 +68,7 @@
合同信息{{ fundLog && fundLog.remark || '-' }}
-
+
暂无事后支付表格内容
@@ -182,6 +182,9 @@ export default { try { this.fundLog = null const res = await detailFundLog({ id }) + if (res && res.forms) { + res.forms = this.stripFinanceReviewTable(res.forms) + } this.fundLog = res this.formsRenderKey += 1 } catch (error) { @@ -190,6 +193,17 @@ export default { throw error } }, + /** 移除 forms 中误保存的合同信息表(历史数据兼容) */ + stripFinanceReviewTable(html) { + if (!html || typeof html !== 'string') return html + const wrapper = document.createElement('div') + wrapper.innerHTML = html + wrapper.querySelectorAll('.finance-review-table').forEach(el => el.remove()) + return wrapper.innerHTML + }, + getFormContentDom() { + return this.$refs.formsContent || this.$refs.printtable + }, handleCancel() { this.isShow = false }, @@ -316,7 +330,7 @@ export default { this.syncAllUppercase(dom) }, syncFormDomToHtml() { - const dom = this.$refs.printtable + const dom = this.getFormContentDom() if (!dom || !this.fundLog) return const templateFields = this.fundLog.other_data const inputs = dom.querySelectorAll('input, select, textarea') @@ -351,13 +365,13 @@ export default { input.setAttribute('value', input.value) } }) - this.fundLog.forms = dom.innerHTML + this.fundLog.forms = this.stripFinanceReviewTable(dom.innerHTML) }, async syncAndSave() { if (!this.fundLog || !this.fundLog.id) { throw new Error('缺少付款登记数据') } - const dom = this.$refs.printtable + const dom = this.getFormContentDom() if (dom) { this.syncAllUppercase(dom) this.syncFormDomToHtml() @@ -918,20 +932,23 @@ export default { }, async print() { try { + const sourceDom = this.getFormContentDom() + if (!sourceDom) { + this.$Message.error('暂无可打印内容') + return + } + const tempContainer = document.createElement('div') tempContainer.style.position = 'absolute' tempContainer.style.left = '-9999px' tempContainer.style.top = '-9999px' document.body.appendChild(tempContainer) - const originalContent = this.$refs['printtable'].cloneNode(true) + const originalContent = sourceDom.cloneNode(true) tempContainer.appendChild(originalContent) - // 移除财务审核表 - const financeTable = tempContainer.querySelector('.finance-review-table') - if (financeTable) { - financeTable.remove() - } + // 移除所有合同信息表 + tempContainer.querySelectorAll('.finance-review-table').forEach(el => el.remove()) this.replaceControls(tempContainer) @@ -958,8 +975,9 @@ export default { return Number(val).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') }, printHtml() { - // 先同步用户输入到HTML - const dom = this.$refs.printtable + // 只同步/打印表单内容,不包含预览用的合同信息表 + const formsDom = this.getFormContentDom() + const dom = formsDom || this.$refs.printtable if (dom) { this.syncAllUppercase(dom) // 获取所有输入控件 @@ -1019,15 +1037,12 @@ export default { }) } - // 使用同步后的HTML数据 + // 使用同步后的HTML数据(仅表单区域) const printNode = document.createElement('div') - printNode.innerHTML = dom.innerHTML + printNode.innerHTML = dom ? dom.innerHTML : '' - // 移除财务审核表 - const financeTable = printNode.querySelector('.finance-review-table') - if (financeTable) { - financeTable.remove() - } + // 移除所有合同信息表 + printNode.querySelectorAll('.finance-review-table').forEach(el => el.remove()) // 替换控件为纯文本(保留样式) this.replaceControls(printNode)