import * as React from 'react'; import './index.scss'; import Header from './Header'; import QuickOperation from './QuickOperation'; import PropTypes from 'prop-types'; import { Scrollbars } from 'react-custom-scrollbars'; import Notification from '&/components/common/Notification'; import RightFixed from './RightFixed'; import HonourIframe from './HonourIframe'; import { taker, getApiUrl } from '&/helper'; // import Connect from '../ConnectColumns' interface Prop { connectLayoutItem: Function, data: any; channelSetting?: any; hisPeers?: boolean; hisSubordinate?: boolean; hisSimilar?: boolean; hisVistors?: boolean; honorPageOperation?: any honorWall?: any tagShow?: boolean } interface personItem { Avatar: Avatar, EnrolledYears: string, Name: string, Sex: string, UserId: number } interface Avatar { Big: string, Color: string, HasAvatar: boolean, Large: string, Medium: string, Normal: string, Original: string, Small: string } const HeaderBg = () => (
) const userAgent = window.navigator.userAgent.toLowerCase(), ios = /iphone|ipod|ipad/.test(userAgent); // @Connect export default (columns:number) => class Honour extends React.Component{ static childContextTypes = { getSelectedUsers: PropTypes.func, updateSelectedUsers: PropTypes.func, getNewAddUserPosition: PropTypes.func, toEmptyNewAddUserPosition: PropTypes.func, showPromptPop: PropTypes.func } static defaultTemplateProps = ['__background__'] getChildContext() { return { getSelectedUsers: this.getSelectedUsers, updateSelectedUsers: this.updateSelectedUsers, getNewAddUserPosition: this.getNewAddUserPosition, toEmptyNewAddUserPosition: this.toEmptyNewAddUserPosition, showPromptPop: this.showPromptPop }; } static getEditProps = function () { return [ { pType: 'Toggle', name: 'ta的同级', key: 'hisPeers', selected: false }, { pType: 'Toggle', name: 'ta的下属', key: 'hisSubordinate', selected: false }, { pType: 'Toggle', name: '与ta相似的人', key: 'hisSimilar', selected: false }, { pType: 'Toggle', name: '最近访客', key: 'hisVistors', selected: false }, { pType: 'Toggle', name: '显示标签', key: 'tagShow', selected: true }, { pType: 'HonorPageOperation', name: '页面操作', key: 'honorPageOperation' }, { pType: 'HonorWall', name: '荣誉墙', key: 'honorWall' }, { pType: 'ChannelSetting', name: '页签设置', key: 'channelSetting' } ] } constructor(p: Prop) { super(p) const { channelSetting = [], hisPeers = false, hisSubordinate = false, hisSimilar = false, hisVistors = false, honorWall, tagShow } = p.data; this.state = { users: [], currentConten: channelSetting.length ? channelSetting[0].code : '', channelSetting, hisPeers, hisSubordinate, hisSimilar, hisVistors, honorWall, tagShow } } getSelectedUsers = () => { return this.state.users } newAddUser = {} updateSelectedUsers = async (userid: number, node?: any) => { const { users } = this.state; if (users.length >= 5) return; const origin = users.filter((d: personItem, k: number) => d.UserId == userid); if (origin.length) { this.showPromptPop('该用户已在对比列表啦~') return new Error('添加失败') } const userIds: any = []; if (node) { const { left, top } = node.getBoundingClientRect(); this.newAddUser = { userid, left, top } } users.forEach((item: any, i: number) => { userIds.push(item.UserId) }) userIds.push(userid); const url = `${getApiUrl('proxy/PostUPaaSCoreGateway/TalentVS/UpdateVsUsers')}`; const body = { "userIds": userIds //要对比的用户ID } const response = await taker(url, 'POST', body); if (response.OperationResult) { const newUsers = response.OperationObject || []; this.setState({ users: newUsers }) return newUsers } else { return new Error('添加失败') } } getNewAddUserPosition = () => { return this.newAddUser; } toEmptyNewAddUserPosition = () => { this.newAddUser = {} } componentWillMount() { } componentWillReceiveProps(nextProps: Prop) { const { data } = nextProps; const { channelSetting, hisPeers, hisSubordinate, hisSimilar, hisVistors, honorWall, tagShow } = data; this.setState({ channelSetting, hisPeers, hisSubordinate, hisSimilar, hisVistors, honorWall, tagShow }) } // 获取添加vs的人员 async componentDidMount() { const url = `${getApiUrl('proxy/GetUPaaSCoreGateway/TalentVS/GetVsUsers')}`; const response = await taker(url); const users = response && response.OperationObject ? response.OperationObject : []; this.setState({ users }) } componentWillUnmount() { } state: any // 添加VS人员 addVs = async (id: number) => { const { users } = this.state; if (users.length >= 5) return; const origin = users.filter((d: personItem, k: number) => d.UserId == id); if (origin.length) return; const userIds: any = []; users.forEach((item: any, i: number) => { userIds.push(item.UserId) }) userIds.push(id); this.updateUsers(userIds); } // 删除VS人员 deleteOneVs = async (id: number) => { const newUsers = this.state.users.filter((d: personItem) => d.UserId != id) const userIds: any = []; newUsers.forEach((item: any, i: number) => { userIds.push(item.UserId) }) this.updateUsers(userIds); } // 更新对比人信息 updateUsers = async (ids: number[]) => { const url = `${getApiUrl('proxy/PostUPaaSCoreGateway/TalentVS/UpdateVsUsers')}`; const body = { "userIds": ids //要对比的用户ID } const response = await taker(url, 'POST', body); if (response.OperationResult) { const newUsers = response.OperationObject || []; this.setState({ users: newUsers }) } } changeContent = (code: any) => { this.setState({ currentConten: code }) } connectLayoutItem = () => { const { currentConten } = this.state; const indexIframe = currentConten.indexOf('__ISIFRAME'); const { connectLayoutItem } = this.props; if (indexIframe < 0) { return connectLayoutItem(`grid${currentConten}`, columns)(
) } else { return
} } setDefatuleChannel = (defatuleChannel: string) => { this.setState({ currentConten: defatuleChannel }) } topPosition = 0; showPromptPop = (msg = "最多可添加5人!") => { Notification.warning(msg); } handleScroll = (scrollData: any) => { } render() { const { honorPageOperation } = this.props.data; const { vs = true } = honorPageOperation || {}; const { channelSetting, honorWall, tagShow, users, hisPeers, hisSubordinate, hisSimilar, hisVistors } = this.state; const { currentConten } = this.state; console.log('dddd', this.state) return (
{ ( hisPeers || hisSubordinate || hisSimilar || hisVistors ) ? : null }
} renderTrackVertical={() =>
} >
{/* */}
{ currentConten ? this.connectLayoutItem() : null }
{honorPageOperation && }
) } }