/* * @Author: code4eat awesomedema@gmail.com * @Date: 2023-02-15 16:48:56 * @LastEditors: code4eat awesomedema@gmail.com * @LastEditTime: 2023-09-26 10:49:17 * @FilePath: /BudgetManaSystem/src/components/BMSUpload/index.tsx * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import React, { useState } from 'react'; import { InboxOutlined } from '@ant-design/icons'; import { Alert, UploadFile, UploadProps } from 'antd'; import { Upload } from 'antd'; import './style.less'; const { Dragger } = Upload; type KCIMUploadPropsType = { onChange?: () => void; ifShowTip?: boolean; //是否展示黄底提示 ifShowTemplateDownload?: boolean; //是否展示模板下载 downloadTemplateFile?: () => void; //模板下载回调 } & UploadProps; const KCIMUpload = (props: KCIMUploadPropsType) => { const [fileList, setFileList] = useState([]); const { onChange, downloadTemplateFile, ifShowTip = true, ifShowTemplateDownload = true, } = props; const config: UploadProps = { action: () => Promise.resolve(''), name: 'file', multiple: false, beforeUpload: (file) => { setFileList([...fileList, file]); return false; }, //onChange:onChange?onChange:()=>{}, onChange: (fileInfo) => { onChange && onChange(fileInfo); }, onDrop(e) { console.log('Dropped files', e.dataTransfer.files); }, }; const download = () => { downloadTemplateFile && downloadTemplateFile(); }; return (
{ifShowTemplateDownload && (
文件下载 download()}>模板下载
)} {ifShowTip && ( )}

点击或将文件拖拽到这里上传

); }; export default KCIMUpload;