import React, { useEffect, useRef, useState } from 'react'; import { ApolloUploadProps } from '../editInterface'; import { antiAssign } from '@/apollo-table/utils/utils'; import CellContainer from '../container'; import s from './index.less'; import Upload from '../../extra/upload'; import IconFont from '@/apollo-table/component/base/extra/iconFont'; import { Modal, Tooltip } from 'antd'; const ApolloUpload = (props) => { const { isMultiple, onEmitChange } = props; const selfProps = antiAssign(props, ['onChange', 'value']); if (isMultiple) { selfProps.multiple = true; } const [value, setValue] = useState(props.value || []); const changeValue = (value) => { console.log(value); setValue(value); }; const [visible, setVisible] = useState(false); const refHelper = useRef(visible); const toggleUploadDialog = (flag) => { refHelper.current = flag; setVisible(flag); }; useEffect(() => { document.addEventListener('click', onBlur, false); return () => { document.removeEventListener('click', onBlur, false); }; }, []); const onBlur = () => { if (refHelper.current) { return; } if (typeof onEmitChange === 'function') { onEmitChange(props.value); } }; const onOk = () => { if (typeof onEmitChange === 'function') { onEmitChange(value); } toggleUploadDialog(false); }; const onCancel = () => { if (typeof onEmitChange === 'function') { onEmitChange(props.value); } toggleUploadDialog(false); }; const onClickContainer = (e) => { e.stopPropagation(); //阻止事件冒泡 e.nativeEvent.stopImmediatePropagation(); }; return (
{value && value.map((item, i) => { return (
); })}
); }; export default ApolloUpload;