<script setup lang="ts">
import ahTable from "@/components/hTable/index.vue";
import { ConditionalType, 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 = {
  apiUrl: ControllerName,
  selectColumn: false, // 列表选择
  border: false, // 是否显示表格边框
  searchCallback: searchCallback,
  search: {
    // 查询条件
    show: true,
    PageIndex: 0,
    PageSize: 20,
    OrderBy: "Id", // 排序
    OrderByType: 1, // 排序方式
    defaultConditions: [], // 默认查询条件
    Conditions: [],
  },
  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: "学校",
      search: true,
      searchType: ConditionalType.Like, // 搜索类型
      add: false, // 字段允许添加
      edit: false, // 字段允许修改
      width: "180px",
    },
    grade: {
      label: "年级",
      width: "120px",
      // custom: (s) => `${s.gradeLevel}${s.gradeYear}`,
      search: true,
      add: false, // 字段允许添加
      edit: false, // 字段允许修改
    },
    className: {
      label: "班级",
      width: "80px",
      search: true,
      searchType: ConditionalType.Like, // 搜索类型
      add: false, // 字段允许添加
      edit: false, // 字段允许修改
    },
    examName: {
      label: "最近考试",
      width: "200px",
      search: false,
    },
    peopleCount: {
      label: "参考人数",
      width: "100px",
      search: false,
    },
    onLineCount: {
      label: "重本人数",
      width: "100px",
      search: false,
    },
    onLineRate: {
      label: "重本率",
      width: "100px",
      custom: (row) => `${row.onLineRate * 100}%`,
      search: false,
    },
    onLineRanking: {
      label: "重本率排名",
      search: false,
    },
  },
  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>
