import React from 'react'; import Wrap from '../wrap/Wrap'; import { Upload } from 'antd'; import '../g.scss'; import Icon from 'src/components/Icon/index'; const { Dragger } = Upload; const LabelUpload = (props: IProps) => { let timer = null; const { value, title = '', change, wrapStyle = { padding: '6px 20px 6px 20px' }, icon } = props; const uploadProps = { maxCount: 1, // accept: '.json', name: 'file', listType: 'text', showUploadList: false, onChange(info) { change?.(info, 'changeUpload'); }, beforeUpload(info, fileList) { //防抖 clearTimeout(timer); timer = setTimeout(() => { change?.({ file: info, fileList: fileList }, 'beforeUpload'); }, 300); return false; }, onDrop(e) { e.stopPropagation(); } }; return (
{ value&&<>
{value}
{ change?.(name, 'uploadDel'); }} > 删除 }
{icon ? : <>} {title}
); }; export default LabelUpload; export interface IProps { title: string; change: Function; wrapStyle?: React.CSSProperties; value: string; icon?: string; }