
import { http } from '@/utils/http/axios';
import type { QueryPageRequest, QueryPageResponse } from '@/types/basic-query';

export interface EmployeeTableType {
  id: number;
  serialNum: number;
  staffNo: number;
  staffName: string;
  staffBirthday: Date;
  staffIdCard: string;
  staffAddress: string;
  staffImg?: string;
  deptName: string;
  dateOfJoining: Date;
  highestDegree: string;
  staffJob: string;
  jobSeniority: string;
  technicalLvl: string;
  professionalTitle: string;
  statusName: string;
  createdUserName: string;
  createdAt: Date;
  updatedAt: Date;
}

interface  QueryParamType {
    numOrName?: string;
    status?: number | string;
    dateOfJoiningStart?: string;
    dateOfJoiningEnd?: string;
  };
// 分页查询参数接口
export interface EducationStaffTrainingCardQueryParam {
  pageNumber: number;
  pageSize: number;
  queryParam?: QueryParamType
}

// 员工培训记录卡项接口
export interface EducationStaffTrainingCardItem {
  id: number;
  logType: number;
  pestcId: number;
  serialNum: number;
  logDate: Date;
  educationContentId: number;
  educationContent: string;
  scoreMust: number;
  creditHour: number;
  score: number;
  operationCertificateNum: string;
  trainingCompany: string;
  educationSign: string;
  createdUserName: string;
  createdAt: string;
  updatedAt: string;
}

/**
 * 分页查询员工培训记录卡列表
 * @param data 查询参数
 */
export function queryEducationStaffTrainingCardPage(data: EducationStaffTrainingCardQueryParam) {
  return http.request<QueryPageResponse<EducationStaffTrainingCardItem>>({
    url: `/educationStaffTrainingCard/queryEducationStaffTrainingCard`,
    method: 'post',
    data,
  });
}

/**
 * 删除员工培训记录卡
 * @param id 要删除的记录卡ID
 */
export function deleteEducationStaffTrainingCard(id: number) {
  return http.request<void>({
    url: `/educationStaffTrainingCard/deleteEducationStaffTrainingCard?id=${id}`,
    method: 'delete',
  });
}

/**
 * @description: 安全教育培训 员工培训记录卡-记录卡详情
 * @return {*}
 */
export function getEducationStaffTrainingCardDetail(id: number) {
  return http.request<EducationStaffTrainingCardItem>({
    url: `/educationStaffTrainingCard/queryEducationStaffTrainingCardDetail?id=${id}`,
    method: 'get',
  });
}

/**
 * @description: 导出
 * @param {QueryParamType} params
 * @return {*}
 */
export function exportTableData(params: QueryParamType){
  return http.request(
    {
        url: '/educationStaffTrainingCard/exportEducationStaffTrainingCard',
        method: 'post',
        responseType: 'blob',
        params,
        },
        { isTransformResponse: false },
    );
}

// ______查看详情数据_____________

/**
 * @description: 安全教育培训 员工培训记录卡-员工培训记录分页查询
 * @return {*}
 */
export function getEmployeeDetailTableList(data: any) {
  return http.request<QueryPageResponse<EducationStaffTrainingCardItem>>({
    url: `/educationStaffTrainingCard/queryEducationStaffTrainingCardLog`,
    method: 'post',
    data,
  });
}

/**
 * @description: 安全教育培训 员工培训记录卡-编辑员工培训记录分数
 * @return {*}
 */
export function updateEducationStaffTrainingCardScore(data: any) {
  return http.request<void>({
    url: `/educationStaffTrainingCard/updateEducationStaffTrainingCardLogScore`,
    method: 'put',
    data,
  });
}

/**
 * @description: 安全教育培训 员工培训记录卡-删除员工培训记录
 * @return {*}
 */
export function delateEducationStaffTrainingCardScore(id: number) {
  return http.request<void>({
    url: `/educationStaffTrainingCard/deleteEducationStaffTrainingCardLog?id=${id}`,
    method: 'delete',
  });
}
