<template>
  <div class="app-container">
    <evaluation-title
    :title="`${mxGlobal.TailingClassName(className)}知识点错误次数详情${mxGlobal.EvalTitleSeperator}${queryParams.knownledgeName}`"
    :navBackButton="true"
    ></evaluation-title>
    <el-table v-loading="loading" :data="dataList" style="width: 100%">
      <el-table-column label="序号" type="index" align="center" width="100" />
      <el-table-column label="姓名" prop="name" align="center" />
      <el-table-column label="次数" prop="wrongCount" align="center" />
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button
            type="text"
            icon="el-icon-view"
            @click="detail(scope.$index)"
            >查看详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getClassStudentStats } from "@/api/webApi/front";

export default {
  data() {
    return {
      queryParams: {
        classId: "",
        beginTime: "",
        endTime: "",
        //knownledgeId: "",
        knownledgeName: "",
      },
      className: "",
      loading: false,
      dataList: [],
    };
  },
  created() {
    this.queryParams = this.$route.query;
    this.className = this.queryParams.className;
    delete this.queryParams.className;
    this.handleQuery();
  },
  methods: {
    detail(idx) {
      const studentName = this.dataList[idx].name
      const userCode = this.dataList[idx].code
      const nextParams = { ...this.queryParams, customerCode: userCode, className: this.className, studentName: studentName }
      this.$router.push({ path: "/idc/mistakes/detail", query: nextParams });
    },
    handleQuery() {
      this.getList();
    },
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    getList() {
      this.loading = true;
      getClassStudentStats(this.queryParams).then((rep) => {
        console.log("getClassStudentStats rep =", rep);
        if (rep.code == 200 || rep.code == 0) {
          this.dataList = rep.data;
        } else {
          this.msgError(rep.msg || "getClassStudentStats请求异常");
        }
        this.loading = false;
      });
    },
  },
};
</script>

<style>
</style>
