完成合同支持两个表格

master
linyongLynn 4 months ago
parent 8386826a16
commit 611b700d80

File diff suppressed because it is too large Load Diff

@ -277,7 +277,16 @@
<i class="el-icon-time" /> 查看同类历史记录 <i class="el-icon-time" /> 查看同类历史记录
</el-button> </el-button>
</div> </div>
<div ref="mainTable" class="payment-table" v-html="forms" />
<!-- Tab切换 -->
<el-tabs v-model="activePostPaymentTab" @tab-click="handleTabClick">
<el-tab-pane label="事后支付表格1" name="form1">
<div ref="mainTable1" class="payment-table" v-html="forms1" />
</el-tab-pane>
<el-tab-pane label="事后支付表格2" name="form2">
<div ref="mainTable2" class="payment-table" v-html="forms2" />
</el-tab-pane>
</el-tabs>
</div> </div>
</template> </template>
@ -293,7 +302,7 @@
<!-- 放大窗口 --> <!-- 放大窗口 -->
<el-dialog <el-dialog
title="事后支付表格" :title="getZoomedDialogTitle()"
:visible.sync="zoomedDialogVisible" :visible.sync="zoomedDialogVisible"
width="80%" width="80%"
:append-to-body="false" :append-to-body="false"
@ -303,7 +312,7 @@
custom-class="zoomed-table-dialog" custom-class="zoomed-table-dialog"
@close="handleZoomedDialogClose" @close="handleZoomedDialogClose"
> >
<div ref="zoomedTable" class="zoomed-table" v-html="forms" /> <div ref="zoomedTable" class="zoomed-table" v-html="getCurrentZoomedForms()" />
</el-dialog> </el-dialog>
<!-- 历史记录弹窗 --> <!-- 历史记录弹窗 -->
@ -560,6 +569,9 @@ export default {
payment: [], // payment: [], //
contractTemplate: null, // HTML contractTemplate: null, // HTML
forms: null, // HTML forms: null, // HTML
forms1: null, // 1HTML
forms2: null, // 2HTML
activePostPaymentTab: 'form1', // tab
payTable: [ payTable: [
{ {
label: '款项类型', label: '款项类型',
@ -810,8 +822,11 @@ export default {
this.currentStep = 1 // this.currentStep = 1 //
this.paymentRegistrationForm = this.getDefaultPaymentRegistrationForm() // this.paymentRegistrationForm = this.getDefaultPaymentRegistrationForm() //
this.forms = null // <---HTML this.forms = null // <---HTML
this.forms1 = null // <---1HTML
this.forms2 = null // <---2HTML
this.contract = {} // <--- this.contract = {} // <---
this.contractTemplate = null // <--- this.contractTemplate = null // <---
this.activePostPaymentTab = 'form1' // <--- tab
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.paymentRegistration && this.$refs.paymentRegistration.$refs.elForm) { if (this.$refs.paymentRegistration && this.$refs.paymentRegistration.$refs.elForm) {
this.$refs.paymentRegistration.$refs.elForm.resetFields() this.$refs.paymentRegistration.$refs.elForm.resetFields()
@ -819,12 +834,22 @@ export default {
}) })
} }
}, },
forms: { // forms1 forms2
forms1: {
handler(newVal) { handler(newVal) {
if (newVal) { if (newVal) {
// forms
this.$nextTick(() => { this.$nextTick(() => {
this.setupAmountListeners(this.$refs.mainTable) this.setupAmountListeners(this.$refs.mainTable1)
})
}
},
immediate: true
},
forms2: {
handler(newVal) {
if (newVal) {
this.$nextTick(() => {
this.setupAmountListeners(this.$refs.mainTable2)
}) })
} }
}, },
@ -1005,6 +1030,9 @@ export default {
this.currentStep = 1 this.currentStep = 1
this.contractTemplate = this.contract.contract_template.template this.contractTemplate = this.contract.contract_template.template
this.forms = this.contractTemplate this.forms = this.contractTemplate
// tab
this.forms1 = this.contractTemplate
this.forms2 = this.contractTemplate
if (!this.contract.contract_template.contract_template_fields) { if (!this.contract.contract_template.contract_template_fields) {
this.contract.contract_template.contract_template_fields = this.contract.other_data || [] this.contract.contract_template.contract_template_fields = this.contract.other_data || []
} }
@ -1013,6 +1041,8 @@ export default {
this.currentStep = 1 this.currentStep = 1
this.contractTemplate = null this.contractTemplate = null
this.forms = null this.forms = null
this.forms1 = null
this.forms2 = null
} }
// //
@ -1029,13 +1059,43 @@ export default {
// amount // amount
this.$nextTick(() => { this.$nextTick(() => {
// //
this.setupAmountListeners(this.$refs.mainTable) this.setupAmountListeners(this.$refs.mainTable1)
this.setupAmountListeners(this.$refs.mainTable2)
// //
this.setupAmountListeners(this.$refs.zoomedTable) this.setupAmountListeners(this.$refs.zoomedTable)
}) })
}, },
// tab
handleTabClick(tab) {
this.activePostPaymentTab = tab.name
// tab
this.$nextTick(() => {
if (tab.name === 'form1') {
this.setupAmountListeners(this.$refs.mainTable1)
} else if (tab.name === 'form2') {
this.setupAmountListeners(this.$refs.mainTable2)
}
})
},
//
getZoomedDialogTitle() {
return `事后支付表格${this.activePostPaymentTab === 'form1' ? '1' : '2'}`
},
//
getCurrentZoomedForms() {
// tab
if (this.activePostPaymentTab === 'form1') {
return this.forms1
} else if (this.activePostPaymentTab === 'form2') {
return this.forms2
}
return this.forms
},
// //
initTemplateFields(contextData) { initTemplateFields(contextData) {
if (!contextData || !contextData.other_data_fill) return if (!contextData || !contextData.other_data_fill) return
@ -1059,28 +1119,46 @@ export default {
field.value = value field.value = value
// DOM // DOM
const dom = this.$refs.mainTable const dom1 = this.$refs.mainTable1
if (dom) { const dom2 = this.$refs.mainTable2
const input = dom.querySelector(`[data-field="${field.field}"]`)
if (input) { if (dom1) {
if (input.type === 'checkbox' || input.type === 'radio') { const input1 = dom1.querySelector(`[data-field="${field.field}"]`)
// checked if (input1) {
if (field.value === input.value) { if (input1.type === 'checkbox' || input1.type === 'radio') {
input.checked = true if (field.value === input1.value) {
input1.checked = true
}
} else {
input1.value = field.value
}
}
}
if (dom2) {
const input2 = dom2.querySelector(`[data-field="${field.field}"]`)
if (input2) {
if (input2.type === 'checkbox' || input2.type === 'radio') {
if (field.value === input2.value) {
input2.checked = true
} }
} else { } else {
// value input2.value = field.value
input.value = field.value
} }
} }
} }
} }
}) })
// forms // tab
if (this.$refs.mainTable) { if (this.$refs.mainTable1) {
this.forms = syncFormDomToHtml(this.$refs.mainTable, fields) this.forms1 = syncFormDomToHtml(this.$refs.mainTable1, fields)
} }
if (this.$refs.mainTable2) {
this.forms2 = syncFormDomToHtml(this.$refs.mainTable2, fields)
}
// forms
this.forms = this.forms1
} }
}, },
@ -1090,10 +1168,17 @@ export default {
if (res) { if (res) {
// //
if (this.contract.contract_template) { if (this.contract.contract_template) {
const dom = this.$refs.zoomedTable // tabDOM
if (dom) { let currentDom = null
if (this.activePostPaymentTab === 'form1') {
currentDom = this.$refs.mainTable1
} else if (this.activePostPaymentTab === 'form2') {
currentDom = this.$refs.mainTable2
}
if (currentDom) {
// //
const inputs = dom.querySelectorAll('input, select, textarea') const inputs = currentDom.querySelectorAll('input, select, textarea')
// HTML // HTML
inputs.forEach(input => { inputs.forEach(input => {
@ -1103,7 +1188,7 @@ export default {
if (field) { if (field) {
if (input.type === 'checkbox' || input.type === 'radio') { if (input.type === 'checkbox' || input.type === 'radio') {
// //
const checkedInput = dom.querySelector(`[data-field="${fieldName}"]:checked`) const checkedInput = currentDom.querySelector(`[data-field="${fieldName}"]:checked`)
field.value = checkedInput ? checkedInput.value : '' field.value = checkedInput ? checkedInput.value : ''
// HTML checked // HTML checked
if (checkedInput) { if (checkedInput) {
@ -1118,8 +1203,14 @@ export default {
} }
}) })
// HTML // HTML
this.forms = dom.innerHTML if (this.activePostPaymentTab === 'form1') {
this.forms1 = currentDom.innerHTML
this.forms = this.forms1
} else if (this.activePostPaymentTab === 'form2') {
this.forms2 = currentDom.innerHTML
this.forms = this.forms2
}
} }
} }
@ -1255,9 +1346,15 @@ export default {
} }
// //
const mainTable = this.$refs.mainTable let currentDom = null
if (mainTable) { if (this.activePostPaymentTab === 'form1') {
const currentPaymentInput = mainTable.querySelector('input[data-field="currentDuePayment"]') currentDom = this.$refs.mainTable1
} else if (this.activePostPaymentTab === 'form2') {
currentDom = this.$refs.mainTable2
}
if (currentDom) {
const currentPaymentInput = currentDom.querySelector('input[data-field="currentDuePayment"]')
if (currentPaymentInput) { if (currentPaymentInput) {
const inputValue = currentPaymentInput.value const inputValue = currentPaymentInput.value
if (inputValue && Number(inputValue) > 0) { if (inputValue && Number(inputValue) > 0) {
@ -1270,9 +1367,23 @@ export default {
// currentStep=2 // currentStep=2
if (this.hasPostPaymentForm) { if (this.hasPostPaymentForm) {
// HTML openZoomedTable // HTML openZoomedTable
const dom = this.$refs.mainTable let currentDom = null
if (dom && this.contract.contract_template) { if (this.activePostPaymentTab === 'form1') {
this.forms = syncFormDomToHtml(dom, this.contract.contract_template.contract_template_fields) currentDom = this.$refs.mainTable1
} else if (this.activePostPaymentTab === 'form2') {
currentDom = this.$refs.mainTable2
}
if (currentDom && this.contract.contract_template) {
const updatedForms = syncFormDomToHtml(currentDom, this.contract.contract_template.contract_template_fields)
//
if (this.activePostPaymentTab === 'form1') {
this.forms1 = updatedForms
this.forms = this.forms1
} else if (this.activePostPaymentTab === 'form2') {
this.forms2 = updatedForms
this.forms = this.forms2
}
this.contract.forms = this.forms this.contract.forms = this.forms
} }
this.currentStep = 2 this.currentStep = 2
@ -1310,12 +1421,25 @@ export default {
// //
openZoomedTable() { openZoomedTable() {
const dom = this.$refs.mainTable // tabDOM
if (dom && this.contract.contract_template) { let currentDom = null
if (this.activePostPaymentTab === 'form1') {
currentDom = this.$refs.mainTable1
} else if (this.activePostPaymentTab === 'form2') {
currentDom = this.$refs.mainTable2
}
if (currentDom && 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) const updatedForms = syncFormDomToHtml(currentDom, this.contract.contract_template.contract_template_fields)
console.log('forms:'+this.forms) console.log('forms:'+updatedForms)
this.contract.forms = this.forms //
if (this.activePostPaymentTab === 'form1') {
this.forms1 = updatedForms
} else if (this.activePostPaymentTab === 'form2') {
this.forms2 = updatedForms
}
this.contract.forms = updatedForms
} }
this.zoomedDialogVisible = true this.zoomedDialogVisible = true
// amount // amount
@ -1330,8 +1454,28 @@ export default {
handleZoomedDialogClose() { handleZoomedDialogClose() {
const dom = this.$refs.zoomedTable const dom = this.$refs.zoomedTable
if (dom && this.contract.contract_template) { if (dom && this.contract.contract_template) {
this.forms = syncFormDomToHtml(dom, this.contract.contract_template.contract_template_fields) //
this.contract.forms = this.forms const updatedForms = syncFormDomToHtml(dom, this.contract.contract_template.contract_template_fields)
// tab
if (this.activePostPaymentTab === 'form1') {
this.forms1 = updatedForms
} else if (this.activePostPaymentTab === 'form2') {
this.forms2 = updatedForms
}
// forms
this.forms = updatedForms
this.contract.forms = updatedForms
//
this.$nextTick(() => {
if (this.activePostPaymentTab === 'form1' && this.$refs.mainTable1) {
this.setupAmountListeners(this.$refs.mainTable1)
} else if (this.activePostPaymentTab === 'form2' && this.$refs.mainTable2) {
this.setupAmountListeners(this.$refs.mainTable2)
}
})
} }
this.zoomedDialogVisible = false this.zoomedDialogVisible = false
}, },
@ -1514,22 +1658,49 @@ export default {
// //
// this.calculateTotal() // this.calculateTotal()
console.log('setupAmountListeners: listeners setup completed for dom', dom)
console.log('Found inputs:', {
sdate: dom.querySelectorAll('input[data-field^="sdate"]').length,
edate: dom.querySelectorAll('input[data-field^="edate"]').length,
wan: dom.querySelectorAll('input[data-field^="wan"]').length,
qian: dom.querySelectorAll('input[data-field^="qian"]').length,
bai: dom.querySelectorAll('input[data-field^="bai"]').length,
shi: dom.querySelectorAll('input[data-field^="shi"]').length,
yuan: dom.querySelectorAll('input[data-field^="yuan"]').length,
jiao: dom.querySelectorAll('input[data-field^="jiao"]').length,
fen: dom.querySelectorAll('input[data-field^="fen"]').length,
amount: dom.querySelectorAll('input[data-field^="amount"]').length,
total: dom.querySelectorAll('input[data-field="total"]').length
})
}, 100) }, 100)
}, },
caculateRoadDay() { caculateRoadDay() {
const sdateInput = this.$refs.mainTable.querySelector('input[data-field^="sdate"]') //
const edateInput = this.$refs.mainTable.querySelector('input[data-field^="edate"]') let currentDom = null
const sdate = sdateInput.value if (this.activePostPaymentTab === 'form1') {
const edate = edateInput.value currentDom = this.$refs.mainTable1
if (sdate && edate) { } else if (this.activePostPaymentTab === 'form2') {
const s = new Date(sdate) currentDom = this.$refs.mainTable2
const e = new Date(edate) }
//
const roadDay = Math.floor((e - s) / (1000 * 60 * 60 * 24)) + 1 if (currentDom) {
console.log('roadDay', sdate, edate, roadDay) const sdateInput = currentDom.querySelector('input[data-field^="sdate"]')
const roadDayInput = this.$refs.mainTable.querySelector('input[data-field="roadDay"]') const edateInput = currentDom.querySelector('input[data-field^="edate"]')
if (roadDayInput) { if (sdateInput && edateInput) {
roadDayInput.value = roadDay const sdate = sdateInput.value
const edate = edateInput.value
if (sdate && edate) {
const s = new Date(sdate)
const e = new Date(edate)
//
const roadDay = Math.floor((e - s) / (1000 * 60 * 60 * 24)) + 1
console.log('roadDay', sdate, edate, roadDay)
const roadDayInput = currentDom.querySelector('input[data-field="roadDay"]')
if (roadDayInput) {
roadDayInput.value = roadDay
}
}
} }
} }
@ -1553,10 +1724,26 @@ export default {
}, },
calculateTotal() { calculateTotal() {
// console.log('calculateTotal called')
this.calculateTableTotal(this.$refs.mainTable)
//
let currentDom = null
if (this.activePostPaymentTab === 'form1') {
currentDom = this.$refs.mainTable1
} else if (this.activePostPaymentTab === 'form2') {
currentDom = this.$refs.mainTable2
}
if (currentDom) {
console.log('calculateTotal: calculating for current tab dom', currentDom)
this.calculateTableTotal(currentDom)
}
// //
this.calculateTableTotal(this.$refs.zoomedTable) if (this.$refs.zoomedTable) {
console.log('calculateTotal: calculating for zoomed table')
this.calculateTableTotal(this.$refs.zoomedTable)
}
}, },
calculateTableTotal(dom) { calculateTableTotal(dom) {
@ -1979,6 +2166,40 @@ export default {
padding: 20px 0; padding: 20px 0;
} }
// Tab
::v-deep .el-tabs__header {
margin-bottom: 20px;
border-bottom: 2px solid #EBEEF5;
}
::v-deep .el-tabs__item {
font-size: 14px;
font-weight: 500;
color: #606266;
padding: 0 20px;
height: 40px;
line-height: 40px;
transition: all 0.3s;
&.is-active {
color: #409EFF;
font-weight: 600;
}
&:hover {
color: #409EFF;
}
}
::v-deep .el-tabs__active-bar {
background-color: #409EFF;
height: 2px;
}
::v-deep .el-tabs__content {
padding: 0;
}
::v-deep table { ::v-deep table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;

Loading…
Cancel
Save