import { defHttp } from '/@/utils/http/axios';
import { UploadFileParams } from '#/axios';
import { setParams } from '/@/utils/index';
import { useGlobSetting } from '/@/hooks/setting';
const globSetting = useGlobSetting();

enum Api {
  pharmaceuticalsNumber = '/biz/drug/number',
  pharmaceuticalsList = '/biz/drug/query/page',
  pharmaceuticalsDel = '/biz/drug/status',
  pharmaceuticalsAdd = '/biz/drug/add',
  pharmaceuticalsEdit = '/biz/drug/edit',
  pharmaceuticalsById = '/biz/drug/detail',
  pharmaceuticalsExport = '/biz/supplies/drug/export',
  pharmaceuticalsImport = '/biz/supplies/drug/import',
}

export const getpharmaceuticalsList = (params?: object) => {
  return defHttp.post({ url: Api.pharmaceuticalsList, params: setParams(params) });
};

export const pharmaceuticalsDel = (id?: String) => {
  return defHttp.post({ url: Api.pharmaceuticalsDel + '/' + id });
};

export const getStatusNumber = () => {
  return defHttp.get({ url: Api.pharmaceuticalsNumber });
};

export const pharmaceuticalsAdd = (params?: object) => {
  return defHttp.post({ url: Api.pharmaceuticalsAdd, params: params });
};

export const pharmaceuticalsEdit = (params?: object) => {
  return defHttp.post({ url: Api.pharmaceuticalsEdit, params: params });
};

export const pharmaceuticalsById = (id: string) => {
  return defHttp.get({ url: Api.pharmaceuticalsById + '/' + id });
};

/**
 * @description: 批量导入,权限 - archives:patientBasic:import
 * @method: POST
 */
export function pharmaceuticalsImportBatch(
  params: UploadFileParams,
  onUploadProgress: (progressEvent: any) => void,
) {
  return defHttp.uploadFile(
    {
      url: globSetting.apiUrl + Api.pharmaceuticalsImport,
      onUploadProgress,
    },
    params,
  );
}

/**
 * @description: 导出,权限 - archives:patientBasic:export
 * @method: POST
 */
export const pharmaceuticalsExport = (params: Array<string | number>) => {
  return defHttp.post({ url: Api.pharmaceuticalsExport, params: params });
};
