• 徐俊's avatar
    xujun · fa2eef81
    徐俊 authored
    fa2eef81
budgetEdit.vue 4.08 KB
<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="6" class="bg-gray">
        <div class="special-middle">
          <div>预算科目</div>
        </div>
      </a-col>
      <a-col :span="3" class="bg-gray">
        <div class="special-middle">
          <div>总预算数</div>
        </div>
      </a-col>
      <a-col :span="3" class="bg-gray">
        <div class="special-middle">
          <div>省级财政资金</div>
        </div>
      </a-col>
      <a-col :span="3" class="bg-gray">
        <div class="special-middle">
          <div>自筹资金</div>
        </div>
      </a-col>
      <a-col :span="9" 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="6" style="text-align: right;">
        <div class="special-middle">{{ item.budgetName }}</div>
      </a-col>
      <a-col :span="3">
        <div class="special-middle">{{parseFloat(item.totalBudget).toFixed(2)}}</div>
      </a-col>
      <a-col :span="3">
        <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="3">
        <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="9">
        <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" />
export default {
  name: "BudgetEdit",
  data() {
    return {
      invisibleTotalBudget: [],
      invisibleApplyFunds: [0, 2, 3, 4],
      invisibleSelfFunds: [0, 1, 3, 4],
    };
  },
  props: {
    budget: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  created() {},
  methods: {
    //资金来源计算
    calFundFrom() {
      this.budget[0].applyFunds = this.budget[1].applyFunds + this.budget[2].applyFunds
      this.budget[0].selfFunds = this.budget[1].selfFunds + this.budget[2].selfFunds
      this.calRowTotalAmount(0)
    },
    //资金支出计算
    calFundPayment() {
      this.budget[3].applyFunds = this.budget[4].applyFunds + this.budget[8].applyFunds
      this.budget[3].selfFunds = this.budget[4].selfFunds + this.budget[8].selfFunds
      this.calRowTotalAmount(3)
    },
    //直接费计算
    calDirectFee() {
      this.budget[4].applyFunds = this.budget[5].applyFunds + this.budget[6].applyFunds + this.budget[7].applyFunds
      this.budget[4].selfFunds = this.budget[5].selfFunds + this.budget[6].selfFunds + this.budget[7].selfFunds
      this.calRowTotalAmount(4)
    },
    calRowTotalAmount(index) {
      this.budget[index].totalBudget = this.budget[index].applyFunds + this.budget[index].selfFunds
    },
    outNumberChange (index) {
      this.calRowTotalAmount(index)
      this.calDirectFee()
      this.calFundPayment()
      this.calFundFrom()
      if (this.budget[0].totalBudget < this.budget[3].totalBudget)
        this.$message.info('资金支出总数不能大于资金来源总数!')
    },
  },
};
</script>