import * as React from 'react'; import { getApiUrl, taker, getTenantInfo, getToUserId,getQueryString } from '../../../../../helper'; import './index.scss'; import QueueAnim from 'rc-queue-anim'; import classsames from "classnames"; import SupLevel from './SupLevel'; import PeerLevel from './PeerLevel'; import SubLevel from './SubLevel'; // import { User } from './interface'; interface CardInnerProps { toogleCard: Function; currentUserId: number; canVS: boolean; addVSCallback: Function; showVS: Function; } class CardInner extends React.PureComponent { getUserTimer: any state = { isFetching: true, supLevelUsers: [], peerLevelUsers: [], subLevelUsers: [], talentVSUsers: [], currentUserId: this.props.currentUserId, drillDownUsers: [], //记录着可以查看组织架构的人员uiserid列表, RedirectToProfileUsers:[] //需要点击调个人主页的头像 } getData = async (uid: number, type: string = 'all') => { const tid = getTenantInfo()['Id']; const toUserId = getToUserId() const pageCode = getQueryString()['pageCode'] ? getQueryString()['pageCode'] : ''; const url = getApiUrl(`proxy/GetUPaaSCoreGateway/AccountService/GetUserOrgChart?tenantId=${tid}&staffId=${uid}&viewOwnerId=${toUserId}&originPageCode=${pageCode}`) const response = await taker(url); if (!response) return; const { OperationObject } = response; if (!OperationObject) return; const { HigherUsers = [], CurrentLevelUsers = [], SubUsers = [], TalentVSUsers = [], DrillDownUsers, RedirectToProfileUsers = [] } = OperationObject; if (type == 'all') { this.setState({ isFetching: false, supLevelUsers: this.getUser(HigherUsers), peerLevelUsers: this.getUser(CurrentLevelUsers), subLevelUsers: this.getUser(SubUsers), talentVSUsers: TalentVSUsers, currentUserId: uid, drillDownUsers: DrillDownUsers, RedirectToProfileUsers }) } else { this.setState({ subLevelUsers: this.getUser(SubUsers), currentUserId: uid, talentVSUsers: TalentVSUsers, drillDownUsers: DrillDownUsers, RedirectToProfileUsers }) } } getUser = (users: any) => { if (users) { return users.map((item: any) => { return { avatarColor: item.AvatarColor, avatarImg: item.PersonalPictureUrl ? item.PersonalPictureUrl.l : '', name: item.Name, userId: item.UserId, position: item.PositionName, count: item.SubordinateNum, department: item.DepartmentName } }) } else { return [] } } componentDidMount() { this.getData(this.props.currentUserId) } componentWillReceiveProps(nextProps: CardInnerProps) { const { currentUserId } = nextProps; if (this.props.currentUserId != currentUserId) { this.setState({ isFetching: true, currentUserId, }) this.getData(currentUserId) } } handleToogle = (toogle: string, userId: number) => { const { toogleCard } = this.props; toogleCard && toogleCard(toogle, userId) } render() { const { supLevelUsers, peerLevelUsers, subLevelUsers, isFetching, currentUserId, talentVSUsers, drillDownUsers,RedirectToProfileUsers } = this.state; const { canVS, addVSCallback, showVS } = this.props; const classStr = classsames('user-tree-card'); return (
) } } interface CardProps { currentUserId: number; show: boolean; toogleCard: Function; direction: boolean; canVS: boolean; addVSCallback: Function; showVS: Function; } const CardWrap = (props: any) => export default class Card extends React.PureComponent { render() { const { show, direction, currentUserId, toogleCard, canVS, addVSCallback, showVS } = this.props; return ( {show ? : null } ) } }