<template>
  <div class="app-container">
    <evaluation-title
      :title="routeParams.name + '/选择班级'"
      :navBackButton="true"
    ></evaluation-title>
    <form-search
      :withoutSearchButton="true"
      :searchformShow="{ class: '', clbum: '' }"
      @change="handleQuery"
      @handleQuery="handleQuery"
      @resetQuery="resetQuery"
    ></form-search>
    <el-row :gutter="10">
      <el-col
        class="evaluation-card-wrapper"
        v-for="(exam, idx) in searchData"
        :key="idx"
        :xs="12"
        :sm="8"
        :md="8"
        :lg="6"
        :xl="6"
      >
        <evaluation-card
          @click.native="detail(exam)"
          :title="exam.name"
          :subTitle="exam.subjectName"
          :thirdTitle="exam.className"
          :stateOptions="mxGlobal.MergeEvalInspectionStates(exam.stateStr)"
          :state="exam.stateStr"
          :proportion="`${exam.valid}/${exam.total}`"
        ></evaluation-card>
      </el-col>
    </el-row>
    <evaluation-empty v-if="!searchData || !searchData.length" />
    <pagination
      v-show="total > queryParams.pageSize"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      :page-size="20"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getEvaluationForStat } from "@/api/webApi/front";
import { mapGetters } from "vuex";

export default {
  data() {
    return {
      total: 0,
      searchData: [],
      loading: true,
      routeParams: {},
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        //
        catalogId: "1", // 分类 编码
        classId: "", // 班级
        customerCode: "", // 学生编号
        gradeId: "", // 年级
        subjectId: "", // 科目
        termId: "", // 学期
        typeId: "", // 类型 编码
      },
    };
  },
  computed: {
  },
  created() {
    this.routeParams = this.$route.query
    this.queryParams.catalogId = this.routeParams.catalogId;
    this.queryParams.evaluationId = this.routeParams.evaluationId;
    this.handleQuery();
  },
  methods: {
    detail(item) {
      let nextParams = {
        evaluationId: item.evaluationId,
        evaluationClassId: item.evaluationClassId,
        evaluationName: item.name,
        className: item.className
      };
      this.$router.push({
        path: "/idc/mistakesOnce/summary",
        query: nextParams,
      });
    },
    /** 查询菜单列表 */
    getList() {
      this.loading = true;
      getEvaluationForStat(this.queryParams).then((rep) => {
        console.log("getEvaluationForStat rep =", rep);
        if (rep.code == 200 || rep.code == 0) {
          this.searchData = rep.rows || rep.data;
          this.total = rep.total;
        } else {
          this.msgError(rep.msg || "getEvaluationForStat 请求异常");
        }
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.form = {};
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery(ctrlParams = {}) {
      this.queryParams.pageNum = 1;
      this.queryParams.classId = ctrlParams.clbum || "";
      this.getList();
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
