//  大赛情况
<template>
   <div class="resource">
    <!-- <div class="header">
      <span>当前资源情况 {{ useResCount }}/{{ totalResCount }}</span>
    </div>  -->
    <div class="inputcontent">
      
            <el-form :model="form">
            <el-form-item label="查询名称:">
            <el-input      type="text" v-model="form.name" size="small" placeholder="请输入查询名称"></el-input>
        </el-form-item>
        <el-form-item label="查询值:">
            <el-input      type="text" v-model="form.id" size="small" placeholder="请输入内容"></el-input>
        </el-form-item>
          <el-button type="primary" @click="onSubmit">搜索</el-button>
        </el-form>

   </div>
     <el-table
      ref="table"
      stripe
      size="small"
      height="80%"
      :data="tableData"
      element-loading-text="拼命加载中"
     @sort-change="sortChange"
    >
      <el-table-column
        v-for="(header, index) in headerData"
        :key="index"
        align="center"
        :prop="header.prop"
        :label="header.label"
        :sortable="header.sortable"
        :width="header.prop == 'index' ? 60 : ''"
      >
      </el-table-column>
   <el-table-column label="操作">
      <template slot-scope="scope">
         <el-button  size="mini" type="text"  @click="particulars(scope.row['id'])" >查看项目</el-button>
      </template>
    </el-table-column>
    </el-table>
       <div class="pagination">
      <Pagination
        :pagination-config="paginationConfig"
        @putPagination="getPagination"
      ></Pagination>
    </div>
   </div>

</template>
<script>
import Pagination from '@/components/Pagination'
import { formatType, formatStatus,parseTime } from '@/utils/index'
import { request } from '@/utils/request'
export default {
  name: 'IndexLayout',
   components: {
         Pagination
         },
  data() {
    return {
     paginationConfig: {
        hideSinglePage: false,
        page: 1,
        size: 15,
        sizeList: [10, 15, 30, 50],
        layout: 'total, sizes, prev, pager, next, jumper',
        total: 0,
      },
       form: {
          name: '',
          id:'',
       },
      tableData:[],
    
       dsheaderData: [],
      headerData: [], // 头部数据
      xqobjct:{},
      // loading:false
      dialog:{
      xq:false,
    }
    }
    
  },
  created() {
    
  },
  mounted() {
       this.addHeader();
     this.getResource('','')
  },
  methods: {
        addHeader(){
         const header = []
        header.push({ label: '用户ID', prop: 'uid' })
         header.push({ label: '用户名称', prop: 'uname', sortable: 'custom' })
        header.push({ label: 'id', prop: 'id', sortable: 'custom' })
        header.push({ label: '状态', prop: 'status', sortable: 'custom' })
        header.push({ label: '参赛时间', prop: 'enterTime', sortable: 'custom' })
        header.push({ label: '发布时间', prop: 'endTime', sortable: 'custom' })
        header.push({ label: '评审员ID', prop: 'reviewId', sortable: 'custom' })
        header.push({ label: '评审员名称', prop: 'reviewName', sortable: 'custom' })
        header.push({ label: '评语', prop: 'reviewContent', sortable: 'custom' })
        header.push({ label: '评分', prop: 'score', sortable: 'custom' })
        header.push({ label: '大赛id', prop: 'megagameId', sortable: 'custom' })
        header.push({ label: '大赛标题', prop: 'megagameTitle', sortable: 'custom' })
        header.push({ label: '大赛状态', prop: 'megagameStatus', sortable: 'custom' })
        header.push({ label: '题目ID', prop: 'questionId', sortable: 'custom' })
        header.push({ label: '题目标题', prop: 'questionTitle', sortable: 'custom' })
        header.push({ label: '选题方式', prop: 'questionSelectionWay', sortable: 'custom' })
        header.push({ label: '业务类型', prop: 'questionBusinessType', sortable: 'custom' })
        header.push({ label: '求解器类型', prop: 'questionSolverType', sortable: 'custom' })
        header.push({ label: '题目分值', prop: 'questionScore', sortable: 'custom' })
        header.push({ label: '难度级别', prop: 'questionRank', sortable: 'custom' })
        // header.push({ label: '操作', prop: 'operation' })
        this.headerData = header;
        },
       
        // 分页查询
        getPagination(data) {
      this.paginationConfig = data

    },
        // 获取大赛列表
 getResource(name,id) {
   const params = {
        transCode: 'D00010',
         page: this.paginationConfig.page,
        count: this.paginationConfig.size,
        proNames:name,
        proValues:id,
      }
      request(params)
        .then((res) => {
            console.log(res)
           res.rows.forEach((row) => {
             switch (row.status) {
            case "0":
              row.status = "认领";
              break;
            case "1":
           row.status ="发布";
              break;
               case "2":
           row.status ="评分";
              break;
            default:
          };
           switch (row.questionRank) {
            case "1":
              row.questionRank = "普通";
              break;
            case "2":
              row.questionRank ="一般";
              break;
               case "3":
              row.questionRank = "困难";
              break;
               case "5":
              row.questionRank = "地狱）";
              break;
            default:
          };
           switch (row.questionBusinessType) {
            case "1":
              row.questionBusinessType = "航天";
              break;
            case "2":
             row.questionBusinessType ="船舶";
              break;
            default:
          };
           switch (row.questionSelectionWay) {
            case "1":
              row.questionSelectionWay = "必选题";
              break;
            case "2":
             row.questionSelectionWay ="选做题";
              break;
            default:
          };
        
          });
          this.paginationConfig.total = res.total;
          this.tableData=res.rows;
         
        })
        .catch((err) => {})
    },
    
   onSubmit(){
  this.getResource(this.form.name,this.form.id)
   },
   sortChange(column,prop,order){
     console.log(column + '-' + column.prop + '-' + column.order)

   }
  },
}
</script>
<style lang="scss" scoped>
@import '@/styles/variables.scss';
@import '@/styles/mixin.scss';
.resource {
  @include w_h(100%, 100%);
  background: $color_f;
  .el-table {
    color: $color_9;
    .operation:hover {
      color: #2cae00;
      cursor: pointer;
    }
  }
  .pagination {
    @include flex();
    padding: 20px 10px;
    font-size: 12px;
    color: $color_9;
  }
}
.inputcontent{
    padding: 30px 15px  0 15px;
    position: relative;
    .el-input{
        width: 180px;
    }
}
.inputcontent .el-form-item{
    width: 16.5%;
    display: inline-table;

}
.inputcontent .el-button--primary{
    position: absolute;
    top: 32px;
    height: 35px;
    line-height: 13px;
}
</style>