<template>
  <div>
    <table>
        <tr class="table-header">
          <td class="name">任务名称</td>
          <td>预算(元)</td>
          <td>奖金(元)</td>
        </tr>
        <tr v-for="item in arrayData">
          <td>{{item.name}}</td>
          <td>
            <div v-if="!item.showBudgetEdit" @click="item.showBudgetEdit = true">{{item.budget}}</div>
            <van-field v-else v-model="item.budget" type="number" class="input-box" @blur="item.showBudgetEdit = false" />
          </td>
          <td>
            <div v-if="!item.showBonusEdit" @click="item.showBonusEdit = true">{{item.bonus}}</div>
            <van-field v-else v-model="item.bonus" type="number" class="input-box" @blur="item.showBonusEdit = false" />
          </td>
        </tr>
        <tr>
          <td>合计</td>
          <td>{{sumBudget}}</td>
          <td>{{sumBonus}}</td>
        </tr>
    </table>
    <div class="pagination">
        <van-pagination v-model="currentPage" :page-count="12" mode="simple" />
    </div>
  </div>
</template>

<script setup>
import {ref, reactive} from'vue'
const arrayData = ref([
  {
    name:'财务条插件界面设计',
    budget:1000,
    bonus:0,
    showBudgetEdit: false,
    showBonusEdit: false,
  },
   {
    name:'财务条插件界面设计',
    budget:0,
    bonus:0,
    showBudgetEdit: false,
    showBonusEdit: false,
  },
   {
    name:'财务条插件界面设计',
    budget:0,
    bonus:0,
    showBudgetEdit: false,
    showBonusEdit: false,
  },
   {
    name:'财务条插件界面设计',
    budget:0,
    bonus:200,
    showBudgetEdit: false,
    showBonusEdit: false,
  },
  {
    name:'财务条插件界面设计',
    budget:1000,
    bonus:0,
    showBudgetEdit: false,
    showBonusEdit: false,
  },
   {
    name:'财务条插件界面设计',
    budget:0,
    bonus:0,
    showBudgetEdit: false,
    showBonusEdit: false,
  },
   {
    name:'财务条插件界面设计',
    budget:0,
    bonus:0,
    showBudgetEdit: false,
    showBonusEdit: false,
  },
   {
    name:'财务条插件界面设计',
    budget:0,
    bonus:200,
    showBudgetEdit: false,
    showBonusEdit: false,
  }
]);
const sumBudget = arrayData.value.reduce((sum, e) => sum + e.budget, 0);
const sumBonus = arrayData.value.reduce((sum, e) => sum + e.bonus, 0);
const currentPage = ref(1);
const data = reactive({

})
</script>

<style scoped lang="less">
table {
    width: 100%;
    margin-top: 1rem;
    font-size: 14px;
    overflow-x: scroll;
    color:#797878 ;
    td {
      border: 0.5px solid #ccc;
      padding: 0.85rem;
      width: 5.9375rem;
    }
    .table-header{
      background-color: #F2F2F2;
      color: #A0A0A0;
    }
    .name{
      width:50%
    }
  }
  .pagination{
    width:50%;
    margin-left: 50%;
    margin-top:1rem
  }

  .input-box{
    padding: 0!important;
    border-bottom: 1px solid #ccc
  }

</style>
