import * as React from 'react'; import { getQueryString, getUserInfo, getApiUrl, taker, getBSGlobal } from '&/helper' import CommonSudoku from '&/components/common/commonSudoku'; import Header from '&/components/common/componentHeader'; import ScrollWrap from '&/components/common/scrollWrap'; import './index.scss'; interface Props{ data:any } interface State{ gridData:any, fetching:boolean } const data = { userInfo:getBSGlobal('loginUserInfo'),//用户信息 cols:3,//一共cols列 rows:3,//一共rows行 position:[ ], dimensions:[],//维度:横向,纵向 } export default class Sudoku extends React.Component{ static displayTitle = '人才九宫格' static getEditProps() { return [ { pType: 'Text', name: '标题文字', key: 'title', defaultValue: '人才九宫格' },{ pType: 'NineGridSetting', name: '对比维度设置', key: 'dimensions' }] } state = { gridData: data, fetching: true } id:string refs:any wrapWidth:number =0 wrapHeight:number =0 componentDidUpdate(){ // get data info with props.userId and dementions.Id const user = getQueryString().to_user_id || getUserInfo().Id const {data} = this.props; const id = data.dimensions && data.dimensions.dimentions ? data.dimensions.dimentions.id :'000'; if(id != this.id){ this.id = id; const url = getApiUrl(`proxy/GetUPaaSCoreGateway?metaname=Succession&funname=GetUserSuccessionData&userId=${user}&templateId=${id}`); taker(url).then((res:any)=>{ this.setState({gridData:res,fetching:false}) }) } const {gridData} = this.state; this.wrapWidth = this.refs.wrap.clientWidth; this.wrapHeight = this.refs.wrap.clientHeight; if(this.wrapWidth < gridData.cols * 67){ const scrollCon = this.refs.wrap.getElementsByClassName('scrollbar__content')[0]; if(scrollCon){ scrollCon.style.display='inline-block' } } } componentWillMount(){ // get data info with props.userId and dementions.Id const user = getQueryString().to_user_id || getUserInfo().Id const {data} = this.props; const id = data.dimensions && data.dimensions.dimentions ? data.dimensions.dimentions.id :'000'; const url = getApiUrl(`proxy/GetUPaaSCoreGateway?metaname=Succession&funname=GetUserSuccessionData&userId=${user}&templateId=${id}`); taker(url).then((res:any)=>{ let tempData = res; this.setState({gridData:tempData,fetching:false}) }) } render(){ const {gridData,fetching} = this.state; if(!gridData) return null; const user = getQueryString().to_user_id || getUserInfo().Id const {data} = this.props; return
{ this.wrapWidth < gridData.cols * 67 || this.wrapHeight < 100 + gridData.rows * 67 ?
{!fetching && }
:
{!fetching && }
}
} }