|
|
|
@ -1830,110 +1830,62 @@ export default {
|
|
|
|
//提交新建
|
|
|
|
//提交新建
|
|
|
|
async submit() {
|
|
|
|
async submit() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 更新事前支付表格的 HTML 和值
|
|
|
|
// 构建提交数据
|
|
|
|
if (this.form.before_contract_template &&
|
|
|
|
|
|
|
|
this.form.before_contract_template.contract_template_fields &&
|
|
|
|
|
|
|
|
this.$refs.beforePaymentForm) {
|
|
|
|
|
|
|
|
const inputs = this.$refs.beforePaymentForm.querySelectorAll('input, select, textarea');
|
|
|
|
|
|
|
|
inputs.forEach(input => {
|
|
|
|
|
|
|
|
const fieldName = input.getAttribute('data-field');
|
|
|
|
|
|
|
|
if (fieldName) {
|
|
|
|
|
|
|
|
const field = this.form.before_contract_template.contract_template_fields.find(f => f.field === fieldName);
|
|
|
|
|
|
|
|
if (field) {
|
|
|
|
|
|
|
|
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
|
|
|
|
|
|
const checkedInput = this.$refs.beforePaymentForm.querySelector(`[data-field="${fieldName}"]:checked`);
|
|
|
|
|
|
|
|
field.value = checkedInput ? checkedInput.value : '';
|
|
|
|
|
|
|
|
if (checkedInput) {
|
|
|
|
|
|
|
|
checkedInput.setAttribute('checked', 'checked');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
field.value = input.value;
|
|
|
|
|
|
|
|
input.setAttribute('value', input.value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.form.before_contract_template.template = this.$refs.beforePaymentForm.innerHTML;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新事后支付表格的 HTML 和值
|
|
|
|
|
|
|
|
if (this.form.contract_template &&
|
|
|
|
|
|
|
|
this.form.contract_template.contract_template_fields &&
|
|
|
|
|
|
|
|
this.$refs.afterPaymentForm) {
|
|
|
|
|
|
|
|
const inputs = this.$refs.afterPaymentForm.querySelectorAll('input, select, textarea');
|
|
|
|
|
|
|
|
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 : '';
|
|
|
|
|
|
|
|
if (checkedInput) {
|
|
|
|
|
|
|
|
checkedInput.setAttribute('checked', 'checked');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
field.value = input.value;
|
|
|
|
|
|
|
|
input.setAttribute('value', input.value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.form.contract_template.template = this.$refs.afterPaymentForm.innerHTML;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 准备提交数据
|
|
|
|
|
|
|
|
const submitData = {
|
|
|
|
const submitData = {
|
|
|
|
category: this.form.category,
|
|
|
|
...this.form,
|
|
|
|
work_type: this.form.affairType,
|
|
|
|
|
|
|
|
contract_type: this.form.contractType,
|
|
|
|
|
|
|
|
purchase_form: this.form.purchaseForm,
|
|
|
|
|
|
|
|
purchase_sub_form: this.form.purchaseSubForm,
|
|
|
|
|
|
|
|
purchase_method: this.form.purchaseMethod,
|
|
|
|
|
|
|
|
type: this.form.type,
|
|
|
|
|
|
|
|
is_plan: this.form.isBudget ? 1 : 0,
|
|
|
|
is_plan: this.form.isBudget ? 1 : 0,
|
|
|
|
purchase_type_id: this.form.purchaseForm,
|
|
|
|
money_way_id: this.form.moneyWay.join(','),
|
|
|
|
purchase_way_id: this.form.purchaseMethod,
|
|
|
|
plans: this.form.plan.map(item => ({
|
|
|
|
money_way_id: this.form.moneyWay.toString(),
|
|
|
|
plan_id: item.value.plan_id,
|
|
|
|
plan_price: this.form.price,
|
|
|
|
use_money: item.value.use_money
|
|
|
|
name: this.form.name,
|
|
|
|
})),
|
|
|
|
contract_plan_links: this.form.plan.map(item => item.value),
|
|
|
|
contract_carry_department: this.form.contract_carry_department.map(id => ({
|
|
|
|
is_substitute: this.form.is_substitute,
|
|
|
|
carry_department_id: id
|
|
|
|
is_simple: this.form.is_simple,
|
|
|
|
}))
|
|
|
|
has_charge: this.form.has_charge,
|
|
|
|
|
|
|
|
supply: this.form.supply,
|
|
|
|
|
|
|
|
money: this.form.money,
|
|
|
|
|
|
|
|
status: this.form.is_simple ? 2 : 1,
|
|
|
|
|
|
|
|
gov_plane_id: this.form.gov_plane_id,
|
|
|
|
|
|
|
|
contract_carry_department: this.form.contract_carry_department?.map(i => ({carry_department_id: i})) || [],
|
|
|
|
|
|
|
|
before_contract_template: this.form.before_contract_template,
|
|
|
|
|
|
|
|
contract_template: this.form.contract_template
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 根据模式调用不同的接口
|
|
|
|
// 处理事前支付模板
|
|
|
|
let res;
|
|
|
|
if (this.form.skipBeforeTemplate) {
|
|
|
|
|
|
|
|
// 如果用户选择跳过,提交空的模板和字段列表
|
|
|
|
|
|
|
|
submitData.before_forms = '';
|
|
|
|
|
|
|
|
submitData.before_other_data = [];
|
|
|
|
|
|
|
|
} else if (this.form.before_contract_template) {
|
|
|
|
|
|
|
|
// 如果用户填写了模板,提交当前填写的模板和字段列表
|
|
|
|
|
|
|
|
submitData.before_forms = this.form.before_contract_template.template;
|
|
|
|
|
|
|
|
submitData.before_other_data = this.form.before_contract_template.contract_template_fields;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理事后支付模板
|
|
|
|
|
|
|
|
if (this.form.skipAfterTemplate) {
|
|
|
|
|
|
|
|
// 如果用户选择跳过,提交空的模板和字段列表
|
|
|
|
|
|
|
|
submitData.forms = '';
|
|
|
|
|
|
|
|
submitData.other_data = [];
|
|
|
|
|
|
|
|
} else if (this.form.contract_template) {
|
|
|
|
|
|
|
|
// 如果用户填写了模板,提交当前填写的模板和字段列表
|
|
|
|
|
|
|
|
submitData.forms = this.form.contract_template.template;
|
|
|
|
|
|
|
|
submitData.other_data = this.form.contract_template.contract_template_fields;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据是新增还是编辑调用不同的API
|
|
|
|
if (this.isEditMode) {
|
|
|
|
if (this.isEditMode) {
|
|
|
|
// 编辑模式
|
|
|
|
|
|
|
|
submitData.id = this.currentContractId;
|
|
|
|
submitData.id = this.currentContractId;
|
|
|
|
res = await editorContract(submitData);
|
|
|
|
await editorContract(submitData);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 新增模式
|
|
|
|
await addContrant(submitData);
|
|
|
|
res = await addContrant(submitData);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 提交成功后关闭弹窗并刷新列表
|
|
|
|
this.isShowAdd = false;
|
|
|
|
this.isShowAdd = false;
|
|
|
|
|
|
|
|
this.getContracts();
|
|
|
|
Message({
|
|
|
|
Message({
|
|
|
|
type: 'success',
|
|
|
|
type: 'success',
|
|
|
|
message: '操作成功'
|
|
|
|
message: this.isEditMode ? '编辑成功' : '新增成功'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.resetForm();
|
|
|
|
|
|
|
|
this.$refs.planTable?.clearSelection();
|
|
|
|
|
|
|
|
this.getContracts();
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.error('提交失败:', error);
|
|
|
|
console.error('提交失败:', error);
|
|
|
|
Message({
|
|
|
|
Message({
|
|
|
|
type: 'error',
|
|
|
|
type: 'error',
|
|
|
|
message: error.message || '提交失败'
|
|
|
|
message: '提交失败'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -2030,32 +1982,24 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
nextStep() {
|
|
|
|
nextStep() {
|
|
|
|
// 验证当前步骤的表单
|
|
|
|
|
|
|
|
if (this.currentStep === 1) {
|
|
|
|
if (this.currentStep === 1) {
|
|
|
|
// 验证是否至少选择了一个下拉框
|
|
|
|
// 验证是否至少选择了一个下拉框
|
|
|
|
if (!this.form.category && !this.form.affairType && !this.form.contractType &&
|
|
|
|
if (!this.form.category && !this.form.affairType && !this.form.contractType &&
|
|
|
|
!this.form.purchaseForm && !this.form.purchaseMethod) {
|
|
|
|
!this.form.purchaseForm && !this.form.purchaseMethod) {
|
|
|
|
this.$Message.warning('请至少选择一个选项')
|
|
|
|
this.$Message.warning('请至少选择一个选项');
|
|
|
|
return
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取模版配置
|
|
|
|
// 获取模版配置
|
|
|
|
this.getTemplateConfig()
|
|
|
|
this.getTemplateConfig();
|
|
|
|
|
|
|
|
|
|
|
|
} else if (this.currentStep === 2) {
|
|
|
|
} else if (this.currentStep === 2) {
|
|
|
|
this.$refs.basicInfoForm.validate((valid) => {
|
|
|
|
this.$refs.basicInfoForm.validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
if (valid) {
|
|
|
|
// 如果显示预算计划字段,需要验证是否选择了预算计划
|
|
|
|
this.currentStep++;
|
|
|
|
if (this.showFields.budgetPlan && (!this.form.plan || this.form.plan.length === 0)) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'warning',
|
|
|
|
|
|
|
|
message: '请选择关联预算计划'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.currentStep++
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
} else if (this.currentStep === 3) {
|
|
|
|
} else if (this.currentStep === 3) {
|
|
|
|
this.currentStep++
|
|
|
|
this.currentStep++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
@ -2097,7 +2041,6 @@ export default {
|
|
|
|
// 更新模板
|
|
|
|
// 更新模板
|
|
|
|
this.form.contract_template.template = afterFormHtml;
|
|
|
|
this.form.contract_template.template = afterFormHtml;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.currentStep === 3 && this.form.showAfterPayment && this.form.before_contract_template) {
|
|
|
|
if (this.currentStep === 3 && this.form.showAfterPayment && this.form.before_contract_template) {
|
|
|
|
// 如果在事后支付表格且有事前支付表格,则返回事前支付表格
|
|
|
|
// 如果在事后支付表格且有事前支付表格,则返回事前支付表格
|
|
|
|
this.form.showAfterPayment = false;
|
|
|
|
this.form.showAfterPayment = false;
|
|
|
|
@ -2589,10 +2532,22 @@ export default {
|
|
|
|
// 跳过事前支付表格
|
|
|
|
// 跳过事前支付表格
|
|
|
|
skipPrePayment() {
|
|
|
|
skipPrePayment() {
|
|
|
|
this.form.showAfterPayment = true
|
|
|
|
this.form.showAfterPayment = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.form.skipBeforeTemplate = true;
|
|
|
|
|
|
|
|
this.form.before_contract_template = {
|
|
|
|
|
|
|
|
template: '',
|
|
|
|
|
|
|
|
contract_template_fields: []
|
|
|
|
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 跳过事后支付表格
|
|
|
|
// 跳过事后支付表格
|
|
|
|
skipPostPayment() {
|
|
|
|
skipPostPayment() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.form.skipAfterTemplate = true;
|
|
|
|
|
|
|
|
this.form.contract_template = {
|
|
|
|
|
|
|
|
template: '',
|
|
|
|
|
|
|
|
contract_template_fields: []
|
|
|
|
|
|
|
|
};
|
|
|
|
this.submit()
|
|
|
|
this.submit()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
@ -2632,14 +2587,11 @@ export default {
|
|
|
|
if (res && res.list && res.list.data && res.list.data.length > 0) {
|
|
|
|
if (res && res.list && res.list.data && res.list.data.length > 0) {
|
|
|
|
const detail = res.list.data[0];
|
|
|
|
const detail = res.list.data[0];
|
|
|
|
|
|
|
|
|
|
|
|
// 这里缺少合同分类, 先设置为20, 后续需要服务器返回该字段.
|
|
|
|
|
|
|
|
detail.category = 20;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 通过正常的流程来初始化下拉框
|
|
|
|
// 3. 通过正常的流程来初始化下拉框
|
|
|
|
// 设置分类
|
|
|
|
// 设置分类
|
|
|
|
if (detail.category) {
|
|
|
|
if (detail.contract_category) {
|
|
|
|
this.form.category = detail.category;
|
|
|
|
this.form.category = detail.contract_category;
|
|
|
|
this.handleCategoryChange(detail.category);
|
|
|
|
this.handleCategoryChange(detail.contract_category);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 设置事项类型
|
|
|
|
// 设置事项类型
|
|
|
|
@ -2797,6 +2749,96 @@ export default {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 验证表单
|
|
|
|
|
|
|
|
validateForm() {
|
|
|
|
|
|
|
|
// 验证第一步的必填字段
|
|
|
|
|
|
|
|
if (this.currentStep === 1) {
|
|
|
|
|
|
|
|
if (!this.form.category) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请选择合同分类'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.form.affairType) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请选择事项类型'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.form.contractType) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请选择合同类型'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.form.purchaseForm) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请选择采购形式'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.form.purchaseMethod) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请选择采购方式'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 验证第二步的必填字段
|
|
|
|
|
|
|
|
if (this.currentStep === 2) {
|
|
|
|
|
|
|
|
if (!this.form.type) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请选择合同性质'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.form.name) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请输入合同名称'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.form.price) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请输入合同金额'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.form.moneyWay || this.form.moneyWay.length === 0) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请选择资金来源'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.form.plan || this.form.plan.length === 0) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请选择预算计划'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.form.contract_carry_department || this.form.contract_carry_department.length === 0) {
|
|
|
|
|
|
|
|
Message({
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
message: '请选择合同承办部门'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
this.window.width = screen.availWidth * 0.95
|
|
|
|
this.window.width = screen.availWidth * 0.95
|
|
|
|
|