import { memo } from 'react'; import type { FC } from 'react'; import { Badge } from 'antd'; import React from 'react'; import { useModel } from '../../utils/umiExport'; type Props = { badgeKey: string; value: number | string; replaceText?: string; isExternalText?: boolean; }; const RBadge: FC = (props) => { const { initialState } = useModel('@@initialState'); const dictionary = initialState?.dictionary; const item: any = dictionary[props.badgeKey]?.filter( (res: any) => res.value == props.value, )?.[0]; const badge = (colData: any) => { if (colData && colData.status && colData.status !== 'none') { if (colData.status !== 'gary') { return ; } else { console.log(colData); return ; } } else if (colData) { return colData.text; } return props.replaceText ? props.replaceText : props.value; }; return ( <> {badge(item)} {props?.isExternalText ? item.text : ''} ); }; export default memo(RBadge); RBadge.defaultProps = { replaceText: '', };