完成合同两个表格选择

master
linyongLynn 4 months ago
parent 611b700d80
commit f4eb7186f4

@ -278,15 +278,22 @@
</el-button> </el-button>
</div> </div>
<!-- Tab切换 --> <!-- 根据是否有第二个表格决定显示方式 -->
<el-tabs v-model="activePostPaymentTab" @tab-click="handleTabClick"> <div v-if="hasSecondPostPaymentForm">
<el-tab-pane label="事后支付表格1" name="form1"> <!-- 有第二个表格时显示Tab切换 -->
<div ref="mainTable1" class="payment-table" v-html="forms1" /> <el-tabs v-model="activePostPaymentTab" @tab-click="handleTabClick">
</el-tab-pane> <el-tab-pane label="事后支付表格1" name="form1">
<el-tab-pane label="事后支付表格2" name="form2"> <div ref="mainTable1" class="payment-table" v-html="forms1" />
<div ref="mainTable2" class="payment-table" v-html="forms2" /> </el-tab-pane>
</el-tab-pane> <el-tab-pane label="事后支付表格2" name="form2">
</el-tabs> <div ref="mainTable2" class="payment-table" v-html="forms2" />
</el-tab-pane>
</el-tabs>
</div>
<div v-else>
<!-- 只有一个表格时直接显示事后支付表格1 -->
<div ref="mainTable1" class="payment-table" v-html="forms1" />
</div>
</div> </div>
</template> </template>
@ -732,6 +739,7 @@ export default {
], ],
zoomedDialogVisible: false, // zoomedDialogVisible: false, //
hasPostPaymentForm: false, // hasPostPaymentForm: false, //
hasSecondPostPaymentForm: false, //
contract_category: {}, contract_category: {},
templateContextData: null, // templateContextData: null, //
total: 0, total: 0,
@ -826,6 +834,7 @@ export default {
this.forms2 = null // <---2HTML this.forms2 = null // <---2HTML
this.contract = {} // <--- this.contract = {} // <---
this.contractTemplate = null // <--- this.contractTemplate = null // <---
this.hasSecondPostPaymentForm = false // <---
this.activePostPaymentTab = 'form1' // <--- tab 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) {
@ -1030,14 +1039,28 @@ 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 // tab
this.forms1 = this.contractTemplate this.forms1 = this.contractTemplate
this.forms2 = this.contractTemplate
//
if (this.contract.contract_template2 && this.contract.contract_template2.template) {
this.hasSecondPostPaymentForm = true
// tab
this.forms2 = this.contract.contract_template2.template
if (!this.contract.contract_template2.contract_template_fields) {
this.contract.contract_template2.contract_template_fields = this.contract.other_data || []
}
} else {
this.hasSecondPostPaymentForm = false
this.forms2 = null
}
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 || []
} }
} else { } else {
this.hasPostPaymentForm = false this.hasPostPaymentForm = false
this.hasSecondPostPaymentForm = false
this.currentStep = 1 this.currentStep = 1
this.contractTemplate = null this.contractTemplate = null
this.forms = null this.forms = null
@ -1100,65 +1123,63 @@ export default {
initTemplateFields(contextData) { initTemplateFields(contextData) {
if (!contextData || !contextData.other_data_fill) return if (!contextData || !contextData.other_data_fill) return
// //
if (this.contract.contract_template && this.contract.contract_template.contract_template_fields) { if (this.contract.contract_template && this.contract.contract_template.contract_template_fields) {
const fields = this.contract.contract_template.contract_template_fields const fields = this.contract.contract_template.contract_template_fields
this.initTemplateFieldsForTable(fields, contextData, 1)
}
// //
fields.forEach(field => { if (this.contract.contract_template2 && this.contract.contract_template2.contract_template_fields) {
// link_typeother_data_fill const fields2 = this.contract.contract_template2.contract_template_fields
if (field.link_field && contextData.other_data_fill[field.link_field]) { this.initTemplateFieldsForTable(fields2, contextData, 2)
let value = contextData.other_data_fill[field.link_field] }
},
// upper_money //
if (field.link_field === 'upper_money') { initTemplateFieldsForTable(fields, contextData, tableIndex) {
value = numberToChinese(Number(value)) //
} fields.forEach(field => {
// link_typeother_data_fill
if (field.link_field && contextData.other_data_fill[field.link_field]) {
let value = contextData.other_data_fill[field.link_field]
// upper_money
if (field.link_field === 'upper_money') {
value = numberToChinese(Number(value))
}
// //
field.value = value field.value = value
// DOM // DOM
const dom1 = this.$refs.mainTable1 const dom = tableIndex === 1 ? this.$refs.mainTable1 : this.$refs.mainTable2
const dom2 = this.$refs.mainTable2
if (dom) {
if (dom1) { const input = dom.querySelector(`[data-field="${field.field}"]`)
const input1 = dom1.querySelector(`[data-field="${field.field}"]`) if (input) {
if (input1) { if (input.type === 'checkbox' || input.type === 'radio') {
if (input1.type === 'checkbox' || input1.type === 'radio') { if (field.value === input.value) {
if (field.value === input1.value) { input.checked = true
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 {
input2.value = field.value
} }
} else {
input.value = field.value
} }
} }
} }
})
// tab
if (this.$refs.mainTable1) {
this.forms1 = syncFormDomToHtml(this.$refs.mainTable1, fields)
} }
if (this.$refs.mainTable2) { })
this.forms2 = syncFormDomToHtml(this.$refs.mainTable2, fields)
// tab
const dom = tableIndex === 1 ? this.$refs.mainTable1 : this.$refs.mainTable2
if (dom) {
const updatedForms = syncFormDomToHtml(dom, fields)
if (tableIndex === 1) {
this.forms1 = updatedForms
this.forms = this.forms1 // 使
} else if (tableIndex === 2) {
this.forms2 = updatedForms
} }
// forms
this.forms = this.forms1
} }
}, },
@ -1167,16 +1188,20 @@ export default {
this.$refs['paymentRegistration'].$refs['elForm'].validate().then(res => { this.$refs['paymentRegistration'].$refs['elForm'].validate().then(res => {
if (res) { if (res) {
// //
if (this.contract.contract_template) { if (this.contract.contract_template || this.contract.contract_template2) {
// tabDOM // tabDOM
let currentDom = null let currentDom = null
if (this.activePostPaymentTab === 'form1') { let templateFields = null
if (this.activePostPaymentTab === 'form1' && this.contract.contract_template) {
currentDom = this.$refs.mainTable1 currentDom = this.$refs.mainTable1
} else if (this.activePostPaymentTab === 'form2') { templateFields = this.contract.contract_template.contract_template_fields
} else if (this.activePostPaymentTab === 'form2' && this.contract.contract_template2) {
currentDom = this.$refs.mainTable2 currentDom = this.$refs.mainTable2
templateFields = this.contract.contract_template2.contract_template_fields
} }
if (currentDom) { if (currentDom && templateFields) {
// //
const inputs = currentDom.querySelectorAll('input, select, textarea') const inputs = currentDom.querySelectorAll('input, select, textarea')
@ -1184,7 +1209,7 @@ export default {
inputs.forEach(input => { inputs.forEach(input => {
const fieldName = input.getAttribute('data-field') const fieldName = input.getAttribute('data-field')
if (fieldName) { if (fieldName) {
const field = this.contract.contract_template.contract_template_fields.find(f => f.field === fieldName) const field = templateFields.find(f => f.field === fieldName)
if (field) { if (field) {
if (input.type === 'checkbox' || input.type === 'radio') { if (input.type === 'checkbox' || input.type === 'radio') {
// //
@ -1423,15 +1448,23 @@ export default {
openZoomedTable() { openZoomedTable() {
// tabDOM // tabDOM
let currentDom = null let currentDom = null
let templateFields = null
if (this.activePostPaymentTab === 'form1') { if (this.activePostPaymentTab === 'form1') {
currentDom = this.$refs.mainTable1 currentDom = this.$refs.mainTable1
if (this.contract.contract_template) {
templateFields = this.contract.contract_template.contract_template_fields
}
} else if (this.activePostPaymentTab === 'form2') { } else if (this.activePostPaymentTab === 'form2') {
currentDom = this.$refs.mainTable2 currentDom = this.$refs.mainTable2
if (this.contract.contract_template2) {
templateFields = this.contract.contract_template2.contract_template_fields
}
} }
if (currentDom && this.contract.contract_template) { if (currentDom && templateFields) {
//console.log(this.contract.contract_template.contract_template_fields) //console.log(templateFields)
const updatedForms = syncFormDomToHtml(currentDom, this.contract.contract_template.contract_template_fields) const updatedForms = syncFormDomToHtml(currentDom, templateFields)
console.log('forms:'+updatedForms) console.log('forms:'+updatedForms)
// //
if (this.activePostPaymentTab === 'form1') { if (this.activePostPaymentTab === 'form1') {
@ -1453,29 +1486,39 @@ export default {
handleZoomedDialogClose() { handleZoomedDialogClose() {
const dom = this.$refs.zoomedTable const dom = this.$refs.zoomedTable
if (dom && this.contract.contract_template) { if (dom) {
// // tab
const updatedForms = syncFormDomToHtml(dom, this.contract.contract_template.contract_template_fields) let templateFields = null
if (this.activePostPaymentTab === 'form1' && this.contract.contract_template) {
// tab templateFields = this.contract.contract_template.contract_template_fields
if (this.activePostPaymentTab === 'form1') { } else if (this.activePostPaymentTab === 'form2' && this.contract.contract_template2) {
this.forms1 = updatedForms templateFields = this.contract.contract_template2.contract_template_fields
} else if (this.activePostPaymentTab === 'form2') {
this.forms2 = updatedForms
} }
// forms if (templateFields) {
this.forms = updatedForms //
this.contract.forms = updatedForms const updatedForms = syncFormDomToHtml(dom, templateFields)
// // tab
this.$nextTick(() => { if (this.activePostPaymentTab === 'form1') {
if (this.activePostPaymentTab === 'form1' && this.$refs.mainTable1) { this.forms1 = updatedForms
this.setupAmountListeners(this.$refs.mainTable1) } else if (this.activePostPaymentTab === 'form2') {
} else if (this.activePostPaymentTab === 'form2' && this.$refs.mainTable2) { this.forms2 = updatedForms
this.setupAmountListeners(this.$refs.mainTable2)
} }
})
// 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
}, },

Loading…
Cancel
Save