import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons'; import { Avatar, Comment, Divider, Popconfirm, Space, Timeline } from 'antd'; import Link from 'antd/lib/typography/Link'; import type { CSSProperties } from 'react'; import { useIntl, useModel, useRequest } from 'umi'; import MentionText from '../MentionText'; import { getFeishuUserDetail } from '../server'; import TimeFromNow from '../TimeFromNow'; import UserLink from '../UserInfo/link'; import lessStyle from './index.less'; const styles: Record<'divider' | 'span' | 'userWrap' | 'avatar' | 'title', CSSProperties> = { divider: { margin: 0, backgroundColor: 'rgba(0,0,0,0.1)', }, span: { whiteSpace: 'nowrap', }, userWrap: { display: 'contents', }, avatar: { color: '#f56a00', backgroundColor: '#fde3cf', }, title: { whiteSpace: 'nowrap', color: 'rgba(0,0,0,0.3)', }, }; export interface ReasonDataType { user: any; content: string; isDeleted: boolean; deletedAt: number; createdAt: number; id: number; } export interface ReasonItemProps extends ReasonDataType { initiator?: any; index: number; length: number; fold?: boolean; canFold?: boolean; restLength?: number; readOnly?: boolean; onDelete: (id: number) => void; onFold?: () => void; onExpand?: () => void; } const ReasonItem = (props: ReasonItemProps) => { const { user, content, isDeleted, deletedAt, createdAt, id: msgId, initiator, index, length, fold, canFold, restLength, readOnly, onDelete, onFold, onExpand, } = props; const { initialState } = useModel('@@initialState'); const { currentUser } = initialState || {}; const { formatMessage } = useIntl(); const { data: userData } = useRequest( () => { return getFeishuUserDetail({ userId: user.id }); }, { ready: Boolean(user.id), cacheKey: `getFeishuUserDetail-${user.id}`, refreshDeps: [user.id], cacheTime: 3 * 60 * 1000, staleTime: 2 * 60 * 1000, }, ); const discard = isDeleted ? formatMessage({ id: 'component.AuditList.reason.deleted' }) : undefined; const lastItem = index === length - 1; return ( {String(user.nameZh || user.account) .slice(0, 1) .toLocaleUpperCase()} } > } content={} datetime={ }> {Boolean(index === 0 && initiator?.id) && ( (   {formatMessage({ id: 'base.proxy.apply' })}) )} {!isDeleted && currentUser?.id === user?.id && msgId !== 0 && !readOnly && ( onDelete(msgId)} > {formatMessage({ id: 'base.common.del' })} )} {lastItem && canFold && ( {formatMessage({ id: `base.common.${fold ? 'expand.more' : 'collapse'}` })} {fold && `(${restLength ?? 0})`} {fold ? : } )} } /> ); }; export default ReasonItem;