<template>
  <div class="container-accountability scoringWeightCitySee">
    <el-row>
      <el-col :span="24">
        <h3 class="titH3">考核年度</h3>
      </el-col>
    </el-row>
    <el-form ref="form" :model="form" label-width="230px" :rules="rules">
      <el-row>
        <el-col :span="10">
          <el-form-item label="考核年度" prop="year">
            <el-select v-model="form.year" placeholder="请选择考核年度" clearable  disabled>
              <el-option :key="item.index" :label="item" :value="item" v-for="item in dateyear"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <h3 class="titH3">自评起止时间</h3>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="配合部门" prop="sjPhbmPsTime">
            <el-date-picker
              :disabled="true"
              v-model="form.sjPhbmPsTime"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              style="width:100%;"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="牵头部门" prop="sjQtbmPsTime">
            <el-date-picker
              :disabled="true"
              v-model="form.sjQtbmPsTime"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              style="width:100%;"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <h3 class="titH3">考核起止时间</h3>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="配合部门" prop="sjPhbmTime">
            <el-date-picker
              :disabled="true"
              v-model="form.sjPhbmTime"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              style="width:100%;"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="牵头部门" prop="sjQtbmTime">
            <el-date-picker
              :disabled="true"
              v-model="form.sjQtbmTime"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              style="width:100%;"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <h3 class="titH3">考核评分权重设置</h3>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="自评权重(%)" prop="zsZpbmWeight" >
            <el-input v-model="form.zsZpbmWeight" type="text" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="考核权重(%)" prop='sjQtbmWeight'>
            <el-input v-model="form.sjQtbmWeight" type="text" disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="抽查权重(%)"  prop="sjQtbmFpWeight">
            <el-input v-model="form.sjQtbmFpWeight" type="text" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <h3 class="titH3">考核等级设置</h3>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20">
          <el-form-item label="">
          <!-- <table border="1" class="tabStyle">
            <tr>
              <td class="tabTit">等级名称</td>
              <td class="tabTit" colspan="2">分值区间</td>
            </tr>
            <tr  v-for = "(weightRank,index) in form.weightRankList" :key="index">
              <td class="tabTit">{{weightRank.rankName}}</td>
              <td>
                <el-input v-model="weightRank.fzStart"  type="text" size="mini" disabled ></el-input>
              </td>
              <td>
                <el-input v-model="weightRank.fzEnd" type="text" size="mini" disabled></el-input>
              </td>
            </tr>
          </table> -->
          <el-table
              :data="form.weightRankList"
              border
              stripe
              highlight-current-row
              style="margin-top: 0px;"
            >
              <el-table-column prop="rankName" label="等级名称" align="center" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column label="分值区间" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.fzStart"  type="text" size="mini" maxlength="3" disabled></el-input>
                </template>
              </el-table-column>
              <el-table-column label="分值区间" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.fzEnd" type="text" size="mini" maxlength="3" disabled></el-input>
                </template>
              </el-table-column>
            </el-table>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <div style="width: 80%; margin: 0 auto; text-align: center; ">
            <el-button
              type="primary"
              size='small'
              class="iconfont iconfanhui"
              @click="back"
            >返回</el-button>
          </div>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import * as management from "@/api/headResponsibility/scoringWeight";
import * as validate from "@/utils/validate"
export default {
  data() {
    return {
      form: {
        year: "",
        sjQtbmFpWeight:"",
        sjQtbmWeight:"",
        weightRankList:[]
      },
      dateyear: [],
      loading: false,
      rules: {
        year: [
          { required: true, message: "请选择考核年度", trigger: ['blur',"change"] }
        ],
        sjPhbmTime: [
          { required: true, message: "请选择配合部门起止时间", trigger: "blur" }
        ],
        sjQtbmTime: [
          { required: true, message: "请选择牵头部门起止时间", trigger: "blur" }
        ],
        sjQtbmPsTime: [
          { required: true, message: "请选择牵头部门起止时间", trigger: "blur" }
        ],
        sjPhbmPsTime: [
          { required: true, message: "请选择配合部门起止时间", trigger: "blur" }
        ],
        sjQtbmWeight: [
          { required: true, message: "考核权重不能为空", trigger: "blur" },
          {trigger: ['blur', 'change'], validator: validate.validateNumber}
        ],
        zsZpbmWeight:[
          { required: true, message: "自评权重不能为空", trigger: "blur" },
          {validator: validate.validateNumber, trigger: ['blur', 'change']}
        ],
      }
    };
  },
  methods: {
    /**
     * 返回按钮
     */
    back() {
      this.$router.back(-1);
    },
    // 粮食安全行政首长责任制-----考核评分权重----根据id查询考核内容--明细
    findById(id){
        management.findById(id).then(res => {
          if (res.infoCode == 200) {
          this.form=res.data;
        }
      });
    }
  },
  created() {
    this.findById(this.$route.query.id);
  }
};
</script>
<style lang="scss">
.scoringWeightCitySee {
  .el-select {
    display: block;
  }
  .el-date-editor {
    width: 100%;
  }
  .el-date-editor .el-range-separator {
    padding: 0 0;
  }
  .el-checkbox {
    margin-left: 20px;
  }
  .tabStyle {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 16px;
    table-layout: fixed;
    border: 1px solid #ccc;
    text-align: center;
    margin: 20px 0 20px 230px;
    td {
      padding: 5px;
    }
    .tabTit {
      padding: 10px;
    }
  }
}
</style>
