import { defHttp } from '/@/utils/http/axios';
import { ReportModel, ReportQueryParam } from './model/reportModel';

enum ReportManagerApi {
  GET_REPORT_API = '/report_form/config',
  POST_REPORT_API = '/report_form/config',
  DELETE_REPORT_API = '/report_form/config',
  PUT_REPORT_API = '/report_form/config',
  PUTID_REPORT_API = '/report_form',
  EDIT_DETAIL_REPORT_API = '/report_form',
}

//分页
export const reportPage = (params: ReportQueryParam) => {
  return defHttp.get<ReportQueryParam>({
    url: ReportManagerApi.GET_REPORT_API,
    params,
  });
};

//删除
export const deleteReportManage = (ids: string[]) => {
  return defHttp.delete({
    url: ReportManagerApi.DELETE_REPORT_API,
    data: {
      ids: ids,
    },
  });
};

// 创建
export const createOrEditReportManage = (data) => {
  return defHttp.post<ReportModel>({
    url: ReportManagerApi.POST_REPORT_API,
    data,
  });
};

// 编辑
export const putReportConfigManage = (data) => {
  return defHttp.put<ReportModel>({
    url: ReportManagerApi.PUT_REPORT_API,
    data,
  });
};

// 修改状态 id status
export const putReportByidAndStatusManage = (id, status) => {
  return defHttp.put<ReportModel>({
    url: ReportManagerApi.PUTID_REPORT_API + '/config/' + id + '/' + status,
  });
};

//编辑详情
export const reportEditDetailPage = (params) => {
  return defHttp.get<ReportQueryParam>({
    url: ReportManagerApi.EDIT_DETAIL_REPORT_API + '/config/' + params,
  });
};
