<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 = "ExamUserInfo";

defineOptions({
  name: ControllerName,
});

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,
    showPage: false,
    PageSize: 9999,
    OrderBy: "AssignRanking", // 排序
    OrderByType: 0,
    defaultConditions: [
      {
        FieldName: "ExamId",
        FieldValue: props.data[0].examId + "",
      },
      {
        FieldName: "ClassId",
        FieldValue: props.data[0].classId + "",
      },
    ], // 默认查询条件
    Conditions: [],
  },
  operationColumn: true, // 显示操作按钮
  operationColumnData: [
    {
      topBtn: false, // 头部按钮
      label: "个人详情",
      btnType: "custom",
      btnStyle: "primary",
      custom: {
        title: "考试学生班级详情", // 弹出框title
        src: "exam/userExam", // 组件路径
        width: "1600px", // 弹框宽度
        height: "800px", // 弹框高度
      },
    },
  ],
  column: {
    // 行数据
    userName: {
      label: "姓名",
      width: "180px",
      search: new TableColumnSearch(true, ConditionalType.Like),
    },
    语文: {
      label: "语文",
      width: "100px",
      custom: (row) => row.subjectDic.语文,
      search: { sort: true },
    },
    数学: {
      label: "数学",
      width: "100px",
      custom: (row) => row.subjectDic.数学,
      search: { sort: true },
    },
    英语: {
      label: "英语",
      width: "100px",
      custom: (row) => row.subjectDic.英语,
      search: { sort: true },
    },
    物理: {
      label: "物理",
      width: "100px",
      custom: (row) => row.subjectDic.物理,
      search: { sort: true },
    },
    化学: {
      label: "化学",
      width: "100px",
      custom: (row) => row.subjectDic.化学,
      search: { sort: true },
    },
    生物: {
      label: "生物",
      width: "100px",
      custom: (row) => row.subjectDic.生物,
      search: { sort: true },
    },
    政治: {
      label: "政治",
      width: "100px",
      custom: (row) => row.subjectDic.政治,
      search: { sort: true },
    },
    历史: {
      label: "历史",
      width: "100px",
      custom: (row) => row.subjectDic.历史,
      search: { sort: true },
    },
    地理: {
      label: "地理",
      width: "100px",
      custom: (row) => row.subjectDic.地理 ?? "--",
      search: { sort: true },
    },
    assignScore: {
      label: "赋分总分",
      width: "180px",
      search: { sort: true },
    },
    assignRanking: {
      label: "赋分后的排名",
      width: "200px",
      search: { sort: true },
    },
  },
  data: [],
  pageData: {
    total: 0,
  },
  selectRows: [],
});

const showTable = ref(false);
onMounted(async () => {
  //初始化数据原
  showTable.value = true;
});
const exam = props.data[0];
</script>

<template>
  <div>
    <div class="p-[10px] text-[1.5rem]">
      <strong>学校：</strong>{{ exam.schoolName }}&nbsp;&nbsp; <strong>年级：</strong
      >{{ exam.gradeLevel + exam.gradeYear }}届&nbsp;&nbsp; <strong>班级：</strong
      >{{ exam.className }}&nbsp;&nbsp; <strong>考试名称：</strong
      >{{ exam.examName }}&nbsp;&nbsp;
      <!-- <strong>考试类型：</strong>{{exam.className}}&nbsp;&nbsp;
      <strong>试卷类型：</strong>{{exam.className}}&nbsp;&nbsp; -->
    </div>
    <ahTable v-if="showTable" ref="table" :tableConfig="tableData" />
  </div>
</template>
