<template> <div> <a-row> <a-col :span="24"> <div class="tb-title"> <span>经费预算 <strong>(单位:万元)</strong></span> </div> </a-col> </a-row> <a-row type="flex" class="row_center"> <a-col :span="4" class="bg-gray"> <div class="special-middle"> <div>概算科目名称</div> </div> </a-col> <a-col :span="4" class="bg-gray"> <div class="special-middle"> <div class="required">合计</div> </div> </a-col> <a-col :span="4" class="bg-gray"> <div class="special-middle"> <div>申请专项经费</div> </div> </a-col> <a-col :span="4" class="bg-gray"> <div class="special-middle"> <div>自筹经费</div> </div> </a-col> <a-col :span="8" class="bg-gray"> <div class="special-middle"> <div>备注</div> </div> </a-col> </a-row> <a-row v-for="(item, index) in budget" :key="index" type="flex" class="row_center"> <a-col :span="4" style="text-align: left;"> {{item.budgetName}} </a-col> <a-col :span="4"> <a-form-model-item v-if="invisibleTotalBudget.includes(index)" :prop="'budget.' + index + '.totalBudget'" :rules="{required: true, message: '*', trigger: 'blur',}"> <a-input-number v-model="item.totalBudget" @change="totalNumberChange(index)" :min="0" :step="0.01" style="width: 80%" /> </a-form-model-item> <div class="special-middle" v-else>{{parseFloat(item.totalBudget).toFixed(2)}}</div> </a-col> <a-col :span="4"> <a-form-model-item v-if="!invisibleApplyFunds.includes(index)" :prop="'budget.' + index + '.applyFunds'" :rules="{required: true, message: '*', trigger: 'blur',}"> <a-input-number v-model="item.applyFunds" @change="outNumberChange(index)" :min="0" :step="0.01" style="width: 80%" /> </a-form-model-item> <div class="special-middle" v-else>{{parseFloat(item.applyFunds).toFixed(2)}}</div> </a-col> <a-col :span="4"> <a-form-model-item v-if="!invisibleSelfFunds.includes(index)" :prop="'budget.' + index + '.selfFunds'" :rules="{required: true, message: '*', trigger: 'blur',}"> <a-input-number v-model="item.selfFunds" @change="outNumberChange(index)" :min="0" :step="0.01" style="width: 80%" /> </a-form-model-item> <div class="special-middle" v-else>{{parseFloat(item.selfFunds).toFixed(2)}}</div> </a-col> <a-col :span="8"> <a-form-model-item :prop="'budget.' + index + '.calculationBasis'"> <a-input v-model="item.calculationBasis" :maxLength="100" style="width: 90%;" /> </a-form-model-item> </a-col> </a-row> </div> </template> <script> // 用法 <budget-edit :budget.sync="formData.budget" /> const Budget = { id: null, budgetName: null, budgetId: null, objectId: null, totalBudget: null, applyFunds: null, selfFunds: null, calculationBasis: null } export default { name: "BudgetEidt", props: { budget: { type: Array, default: () => { return [{ ...Budget }]; }, }, }, created() { }, data() { return { invisibleTotalBudget: [ 16, 18, 19, 20 ], invisibleApplyFunds: [ 0, 1, 10, 15, 16, 17, 18, 19, 20 ], invisibleSelfFunds: [ 0, 1, 10, 15, 16, 17, 18, 19, 20 ], //一、经费支出 TotalExpenditure: 0, ApplyExpenditure: 0, SelfExpenditure: 0, //(一)经费支出 expenditureTotal: 0, expenditureApply: 0, expenditureSelf: 0, //(二)间接经费 indirectfundTotal: 0, indirectfundApply: 0, indirectfundSelf: 0, //二、经费来源 TotalSource: 0, //(一)申请专项经费 applySpecialTotal: 0, //(二)自筹经费来源 selfFundsTotal: 0, selfFundsApply: 0, selfFundsSelf: 0, }; }, methods: { outNumberChange (index) { this.budget[index].totalBudget = (parseFloat(this.budget[index].applyFunds) + parseFloat(this.budget[index].selfFunds)).toFixed(2); this.expenditureCal(); this.indirectfundCal(); this.selfFundsCal(); this.budget[0].totalBudget = (parseFloat(this.expenditureTotal) + parseFloat(this.indirectfundTotal)).toFixed(2); this.budget[0].applyFunds = (parseFloat(this.expenditureApply) + parseFloat(this.indirectfundApply)).toFixed(2); this.budget[0].selfFunds = (parseFloat(this.expenditureSelf) + parseFloat(this.indirectfundSelf)).toFixed(2); this.TotalExpenditure = this.budget[0].totalBudget; this.ApplyExpenditure = this.budget[0].applyFunds; this.SelfExpenditure = this.budget[0].selfFunds; }, //一、经费支出 begin //(一)经费支出 begin expenditureCal() { this.expenditureApplyCal(); this.expenditureSelfCal(); this.expenditureTotalCal(); }, expenditureApplyCal() { this.budget[1].applyFunds = (parseFloat(this.budget[2].applyFunds) + parseFloat(this.budget[3].applyFunds) + parseFloat(this.budget[4].applyFunds) + parseFloat(this.budget[5].applyFunds) + parseFloat(this.budget[6].applyFunds) + parseFloat(this.budget[7].applyFunds) + parseFloat(this.budget[8].applyFunds) + parseFloat(this.budget[9].applyFunds)).toFixed(2); this.expenditureApply = this.budget[1].applyFunds; }, expenditureSelfCal() { this.budget[1].selfFunds = (parseFloat(this.budget[2].selfFunds) + parseFloat(this.budget[3].selfFunds) + parseFloat(this.budget[4].selfFunds) + parseFloat(this.budget[5].selfFunds) + parseFloat(this.budget[6].selfFunds) + parseFloat(this.budget[7].selfFunds) + parseFloat(this.budget[8].selfFunds) + parseFloat(this.budget[9].selfFunds)).toFixed(2); this.expenditureSelf = this.budget[1].selfFunds; }, expenditureTotalCal() { this.budget[1].totalBudget = (parseFloat(this.budget[2].totalBudget) + parseFloat(this.budget[3].totalBudget) + parseFloat(this.budget[4].totalBudget) + parseFloat(this.budget[5].totalBudget) + parseFloat(this.budget[6].totalBudget) + parseFloat(this.budget[7].totalBudget) + parseFloat(this.budget[8].totalBudget) + parseFloat(this.budget[9].totalBudget)).toFixed(2); this.expenditureTotal = this.budget[1].totalBudget; }, //(一)经费支出 end //(二)间接经费 begin indirectfundCal() { this.indirectfundApplyCal(); this.indirectfundSelfCal(); this.indirectfundTotalCal(); }, indirectfundApplyCal() { this.budget[10].applyFunds = (parseFloat(this.budget[11].applyFunds) + parseFloat(this.budget[12].applyFunds) + parseFloat(this.budget[13].applyFunds) + parseFloat(this.budget[14].applyFunds)).toFixed(2); this.indirectfundApply = this.budget[10].applyFunds; }, indirectfundSelfCal() { this.budget[10].selfFunds = (parseFloat(this.budget[11].selfFunds) + parseFloat(this.budget[12].selfFunds) + parseFloat(this.budget[13].selfFunds) + parseFloat(this.budget[14].selfFunds)).toFixed(2); this.indirectfundSelf = this.budget[10].selfFunds; }, indirectfundTotalCal() { this.budget[10].totalBudget = (parseFloat(this.budget[11].totalBudget) + parseFloat(this.budget[12].totalBudget) + parseFloat(this.budget[13].totalBudget) + parseFloat(this.budget[14].totalBudget)).toFixed(2); this.indirectfundTotal = this.budget[10].totalBudget; }, //(二)间接经费 end //一、经费支出 end //二、经费来源 begin //(一)申请专项经费 begin //(一)申请专项经费 end //(二)自筹经费来源 begin selfFundsCal() { this.selfFundsApplyCal(); this.selfFundsSelfCal(); this.selfFundsTotalCal(); }, selfFundsApplyCal() { this.budget[17].applyFunds = (parseFloat(this.budget[18].applyFunds) + parseFloat(this.budget[19].applyFunds) + parseFloat(this.budget[20].applyFunds)).toFixed(2); this.selfFundsApply = this.budget[17].applyFunds; }, selfFundsSelfCal() { this.budget[17].selfFunds = (parseFloat(this.budget[18].selfFunds) + parseFloat(this.budget[19].selfFunds) + parseFloat(this.budget[20].selfFunds)).toFixed(2); this.selfFundsSelf = this.budget[17].selfFunds; }, selfFundsTotalCal() { this.budget[17].totalBudget = (parseFloat(this.budget[18].totalBudget) + parseFloat(this.budget[19].totalBudget) + parseFloat(this.budget[20].totalBudget)).toFixed(2); this.selfFundsTotal = this.budget[17].totalBudget; }, //(二)自筹经费来源 end //二、经费来源 end totalNumberChange() { //(一)申请专项经费 this.applySpecialTotal = this.budget[16].totalBudget; //(二)自筹经费来源 this.selfFundsCal(); this.budget[15].totalBudget = (parseFloat(this.selfFundsTotal) + parseFloat(this.applySpecialTotal)).toFixed(2); this.TotalSource = this.budget[15].totalBudget; }, }, computed: { }, }; </script>