import React from 'react'; import { UploadFile } from 'antd/es/upload/interface'; export type UploadType = 'drag' | 'button' | 'image'; export interface UploadFileRes { url: string; [key: string]: any; } export interface ExampleModalProps { width?: string | number; wrapClassName?: string; [key: string]: any; } export interface fieldNamesProps { uid?: number; name?: string; url?: string; status?: 'done' | 'uploading' | 'error'; } export interface ProUploadProps { /** * @description 拖拽框顶部的内容 * @default - */ headerRender?: React.ReactNode | (() => React.ReactNode); /** * @description 拖拽框底部内容 * @default - */ footerRender?: React.ReactNode | (() => React.ReactNode); /** * @description 是否显示示例弹窗 * @default false */ showExampleContent?: boolean; /** * @description 示例弹窗的内容 * @default - */ exampleContent?: React.ReactNode; /** * @description 示例弹窗的属性配置继承与antd 的Modal对话框 * @default - */ exampleModalProps?: ExampleModalProps; /** * @description 接受上传的文件类型, '.png,.jpeg,.jpg,.xlsx,.xls,.json,.doc,.docx' 详见 input accept Attribute * @default - */ accept?: string; /** * @description 控制文件的上传大小,单位MB * @default 10 */ size?: number; /** * @description 上传请求的地址 * @default - */ action?: string; /** * @description 组件的ui类型 drag 拖拽 button 上传按钮 image 类型 * @default drag */ uploadType: UploadType; /** * @description 上传格式提示文案 * @default - */ extraTipText?: string | (() => React.ReactNode); /** * @description 组件类型为button时可用, 参考 [antd button的api](https://ant-design.gitee.io/components/button-cn#api) * @default - */ buttonProps?: Object; /** * @description 组件文案 仅按钮类型的可用。 * @default - */ buttonText?: string; /** * @description 上传所需额外参数或返回上传额外参数的方法 * @default - */ dataParams?: Object; /** * @description 用来设置控件的默认已经上传的文件列表 * @default - */ defaultValue?: UploadFile[]; /** * @description 用来设置控件的已经上传的文件列表 * @default - */ value?: UploadFile[]; /** * @description 是否禁用 * @default false */ disabled?: boolean; /** * @description 设置上传的请求头部,IE10 以上有效 * @default - */ headers?: { [key: string]: any; }; /** * @description 限制上传数量。当为 1 时,始终用最新上传的文件代替当前文件 * @default 1 */ maxCount?: number; /** * @description 上传请求的 http method * @default "post" */ method?: 'post' | 'POST' | 'PUT' | 'PATCH' | 'put' | 'patch'; /** * @description 发到后台的文件参数名 * @default - */ name?: string; /** * @description 查看示例title * @default "查看示例" */ exampleTitle?: string | React.ReactNode; /** * @description 上传文件之前的钩子,参数为上传的文件,若返回 false 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传( resolve 传入 File 或 Blob 对象则上传 resolve 传入对象);也可以返回 Upload.LIST_IGNORE,此时列表中将不展示此文件。 注意:IE9 不支持该方法 * @default - */ beforeUpload?: (file: any, fileList: any) => boolean | Promise; /** * @description 上传文件改变时的回调,详见 onChange * @default - */ onChange?: (value: Array) => void; /** * @description 点击下载文件时的回调,如果没有指定,则默认跳转到文件 url 对应的标签页 * @default - */ onDownload?: (file: UploadFile) => void; /** * @description 点击文件链接或预览图标时的回调 * @default - */ onPreview?: (file: UploadFile) => any; /** * @description 点击移除文件时的回调,返回值为 false 时不移除。支持返回一个 Promise 对象,Promise 对象 resolve(false) 或 reject 时不移除 * @default - */ onRemove?: (file: UploadFile) => boolean | Promise; /** * @description 样式类名 * @default - */ className?: string; /** * @description 上传接口处理方法 返回一个数组 UploadFile【】 * @default - */ transformResponse?: (res: any) => UploadFileRes; /** * @description 可以调用组件的内部方法,例如:uploadStart方式 * @default - */ ref?: any; /** * @description 按钮类型的右侧辅助信息 * @default - */ afterRender?: React.ReactNode; /** * @description 是否展示文件列表 * @default true */ showUploadList?: boolean; /** * @description 文件对象的字段映射 * @default true */ fieldNames?: fieldNamesProps; } export interface DraggableUploadListItemProps { file: UploadFile; children: React.ReactNode; }