import * as React from 'react'; import styled from 'styled-components' import { taker,getApiUrl2, getToUserId } from '&/components/helper' // import Card from './components/Card' import Map from './Map' import { WorkInfo } from './types'; // import Select from '&/components/common/select'; import Empty from './Empty'; import PropTypes from 'prop-types' import QuickOperation from '&/components/profileWrapper/Honour/QuickOperation' import MapBar from '&/components/target-maps-bar/index' import PushScreen from './pushScreen' interface OkrMapProps { containerId: string, widget:any talent:any } interface OkrMapState { okrList:WorkInfo[] currentRoot?: WorkInfo year: string status: number cycle: string user: string selectOkr?:WorkInfo } const PageContainer = styled.div` height: 100%; display: flex; .honour-quick-operations { bottom: 50px; } .honour-quick-operations .quick-operation.hover .quick-operation-title{ width: 180px; } ` const Header = styled.div` display: flex; background-color: #F2F5F8; height: 64px; align-items: center; ` const Icon = styled.img` height: 22px; margin-left: 30px; margin-right: 12px; ` const Title = styled.span` font-size: 20px; color: #666666; ` const Body = styled.div` box-sizing: border-box; width: 100%; min-height: calc(100% - 64px); padding: 0 60px 30px; position: relative; ` // const FilterWrapper = styled.div` // display: flex; // align-items: center; // height: 40px; // ` let years = [{text:'全部年份',value:''}]; for(let i = 2013;i<2051;i++){ years.push({text:i+'年',value:i+''}); } // const status = [{text:'全部状态',value:0},{text:'进行中',value:1},{text:'已完成',value:2}] const cycles = [{text:'全部周期',value:'all'},{text:'年度',value:'year'},{text:'第一季度',value:'s1'},{text:'第二季度',value:'s2'},{text:'第三季度',value:'s3'},{text:'第四季度',value:'s4'}] for(let i = 1; i < 13; i++){ cycles.push({ text: i+'月', value: 'm'+i }) } cycles.push({ text:'自定义', value: 'custom' }) export default class OkrMap extends React.Component { constructor(p:OkrMapProps){ super(p) this.state = { okrList:[], user: getToUserId(), year: new Date().getFullYear()+'', status: 0, cycle: 'all' } } map:Map pushScreen:PushScreen componentDidMount(){ this.getOkrListData(); } back = () => { this.setState({ currentRoot: undefined }) } componentWillUnmount(){ } getOptions = () => { //cycleType: 0:自定义 1:年度 2:季度 3:月度 const {year,status,cycle,user} = this.state; let options:any = { toUserId: user, relation: 1, status: 0, pageNum: 1, pageSize: 999, appId: 1, cycleType:-1, appType: 1, workType: 6, orderType: 1, yqmnum: "", annualNum: "" }; options.annualNum = year; options.status = status; if(cycle == 'all'){ options.cycleType = '-1'; }else if(cycle == 'year'){ options.cycleType = '1'; options.yqmnum = year }else if(cycle.startsWith('s')){ options.cycleType = '2'; options.yqmnum = cycle.substring(1); }else if(cycle.startsWith('m')){ options.cycleType = '3'; options.yqmnum = cycle.substring(1); }else { options.cycleType = '0'; options.yqmnum = '0'; options.annualNum = '0'; } return options; } private getOkrListData = async () => { const resp = await taker(getApiUrl2(`work/listv2?toUserId=${getToUserId()}`), 'POST', this.getOptions()) if (!resp || !resp.Data) return; this.setState({ okrList: resp.Data.works || [], currentRoot:(resp.Data.works|| [])[0] }) } // private openMap = (work:WorkInfo) => { // this.setState({ // currentRoot:work // }) // } public handleFilterChange = (type:'year'|'status'|'cycle',value:string|number) => { let newState:any = {[type as any]:value}; if(type == "cycle"){ if(value == 'custom'){ newState = { cycle: value as string, year:'' } } } this.setState(newState,()=>{ this.getOkrListData() }) } getSelectedUsers = () => { return []; }; showPushScreen = (data:WorkInfo) => { this.setState({ selectOkr:data },()=>{ this.pushScreen.show() }) } changeUser = (userId:string) => { let hash = decodeURIComponent(location.hash); if(hash.indexOf('?') != -1){ if(hash.indexOf('to_user_id') != -1){ hash = hash.replace(/to_user_id=\d+/,'to_user_id='+userId) }else { hash = hash + '&to_user_id='+userId } }else{ hash = hash + '?to_user_id=' + userId } location.hash = hash; } static childContextTypes = { getSelectedUsers: PropTypes.func, handleChangeUser:PropTypes.func // updateSelectedUsers: PropTypes.func, // getNewAddUserPosition: PropTypes.func, // toEmptyNewAddUserPosition: PropTypes.func, // showPromptPop: PropTypes.func }; getChildContext() { return { getSelectedUsers: this.getSelectedUsers, handleChangeUser: this.changeUser // updateSelectedUsers: this.updateSelectedUsers, // getNewAddUserPosition: this.getNewAddUserPosition, // toEmptyNewAddUserPosition: this.toEmptyNewAddUserPosition, // showPromptPop: this.showPromptPop }; } public render() { const {currentRoot,okrList} = this.state; return ( {this.setState({currentRoot: r})}} currentRoot={currentRoot}/>
目标地图
{currentRoot? this.map = r as Map} containerId={this.props.containerId} goBack={this.back} onSelectOkr = {this.showPushScreen}/>:} {}} deleteOneVS={()=>{}} />
this.pushScreen = r as PushScreen} widget={this.props.widget} talent={this.props.talent}/>
); } }