import React, { Component } from 'react'; import NoTask from '../../quadrant/noTask' import OkrList from './OkrList' import tubiao from '../panelimages/1.png' import okr from '../panelimages/okrnotask.png' import { getApiUrl, taker } from '&/components/helper'; import { getBSGlobal } from '&/components/helper'; import ReactToolTip from 'react-tooltip' interface Props { workName?: string toUserId?: number workId: number status:number isSuper:boolean evaluateValue: number progress: number getKrComments:Function showPush?:Function changeKrItem:Function isSelf:boolean } interface State { keyResultes:any[] } export default class FirstQuadrant extends Component { constructor(p:Props){ super(p); this.state = { keyResultes:[] } } componentDidMount(){ this.getKeyResults(this.props.workId) } componentDidUpdate(prevProps:Props) { if(prevProps.workId != this.props.workId){ this.getKeyResults(this.props.workId) } } async getKeyResults(workId:number) { let url = getApiUrl(`kr/list?workId=${workId}`); taker(url, 'GET').then(res => { if (res.Code == 1 && res.Data) { this.setState({ keyResultes: res.Data }) } else { this.setState({ keyResultes: [] }) } }) } //在推屏中修改kr的信息 changeProp = (propName:any,data:any,id:number) => { let {keyResultes} = this.state; const index = keyResultes.findIndex(m => m.mileStoneId == id); if(index != -1){ let newMile = [...keyResultes]; newMile[index] = {...newMile[index],...{[propName]:data}} if(propName == 'evaluateValue'){ newMile[index] = {...newMile[index],...{'isEvaluate':true}} } this.setState({ keyResultes: newMile, },()=>{ ReactToolTip.rebuild(); let opt = newMile[index]; opt.index = index+1; this.props.changeKrItem(opt) }) } } //修改起止时间的函数 // refresh = async()=>{ // let url = getApiUrl(`kr/list?workId=${this.props.workId}`); // const res = await taker(url,'GET'); // return res; // } render() { const { workName, toUserId, workId,status ,isSuper,progress,evaluateValue,getKrComments,showPush,isSelf} = this.props; const {keyResultes} = this.state; const { Id } = getBSGlobal().loginUserInfo const { apiPath } = getBSGlobal() const noTaskConfig = { noTaskText: '请先制定衡量目标达成的关键成果', linkText: '去制定', gotoLink: Id == toUserId ? `${apiPath}/u/${toUserId}/Home#okr/manage?relation=1&work_id=${workId}` :'javascript:;', taNoTaskText: "尚未制定关键成果", taLinkText: '提醒ta制定', toUserId: toUserId, workId: workId, workName: workName, status: status, titaimg:okr, tubiao:tubiao, isSelf, isSuper:isSuper, xiangxian:1 } return (
OKR 了解目标管理
{ keyResultes.length == 0 ? : }
) } }