diff --git a/src/views/contract/components/paymentRegistration.vue b/src/views/contract/components/paymentRegistration.vue
index 4d900f4..4487307 100644
--- a/src/views/contract/components/paymentRegistration.vue
+++ b/src/views/contract/components/paymentRegistration.vue
@@ -1084,8 +1084,24 @@ export default {
let filledHtml = html
fields.forEach(field => {
- if (field.link_field && field.value !== undefined && field.value !== null && field.value !== '') {
- const fieldValue = String(field.value)
+ // 特殊字段:即使值为0或空字符串也要填充
+ const isSpecialField = field.field === 'auditAmount' || field.field === 'currentDuePayment' ||
+ field.field === 'currentPayment' || field.field === 'currentPaymentRemark' ||
+ field.field === 'totalPaid' || field.field === 'totalPlanned'
+
+ // 特殊字段或普通字段,只要有值就填充
+ if (isSpecialField || (field.value !== undefined && field.value !== null && field.value !== '')) {
+ // 特殊字段如果值为空,根据字段类型设置默认值
+ let fieldValue = ''
+ if (isSpecialField) {
+ if (field.field === 'currentPaymentRemark') {
+ fieldValue = String(field.value || '')
+ } else {
+ fieldValue = String(field.value || '0')
+ }
+ } else {
+ fieldValue = String(field.value)
+ }
// 先处理 textarea(双标签,需要特殊处理)
const textareaRegex = new RegExp(`()`, 'gi')
@@ -1096,6 +1112,21 @@ export default {
}
// 处理其他单标签控件(input, select等)
+ // 对于单选框,需要先移除所有同名的单选框的 checked 属性
+ if (field.field === 'currentPaymentRemark') {
+ const radioNameMatch = filledHtml.match(new RegExp(`]*data-field="${field.field}"[^>]*name="([^"]*)"[^>]*>`, 'i'))
+ if (radioNameMatch) {
+ const radioName = radioNameMatch[1]
+ // 转义特殊字符
+ const escapedRadioName = radioName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
+ // 先移除所有同名单选框的 checked 属性
+ const allRadioRegex = new RegExp(`(]*name="${escapedRadioName}"[^>]*)checked[^>]*>`, 'gi')
+ filledHtml = filledHtml.replace(allRadioRegex, (match) => {
+ return match.replace(/\s+checked(\s|>)/g, '$1')
+ })
+ }
+ }
+
const singleTagRegex = new RegExp(`<([^>]*data-field="${field.field}"[^>]*)>`, 'gi')
filledHtml = filledHtml.replace(singleTagRegex, (match) => {
const controlType = this.getControlType(match)
@@ -1103,9 +1134,24 @@ export default {
if (controlType === 'checkbox' || controlType === 'radio') {
// 对于复选框和单选框,需要处理 checked 属性
const currentValue = this.getControlValue(match)
- if (String(fieldValue) === String(currentValue)) {
+ const fieldValueTrimmed = String(fieldValue).trim()
+ const currentValueTrimmed = String(currentValue).trim()
+ if (field.field === 'currentPaymentRemark') {
+ console.log('HTML fill - currentPaymentRemark:', {
+ fieldValue: fieldValueTrimmed,
+ currentValue: currentValueTrimmed,
+ match: fieldValueTrimmed === currentValueTrimmed,
+ originalMatch: match
+ })
+ }
+ if (fieldValueTrimmed === currentValueTrimmed) {
if (!match.includes('checked')) {
- return match.replace('>', ' checked>')
+ // 在 > 之前插入 checked 属性,确保格式正确
+ const newMatch = match.replace(/(\s*)>/, ' checked$1>')
+ if (field.field === 'currentPaymentRemark') {
+ console.log('Added checked to HTML:', newMatch)
+ }
+ return newMatch
}
} else {
// 如果值不匹配,移除 checked 属性
@@ -1144,10 +1190,46 @@ export default {
// 为指定表格初始化模板字段值
initTemplateFieldsForTable(fields, contextData, tableIndex) {
+ // 先获取 previousPayment 的值(用于计算 totalPaid)
+ let previousPaymentValue = 0
+ const previousPaymentField = fields.find(f => f.field === 'previousPayment')
+ if (previousPaymentField && previousPaymentField.link_field && contextData && contextData.other_data_fill && contextData.other_data_fill[previousPaymentField.link_field]) {
+ previousPaymentValue = parseFloat(contextData.other_data_fill[previousPaymentField.link_field]) || 0
+ }
+
+ // 获取 currentPayment 的值(用于计算 totalPaid 和 totalPlanned)
+ const currentPaymentValue = parseFloat(this.paymentRegistrationForm.deductionMoney) || 0
+
// 遍历模板字段,先设置字段值
fields.forEach(field => {
- // 检查字段是否有link_field且该字段在other_data_fill中存在
- if (field.link_field && contextData.other_data_fill[field.link_field]) {
+ // 特殊字段处理:从 paymentRegistrationForm 中获取值
+ if (field.field === 'auditAmount') {
+ // 审计金额:从 paymentRegistrationForm.audit_money 获取,如果没有则为 0
+ field.value = this.paymentRegistrationForm.audit_money || '0'
+ } else if (field.field === 'currentDuePayment') {
+ // 当前应付金额:从 paymentRegistrationForm.applyMoney 获取,如果没有则为 0
+ field.value = this.paymentRegistrationForm.applyMoney || '0'
+ } else if (field.field === 'currentPayment') {
+ // 当前扣款金额:从 paymentRegistrationForm.deductionMoney 获取,如果没有则为 0
+ field.value = this.paymentRegistrationForm.deductionMoney || '0'
+ } else if (field.field === 'currentPaymentRemark') {
+ // 当前付款备注:从 paymentRegistrationForm.type 获取,如果没有则为空字符串
+ field.value = this.paymentRegistrationForm.type || ''
+ console.log('currentPaymentRemark field value:', field.value, 'from paymentRegistrationForm.type:', this.paymentRegistrationForm.type)
+ } else if (field.field === 'totalPaid') {
+ // 累计已付款:previousPayment + currentPayment
+ const totalPaidValue = previousPaymentValue + currentPaymentValue
+ field.value = totalPaidValue.toString()
+ } else if (field.field === 'totalPlanned') {
+ // 累计计划付款:对照值(从 other_data_fill 获取)+ currentPayment
+ let baseValue = 0
+ if (field.link_field && contextData && contextData.other_data_fill && contextData.other_data_fill[field.link_field]) {
+ baseValue = parseFloat(contextData.other_data_fill[field.link_field]) || 0
+ }
+ const totalPlannedValue = baseValue + currentPaymentValue
+ field.value = totalPlannedValue.toString()
+ } else if (field.link_field && contextData && contextData.other_data_fill && contextData.other_data_fill[field.link_field]) {
+ // 普通字段:从 other_data_fill 中获取
let value = contextData.other_data_fill[field.link_field]
// 如果是upper_money字段,转换为金额大写
@@ -1166,18 +1248,86 @@ export default {
const dom = tableIndex === 1 ? this.$refs.mainTable1 : this.$refs.mainTable2
if (dom) {
+ // 先处理所有单选框组,取消选中状态
+ const radioGroups = new Set()
+ fields.forEach(field => {
+ if (field.field === 'currentPaymentRemark') {
+ const input = dom.querySelector(`[data-field="${field.field}"]`)
+ if (input && input.type === 'radio' && input.name) {
+ radioGroups.add(input.name)
+ }
+ }
+ })
+
+ // 取消所有单选框组的选中状态
+ radioGroups.forEach(radioName => {
+ const allRadios = dom.querySelectorAll(`input[type="radio"][name="${radioName}"]`)
+ allRadios.forEach(radio => {
+ radio.checked = false
+ radio.removeAttribute('checked')
+ })
+ })
+
// 遍历字段,填充到DOM
fields.forEach(field => {
- if (field.link_field && field.value !== undefined && field.value !== null && field.value !== '') {
+ if (field.field === 'currentPaymentRemark') {
+ // 特殊处理 currentPaymentRemark 单选框
+ const fieldValueStr = String(field.value || '').trim()
+ console.log('Processing currentPaymentRemark, fieldValue:', fieldValueStr)
+ if (fieldValueStr) {
+ // 先取消所有单选框的选中状态
+ const allRadios = dom.querySelectorAll(`input[type="radio"][data-field="currentPaymentRemark"]`)
+ console.log('Found radios:', allRadios.length)
+ allRadios.forEach(radio => {
+ radio.checked = false
+ radio.removeAttribute('checked')
+ const inputValueStr = String(radio.value || '').trim()
+ console.log('Radio value:', inputValueStr, 'matches?', fieldValueStr === inputValueStr)
+ if (fieldValueStr === inputValueStr) {
+ radio.checked = true
+ radio.setAttribute('checked', 'checked')
+ // 触发 change 事件以确保UI更新
+ const changeEvent = new Event('change', { bubbles: true })
+ radio.dispatchEvent(changeEvent)
+ // 也触发 click 事件以确保视觉更新
+ const clickEvent = new Event('click', { bubbles: true })
+ radio.dispatchEvent(clickEvent)
+ console.log('currentPaymentRemark selected:', {
+ fieldValue: fieldValueStr,
+ inputValue: inputValueStr,
+ radio: radio
+ })
+ }
+ })
+ }
+ } else {
const input = dom.querySelector(`[data-field="${field.field}"]`)
- if (input) {
- if (input.type === 'checkbox' || input.type === 'radio') {
- if (String(field.value) === input.value) {
+ if (!input) return
+
+ // 处理单选框和复选框
+ if (input.type === 'checkbox' || input.type === 'radio') {
+ // 检查值是否匹配
+ if (field.value !== undefined && field.value !== null && field.value !== '') {
+ const fieldValueStr = String(field.value).trim()
+ const inputValueStr = String(input.value).trim()
+ if (fieldValueStr === inputValueStr) {
input.checked = true
+ input.setAttribute('checked', 'checked')
}
- } else if (input.tagName.toLowerCase() === 'textarea') {
+ }
+ } else if (input.tagName.toLowerCase() === 'textarea') {
+ // 处理文本域
+ if (field.value !== undefined && field.value !== null) {
input.textContent = field.value
- } else {
+ }
+ } else {
+ // 处理普通输入框
+ // 特殊字段即使值为0也要填充
+ if (field.field === 'auditAmount' || field.field === 'currentDuePayment' ||
+ field.field === 'currentPayment' || field.field === 'totalPaid' ||
+ field.field === 'totalPlanned') {
+ input.value = field.value || '0'
+ } else if (field.value !== undefined && field.value !== null && field.value !== '') {
input.value = field.value
}
}
diff --git a/src/views/contract/components/printPaymentForm.vue b/src/views/contract/components/printPaymentForm.vue
index bf8bf0b..e35ad45 100644
--- a/src/views/contract/components/printPaymentForm.vue
+++ b/src/views/contract/components/printPaymentForm.vue
@@ -745,26 +745,26 @@ export default {
// 对于其他类型的输入,直接设置value
// 如果是资金划拨审批单,为特定字段设置默认值
if (this.getForms && this.getForms.includes('资金划拨审批单')) {
- const amountFields = ['contractAmount', 'auditAmount', 'previousPayment', 'currentPayment', 'currentDuePayment', 'totalPaid', 'totalPlanned']
- if (amountFields.includes(fieldName)) {
- if (fieldName === 'previousPayment' && this.fundLog) {
- // previousPayment字段设置为this.fundLog中的total_act_money字段值
- input.setAttribute('value', this.fundLog.total_act_money)
- } else if (fieldName === 'totalPaid' && this.fundLog) {
- // totalPaid字段设置为this.fundLog.total_act_money + currentPayment的值
- const currentPaymentInput = dom.querySelector('input[data-field="currentDuePayment"]')
- console.log('currentPaymentInput',currentPaymentInput.value)
- const currentPaymentValue = currentPaymentInput ? (parseFloat(currentPaymentInput.value) || 0) : 0
- const totalPaidValue = (parseFloat(this.fundLog.total_act_money) || 0) + currentPaymentValue
- input.setAttribute('value', totalPaidValue.toString())
- } else if (!input.value || input.value === '') {
- input.setAttribute('value', '0')
- } else {
- input.setAttribute('value', input.value)
- }
- } else {
- input.setAttribute('value', input.value)
- }
+ // const amountFields = ['contractAmount', 'auditAmount', 'previousPayment', 'currentPayment', 'currentDuePayment', 'totalPaid', 'totalPlanned']
+ // if (amountFields.includes(fieldName)) {
+ // if (fieldName === 'previousPayment' && this.fundLog) {
+ // // previousPayment字段设置为this.fundLog中的total_act_money字段值
+ // input.setAttribute('value', this.fundLog.total_act_money)
+ // } else if (fieldName === 'totalPaid' && this.fundLog) {
+ // // totalPaid字段设置为this.fundLog.total_act_money + currentPayment的值
+ // const currentPaymentInput = dom.querySelector('input[data-field="currentDuePayment"]')
+ // console.log('currentPaymentInput',currentPaymentInput.value)
+ // const currentPaymentValue = currentPaymentInput ? (parseFloat(currentPaymentInput.value) || 0) : 0
+ // const totalPaidValue = (parseFloat(this.fundLog.total_act_money) || 0) + currentPaymentValue
+ // input.setAttribute('value', totalPaidValue.toString())
+ // } else if (!input.value || input.value === '') {
+ // input.setAttribute('value', '0')
+ // } else {
+ // input.setAttribute('value', input.value)
+ // }
+ // } else {
+ // input.setAttribute('value', input.value)
+ // }
} else {
input.setAttribute('value', input.value)
}
diff --git a/src/views/contract/contractList.vue b/src/views/contract/contractList.vue
index 971001c..74e8ba6 100644
--- a/src/views/contract/contractList.vue
+++ b/src/views/contract/contractList.vue
@@ -215,6 +215,7 @@
+
-
-
+
-
+
@@ -537,6 +537,9 @@ import {
getInfo
} from '@/api/user.js'
import { getContractCategoryTemplateBaseConfig } from '@/api/businessConfig/businessConfig'
+import {
+ download
+} from '@/utils/downloadRequest'
import editor from './components/editorContract'
import detail from './components/detailContract'
@@ -1167,6 +1170,20 @@ export default {
this.select.pageIndex = 1
this.getContracts()
},
+ // 导出Excel
+ downloadExel() {
+ download(
+ '/api/admin/contract/index',
+ 'get', {
+ is_auth: 1,
+ is_export: 1,
+ ...this.select,
+ contract_category: [null, this.select.contract_category],
+ page:1,
+ page_size:9999
+ },
+ '合同列表.xlsx')
+ },
clearSelectForSearch() {
this.select.plan_id = ''
this.select.plan_name = ''