<template>

  <div class="container-accountability managementList">
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-row>
        <el-col :span="8">
          <el-form-item label="考核内容">
            <el-select
              placeholder="请选择"
              v-model="formInline.khnrId"
              @change="contentSelect(formInline)"
              clearable>
              <el-option
                v-for="item in contentList"
                :key="item.ID"
                :label="item.NAME.length > 33 ? item.NAME.substring(0,33)+'...' : item.NAME"
                :value="item.ID"
                ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="重点考核事项">
            <el-select
              placeholder="请选择"
              v-model="formInline.khsxId"
              @change="itemSelect(formInline)"
              clearable>
              <el-option
                v-for="item in itemList"
                :key="item.ID"
                :label="item.NAME.length > 33 ? item.NAME.substring(0,33)+'...' : item.NAME"
                :value="item.ID"
                ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="考核指标">
            <el-select
              placeholder="请选择"
              v-model="formInline.khzbId"
              clearable>
              <el-option
                v-for="item in qutaList"
                :key="item.ID"
                :label="item.NAME.length > 33 ? item.NAME.substring(0,33)+'...' : item.NAME"
                :value="item.ID"
                ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="考核目标任务">
            <el-input v-model="formInline.khrw" type="text"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="9">
          <el-form-item>
            <el-button type="primary" class="outButton" icon="el-icon-search" @click="search">查询</el-button>
            <el-button type="primary" class="outButton" icon="el-icon-refresh" @click="relect">重置</el-button>
            <el-button type="primary" class="outButton" icon="el-icon-search" @click="back">返回</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <el-row>
      <el-col :span="24">
        <el-table
          :data="tableList"
          v-loading="loading"
          border
          stripe
          highlight-current-row
          style="margin-top:0;"
        >
          <el-table-column align="center" label="序号" width="60">
            <template slot-scope="scope">
              <span>{{scope.$index+1}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="考核目标任务">
            <el-table-column align="center" label="任务名称" sortable :show-overflow-tooltip="true">
              <template slot-scope="scope">
                <span>{{scope.row.TASK_NAME}}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" label="分值" sortable :show-overflow-tooltip="true">
              <template slot-scope="scope">
                <span>{{scope.row.TOTAL_SCORE}}</span>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column align="center" label="盟市考核">
            <el-table-column align="center" label="自评分值"  sortable :show-overflow-tooltip="true">
              <template slot-scope="scope">
                <span>{{scope.row.ZPBM_SCORE}}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" label="牵头部门分值"  sortable :show-overflow-tooltip="true">
              <template slot-scope="scope">
                <span>{{scope.row.QTBM_SCORE}}</span>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column align="center" label="省级复核">
            <el-table-column prop='' align="center" label="配合意见" sortable :show-overflow-tooltip="true"></el-table-column>
            <el-table-column align="center" label="牵头部门分值"  sortable :show-overflow-tooltip="true">
              <template slot-scope="scope">
                <span>{{scope.row.SJ_QTBM_SCORE}}</span>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="操作" width="80" align="center">
            <template slot-scope="scope">
              <el-tooltip class="item" effect="light" content="查看" placement="top">
                <el-button
                  type="primary"
                  size="small"
                  icon="el-icon-zoom-in"
                  class="button"
                  @click.stop="handleSee(scope.row)">
                </el-button>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
        <div v-show="!listLoading" class="pag-right clearFix">
          <el-pagination
            class="right"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="page.page"
            :page-sizes="[10,20,30,50]"
            :page-size="page.size"
            layout="total, sizes, prev, pager, next, jumper"
            v-if="paginationShow"
            :total="page.total"
          ></el-pagination>
        </div>
      </el-col>
    </el-row>


  </div>
</template>
<script>
import * as cityEntry from "@/api/headResponsibility/cityEntry";
import * as management from "@/api/headResponsibility/management";
import * as scoringWeight from "@/api/headResponsibility/scoringWeight";
import {downloadExcel } from "@/api/index";
export default {
  data() {
    return {
      isSub:"",
      weightMessage:"",
      submitButton:true,
      showExcelUplod: false,
      excelFileList: [],
      weight:{},
      contentList:{},
      itemList:{},
      qutaList:{},
      excelDownloadDataFile: `${downloadExcel}`,
      formInline: {
        year:"",
        source: "10",
        areaCode:"",
        billityId:"",
        khnrId:"",
        khsxId:"",
        khzbId:"",
        khrw:""
      },
      dateyear: [],
      tableList: [],
      loading: true,
      listLoading: false,
      paginationShow: true,
      page: {
        page: 1,
        size: 10,
        total: 0
      }
    };
  },
  methods: {


    back(){
      this.$router.back(-1);
    },


    relect(){
      this.formInline.khnrId="";
      this.formInline.khsxId="";
      this.formInline.khzbId="";
      this.formInline.khrw="";
    },

    /**
     * 考核内容ID
     */
    contentSelect(obj){
      for (var i = 0; i < this.contentList.length; i++) {
        var content=this.contentList[i]
        if(obj.khnrId=content.ID){
          this.itemList=content.itemList;
        }
      }
    },

    /**
     * 重点考核事项
     */
    itemSelect(obj){
      for (var i = 0; i < this.itemList.length; i++) {
        var item=this.itemList[i]
        if(obj.khsxId=item.ID){
          this.qutaList=item.qutaList;
        }
      }
    },

    /**
     * 查询按钮
     */
    search() {
      this.loading=true
      this.paginationShow = false;
      this.handleCurrentChange(1);
      this.$nextTick(function() {
        this.paginationShow = true;
      });
    },



    /**
     * 取消
     */
    excelUplodQx() {
      this.showExcelUplod = false;
      this.excelFileList = [];
    },




    /**
     * 表格查看按钮
     */
    handleSee(row) {
      console.log("row",row);
        this.$router.push({
            path:"/supervisionCheck/headResponsibility/cityInfoSee",
            query:{
                id:row.INPUTID,
                year:this.$route.query.year,
                isDisabled:"1"
            }
        })
    },
    /**
     * 分页大小
     */
    handleSizeChange(val) {
      this.page.size = val;
      this.getTabList()
    },

    /**
     * 分页第几页
     */
    handleCurrentChange(val) {
      this.page.page = val;
      this.getTabList()
    },


    /**
     * 考核部门汇总表---查询各盟市考核目标任务列表
     */
    getTabList() {
      cityEntry.findCityByPage(this.formInline, this.page)
        .then(res => {
            this.loading = false;
            if (res.infoCode==200) {
                this.tableList=res.data.list
                this.page.total=res.data.total
            }
        });

    },


    /**
     * 盟市考核进度明细列表查询选项
     */
    findBySelect(areaCode,year,billityId){
      this.formInline.year=year
      this.formInline.areaCode=areaCode
      this.formInline.billityId=billityId
        cityEntry.findBySelect(year,billityId).then(res=>{
          console.log("res.data",res.data);
          this.contentList=res.data;
      })
      this.search();
    }





  },
  created() {
    this.findBySelect(this.$route.query.areaCode,this.$route.query.year,this.$route.query.billityId);

  }
};
</script>
<style lang="scss">
.managementList {
}
</style>
