import React, { useMemo, useState } from 'react'; import Wrap from '../wrap/Wrap'; import Icon from '../../Icon/index'; import { Radio, Upload } from 'antd'; import delIcon from './删除.svg'; import '../g.scss'; let timer = null; function LabelRadioGroup(props: ILabelRadioGroup) { const { title, selectList = [], change, value, wrapStyle = { padding: '6px 20px 6px 20px' }, titleStyle = { width: '72px' }, isShowContent, defaultImgList, imgListActive, precisionCustom, nameType } = props; const [delIconShow, setDelIconShow] = useState(false); const Redio = useMemo(() => { return ( <> {title ? {title} : <>>} change?.('changeControls', e.target.value)} value={value} /> {isShowContent ? ( {value === 'default' && ( {defaultImgList?.length > 0 && defaultImgList?.map((item, index) => { return ( { change?.('selectIcon', item?.key); }} > ); })} )} {value === 'custom' && nameType === 'precision' && ( { //防抖 clearTimeout(timer); timer = setTimeout(() => { change?.('customUpload', { file: info, fileList: fileList }); }, 300); return false; }} > { setDelIconShow(true); }} onMouseOut={() => { setDelIconShow(false); }} > {precisionCustom?.url !== '' ? ( ) : ( <>> )} { e.stopPropagation(); change('customDel', precisionCustom?.key); }} /> {precisionCustom?.url === '' ? ( ) : ( <>> )} )} ) : ( <>> )} > ); }, [ title, value, defaultImgList, imgListActive, delIconShow, precisionCustom, nameType ]); return Redio; } export default LabelRadioGroup; export interface ILabelRadioGroup { title: string; selectList: ISelectList[]; wrapStyle?: React.CSSProperties; titleStyle?: React.CSSProperties; change?: Function; value?: string; isShowContent: boolean; defaultImgList?: IDefaultImgList[]; imgListActive?: string; precisionCustom?: IPrecisionCustom; nameType?: string; } export interface ISelectList { key: number | string; name: string | number; type: string; names?: string; } export interface IDefaultImgList { key: string; active?: boolean; url: string; } export interface IPrecisionCustom { key: string; url: string; }