import { request } from 'umi';
import type { TableListItem } from './data';

/** 获取考试列表 GET  /dsideal_yy/zygh/training/examination/getExaminationList */
export async function queryExaminationList(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: TableListItem[];
    /** 列表的内容总数 */
    total_row?: number;
    /** 页面的容量 */
    page_size?: number;
    success?: boolean;
  }>('/dsideal_yy/zygh/training/examination/getExaminationList', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}


/**
 * 获取主题列表
 * http://10.10.14.252:8080/workspace/myWorkspace.do?projectId=382#6426
 * @param params
 * @returns
 */
export async function querySubjectList(params: {
  page_size: number;
  //count: number;
}): Promise<{ data: { list: CardListItemDataType[] } }> {
  return request('/dsideal_yy/ypt/careerTraining/subject/listSubject', {
    params,
  });
}

/** 获取证书列表 GET  /dsideal_yy/zygh/training/examination/getExaminationList */
export async function queryCertificateList(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: TableListItem[];
    /** 列表的内容总数 */
    total_row?: number;
    /** 页面的容量 */
    page_size?: number;
    success?: boolean;
  }>('/dsideal_yy/zygh/training/examination/getExaminationList', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 新建/修改考试 POST /dsideal_yy/zygh/training/examination/updateExamination */
export async function updateExamination(data: Record<string, any>, options?: Record<string, any>) {
  return request<TableListItem>('/dsideal_yy/zygh/training/examination/updateExamination', {
    data,
    method: 'POST',
    requestType: "form",
    ...(options || {}),
  });
}

/** 删除考试 */
export async function removeExamination(data: { key: number[] }, options?: Record<string, any>) {
  console.log('data:::', data);
  return request<Record<string, any>>('/dsideal_yy/zygh/training/examination/delExamination', {
    data: { examination_id: data?.key[0], rules_id: options?.rules_id }, // 当前接口不支持批量操作
    method: 'POST',
    requestType: 'form',
  });
}

/** saveRegistration */
export async function saveRegistration(data: { key: number[] }, options?: Record<string, any>) {
  return request<Record<string, any>>('/dsideal_yy/ypt/careerTraining/course/delete', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

/** removeRegistration */
export async function removeRegistration(data: { key: number[] }, options?: Record<string, any>) {
  return request<Record<string, any>>('/dsideal_yy/ypt/careerTraining/course/delete', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

/** 查看考试（仅仅获取考试详情，不标记浏览量）GET /dsideal_yy/ypt/careerTraining/course/view */
export async function queryExaminationView(data: Record<string, any>, options?: Record<string, any>) {
  return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/view', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}








/** 获取考试规则列表 GET  /dsideal_yy/zygh/training/examination/getExaminationList */
export async function queryRulesList(
  params: {
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
    rules_type?: number,
    subject_id?: number,
  },
  options?: Record<string, any>,
) {
  return request<{
    data: TableListItem[];
    /** 列表的内容总数 */
    total_row?: number;
    /** 页面的容量 */
    page_size?: number;
    success?: boolean;
  }>('/dsideal_yy/zygh/training/rules/getRulesList', {
    method: 'GET',
    params: {
      ...params,

    },
    ...(options || {}),
  });
}


/** 获取考试规则列表 GET  /dsideal_yy/zygh/training/examination/getExaminationList */
export async function getExaminationPersonApplyList(
  params: {
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
    rules_type?: number,
    subject_id?: number,
  },
  options?: Record<string, any>,
) {
  return request<{
    data: TableListItem[];
    /** 列表的内容总数 */
    total_row?: number;
    /** 页面的容量 */
    page_size?: number;
    success?: boolean;
  }>('/dsideal_yy/zygh/training/person/getExaminationPersonApplyList', {
    method: 'GET',
    params: {
      ...params,

    },
    ...(options || {}),
  });
}



/**
 * 获取省市区
 * http://10.10.14.252:8080/workspace/myWorkspace.do?projectId=382#6426
 * @param params
 * @returns
 */
export async function getAsyncOrgTree(params: {
  page_size: number;
  //count: number;
}): Promise<{ data: { list: CardListItemDataType[] } }> {
  return request('/dsideal_yy/org/getAsyncOrgTree', {
    params,
  });
}


