
import { http } from '@/utils/http/axios';
import type { QueryPageRequest, QueryPageResponse } from '@/types/basic-query';
/**
 * 查询参数
 */
export interface ProductionSafetyFileQuery {
  keyword?: string; // 文件名称/编号（模糊查询）
  status?: number; // 状态：1-启用，0-禁用
  classifyName?: string; // 分类名称
  startDate?: string; // 上传日期范围-开始日期
  endDate?: string; // 上传日期范围-结束日期
}

// 课程参数
export interface QueryType {
  petpiId?:string | number;
  courseName?: string | number;
  dateStart?: string;
  dateEnd?:string;
}
// 新增、编辑表单数据类型
export interface FormDataType {
  id?: string; // 编辑时使用
  trainingPlanName: string;
  categoryName: string;
  trainingContent: string;
  trainingObject: string;
  trainingCount: string;
  trainingTime: string;
  trainingMethod: string;
  assessmentMethod: string;
  responsibleDeptIds: string[];
  studyHours: number | string;
}
export interface FormSubmitDataType {
  id?: number|string; // 编辑时使用
  courseType: number|string;
  petpiId?: number | string;
  courseName: string;
  trainingMethod: string;
  trainingTeacher: string;
  planNumOfParticipants: number | string;
  groupOfParticipants: any;
  startDate: string;
  endDate: string;
  courseIntroduction: string;
  courseContent: any;
  isSign: number | string;
  courseImg?: any;
}

export interface TableParamsType {
  petpiId: number | string;
  courseName?: string | undefined;
  dateStart?: string | undefined;
  dateEnd?: string | undefined;
}
// -------------部门--------------
/**
 * 获取教育培训计划管理（部门）-列表
 */
export function getEducationAndTrainingProgramList(params: QueryPageRequest<ProductionSafetyFileQuery>) {
  return http.request({
    url: '/educationTrainingPlanIssuance/queryEducationTrainingPlanIssuance',
    method: 'post',
    params,
  });
}

/**
 * 安全教育培训 教育培训计划管理（部门）-添加培训课程
 */
export function saveTrainingInformation(data: FormSubmitDataType) {
  return http.request({
    url: '/educationTrainingPlanIssuance/saveEducationTrainingPlanCourse',
    method: 'post',
    data: data,
  });
}

/**
 * 安全教育培训 教育培训计划管理（部门）-编辑培训课程
 */
export function updateTrainingInformation(data: FormSubmitDataType) {
  return http.request({
    url: '/educationTrainingPlanIssuance/updateEducationTrainingPlanCourse',
    method: 'put',
    data: data,
  });
}

/**
 * 安全教育培训 教育培训计划管理（部门）-培训计划中的课程列表
 */
export function queryTrainingTableData(data: QueryPageRequest<TableParamsType>) {
  return http.request({
    url: '/educationTrainingPlanIssuance/queryEducationTrainingPlanCourse',
    method: 'post',
    data: data,
  });
}

/**
 * 安全教育培训 教育培训计划管理（部门）-更新培训课程小结
 */
export function updateEducationTrainingPlanCourseSummary(data: any) {
  return http.request({
    url: '/educationTrainingPlanIssuance/updateEducationTrainingPlanIssueSummary',
    method: 'put',
    data,
  });
}

/**
 * 安全教育培训 教育培训计划管理（部门）-培训计划中的课程-删除
 */
export function deleteTrainingInformation(id: string | number) {
  return http.request({
    url: `/educationTrainingPlanIssuance/deleteEducationTrainingPlanCourse?id=${id}`,
    method: 'delete',
  });
}
/**
 * 安全教育培训 教育培训计划管理（部门）-培训计划中的课程详细
 */
export function queryEducationTrainingPlanCourseDetail(id: string | number) {
  return http.request({
    url: `/educationTrainingPlanIssuance/queryEducationTrainingPlanCourseDetail?id=${id}`,
    method: 'get',
  });
}


/**
 * @description: 导出课程
 * @param {QueryType} params
 * @return {*}
 */
export function exportEducationTrainingPlanCourseData(params: QueryType){
  return http.request(
    {
        url: '/educationTrainingPlanIssuance/exportEducationTrainingPlanCourse',
        method: 'post',
        responseType: 'blob',
        params,
        },
        { isTransformResponse: false },
    );
}


/**
 * 教育培训计划管理（部门）-详情
 */
export function queryEducationAndTrainingProgramDetail(id: string | number) {
  return http.request({
    url: `/educationTrainingPlanIssuance/queryEducationTrainingPlanIssuanceDetail?id=${id}`,
    method: 'get',
  });
}

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