<template>
  <div class="app-container">
    <evaluation-title
      :title="`学生数据管理/学生单次测评数据/${user.name}`"
      :navBackButton="true"
    ></evaluation-title>
    <form-search
      :userData="user"
      :searchformShow="searchformShow"
      @handleQuery="handleQuery"
    ></form-search>
    <el-row :gutter="10">
      <el-col
        class="evaluation-card-wrapper"
        v-for="(item, idx) in dataList"
        :key="idx"
        :xs="12"
        :sm="8"
        :md="8"
        :lg="6"
        :xl="6"
      >
        <evaluation-card
          @click.native="detail(item)"
          :title="item.name"
          :subTitle="item.subjectName"
          :thirdTitle="item.className"
          :stateOptions="mxGlobal.MergeEvalInspectionStates(item.stateStr)"
          :state="item.stateStr"
          :proportion="`${item.valid}/${item.total}`"
        ></evaluation-card>
      </el-col>
    </el-row>
    <evaluation-empty v-if="total == 0" />
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      :page-size="20"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getEvaluationForStudent } from "@/api/webApi/front.js";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";

export default {
  name: "Menu",
  components: { Treeselect, IconSelect },
  data() {
    return {
      total: 0,
      // 遮罩层
      loading: true,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        catalogId: "",
        classId: "",
        customerCode: "",
        gradeId: "",
        subjectId: "",
        termId: "",
        typeId: "",
      },
      dataList: [],
      user: {},
      searchformShow: {},
      routeParams: {},
    };
  },
  created() {
    this.routeParams = this.$route.query;
    this.user.id = this.routeParams.userId;
    this.user.name = this.routeParams.name;
    this.user.img = this.routeParams.avatar;
    this.searchformShow = {
      userSubject: "",
      gradeid: "",
      semester: "",
      exam: "",
    };
    this.handleQuery(); //{gradeid: this.routeParams.gradeId}
    //  this.getDicts("sys_show_hide").then(response => {
    //    this.visibleOptions = response.data;
    //  });
    //  this.getDicts("sys_normal_disable").then(response => {
    //    this.statusOptions = response.data;
    //  });
  },
  methods: {
    detail(item) {
      const nextParams = {
        evaluationName: item.name,
        examineeId: item.examineeId,
        studentName: this.user.name,
      };
      this.$router.push({
        path: "/idc/EvaluationDatabase/statistics",
        query: nextParams,
      });
    },
    // 选择图标
    selected(name) {
      this.form.icon = name;
    },
    /** 查询菜单列表 */
    getList() {
      this.loading = true;
      getEvaluationForStudent(this.queryParams).then((response) => {
        console.log("getEvaluationForStudent rep=", response);
        this.dataList = response.rows || response.data;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.form = {};
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery(ctrlParams = {}) {
      this.queryParams.pageNum = 1;
      this.queryParams.subjectId = ctrlParams.userSubject || "";
      this.queryParams.termId = ctrlParams.semester || "";
      this.queryParams.typeId = ctrlParams.exam || "";
      this.queryParams.gradeId = ctrlParams.gradeid;
      this.queryParams.classId = this.routeParams.classId;
      this.queryParams.customerCode = this.routeParams.customerCode;
      this.getList();
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
