完成支付表格跳过,字段对接

master
lynn 8 months ago
parent a9a320ae89
commit 752c943db9

@ -1830,110 +1830,62 @@ export default {
//
async submit() {
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 = {
category: this.form.category,
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,
...this.form,
is_plan: this.form.isBudget ? 1 : 0,
purchase_type_id: this.form.purchaseForm,
purchase_way_id: this.form.purchaseMethod,
money_way_id: this.form.moneyWay.toString(),
plan_price: this.form.price,
name: this.form.name,
contract_plan_links: this.form.plan.map(item => item.value),
is_substitute: this.form.is_substitute,
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
money_way_id: this.form.moneyWay.join(','),
plans: this.form.plan.map(item => ({
plan_id: item.value.plan_id,
use_money: item.value.use_money
})),
contract_carry_department: this.form.contract_carry_department.map(id => ({
carry_department_id: id
}))
};
//
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) {
//
submitData.id = this.currentContractId;
res = await editorContract(submitData);
await editorContract(submitData);
} else {
//
res = await addContrant(submitData);
await addContrant(submitData);
}
//
this.isShowAdd = false;
this.getContracts();
Message({
type: 'success',
message: '操作成功'
message: this.isEditMode ? '编辑成功' : '新增成功'
});
this.resetForm();
this.$refs.planTable?.clearSelection();
this.getContracts();
} catch (error) {
console.error('提交失败:', error);
Message({
type: 'error',
message: error.message || '提交失败'
message: '提交失败'
});
}
},
@ -2030,32 +1982,24 @@ export default {
},
nextStep() {
//
if (this.currentStep === 1) {
//
if (!this.form.category && !this.form.affairType && !this.form.contractType &&
!this.form.purchaseForm && !this.form.purchaseMethod) {
this.$Message.warning('请至少选择一个选项')
return
this.$Message.warning('请至少选择一个选项');
return;
}
//
this.getTemplateConfig()
this.getTemplateConfig();
} else if (this.currentStep === 2) {
this.$refs.basicInfoForm.validate((valid) => {
if (valid) {
//
if (this.showFields.budgetPlan && (!this.form.plan || this.form.plan.length === 0)) {
Message({
type: 'warning',
message: '请选择关联预算计划'
})
return
this.currentStep++;
}
this.currentStep++
}
})
});
} else if (this.currentStep === 3) {
this.currentStep++
this.currentStep++;
}
},
@ -2097,7 +2041,6 @@ export default {
//
this.form.contract_template.template = afterFormHtml;
}
if (this.currentStep === 3 && this.form.showAfterPayment && this.form.before_contract_template) {
//
this.form.showAfterPayment = false;
@ -2589,10 +2532,22 @@ export default {
//
skipPrePayment() {
this.form.showAfterPayment = true
this.form.skipBeforeTemplate = true;
this.form.before_contract_template = {
template: '',
contract_template_fields: []
};
},
//
skipPostPayment() {
this.form.skipAfterTemplate = true;
this.form.contract_template = {
template: '',
contract_template_fields: []
};
this.submit()
},
@ -2632,14 +2587,11 @@ export default {
if (res && res.list && res.list.data && res.list.data.length > 0) {
const detail = res.list.data[0];
// , 20, .
detail.category = 20;
// 3.
//
if (detail.category) {
this.form.category = detail.category;
this.handleCategoryChange(detail.category);
if (detail.contract_category) {
this.form.category = detail.contract_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() {
this.window.width = screen.availWidth * 0.95

Loading…
Cancel
Save