import { defHttp } from '/@/utils/http/axios'; import { useGlobSetting } from '/@/hooks/setting'; const globSetting = useGlobSetting(); import { downloadByUrl } from '/@/utils/file/download'; import { UploadFileParams } from '/#/axios'; enum Api { listDictModel = '/sys/dictItem/query/list', listDictModelBatch = '/sys/dictItem/query/batch/list', getConfigValue = '/system/sysConfig/getConfigValue', getSystemTime = '/system/sysConfig/getTime', getDownloadUrl = '/sys/storage/file/download/', getPreviewUrl = '/sys/storage/file/preview/', excelSheetDetail = '/excel/sheet/detail', tempDownload = '/archives/patientBasic/export', postFileRemoveByIds = '/sys/storage/file/removeByIds', } export function listDictModel(params?: object) { return defHttp.post({ url: Api.listDictModel, params: params }); } export function listDictModelBatch(params?: Array) { return defHttp.post({ url: Api.listDictModelBatch, params: params }); } export function getConfigValue(params?: object) { return defHttp.get({ url: Api.getConfigValue, params: params }); } export function downloadFile(filepath: string) { downloadByUrl({ url: globSetting.apiUrl + '/common/download?filepath=' + filepath, target: '_self', }); } export function uploadApi( params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void, ) { return defHttp.uploadFile( { url: globSetting.apiUrl + '/sys/storage/file/upload', onUploadProgress, }, params, ); } export function postFileRemoveByIds(params) { return defHttp.post({ url: Api.postFileRemoveByIds, params: params }); } export function getSystemTime() { return defHttp.get({ url: Api.getSystemTime }); } export function getDownloadUrl(id) { return defHttp.get({ url: Api.getDownloadUrl + id }); } export function getPreviewUrl(id) { return defHttp.get({ url: Api.getPreviewUrl + id }); } // 导入数据 export const excelSheetDetail = (id: string) => { return defHttp.get({ url: Api.excelSheetDetail + '/' + id }); }; // 下载模板 export const tempDownload = (params?: Array) => { return defHttp.post({ url: Api.tempDownload, params: params }); };