完成合同新增创建

master
lynn 1 year ago
parent fbddbf82cd
commit d591f28b36

@ -431,12 +431,12 @@
<!-- Step 3: Attachment Information --> <!-- Step 3: Attachment Information -->
<div v-show="currentStep === 3" class="step-content"> <div v-show="currentStep === 3" class="step-content">
<!-- 事前支付表格 --> <!-- 事前支付表格 -->
<div v-if="form.before_contract_template" class="form-section"> <div v-if="form.before_contract_template && !form.showAfterPayment" class="form-section">
<div class="section-title">事前支付表格</div> <div class="section-title">事前支付表格</div>
<div v-html="form.before_contract_template.template"></div> <div v-html="form.before_contract_template.template"></div>
</div> </div>
<!-- 事后支付表格 --> <!-- 事后支付表格 -->
<div v-else-if="form.contract_template" class="form-section"> <div v-else-if="form.contract_template && form.showAfterPayment" class="form-section">
<div class="section-title">事后支付表格</div> <div class="section-title">事后支付表格</div>
<div v-html="form.contract_template.template"></div> <div v-html="form.contract_template.template"></div>
</div> </div>
@ -447,7 +447,8 @@
<div class="modal-footer"> <div class="modal-footer">
<Button v-if="currentStep > 1" @click="prevStep" class="action-button">上一步</Button> <Button v-if="currentStep > 1" @click="prevStep" class="action-button">上一步</Button>
<Button v-if="currentStep < 3" type="primary" @click="nextStep" class="action-button">下一步</Button> <Button v-if="currentStep < 3" type="primary" @click="nextStep" class="action-button">下一步</Button>
<Button v-if="currentStep === 3" type="primary" @click="submit" class="action-button">提交</Button> <Button v-if="currentStep === 3 && form.before_contract_template && !form.showAfterPayment" type="primary" @click="nextPaymentStep" class="action-button">下一步</Button>
<Button v-if="currentStep === 3 && form.contract_template && form.showAfterPayment" type="primary" @click="submit" class="action-button">提交</Button>
<Button @click="cancel" class="action-button">取消</Button> <Button @click="cancel" class="action-button">取消</Button>
</div> </div>
</div> </div>
@ -910,9 +911,7 @@ export default {
width: 320, width: 320,
align: "left", align: "left",
customFn: (row) => { customFn: (row) => {
return row.money_way_detail.map(item => { return row.money_way_detail.map(item => item.value).join(',')
return `<div>${item.value}</div>`
}).join('')
} }
}, },
{ {
@ -920,9 +919,7 @@ export default {
width: 320, width: 320,
align: "left", align: "left",
customFn: (row) => { customFn: (row) => {
return row.plans.map(item => { return row.plans.map(item => `[${item.year}] - ${item.name}`).join(',')
return `<div>[${item.year}] - ${item.name}</div>`
}).join('')
} }
}, },
{ {
@ -948,7 +945,7 @@ export default {
width: 140, width: 140,
customFn: (row) => { customFn: (row) => {
let per = ((((row.fund_log_total) / row.money) || 0) * 100)?.toFixed(2) || 0 let per = ((((row.fund_log_total) / row.money) || 0) * 100)?.toFixed(2) || 0
return `<div style="color: ${per > 100 ? 'red' : 'green'}">${per}%</div>` return `${per}%`
} }
}, },
{ {
@ -1041,9 +1038,7 @@ export default {
minWidth: 200, minWidth: 200,
prop: "contract_carry_department", prop: "contract_carry_department",
customFn: row => { customFn: row => {
return row.contract_carry_department.map(i => { return row.contract_carry_department.map(i => i.carry_department.name).join(',')
return `<Tag color="primary">${i.carry_department.name}</Tag>`
}).join('')
} }
} }
], ],
@ -1754,48 +1749,53 @@ export default {
}, },
//提交新建 //提交新建
async submit() { async submit() {
try { addContrant({
// 获取分类配置 // 第一步的数据
const res = await getContractCategoryTemplateBaseConfig() category: this.form.category,
if (res.errcode !== undefined) { work_type: this.form.affairType,
this.$message.error(res.errmsg || '获取分类配置失败') contract_type: this.form.contractType,
return purchase_form: this.form.purchaseForm,
} purchase_sub_form: this.form.purchaseSubForm,
purchase_method: this.form.purchaseMethod,
// 保存采购方式映射
this.purchaseMethodsMap = res.purchase_methods || {}
// 设置分类选项 - 从第二级开始(合同类、报销类、其他支出类)
this.categoryOptions = res.map?.[0]?.children || []
// 递归处理每一层的 children,确保所有层级都被正确解析
const processChildren = (items) => {
if (!items) return
items.forEach(item => {
if (item.children) {
// 确保每个子项都有正确的 id 和 name
item.children = item.children.map(child => ({
id: child.id,
name: child.name || child.value, // 添加对 value 字段的支持
children: child.children || []
}))
processChildren(item.children)
}
})
}
// 处理所有层级的 children // 第二步的数据
processChildren(this.categoryOptions) type: this.form.type,
is_plan: this.form.isBudget ? 1 : 0,
purchase_type_id: this.form.methods,
purchase_way_id: this.form.modality,
money_way_id: `${this.form.moneyWay.toString()}`,
plan_price: this.form.price,
name: this.form.name,
contract_plan_links: this.form.plan.map(item => {
return 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
}).then(res => {
this.isShowAdd = false
Message({
type: 'success',
message: '操作成功'
})
this.resetForm() this.resetForm()
this.$refs.planTable?.clearSelection()
// 打开模态框 this.getContracts()
this.isShowAdd = true }).catch(error => {
} catch (error) { Message({
console.error('获取分类配置失败:', error) type: 'error',
this.$message.error('获取分类配置失败') message: error.message || '提交失败'
} })
})
}, },
//删除合同 //删除合同
@ -1891,7 +1891,16 @@ export default {
nextStep() { nextStep() {
// 验证当前步骤的表单 // 验证当前步骤的表单
if (this.currentStep === 2) { 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.getTemplateConfig()
} else if (this.currentStep === 2) {
this.$refs.basicInfoForm.validate((valid) => { this.$refs.basicInfoForm.validate((valid) => {
if (valid) { if (valid) {
// 如果显示预算计划字段,需要验证是否选择了预算计划 // 如果显示预算计划字段,需要验证是否选择了预算计划
@ -1911,7 +1920,13 @@ export default {
}, },
prevStep() { prevStep() {
this.currentStep-- if (this.currentStep === 3 && this.form.showAfterPayment && this.form.before_contract_template) {
// 如果在事后支付表格且有事前支付表格,则返回事前支付表格
this.form.showAfterPayment = false
} else {
// 其他情况正常返回上一步
this.currentStep--
}
}, },
validateCurrentStep() { validateCurrentStep() {
@ -1949,7 +1964,10 @@ export default {
purchase_form: this.form.purchaseForm purchase_form: this.form.purchaseForm
} }
console.log('请求模版配置参数:', params)
const res = await getContractCategoryTemplateConfigParams(params) const res = await getContractCategoryTemplateConfigParams(params)
console.log('模版配置返回数据:', res)
if (res.errcode !== undefined) { if (res.errcode !== undefined) {
this.$message.error(res.errmsg || '获取模版配置失败') this.$message.error(res.errmsg || '获取模版配置失败')
return return
@ -2042,7 +2060,8 @@ export default {
ratio: '', ratio: '',
payee: '' payee: ''
} }
] ],
showAfterPayment: false // 是否显示事后支付表格
} }
this.affairTypeOptions = [] this.affairTypeOptions = []
@ -2206,6 +2225,10 @@ export default {
// 更新显示文本 // 更新显示文本
this.form.plan_display = this.plan.map(p => p.label).join(', ') this.form.plan_display = this.plan.map(p => p.label).join(', ')
}, },
// 切换到事后支付表格
nextPaymentStep() {
this.form.showAfterPayment = true
},
}, },
mounted() { mounted() {
this.window.width = screen.availWidth * 0.95 this.window.width = screen.availWidth * 0.95

Loading…
Cancel
Save