|
|
|
|
@ -521,6 +521,7 @@ export default {
|
|
|
|
|
forms1: null, // 事后支付表格1的HTML
|
|
|
|
|
forms2: null, // 事后支付表格2的HTML
|
|
|
|
|
activePostPaymentTab: 'form1', // 当前激活的tab
|
|
|
|
|
_uppercaseDomCleanups: null, // Map<HTMLElement, function> 用于移除大写联动委托监听
|
|
|
|
|
payTable: [
|
|
|
|
|
{
|
|
|
|
|
label: '款项类型',
|
|
|
|
|
@ -1398,6 +1399,7 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentDom && templateFields) {
|
|
|
|
|
this.applyConfigurableUppercase(currentDom, templateFields)
|
|
|
|
|
// 获取所有输入控件
|
|
|
|
|
const inputs = currentDom.querySelectorAll('input, select, textarea')
|
|
|
|
|
|
|
|
|
|
@ -1724,6 +1726,7 @@ export default {
|
|
|
|
|
|
|
|
|
|
// 使用setTimeout确保DOM完全加载
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.detachConfigurableUppercase(dom)
|
|
|
|
|
|
|
|
|
|
const sdateAmountInputs = dom.querySelectorAll('input[data-field^="sdate"]')
|
|
|
|
|
// 移除旧的监听器
|
|
|
|
|
@ -1912,8 +1915,115 @@ export default {
|
|
|
|
|
amount: dom.querySelectorAll('input[data-field^="amount"]').length,
|
|
|
|
|
total: dom.querySelectorAll('input[data-field="total"]').length
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const templateFields = this.getTemplateFieldsForDom(dom)
|
|
|
|
|
this.attachConfigurableUppercase(dom, templateFields)
|
|
|
|
|
}, 100)
|
|
|
|
|
},
|
|
|
|
|
getTemplateFieldsForDom(dom) {
|
|
|
|
|
if (!dom) return null
|
|
|
|
|
const r = this.$refs
|
|
|
|
|
if (r.mainTable1 && dom === r.mainTable1) {
|
|
|
|
|
return (this.contract && this.contract.contract_template && this.contract.contract_template.contract_template_fields) || null
|
|
|
|
|
}
|
|
|
|
|
if (r.mainTable2 && dom === r.mainTable2) {
|
|
|
|
|
return (this.contract && this.contract.contract_template2 && this.contract.contract_template2.contract_template_fields) || null
|
|
|
|
|
}
|
|
|
|
|
if (r.zoomedTable && dom === r.zoomedTable) {
|
|
|
|
|
if (this.activePostPaymentTab === 'form1') {
|
|
|
|
|
return (this.contract && this.contract.contract_template && this.contract.contract_template.contract_template_fields) || null
|
|
|
|
|
}
|
|
|
|
|
if (this.activePostPaymentTab === 'form2') {
|
|
|
|
|
return (this.contract && this.contract.contract_template2 && this.contract.contract_template2.contract_template_fields) || null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
},
|
|
|
|
|
detachConfigurableUppercase(dom) {
|
|
|
|
|
if (!this._uppercaseDomCleanups || !dom) return
|
|
|
|
|
const cleanup = this._uppercaseDomCleanups.get(dom)
|
|
|
|
|
if (cleanup) {
|
|
|
|
|
cleanup()
|
|
|
|
|
this._uppercaseDomCleanups.delete(dom)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
attachConfigurableUppercase(dom, templateFields) {
|
|
|
|
|
if (!dom) return
|
|
|
|
|
if (!this._uppercaseDomCleanups) {
|
|
|
|
|
this._uppercaseDomCleanups = new Map()
|
|
|
|
|
}
|
|
|
|
|
const sourceFields = new Set()
|
|
|
|
|
if (templateFields && templateFields.length) {
|
|
|
|
|
templateFields.forEach(m => {
|
|
|
|
|
const cfg = m.uppercase_source
|
|
|
|
|
const s = cfg && cfg.mode === 'field' && cfg.source_field
|
|
|
|
|
if (s) sourceFields.add(s)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (sourceFields.size > 0) {
|
|
|
|
|
const handler = (e) => {
|
|
|
|
|
const t = e.target
|
|
|
|
|
if (!t || !t.getAttribute) return
|
|
|
|
|
const df = t.getAttribute('data-field')
|
|
|
|
|
if (df && sourceFields.has(df)) {
|
|
|
|
|
this.applyConfigurableUppercase(dom, templateFields)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const types = ['input', 'change', 'blur']
|
|
|
|
|
types.forEach(type => dom.addEventListener(type, handler, true))
|
|
|
|
|
const cleanup = () => {
|
|
|
|
|
types.forEach(type => dom.removeEventListener(type, handler, true))
|
|
|
|
|
}
|
|
|
|
|
this._uppercaseDomCleanups.set(dom, cleanup)
|
|
|
|
|
}
|
|
|
|
|
this.applyConfigurableUppercase(dom, templateFields)
|
|
|
|
|
},
|
|
|
|
|
parseMoneyForUppercase(raw) {
|
|
|
|
|
if (raw == null) return { kind: 'empty' }
|
|
|
|
|
const s = String(raw).trim()
|
|
|
|
|
if (s === '') return { kind: 'empty' }
|
|
|
|
|
const cleaned = s.replace(/[¥¥\s,,]/g, '')
|
|
|
|
|
if (cleaned === '') return { kind: 'empty' }
|
|
|
|
|
const n = parseFloat(cleaned)
|
|
|
|
|
if (!Number.isFinite(n)) return { kind: 'invalid' }
|
|
|
|
|
return { kind: 'ok', value: n }
|
|
|
|
|
},
|
|
|
|
|
getSourceFieldRawValue(dom, fieldName) {
|
|
|
|
|
if (!dom || !fieldName) return ''
|
|
|
|
|
const radios = dom.querySelectorAll(`input[type="radio"][data-field="${fieldName}"]`)
|
|
|
|
|
if (radios.length) {
|
|
|
|
|
const c = dom.querySelector(`input[type="radio"][data-field="${fieldName}"]:checked`)
|
|
|
|
|
return c ? String(c.value) : ''
|
|
|
|
|
}
|
|
|
|
|
const el = dom.querySelector(`input[data-field="${fieldName}"],select[data-field="${fieldName}"],textarea[data-field="${fieldName}"]`)
|
|
|
|
|
if (!el) return ''
|
|
|
|
|
if (el.type === 'checkbox') {
|
|
|
|
|
const c = dom.querySelector(`input[type="checkbox"][data-field="${fieldName}"]:checked`)
|
|
|
|
|
return c ? String(c.value) : ''
|
|
|
|
|
}
|
|
|
|
|
return el.value != null ? String(el.value) : ''
|
|
|
|
|
},
|
|
|
|
|
setConfigurableTargetFieldValue(dom, fieldName, text) {
|
|
|
|
|
if (!dom || !fieldName) return
|
|
|
|
|
const els = dom.querySelectorAll(`input[data-field="${fieldName}"],textarea[data-field="${fieldName}"],select[data-field="${fieldName}"]`)
|
|
|
|
|
els.forEach((el) => {
|
|
|
|
|
if (el.type === 'radio' || el.type === 'checkbox') return
|
|
|
|
|
el.value = text
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
applyConfigurableUppercase(dom, templateFields) {
|
|
|
|
|
if (!dom || !templateFields || !templateFields.length) return
|
|
|
|
|
templateFields.forEach((meta) => {
|
|
|
|
|
const conf = meta.uppercase_source
|
|
|
|
|
if (!conf || conf.mode !== 'field' || !conf.source_field) return
|
|
|
|
|
const src = conf.source_field
|
|
|
|
|
if (src === meta.field) return
|
|
|
|
|
const raw = this.getSourceFieldRawValue(dom, src)
|
|
|
|
|
const parsed = this.parseMoneyForUppercase(raw)
|
|
|
|
|
const val = parsed.kind === 'ok' ? numberToChinese(parsed.value) : ''
|
|
|
|
|
this.setConfigurableTargetFieldValue(dom, meta.field, val)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
caculateRoadDay() {
|
|
|
|
|
// 计算当前激活的表格
|
|
|
|
|
let currentDom = null
|
|
|
|
|
@ -2166,6 +2276,9 @@ export default {
|
|
|
|
|
upperCaseInput.value = numberToChinese(this.otherTotal)
|
|
|
|
|
console.log('更新大写金额2:', upperCaseInput.value, this.otherTotal)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const tf = this.getTemplateFieldsForDom(dom)
|
|
|
|
|
if (tf) this.applyConfigurableUppercase(dom, tf)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updateUpperCaseFromTotal(event, dom) {
|
|
|
|
|
@ -2178,6 +2291,8 @@ export default {
|
|
|
|
|
this.total = parseFloat(totalInput.value.replace(/¥/g, '')) || 0
|
|
|
|
|
upperCaseInput.value = numberToChinese(this.total)
|
|
|
|
|
}
|
|
|
|
|
const tf = this.getTemplateFieldsForDom(dom)
|
|
|
|
|
if (tf) this.applyConfigurableUppercase(dom, tf)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 显示历史记录弹窗
|
|
|
|
|
|