完成合同两个表格选择

master
linyongLynn 4 months ago
parent 611b700d80
commit f4eb7186f4

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

Loading…
Cancel
Save