import { DrawerProps, UploadProps } from 'antd'; import { IUseFetchOptionsType } from '../../hooks/useFetch/types'; export interface RequestProps extends Partial> { /** 请求地址 */ url: string; /** 请求头 */ headers?: Record; /** 请求方法 */ method?: UploadProps['method']; /** Post请求参数 */ data?: Record; /** Get请求参数 */ params?: Record; /** 超时时间 */ timeout?: number; } export type ImportDataProps = { /** 是否显示抽屉 */ visible: boolean; /** 抽屉关闭回调 */ onClose: () => void; /** 是否跳过文件内容合法性验证 */ skipVerify?: boolean; /** 模板下载文件名(需携带扩展名,如:xxxx.xlsx) */ templateName: string; /** * @description 手动获取 content-disposition 中的文件名 * @param contentDisposition 原始的 content-disposition 字段值 * @return 最终文件名 */ getRemoteTemplateName?: (contentDisposition: string) => string; /** 模板下载请求配置项 */ templateRequestProps: RequestProps; /** 文件填写验证请求配置项(选择文件后触发) */ verifyRequestProps: RequestProps; /** 文件导入请求配置项(点击开始导入按钮时触发) */ uploadRequestProps: RequestProps; /** 抽屉配置项 */ drawerProps?: Partial; /** 最大文件大小,默认10M */ maxFileSize?: number; /** 文件上传前验证 */ beforeUpload?: UploadProps['beforeUpload']; /** * @description 开始导入前的回调 * @param res 导入文件解析接口的返回数据 * @returns 返回 false 或 Promise 将阻止导入,返回 true/undefined 或 Promise 将继续导入 * 如果 Promise reject 也会阻止导入 */ beforeImport?: (res: any) => boolean | Promise; /** 是否禁用导入按钮 */ disabled?: boolean; }; export type ImportDataContentProps = Omit & { visible: boolean; maxFileSize?: number; onUploadStatusChange: (status: 'pending' | 'success' | 'failed' | null) => void; onUploadLoadingChange: (loading: boolean) => void; /** 文件上传前验证 */ beforeUpload?: UploadProps['beforeUpload']; }; export type ImportDataContentRef = { uploadFile: () => Promise; getAnalysisInterfaceData: () => any; clearAnalysisInterfaceData: () => void; }; export type ImportDataButtonProps = Omit;