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 {
  suppliesNumber = '/biz/consumable/number',
  suppliesList = '/biz/consumable/query/page',

  suppliesDel = '/biz/consumable/status',
  suppliesAdd = '/biz/consumable/add',
  suppliesEdit = '/biz/consumable/edit',
  suppliesById = '/biz/consumable/detail',
  suppliesExport = '/biz/supplies/consumable/export',
  suppliesImport = '/biz/supplies/consumable/import',
}

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

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

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

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

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

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

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

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