import React, { useMemo, useRef } from 'react'; import Wrap from '../wrap/Wrap'; import Icon from 'src/components/Icon/index'; import { Select } from 'antd'; import { CaretDownOutlined } from '@ant-design/icons'; import '../g.scss'; const { Option } = Select; function LabelIcontUploadSelect(props: ILabelIcontUploadSelect) { const { title = 'label', titleIcon, change, selectValue='', selectList=[], imgUrl, wrapStyle = { padding: '6px 20px 6px 20px' } } = props; const isShow = useRef(null); const enter = (e: any) => { isShow.current.style.display = 'block'; }; const leave = (e: any) => { isShow.current.style.display = 'none'; }; const returnOption = (rest: ISelectList, index: number) => { if (typeof rest.value === 'number') { return ( {rest?.value} ); } else { return ( {rest?.value} ); } }; const Redio = useMemo(() => { return ( {title} {titleIcon ? ( { change?.(null, 'icon'); }} /> ) : ( <>> )} {imgUrl ? : <>>} { e.stopPropagation(); change?.(null, '上传'); }} > 上传 { e.stopPropagation(); change?.(null, '更改'); }} > 删除 change?.(value, 'select')} dropdownClassName='zl-large-screen-select' suffixIcon={ } > {Array.isArray(selectList) && selectList?.length > 0 && selectList?.map((item, index) => { return returnOption(item, index); })} ); }, [title, selectValue, titleIcon, imgUrl, selectList]); return Redio; } export default LabelIcontUploadSelect; export interface ILabelIcontUploadSelect { title?: any; change?: Function; size?: string; titleIcon?: string; imgUrl?: string; selectList: ISelectList[]; selectValue?: string | number; wrapStyle?: React.CSSProperties; } export interface ISelectList { key: string | number; value?: number | string; }