From d070cc04b83aeed45307800d35851e2019e72f48 Mon Sep 17 00:00:00 2001 From: linyongLynn <15926056+linyonglynn@user.noreply.gitee.com> Date: Sun, 27 Jul 2025 20:38:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=B7=AE=E6=97=85=E6=8A=A5?= =?UTF-8?q?=E9=94=80=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/paymentRegistration.vue | 16 ++++++++-- .../contract/components/printPaymentForm.vue | 32 +++++++++++++++---- src/views/contract/contractList.vue | 13 ++++++-- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/views/contract/components/paymentRegistration.vue b/src/views/contract/components/paymentRegistration.vue index f3852f6..a6fa54b 100644 --- a/src/views/contract/components/paymentRegistration.vue +++ b/src/views/contract/components/paymentRegistration.vue @@ -528,8 +528,17 @@ function syncFormDomToHtml(dom, contractTemplateFields) { checkedInput.setAttribute('checked', 'checked') } } else { - field.value = input.value - input.setAttribute('value', input.value) + if (input.tagName.toLowerCase() === 'textarea') { + // textarea 是双标签,内容在标签之间,不使用 value 属性 + field.value = input.value || input.textContent || '' + console.log('fieldName:'+fieldName+"--- "+field.value) + // 对于 textarea,直接设置内容到标签之间 + input.textContent = field.value + } else { + field.value = input.value + console.log('fieldName:'+fieldName+"--- "+input.value) + input.setAttribute('value', input.value) + } } } } @@ -1303,8 +1312,9 @@ export default { openZoomedTable() { const dom = this.$refs.mainTable if (dom && this.contract.contract_template) { - console.log(this.contract.contract_template.contract_template_fields) + //console.log(this.contract.contract_template.contract_template_fields) this.forms = syncFormDomToHtml(dom, this.contract.contract_template.contract_template_fields) + console.log('forms:'+this.forms) this.contract.forms = this.forms } this.zoomedDialogVisible = true diff --git a/src/views/contract/components/printPaymentForm.vue b/src/views/contract/components/printPaymentForm.vue index f604e60..76974b7 100644 --- a/src/views/contract/components/printPaymentForm.vue +++ b/src/views/contract/components/printPaymentForm.vue @@ -141,7 +141,7 @@ export default { isShow: false, currentForm: 'post', fundLog: null, - printOrientation: 'portrait' // 默认横向 + printOrientation: 'portrait' // 默认纵向 } }, computed: { @@ -173,7 +173,19 @@ export default { handler(newVal) { if (newVal) { this.$nextTick(() => { - this.setupAmountListeners() + // 检查 printtable 是否存在 + if (this.$refs.printtable) { + this.setupAmountListeners() + // 界面打开后,根据表单内容设置打印方向 + const hasTravelExpense = this.getForms && this.getForms.includes('差旅报销单'); + if (hasTravelExpense) { + this.printOrientation = 'landscape'; + console.log('检测到差旅报销单,设置为横向打印'); + } else { + this.printOrientation = 'portrait'; + console.log('其他表单,设置为纵向打印'); + } + } }) } }, @@ -354,8 +366,8 @@ export default { // 监听 total 输入框的变化 const totalInput = dom.querySelector('input[data-field="total"]') - console.log('totalInput', totalInput.value) if (totalInput) { + console.log('totalInput', totalInput.value) totalInput.removeEventListener('input', this.updateUpperCaseFromTotal) totalInput.removeEventListener('change', this.updateUpperCaseFromTotal) totalInput.removeEventListener('blur', this.updateUpperCaseFromTotal) @@ -371,6 +383,7 @@ export default { caculateRoadDay() { const sdateInput = this.$refs.printtable.querySelector('input[data-field^="sdate"]') const edateInput = this.$refs.printtable.querySelector('input[data-field^="edate"]') + if (!sdateInput || !edateInput) return const sdate = sdateInput.value const edate = edateInput.value if (sdate && edate) { @@ -684,7 +697,8 @@ export default { const textareas = element.getElementsByTagName('textarea') Array.from(textareas).forEach(textarea => { const span = document.createElement('span') - span.textContent = textarea.value || '' + // 优先使用 textContent,如果没有则使用 value + span.textContent = textarea.textContent || textarea.value || '' const style = window.getComputedStyle(textarea) // 先复制所有样式 span.style.cssText = style.cssText @@ -779,8 +793,14 @@ export default { checkedInput.setAttribute('checked', 'checked') } } else { - // 对于其他类型的输入,直接设置value - input.setAttribute('value', input.value) + if (input.tagName.toLowerCase() === 'textarea') { + // textarea 是双标签,内容在标签之间,不使用 value 属性 + input.textContent = input.value || '' + console.log('textarea fieldName:' + fieldName + "--- " + input.value) + } else { + // 对于其他类型的输入,直接设置value + input.setAttribute('value', input.value) + } } } }) diff --git a/src/views/contract/contractList.vue b/src/views/contract/contractList.vue index 51294e2..10edcd8 100644 --- a/src/views/contract/contractList.vue +++ b/src/views/contract/contractList.vue @@ -838,8 +838,17 @@ function syncFormDomToHtml(dom, contractTemplateFields) { checkedInput.setAttribute('checked', 'checked') } } else { - field.value = input.value - input.setAttribute('value', input.value) + if (input.tagName.toLowerCase() === 'textarea') { + // textarea 是双标签,内容在标签之间,不使用 value 属性 + field.value = input.value || input.textContent || '' + console.log('fieldName:'+fieldName+"--- "+field.value) + // 对于 textarea,直接设置内容到标签之间 + input.textContent = field.value + } else { + field.value = input.value + console.log('fieldName:'+fieldName+"--- "+input.value) + input.setAttribute('value', input.value) + } } } }