|
|
|
|
@ -493,12 +493,12 @@
|
|
|
|
|
<!-- 事前支付表格 -->
|
|
|
|
|
<div v-if="form.before_contract_template && !form.showAfterPayment" class="form-section">
|
|
|
|
|
<div class="section-title">事前支付表格</div>
|
|
|
|
|
<div ref="beforePaymentForm" v-html="form.before_contract_template.template"></div>
|
|
|
|
|
<div ref="beforePaymentForm" v-html="isEditMode ? (form.before_forms || form.before_contract_template.template) : form.before_contract_template.template"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 事后支付表格 -->
|
|
|
|
|
<div v-else-if="form.contract_template" class="form-section">
|
|
|
|
|
<div class="section-title">事后支付表格</div>
|
|
|
|
|
<div ref="afterPaymentForm" v-html="form.contract_template.template"></div>
|
|
|
|
|
<div ref="afterPaymentForm" v-html="isEditMode ? (form.forms || form.contract_template.template) : form.contract_template.template"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 无支付表格提示 -->
|
|
|
|
|
<div v-else class="form-section">
|
|
|
|
|
@ -512,15 +512,39 @@
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
|
<Button v-if="currentStep > 1" @click="prevStep" class="action-button">上一步</Button>
|
|
|
|
|
<Button v-if="currentStep < 3" type="primary" @click="nextStep" class="action-button">下一步</Button>
|
|
|
|
|
<!-- 当有事前支付表格且未显示事后支付表格时,显示"下一步"和"跳过"按钮 -->
|
|
|
|
|
<!-- 当有事前支付表格且未显示事后支付表格时 -->
|
|
|
|
|
<template v-if="currentStep === 3 && form.before_contract_template && !form.showAfterPayment">
|
|
|
|
|
<Button type="primary" @click="nextPaymentStep" class="action-button">下一步</Button>
|
|
|
|
|
<Button @click="skipPrePayment" class="action-button">跳过,稍后填写</Button>
|
|
|
|
|
<!-- 新增模式下显示跳过按钮 -->
|
|
|
|
|
<template v-if="!isEditMode">
|
|
|
|
|
<Button type="primary" @click="nextPaymentStep" class="action-button">下一步</Button>
|
|
|
|
|
<Button @click="skipPrePayment" class="action-button">跳过,稍后填写</Button>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 编辑模式下,只有当before_forms为空时才显示跳过按钮 -->
|
|
|
|
|
<template v-else-if="!form.before_forms || form.before_forms.trim() === ''">
|
|
|
|
|
<Button type="primary" @click="nextPaymentStep" class="action-button">下一步</Button>
|
|
|
|
|
<Button @click="skipPrePayment" class="action-button">跳过,稍后填写</Button>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 编辑模式下,如果before_forms不为空,只显示下一步按钮 -->
|
|
|
|
|
<template v-else>
|
|
|
|
|
<Button type="primary" @click="nextPaymentStep" class="action-button">下一步</Button>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 当显示事后支付表格时,显示"提交"和"跳过"按钮 -->
|
|
|
|
|
<!-- 当显示事后支付表格时 -->
|
|
|
|
|
<template v-else-if="currentStep === 3 && form.contract_template">
|
|
|
|
|
<Button type="primary" @click="submit" class="action-button">提交</Button>
|
|
|
|
|
<Button @click="skipPostPayment" class="action-button">跳过,稍后填写</Button>
|
|
|
|
|
<!-- 新增模式下显示跳过按钮 -->
|
|
|
|
|
<template v-if="!isEditMode">
|
|
|
|
|
<Button type="primary" @click="submit" class="action-button">提交</Button>
|
|
|
|
|
<Button @click="skipPostPayment" class="action-button">跳过,稍后填写</Button>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 编辑模式下,只有当forms为空时才显示跳过按钮 -->
|
|
|
|
|
<template v-else-if="!form.forms || form.forms.trim() === ''">
|
|
|
|
|
<Button type="primary" @click="submit" class="action-button">提交</Button>
|
|
|
|
|
<Button @click="skipPostPayment" class="action-button">跳过,稍后填写</Button>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 编辑模式下,如果forms不为空,只显示提交按钮 -->
|
|
|
|
|
<template v-else>
|
|
|
|
|
<Button type="primary" @click="submit" class="action-button">提交</Button>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 当没有支付表格时,只显示"提交"按钮 -->
|
|
|
|
|
<Button v-else-if="currentStep === 3" type="primary" @click="submit" class="action-button">提交</Button>
|
|
|
|
|
@ -995,7 +1019,13 @@ export default {
|
|
|
|
|
width: 320,
|
|
|
|
|
align: "left",
|
|
|
|
|
customFn: (row) => {
|
|
|
|
|
return row.plans.map(item => `[${item.year}] - ${item.name}`).join(',')
|
|
|
|
|
return row.plans.map(item => {
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
[{item.year}] - {item.name}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@ -1234,6 +1264,10 @@ export default {
|
|
|
|
|
purchaseForm: '',
|
|
|
|
|
purchaseSubForm: '',
|
|
|
|
|
purchaseMethod: '',
|
|
|
|
|
forms:'',
|
|
|
|
|
before_forms:'',
|
|
|
|
|
other_data:[],
|
|
|
|
|
before_other_data:[],
|
|
|
|
|
name: '',
|
|
|
|
|
type: '', // 项目类型
|
|
|
|
|
moneyWay: [],
|
|
|
|
|
@ -1800,8 +1834,8 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
// 设置表单数据
|
|
|
|
|
this.form.plan = this.plan
|
|
|
|
|
// 设置显示文本
|
|
|
|
|
this.form.plan_display = this.plan.map(item => item.label).join(', ')
|
|
|
|
|
// 设置显示文本,使用换行符分隔
|
|
|
|
|
this.form.plan_display = this.plan.map(item => item.label).join('\n')
|
|
|
|
|
// 关闭对话框
|
|
|
|
|
this.isShowPlan = false
|
|
|
|
|
},
|
|
|
|
|
@ -1835,7 +1869,7 @@ export default {
|
|
|
|
|
...this.form,
|
|
|
|
|
is_plan: this.form.isBudget ? 1 : 0,
|
|
|
|
|
money_way_id: this.form.moneyWay.join(','),
|
|
|
|
|
plans: this.form.plan.map(item => ({
|
|
|
|
|
contract_plan_links: this.form.plan.map(item => ({
|
|
|
|
|
plan_id: item.value.plan_id,
|
|
|
|
|
use_money: item.value.use_money
|
|
|
|
|
})),
|
|
|
|
|
@ -1844,6 +1878,12 @@ export default {
|
|
|
|
|
}))
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
submitData.contract_category = this.form.category
|
|
|
|
|
submitData.work_type = this.form.affairType
|
|
|
|
|
submitData.contract_type = this.form.contractType
|
|
|
|
|
submitData.purchase_type_id = this.form.purchaseForm
|
|
|
|
|
submitData.purchase_way_id = this.form.purchaseMethod
|
|
|
|
|
|
|
|
|
|
// 处理事前支付模板
|
|
|
|
|
if (this.form.skipBeforeTemplate) {
|
|
|
|
|
// 如果用户选择跳过,提交空的模板和字段列表
|
|
|
|
|
@ -1995,6 +2035,10 @@ export default {
|
|
|
|
|
} else if (this.currentStep === 2) {
|
|
|
|
|
this.$refs.basicInfoForm.validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
// 在进入第三步之前,重置 showAfterPayment 状态
|
|
|
|
|
if (this.form.before_contract_template) {
|
|
|
|
|
this.form.showAfterPayment = false;
|
|
|
|
|
}
|
|
|
|
|
this.currentStep++;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
@ -2004,48 +2048,53 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
prevStep() {
|
|
|
|
|
// 如果在事后支付表格,先保存内容
|
|
|
|
|
if (this.currentStep === 3 && this.form.showAfterPayment &&
|
|
|
|
|
this.form.contract_template &&
|
|
|
|
|
this.form.contract_template.contract_template_fields &&
|
|
|
|
|
this.$refs.afterPaymentForm) {
|
|
|
|
|
// 获取所有输入控件
|
|
|
|
|
const inputs = this.$refs.afterPaymentForm.querySelectorAll('input, select, textarea');
|
|
|
|
|
|
|
|
|
|
// 遍历所有输入控件,更新值到 HTML
|
|
|
|
|
inputs.forEach(input => {
|
|
|
|
|
const fieldName = input.getAttribute('data-field');
|
|
|
|
|
if (fieldName) {
|
|
|
|
|
const field = this.form.contract_template.contract_template_fields.find(f => f.field === fieldName);
|
|
|
|
|
if (field) {
|
|
|
|
|
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
|
|
|
// 对于复选框和单选框,需要找到选中的值
|
|
|
|
|
const checkedInput = this.$refs.afterPaymentForm.querySelector(`[data-field="${fieldName}"]:checked`);
|
|
|
|
|
field.value = checkedInput ? checkedInput.value : '';
|
|
|
|
|
// 更新 HTML 中的 checked 状态
|
|
|
|
|
if (checkedInput) {
|
|
|
|
|
checkedInput.setAttribute('checked', 'checked');
|
|
|
|
|
if (this.currentStep === 3) {
|
|
|
|
|
// 如果在事后支付表格,先保存内容
|
|
|
|
|
if (this.form.showAfterPayment &&
|
|
|
|
|
this.form.contract_template &&
|
|
|
|
|
this.form.contract_template.contract_template_fields &&
|
|
|
|
|
this.$refs.afterPaymentForm) {
|
|
|
|
|
// 获取所有输入控件
|
|
|
|
|
const inputs = this.$refs.afterPaymentForm.querySelectorAll('input, select, textarea');
|
|
|
|
|
|
|
|
|
|
// 遍历所有输入控件,更新值到 HTML
|
|
|
|
|
inputs.forEach(input => {
|
|
|
|
|
const fieldName = input.getAttribute('data-field');
|
|
|
|
|
if (fieldName) {
|
|
|
|
|
const field = this.form.contract_template.contract_template_fields.find(f => f.field === fieldName);
|
|
|
|
|
if (field) {
|
|
|
|
|
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
|
|
|
// 对于复选框和单选框,需要找到选中的值
|
|
|
|
|
const checkedInput = this.$refs.afterPaymentForm.querySelector(`[data-field="${fieldName}"]:checked`);
|
|
|
|
|
field.value = checkedInput ? checkedInput.value : '';
|
|
|
|
|
// 更新 HTML 中的 checked 状态
|
|
|
|
|
if (checkedInput) {
|
|
|
|
|
checkedInput.setAttribute('checked', 'checked');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
field.value = input.value;
|
|
|
|
|
// 更新 HTML 中的 value
|
|
|
|
|
input.setAttribute('value', input.value);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
field.value = input.value;
|
|
|
|
|
// 更新 HTML 中的 value
|
|
|
|
|
input.setAttribute('value', input.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 获取更新后的 HTML
|
|
|
|
|
const afterFormHtml = this.$refs.afterPaymentForm.innerHTML;
|
|
|
|
|
|
|
|
|
|
// 更新模板
|
|
|
|
|
this.form.contract_template.template = afterFormHtml;
|
|
|
|
|
}
|
|
|
|
|
if (this.currentStep === 3 && this.form.showAfterPayment && this.form.before_contract_template) {
|
|
|
|
|
// 如果在事后支付表格且有事前支付表格,则返回事前支付表格
|
|
|
|
|
this.form.showAfterPayment = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 获取更新后的 HTML
|
|
|
|
|
const afterFormHtml = this.$refs.afterPaymentForm.innerHTML;
|
|
|
|
|
|
|
|
|
|
// 更新模板和保存数据
|
|
|
|
|
this.form.contract_template.template = afterFormHtml;
|
|
|
|
|
this.form.forms = afterFormHtml;
|
|
|
|
|
}
|
|
|
|
|
if (this.form.showAfterPayment && this.form.before_contract_template) {
|
|
|
|
|
// 如果在事后支付表格且有事前支付表格,则返回事前支付表格
|
|
|
|
|
this.form.showAfterPayment = false;
|
|
|
|
|
} else {
|
|
|
|
|
// 其他情况正常返回上一步
|
|
|
|
|
this.currentStep--;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 其他情况正常返回上一步
|
|
|
|
|
this.currentStep--;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -2094,9 +2143,23 @@ export default {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 在编辑模式下,保存当前的forms和before_forms值
|
|
|
|
|
let currentForms = null;
|
|
|
|
|
let currentBeforeForms = null;
|
|
|
|
|
if (this.isEditMode) {
|
|
|
|
|
currentForms = this.form.forms;
|
|
|
|
|
currentBeforeForms = this.form.before_forms;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据返回的配置参数设置表单
|
|
|
|
|
this.setFormConfig(res)
|
|
|
|
|
|
|
|
|
|
// 在编辑模式下,恢复forms和before_forms的值
|
|
|
|
|
if (this.isEditMode) {
|
|
|
|
|
this.form.forms = currentForms;
|
|
|
|
|
this.form.before_forms = currentBeforeForms;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 进入下一步
|
|
|
|
|
this.currentStep++
|
|
|
|
|
} catch (error) {
|
|
|
|
|
@ -2471,7 +2534,7 @@ export default {
|
|
|
|
|
// 切换到事后支付表格
|
|
|
|
|
nextPaymentStep() {
|
|
|
|
|
// 保存事前支付表格的数据
|
|
|
|
|
if (this.form.before_contract_template && this.form.before_contract_template.contract_template_fields) {
|
|
|
|
|
if (this.form.before_contract_template && !this.form.showAfterPayment) {
|
|
|
|
|
// 获取所有输入控件
|
|
|
|
|
const inputs = this.$refs.beforePaymentForm.querySelectorAll('input, select, textarea');
|
|
|
|
|
|
|
|
|
|
@ -2500,10 +2563,10 @@ export default {
|
|
|
|
|
|
|
|
|
|
// 获取更新后的 HTML
|
|
|
|
|
const beforeFormHtml = this.$refs.beforePaymentForm.innerHTML;
|
|
|
|
|
console.log("被修改的模板", beforeFormHtml);
|
|
|
|
|
|
|
|
|
|
// 更新模板
|
|
|
|
|
// 更新模板和保存数据
|
|
|
|
|
this.form.before_contract_template.template = beforeFormHtml;
|
|
|
|
|
this.form.before_forms = beforeFormHtml;
|
|
|
|
|
}
|
|
|
|
|
this.form.showAfterPayment = true;
|
|
|
|
|
},
|
|
|
|
|
@ -2616,10 +2679,16 @@ export default {
|
|
|
|
|
if (detail.purchase_way_id) {
|
|
|
|
|
this.form.purchaseMethod = detail.purchase_way_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log("detail", detail);
|
|
|
|
|
|
|
|
|
|
// 保存其他表单数据
|
|
|
|
|
this.form = {
|
|
|
|
|
...this.form,
|
|
|
|
|
forms: detail.forms,
|
|
|
|
|
before_forms: detail.before_forms,
|
|
|
|
|
other_data: detail.other_data,
|
|
|
|
|
before_other_data: detail.before_other_data,
|
|
|
|
|
type: detail.type,
|
|
|
|
|
isBudget: detail.is_plan,
|
|
|
|
|
is_simple: detail.is_simple,
|
|
|
|
|
@ -2708,7 +2777,7 @@ export default {
|
|
|
|
|
purchaseMethod: detail.purchase_way_id, // 采购方式
|
|
|
|
|
// 其他基本信息
|
|
|
|
|
type: detail.type,
|
|
|
|
|
isBudget: detail.is_plan === 1,
|
|
|
|
|
isBudget: detail.is_plan,
|
|
|
|
|
is_simple: detail.is_simple,
|
|
|
|
|
has_charge: detail.has_charge,
|
|
|
|
|
is_substitute: detail.is_substitute,
|
|
|
|
|
|