<template>
  <div class="from-table font-line-space">
    <a-row>
      <a-col :span="24">
        <div class="tb-title">
          <span>项目绩效目标表</span>
        </div>
      </a-col>
    </a-row>
    <table class="tab-content" cellpadding="3" cellspacing="3" style="width: 98%">
      <tr>
          <td colspan="20" class="bg-title">{{ projectKPI.reportYear }}年度</td>
        </tr>
        <tr>
          <td class="bg-title">项目名称</td>
          <td colspan="19">{{ projectKPI.projName }}</td>
        </tr>
        <tr>
          <td class="bg-title">主管处室</td>
          <td colspan="10">
            <a-form-model-item :prop="'projectKPI.managerDept'" :rules="{required: true, message: '*', trigger: 'blur',}">
              <a-input placeholder="主管处室" v-model="projectKPI.managerDept" :maxLength="50"  />
            </a-form-model-item>
          </td>
          <td colspan="2" class="bg-title">实施单位</td>
          <td colspan="7">{{ projectKPI.appUnitName }}</td>
        </tr>
        <tr>
          <td class="bg-title">项目属性</td>
          <td colspan="10">
            <a-radio-group v-model="projectKPI.projAttribute">
              <a-radio :value="projAttributes[0].id">{{projAttributes[0].name}}</a-radio>
              <a-radio :value="projAttributes[1].id">{{projAttributes[1].name}}</a-radio>
            </a-radio-group>
          </td>
          <td colspan="2" class="bg-title">项目期</td>
          <td colspan="7">{{ projectKPI.projDeadline }}</td>
        </tr>
        <tr>
          <td rowspan="3" class="bg-title">项目资金(万元)</td>
          <td colspan="2" class="bg-title">总体资金总额：</td>
          <td colspan="8">{{ parseFloat(projectKPI.totalBudget).toFixed(2) }}</td>
          <td colspan="2" class="bg-title">年度资金总额：</td>
          <td colspan="7">{{ parseFloat(projectKPI.yearTotal).toFixed(2) }}</td>
        </tr>
        <tr>
          <td colspan="2" class="bg-title">其中：财政拨款</td>
          <td colspan="8">{{ parseFloat(projectKPI.applyFunds).toFixed(2) }}</td>
          <td colspan="2" class="bg-title">其中：财政拨款</td>
          <td colspan="7">{{ parseFloat(projectKPI.yearApply).toFixed(2) }}</td>
        </tr>
        <tr>
          <td colspan="2" class="bg-title">其他资金</td>
          <td colspan="8">{{ parseFloat(projectKPI.selfFunds).toFixed(2) }}</td>
          <td colspan="2" class="bg-title">其他资金</td>
          <td colspan="7">{{ parseFloat(projectKPI.yearSelf).toFixed(2) }}</td>
        </tr>
      <tr>
        <td rowspan="3" class="bg-title" style="width: 100px;">总体考核目标</td>
        <td colspan="10" class="bg-title">
          总体目标({{ moment(projectKPI.startDate).year() }}年—{{moment(projectKPI.endDate).year()}}年)
        </td>
        <td class="bg-title" colspan="9">分年度指标</td>
      </tr>
      <tr>
        <td colspan="10" rowspan="2">
          <a-form-model-item :prop="'projectKPI.yearTarget'" :rules="{required: true, message: '*', trigger: 'blur',}">
            <a-textarea placeholder="总体目标" v-model="projectKPI.yearTarget" :maxLength="600" style="width: 90%; height: 100px;" />
          </a-form-model-item>
        </td>
        <td class="target-value" colspan="3">{{ moment(projectKPI.startDate).year() }}年</td>
        <td class="target-value" colspan="3">{{ moment(projectKPI.startDate).add(1, 'year').year() }}年</td>
        <td class="target-value" colspan="3">{{ moment(projectKPI.startDate).add(2, 'year').year() }}年</td>
      </tr>
      <tr>
        <td colspan="3" style="margin-top: 10px;">
          <a-form-model-item :prop="'projectKPI.year1Goal'" :rules="{required: true, message: '*', trigger: 'blur',}">
            <a-textarea v-model="projectKPI.year1Goal" :maxLength="200" style="width: 250px; height: 60px;" />
          </a-form-model-item>
        </td>
        <td colspan="3">
          <a-form-model-item :prop="'projectKPI.year2Goal'" :rules="{required: true, message: '*', trigger: 'blur',}">
            <a-textarea v-model="projectKPI.year2Goal" :maxLength="200" style="width: 250px; height: 60px;" />
          </a-form-model-item>
        </td>
        <td colspan="3">
          <a-form-model-item :prop="'projectKPI.year3Goal'" :rules="{required: true, message: '*', trigger: 'blur',}">
            <a-textarea v-model="projectKPI.year3Goal" :maxLength="200" style="width: 90%; height: 60px;" />
          </a-form-model-item>
        </td>
      </tr>
      <tr>
        <td :rowspan="projectKPI.totalRowSpan"></td>
        <td rowspan="2" class="bg-title">一级指标</td>
        <td rowspan="2" class="bg-title">二级指标</td>
        <td rowspan="2" colspan="6" class="bg-title">三级指标</td>
        <td rowspan="2" class="bg-title">指标值</td>
        <td rowspan="2" class="bg-title">绩效标准</td>
        <td rowspan="2" class="bg-title">二级指标</td>
        <td rowspan="2" colspan="5" class="bg-title">三级指标</td>
        <td colspan="3" class="bg-title">指标值</td>
      </tr>
      <tr>
        <td>{{ moment(projectKPI.startDate).year() }}</td>
        <td>{{ moment(projectKPI.startDate).add(1, 'year').year() }}</td>
        <td>{{ moment(projectKPI.startDate).add(2, 'year').year() }}</td>
      </tr>
      <tr v-for="(item, index) in projectKPI.threeLevel" :key="index">
        <td class="bg-title" v-if="item.oneDisplay" :rowspan="item.oneRowSpan">
          {{ item.oneLevelName }}
        </td>
        <td class="bg-title" v-if="item.towDisplay" :rowspan="item.towRowSpan">
          {{ item.towLevelName }}
        </td>
        <td colspan="6">{{ item.kpitName }}</td>
        <td class="target-value">
          <a-form-model-item :prop="'projectKPI.threeLevel.' + index + '.targetValue'" :rules="{required: false, message: '*', trigger: 'blur',}">
            <a-input-number v-model="item.targetValue" :min="0" :step="1" style="width: 90%" />
          </a-form-model-item>
        </td>
        <td class="target-value">
          <a-form-model-item :prop="'projectKPI.threeLevel.' + index + '.performanceStandard'" :rules="{required: false, message: '*', trigger: 'blur',}">
            <a-input-number v-model="item.performanceStandard" :min="0" :step="1" style="width: 90%" />
          </a-form-model-item>
        </td>
        <td class="bg-title" v-if="item.towDisplay" :rowspan="item.towRowSpan">
          {{ item.towLevelName }}
        </td>
        <td colspan="5">{{ item.kpitName }}</td>
        <td class="target-value">
          <a-form-model-item :prop="'projectKPI.threeLevel.' + index + '.yearValue1'" :rules="{required: false, message: '*', trigger: 'blur',}">
            <a-input-number v-model="item.yearValue1" :min="0" :step="1" style="width: 90%" />
          </a-form-model-item>
        </td>
        <td class="target-value">
          <a-form-model-item :prop="'projectKPI.threeLevel.' + index + '.yearValue2'" :rules="{required: false, message: '*', trigger: 'blur',}">
            <a-input-number v-model="item.yearValue2" :min="0" :step="1" style="width: 90%" />
          </a-form-model-item>
        </td>
        <td class="target-value">
          <a-form-model-item :prop="'projectKPI.threeLevel.' + index + '.yearValue3'" :rules="{required: false, message: '*', trigger: 'blur',}">
            <a-input-number v-model="item.yearValue3" :min="0" :step="1" style="width: 90%" />
          </a-form-model-item>
        </td>
      </tr>
    </table>
  </div>
</template>
  
<script>
import moment from "moment";

export default {
  name: "projectKpiEdit",
  props: {
    projectKPI: {
      type: Object,
      default: () => {
        return null;
      },
    },
  },
  data() {
    return {
      projAttributes: [
        { id: "5b9d6509-aece-11ef-b6cb-0c42a1380f01", name: "新增项目" },
        { id: "5b9d6509-aece-11ef-b6cb-0c42a1380f02", name: "延期项目" },
      ],
    };
  },
  created() {
    //this.getProjectKpitStatistic()
    this.LoadParameterInfo();
  },
  methods: {
    moment,
    LoadParameterInfo() {
      let pars1 = { typeId: 67 };
      this.$api.parameter
        .getParameterListByTypeId(pars1)
        .then(({ data = {} }) => {
          this.projAttributes = data;
          //console.log(this.projAttribute[0].id)
        })
        .catch(() => {});
    },
    getProjectKpitStatistic() {
      this.$api.statistical.getProjectKpitStatistic().then(({ data = {} }) => {
        if (data) {
        }
      });
    },
  },
};
</script>
  
  <style scoped lang="less">
table,
tr,
td {
  border: 1px solid #080808;
  font-size: 10pt;
  text-align: left;
  line-height: 25px;
  height: 25px;
}
.bg-title {
  background-color: #f5f5f5;
  font-weight: bold;
  text-align: center;
}
.target-value {
  text-align: center;
}
</style>