diff --git a/gridPaymentForm.html b/gridPaymentForm.html new file mode 100644 index 0000000..909940a --- /dev/null +++ b/gridPaymentForm.html @@ -0,0 +1,459 @@ + + + + + + 苏州市河道管理处资金划拨审批单 + + + +
+

苏州市河道管理处资金划拨审批单

+ + +
+ + \ No newline at end of file diff --git a/printRegistration.html b/printRegistration.html new file mode 100644 index 0000000..cca374f --- /dev/null +++ b/printRegistration.html @@ -0,0 +1,216 @@ +
+
+

苏州市河道管理处报销贴单

+
+
科室:
${department}
+
${date}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
用途说明金额报销(领款)人 +
+ +
+
${handler}
+
+
附单据
${receipts}
+
+
+ +
+
${purpose1}
+
+
+ +
+
${amount1}
+
+
+ +
+
${purpose2}
+
+
+ +
+
${amount2}
+
科室负责人 +
+ +
+
${departmentHead}
+
+
+ +
+
${purpose3}
+
+
+ +
+
${amount3}
+
+
+ +
+
${purpose4}
+
+
+ +
+
${amount4}
+
财务审计科审核 +
+ +
+
${financeApproval}
+
+
+ +
+
${purpose5}
+
+
+ +
+
${amount5}
+
+
+ +
+
${purpose6}
+
+
+ +
+
${amount6}
+
分管领导审核 +
+ +
+
${leaderApproval}
+
+
+ +
+
${purpose7}
+
+
+ +
+
${amount7}
+
+
+ +
+
${purpose8}
+
+
+ +
+
${amount8}
+
财务分管领导审核 +
+ +
+
${financeLeaderApproval}
+
+
+ +
+
${purpose9}
+
+
+ +
+
${amount9}
+
合计 +
+ +
+
${total}
+
单位负责人审批 +
+ +
+
${unitLeaderApproval}
+
报销金额(大写) +
+ +
+
${upperCaseAmount}
+
+
+
\ No newline at end of file diff --git a/src/views/contract/components/paymentRegistration.vue b/src/views/contract/components/paymentRegistration.vue index cf2143f..f3852f6 100644 --- a/src/views/contract/components/paymentRegistration.vue +++ b/src/views/contract/components/paymentRegistration.vue @@ -455,6 +455,11 @@ import { replaceControls } from './printPaymentForm.vue' // 添加金额转大写的工具函数 function numberToChinese(num) { + // 特殊处理:当金额为0时,直接返回"零元" + if (num === 0) { + return '零元' + } + const units = ['', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟', '万'] const digits = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'] const [integer, decimal] = num.toString().split('.') @@ -490,6 +495,7 @@ function numberToChinese(num) { result = result.replace(/零+$/, '') result = result.replace(/零+/, '零') } + if (decimal) { const decimalNum = parseInt(decimal) if (decimalNum > 0) { @@ -499,6 +505,7 @@ function numberToChinese(num) { } } } + if (!decimal || parseInt(decimal) === 0) { result += '整' } @@ -1690,7 +1697,7 @@ export default { } this.otherTotal = wanTotal * 10000 + qianTotal * 1000 + baiTotal * 100 + shiTotal * 10 + yuanTotal + jiaoTotal * 0.1 + fenTotal * 0.01 - this.otherTotal = this.otherTotal.toFixed(2) + this.otherTotal = parseFloat(this.otherTotal.toFixed(2)) // console.log('this.otherTotal', this.otherTotal) this.total = 0 // 只计算以 amount 开头的输入框 @@ -1704,22 +1711,24 @@ export default { const totalInput = dom.querySelector('input[data-field="total"]') if (totalInput) { if (this.total===0) { - this.total = parseFloat(totalInput.value) || 0 + this.total = parseFloat(totalInput.value.replace(/¥/g, '')) || 0 } else { - totalInput.value = this.total.toFixed(2) + totalInput.value = "¥"+this.total.toFixed(2) } } // 更新大写金额 const upperCaseInput = dom.querySelector('input[data-field="upperCaseAmount"]') if (upperCaseInput) { - if (this.total !== 0) { - upperCaseInput.value = numberToChinese(this.total) - } + upperCaseInput.value = numberToChinese(this.total) + console.log('更新大写金额:', upperCaseInput.value, this.total) + } + - if (this.otherTotal !== 0) { + + if (this.otherTotal !== 0) { upperCaseInput.value = numberToChinese(this.otherTotal) - } + console.log('更新大写金额2:', upperCaseInput.value, this.otherTotal) } }, @@ -1730,7 +1739,7 @@ export default { const upperCaseInput = dom.querySelector('input[data-field="upperCaseAmount"]') if (totalInput && upperCaseInput) { - this.total = parseFloat(totalInput.value) || 0 + this.total = parseFloat(totalInput.value.replace(/¥/g, '')) || 0 upperCaseInput.value = numberToChinese(this.total) } }, diff --git a/src/views/contract/components/printPaymentForm.vue b/src/views/contract/components/printPaymentForm.vue index 6b3ac15..04a0b2b 100644 --- a/src/views/contract/components/printPaymentForm.vue +++ b/src/views/contract/components/printPaymentForm.vue @@ -79,6 +79,10 @@ import * as printJS from 'print-js' // 添加金额转大写的工具函数 function numberToChinese(num) { + if (num === 0) { + return '零元' + } + const units = ['', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟', '万'] const digits = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'] const [integer, decimal] = num.toString().split('.') @@ -123,6 +127,7 @@ function numberToChinese(num) { } } } + if (!decimal || parseInt(decimal) === 0) { result += '整' } @@ -153,6 +158,12 @@ export default { if (newVal) { this.$nextTick(() => { this.setupAmountListeners() + // 如果是差旅报销单,默认设置为横向打印 + if (newVal.includes('差旅报销单')) { + this.printOrientation = 'landscape' + }else{ + this.printOrientation = 'portrait' + } }) } }, @@ -537,7 +548,7 @@ export default { // 更新总金额输入框 const totalInput = dom.querySelector('input[data-field="total"]') if (totalInput) { - totalInput.value = total.toFixed(2) + totalInput.value = "¥"+total.toFixed(2) console.log('更新总金额输入框:', totalInput.value) } @@ -560,7 +571,7 @@ export default { const upperCaseInput = dom.querySelector('input[data-field="upperCaseAmount"]') if (totalInput && upperCaseInput) { - const total = parseFloat(totalInput.value) || 0 + const total = parseFloat(totalInput.value.replace(/¥/g, '')) || 0 upperCaseInput.value = numberToChinese(total) console.log('从总金额更新大写金额:', total, upperCaseInput.value) } @@ -702,6 +713,12 @@ export default { const originalContent = this.$refs['printtable'].cloneNode(true) tempContainer.appendChild(originalContent) + // 移除财务审核表 + const financeTable = tempContainer.querySelector('.finance-review-table') + if (financeTable) { + financeTable.remove() + } + this.replaceControls(tempContainer) const canvas = await html2canvas(tempContainer, { @@ -804,7 +821,7 @@ export default { const hasTravelExpense = this.getForms && this.getForms.includes('差旅报销单'); const hasUtilityBill = this.getForms && this.getForms.includes('水电费结算单'); const hasReimbursementForm2 = this.getForms && this.getForms.includes('报销贴单2'); - const scale = hasTravelExpense ? 0.66 : 0.9; + const scale = hasTravelExpense ? 1 : 1; const offset = hasTravelExpense ? 62 : 5; const translateX = ((pageWidth - pageWidth * scale) / 2 + offset).toFixed(2) + 'mm'; @@ -878,6 +895,33 @@ export default { table tr { height: 80px !important; min-height: 60px !important; } ` : ''} + /* 所有打印表格字体放大1.5倍 */ + table td[style*="font-size: 16px"] { font-size: 24px !important; } + table span[style*="font-size: 16px"] { font-size: 24px !important; } + table div[style*="font-size: 16px"] { font-size: 24px !important; } + table h2[style*="font-size: 20px"] { font-size: 30px !important; } + table h3[style*="font-size: 18px"] { font-size: 27px !important; } + table h4[style*="font-size: 16px"] { font-size: 24px !important; } + /* 覆盖所有可能的字体大小 */ + table * { font-size: 24px !important; } + table td { font-size: 24px !important; } + table span { font-size: 24px !important; } + table div { font-size: 24px !important; } + table input { font-size: 24px !important; } + table th { font-size: 24px !important; } + /* 表格外的标题和申请日期字体放大 */ + h2[style*="font-size: 20px"] { font-size: 30px !important; } + h3[style*="font-size: 18px"] { font-size: 27px !important; } + h4[style*="font-size: 16px"] { font-size: 24px !important; } + div[style*="font-size: 16px"] { font-size: 24px !important; } + span[style*="font-size: 16px"] { font-size: 24px !important; } + p[style*="font-size: 16px"] { font-size: 24px !important; } + /* 覆盖所有元素 */ + * { font-size: 24px !important; } + h2 { font-size: 30px !important; } + h3 { font-size: 27px !important; } + h4 { font-size: 24px !important; } + /* 报销贴单2特殊行高控制 */ ${hasReimbursementForm2 ? ` table td { height: 80px !important; min-height: 80px !important; line-height: 2.0 !important; } @@ -898,6 +942,30 @@ export default { transform-origin: top left; display: inline-block; } + /* 打印时所有表格字体放大1.5倍 */ + table td[style*="font-size: 16px"] { font-size: 24px !important; } + table span[style*="font-size: 16px"] { font-size: 24px !important; } + table div[style*="font-size: 16px"] { font-size: 24px !important; } + table h2[style*="font-size: 20px"] { font-size: 30px !important; } + table h3[style*="font-size: 18px"] { font-size: 27px !important; } + table h4[style*="font-size: 16px"] { font-size: 24px !important; } + table * { font-size: 24px !important; } + table td { font-size: 24px !important; } + table span { font-size: 24px !important; } + table div { font-size: 24px !important; } + table input { font-size: 24px !important; } + table th { font-size: 24px !important; } + /* 打印时表格外的标题和申请日期字体放大 */ + h2[style*="font-size: 20px"] { font-size: 30px !important; } + h3[style*="font-size: 18px"] { font-size: 27px !important; } + h4[style*="font-size: 16px"] { font-size: 24px !important; } + div[style*="font-size: 16px"] { font-size: 24px !important; } + span[style*="font-size: 16px"] { font-size: 24px !important; } + p[style*="font-size: 16px"] { font-size: 24px !important; } + * { font-size: 24px !important; } + h2 { font-size: 30px !important; } + h3 { font-size: 27px !important; } + h4 { font-size: 24px !important; } }