<script setup lang="ts">
import ahTable from "@/components/hTable/index.vue";
import {
  ConditionalType,
  intTableData,
  TableColumnSearch,
  TableConfig,
} from "@/components/hTable/hTable";
import { onMounted, ref } from "vue";
import { fa } from "element-plus/es/locales.mjs";
import { hTableAPI } from "@/api/hTable";
import { getenum } from "@/api/enum";
import { ruleRequired, ruleRequiredNumber } from "@/utils/rules";
const ControllerName = "ExamClassInfo";

defineOptions({
  name: "ClassExam",
});

const props = defineProps<{
  data: any;
}>();

function searchCallback(data) {}
const table = ref<{ initTable: (config: TableConfig) => void }>();
const tableData: TableConfig = intTableData({
  apiUrl: ControllerName,
  selectColumn: false, // 列表选择
  border: false, // 是否显示表格边框
  searchCallback: searchCallback,
  search: {
    // 查询条件
    show: true,
    PageSize: 999,
  },
  operationColumn: true, // 显示操作按钮
  operationColumnData: [
    {
      topBtn: false, // 头部按钮
      show: true,
      label: "详情",
      btnType: "custom",
      btnStyle: "primary",
      custom: {
        title: "考试班级详情", // 弹出框title
        src: "exam/classExamRecord", // 组件路径
        width: "1600px", // 弹框宽度
        height: "800px", // 弹框高度
      },
    },
  ],
  column: {
    // 行数据
    schoolName: {
      label: "学校",
      width: "180px",
      search: new TableColumnSearch(true, ConditionalType.Like),
    },
    grade: {
      label: "年级",
      width: "120px",
      custom: (row) => row.gradeLevel + row.gradeYear + "届",
      search: new TableColumnSearch(true),
    },
    className: {
      label: "班级",
      width: "80px",
      search: new TableColumnSearch(true, ConditionalType.Like),
    },
    examName: {
      label: "最近考试",
      width: "200px",
    },
    peopleCount: {
      label: "参考人数",
      width: "100px",
    },
    onLineCount: {
      label: "重本人数",
      width: "100px",
    },
    onLineRate: {
      label: "重本率",
      width: "100px",
      custom: (row) => `${row.onLineRate * 100}%`,
    },
    onLineRanking: {
      label: "重本率排名",
    },
  },
  data: [],
  pageData: {
    total: 0,
  },
  selectRows: [],
});

const showTable = ref(false);
onMounted(async () => {
  //初始化数据原

  showTable.value = true;
});
</script>

<template>
  <div><ahTable v-if="showTable" ref="table" :tableConfig="tableData" /></div>
</template>
