<template>
  <div class="item-list">
    <bread-crumb :curmbFirst="curmbFirst" :curmbSecond="curmbSecond"></bread-crumb>
    <div class="itemlist-content screenSet" id="screenSet">
      <el-row :gutter="30" class="row" type="flex" style="margin-top: 10px;">
        <el-form ref="serchForm" :model="selectProgress" label-width="75px" style="width:100%;">
          <el-col :span="6">
            <el-form-item label="项目状态:">
              <el-select
                v-model="selectProgress.status"
                size="small"
                style="width: 100%;"
                placeholder="请选择项目状态"
              >
                <el-option
                  v-for="(item,index) in statusSelect"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-input v-model="selectProgress.name" size="small" placeholder="请输入项目名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" style="padding:0;text-align:right;padding-right:15px;">
            <el-button type="default" size="small" @click="resetMessage" style="margin-left:0;">重置</el-button>
            <el-button type="primary" size="small" @click="search(1)">查询</el-button>
          </el-col>
        </el-form>
      </el-row>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="name" label="项目名称" min-width="200" align="center"></el-table-column>
        <el-table-column prop="status" label="项目状态" min-width="100" align="center"></el-table-column>
        <el-table-column prop="startTime" label="开始时间" min-width="80" align="center"></el-table-column>
        <el-table-column prop="endTime" label="结束时间" min-width="80" align="center"></el-table-column>
        <el-table-column label="操作" fixed="right" align="center" min-width="200">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="go(scope.row)">查看学情报告</el-button>
          </template>
        </el-table-column>
        <div slot="empty">
          <div class="table-empty">
            <img src="../../assets/image/no-content1.png">
            <p>没有查询到相关结果</p>
          </div>
        </div>
      </el-table>
    </div>
    <!-- 分页 -->
    <div class="pagination">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="searchParam.pageNo"
        :page-sizes="[15, 30, 50, 100, 200, 500, 700, 1000, 1500, 2000]"
        :page-size="searchParam.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalRows"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import { openLoading, closeLoading } from "../../utils/utils";
import * as commonUtil from "../../utils/utils";
import BreadCrumb from "../../components/breadcrumb.vue";
let vm = null;

export default {
  data() {
    return {
      curmbFirst: "学情报告",
      curmbSecond: "项目列表",
      selectProgress: {
        //搜索信息
        status: "",
        name: ""
      },
      statusSelect: [
        //项目状态
        {
          label: "进行中",
          value: "1"
        },
        {
          label: "已结束",
          value: "2"
        }
      ],
      tableData: [
        // table数据
        {
          name: "one",
          status: "进行中",
          startTime: "12-12-12",
          endTime: "23-23-23"
        }
      ],
      totalRows: 0, //数据总数
      searchParam: {
        pageNo: 1, //当前是第几页
        pageSize: 20 //页面总数
      }
     
    };
  },
  components: {
    BreadCrumb
  },
  created() {
    vm = this;
  },
  // 挂载到Dom完成时
  mounted: function() {
    commonUtil.resizeHeight();
  },
  methods: {
    // 搜索列表
    search(flag) {
      if(flag) vm.searchParam.pageNo = 1
      openLoading(vm)
      let params = {}
      vm.GET(url, params).then(res => {
        closeLoading(vm);
        if (res.code == "000000") {
        } else {
          vm.$message.info(res.message)
        }
      })
    },
    // 重置搜索信息
    resetMessage() {
      this.selectProgress = {
        status: "",
        name: ""
      };
      vm.search()
    },
    // 更改数据显示数量
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      vm.searchParam.pageSize = val
      vm.search()
    },
    // 换页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      vm.searchParam.pageNo = value
      vm.search()
    },
    //跳转到报告详情页
    go(row) {
      vm.$router.push({path:"/item-list",params: row})
    }
  }
};
</script>
<style lang="scss">
.item-list {
  .itemlist-content {
    padding: 10px;
    background: #fff;
  }
}
</style>