import { request } from "@/utils/request";
import { getFileMD5 } from "@/utils/crypto";
import { download, obj2formData } from "@/utils/tool";

//获取扫描批次科目列表
export const batchSubjectList = (params: {
  examId: any;
  startTime?: number;
  endTime?: number;
}) =>
  request({
    url: "/api/admin/batch/subject/list",
    params,
  });
//根据科目查询扫描批次机器列表
export const batchDeviceList = (params: {
  examId: any;
  subjectCode: string;
  startTime?: number;
  endTime?: number;
}) =>
  request({
    url: "/api/admin/batch/device/list",
    params,
  });

//根据机器查询批次列表
export const batchList = (params: {
  examId: any;
  subjectCode: string;
  device: string;
  startTime?: number;
  endTime?: number;
}) =>
  request({
    url: "/api/admin/batch/list",
    params,
  });
//根据批次查询考生列表
export const batchStudentList = (params: { batchId: any }) =>
  request({
    url: "/api/admin/batch/student/list",
    params,
  });

//查询考生答题卡扫描详情
export const getStuCardDetail = (params: {
  batchId: number | string;
  studentId: number | string | undefined;
}) =>
  request({
    url: "/api/admin/student/answer",
    params,
    loading: true,
  });

export const scanProcessData = (params: {
  examId: number | undefined;
  subjectCode: string;
}) =>
  request({
    url: "/api/admin/subject/scan/progress",
    params,
    loading: true,
  });

export const getWorkStatistics = (params: {
  examId: number | undefined;
  startTime: number | undefined;
  endTime: number | undefined;
}) =>
  request({
    url: "/api/admin/scanner/workload",
    params,
    loading: true,
  });
export const exportWorkStatistics = (params: {
  examId: number | undefined;
  startTime: number | undefined;
  endTime: number | undefined;
}) =>
  request({
    url: "/api/admin/scanner/workload/export",
    params,
    download: true,
  });

export const getSiteList = (params: { examId: number | undefined }) =>
  request({
    url: "/api/admin/exam-site/list",
    params,
  });

export const getCampusList = (params: { examId: number | undefined }) =>
  request({
    url: "/api/admin/campus/list",
    params,
  });
export const getScannedList = (
  params: {
    examId: number | undefined;
    campusCode?: string;
    subjectCode?: string;
    province?: string;
    examSite?: string;
    examRoom?: string;
    scanned?: boolean | null;
  } & PageBaseParams
) =>
  request({
    url: "/api/admin/exam-room/scanned/page",
    params,
  });

export const exportScanned = (params: {
  examId: any;
  campusCode?: string;
  subjectCode?: string;
  province?: string;
  examSite?: string;
  examRoom?: string;
  scanned?: boolean | null;
}) =>
  request({
    url: "/api/admin/exam-room/scanned/export",
    params,
    download: true,
  });

export const getStuPage = (params: {
  examId: any;
  campusCode?: string;
  subjectCode?: string;
  name?: string;
  examSite?: string;
  examRoom?: string;
  packageCode?: string;
}) =>
  request({
    url: "/api/admin/student/page",
    params,
  });
