import * as React from 'react'; import styled from 'styled-components' import { WorkInfo } from './type'; import { taker, getApiUrl2, getApiUrl, getToUserId } from '&/components/helper' import './index.scss' import ReactToolTip from 'react-tooltip'; import Pop from '../../components/common/pop' import ErrorAlertPop from '&/components/millpostItem/error-alert-pop' import KrNamePush from './krName' import { getBSGlobal } from '&/components/profileWrapper/helper'; import noTask from './none-permission.png' import BasicInfo from './basicInfo' import 'react-perfect-scrollbar/dist/css/styles.css'; interface KR { mileStoneId: number; workId: number; mileStoneName: string; startDate: string; endDate: string; user: User; status: number; taskTotal: number; finishTaskTotal: number; remainingDays: number; progress: number; riskLevel: number; isOpen: boolean; remainingContent: string; progressDescription: string; editable: boolean; evaluateEditable: boolean; confidenceIndex: number; evaluateValue: string; tasks?: any; isEvaluate:boolean; index?:number } interface User { userId: number; userType: number; Name: string; email: string; departmentName: string; postition: string; avatar: Avatar; } interface Avatar { original: string; small: string; medium: string; big: string; normal: string; large: string; hasAvatar: boolean; color?: any; } const PushContainer = styled.div` width: 465px; height: 100%; position: fixed; display: flex; flex-direction: column; right: 0; top:38px; background: #FAFBFC; box-shadow: -4px 0 6px 0 rgba(0,0,0,0.06); box-sizing: border-box; padding: 0 20px; transition: transform .3s ease-in; transform: translateX(100%); z-index:10000; overflow-y:auto; ` const Header = styled.div` display: flex; width: 100%; height: 50px; align-items: center; justify-content: space-between; position:relative; // border-bottom: 1px solid #E9ECEE; ` const HeaderLeft = styled.div` width: 100%; flex:1; display: flex; align-items: center; height: 50px; ` const CloseBtn = styled.a` font-size: 14px; color: #667580; ` const KrLine = styled.div` position:absolute; bottom:0px; width:calc(100% + 40px); background:#E9ECEE; height:1px; left:-20px; ` const BtnWrapper = styled.div` background: #eeeeee; height: 48px; line-height: 48px; text-align: center; ` const Button = styled.span` display: inline-block; width: 62px; height: 28px; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3); border-radius: 2px; font-family: PingFangSC-Regular; font-size: 12px; text-align: center; line-height: 28px; margin-top: 10px; cursor: pointer; ` const Card = styled.div` background: #FFFFFF; border-radius: 4px; padding: 16px 20px 15px; margin-bottom: 15px; white-space:normal; .kr-push-screen { .kr-logo{ width:36px; height:20px; line-height:20px; } .krname{ font-size: 16px; width: 50%; margin-top: 0; } .heart{ text-align: right; } } ` const DeleteWrapper = styled.div` width: 226px; height: 84px; border-radius: 2px; ` const Radio = styled.div` display: inline-block; padding: 1px 10px; font-size: 13px; border-radius: 30px; margin-right: 17px; margin-bottom: 16px; cursor: pointer; transition: all .3s ease-in; ` const Dot = styled.div` width: 19px; position: absolute; top:0; ${(p:any)=> p.last? 'height:24px':`bottom:0}`}; left: 62px; &::before{ display: block; content:''; position: absolute; width: 1px; top: ${(p:any)=> p.first? '10px':0}; background: #C2CBD1; bottom: ${(p:any)=>p.last? '10px':'0'}; left: 8px; } &::after{ display: block; content:''; position: absolute; left: 6px; top: 9px; width: 5px; height: 5px; border-radius: 2.5px; background-color:${(p:any)=>p.last?'rgb(56, 186, 115)': '#C2CBD1'}; } ` const KrName = styled.div` width:425px; margin:20px auto; display:flex; align-items:baseline; margin-bottom:24px; ` const Krlogo = styled.div` background: #E3F4FF; text-align: center; color: #1D86F0; border-radius: 22px; line-height: 12px; padding: 5px 10px; margin-right: 12px; height:12px; ` const DeleteKr = styled.div` padding-top: 120px; text-align: center; font-size: 15px; color: #2E9CFF; position:relation; img{ width: 203px; height: 167px; display: block; margin: auto; } ` const SpanIcon = styled.span` padding-right:5px; ` export interface PushScreenProps { data: KR getKrComments:Function refresh?: Function onChangeName:Function changeProp: (propName:string,data:any,id:number) => void showUserSelector?:(node:HTMLDivElement,after:Function,data?:any) => void eventBridge:Function infoTipView:any } interface PushScreenState { keyResultes:any[] comments:any operations:any parent?:WorkInfo contactType: number showCannotDeletePop:boolean deleteKr?:boolean container:HTMLDivElement|HTMLElement shareLists?:number } export default class PushScreen extends React.Component { container:HTMLDivElement; feedItemCompositeView:any; detailShareView:any; comments: HTMLDivElement; basicInfo:HTMLDivElement; shareInfo:HTMLDivElement; timer:any; constructor(p:PushScreenProps){ super(p) this.state = { keyResultes:[], comments:{}, operations:[], contactType:1, showCannotDeletePop:false, deleteKr:false, container:document.body, shareLists:0 } } public show = (data:any) => { this.container.style.transform = 'translateX(0)' document.addEventListener('mousedown',this.hide); this.props.getKrComments(data,this.comments); const {eventBridge} = this.props; //监听创建进展的事件,更新最新的进展 //@ts-ignore eventBridge.listenTo('addKrShare',(data)=>{ this.props.changeProp('progressDescription',data,this.props.data.mileStoneId) }) //@ts-ignore eventBridge.listenTo('getShareList',(data)=>{ this.setState({ shareLists:data }) //@ts-ignore eventBridge.listenTo('experienceTotal',(data)=>{ this.setState({ shareLists:data }) }) }) // this.renderDetailShare(data.mileStoneId) this.renderTrack(data.mileStoneId); } public hide = (e?:Event) => { if(e && e.srcElement ){ const container = document.getElementById('bs_layout_container'); if(container && !container.contains(e.srcElement as Node)) return } this.container.style.transform = 'translateX(100%)' document.removeEventListener('mousedown',this.hide) } componentDidMount(){ document.addEventListener('click',()=>{ //@ts-ignore this.refs.pop && this.refs.pop.hide(); }) } componentWillUnmount(){ ReactToolTip.rebuild(); document.removeEventListener('mousedown',this.hide) document.removeEventListener('click',()=>{ //@ts-ignore this.refs.pop.hide(); }) } componentWillReceiveProps(newProps:PushScreenProps){ const {data} = newProps; if(data && (!this.props.data || data.mileStoneId!=this.props.data.mileStoneId)){ this.getKeyResults(data.workId); } } renderTrack = (krId:number) => { const url = getApiUrl('kr/operation/get?krId='+krId); taker(url,'GET').then(res => { if(res.Data){ this.setState({ // comments:res.Data.feedComments, operations: res.Data }) } }) } //@ts-ignore _requestFeed = (node, options, params) => { //@ts-ignore var options = { // FeedId: this.props.data&& this.props.data.feedId, CommentId: options["commentId"] || 0, Content: options["context"], FileUrl: options["files"], ObjId: options["privateObjId"], ObjType: options["privateObjType"], IsSendSMS: options["isSendSMS"], OtherDocuments: options["YFYDocuments"], } options = {...options, ...params} const url = getApiUrl2('comment/Add'); let promise = taker(url,'POST',options).then(res => { this.setState({ comments: this.state.comments.comments? {...this.state.comments,...{comments:[...this.state.comments.comments,res.Data]}} : [res.Data] }) }) //@ts-ignore promise.done = (data) => { promise.then(data); return promise; }; //@ts-ignore promise.fail = (data) => { promise.catch(data); return promise; }; return promise } 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: [] }) } }) } openDetail = (workId:string) => { if(!workId) return; window.open(`#okr/manage?&work_id=${workId}&to_user_id=${getToUserId()}`) } handleDelete=(ev:any)=>{ //删除kr ev.nativeEvent.stopImmediatePropagation() const {data:{taskTotal}} = this.props; clearTimeout(this.timer) if(taskTotal && taskTotal > 0){ this.setState({ showCannotDeletePop: true }) this.timer = setTimeout(() => { this.setState({ showCannotDeletePop: false }) }, 1500) return; } this.setState({ showCannotDeletePop: false }) //@ts-ignore this.refs.pop.show(this.refs.delete); } handleClickConfirmDelete = async () => { const { data:{mileStoneId}} = this.props; var workMileStoneId = mileStoneId; //@ts-ignore this.refs.pop.hide() this.setState({ deleteKr:true }) let url = getApiUrl(`WorkMileStone/Delete?workMileStoneId=${mileStoneId}`); await taker(url, 'POST', workMileStoneId); // refresh() } handleClickCancelDelete = () => { //@ts-ignore this.refs.pop.hide() } handleHide=(e:any)=>{ e.nativeEvent.stopImmediatePropagation() // e.stopPropagation() //@ts-ignore this.basicInfo.hideHide() } //改变Tab changeTab = (value:number) =>{ const {eventBridge} = this.props; this.setState({contactType:value},()=>{ if(value == 1){ this.props.getKrComments(this.props.data,this.comments) // this.renderDetailShare(this.props.data.mileStoneId) //@ts-ignore eventBridge.listenTo('addKrShare',(data)=>{ this.props.changeProp('progressDescription',data,this.props.data.mileStoneId) }) }else if(value == 2){ this.renderTrack(this.props.data.mileStoneId); } }) } stopPropagation = (e:any)=>{ e.nativeEvent.stopImmediatePropagation() e.stopPropagation() } public render() { const {data,changeProp,refresh,showUserSelector,infoTipView} = this.props; const {operations,contactType,showCannotDeletePop,deleteKr,shareLists} = this.state; const {mileStoneName,editable} = data; const confirmAlertConfig = { errorAlertText: "此操作不可恢复,您确定删除吗?", position: 'relative', showQuestionMark: true, boxShadow: 'none' } const errorAlertConfig = { errorAlertText: "该关键成果下有待执行的任务,请转移任务后才能删除该关键成果", top: 37, right:0, showExclamationMark: true } const userInfo = getBSGlobal('loginUserInfo'); const allowEdit = editable || userInfo.IsRoot || userInfo.IsBoss || userInfo.IsOkrManager; return ( { this.container = r;if(this.container && this.state.container == document.body){this.setState({container:this.container})}}} onMouseDown={(e:any)=>{this.handleHide(e)}}> {!!data && !deleteKr &&
{data.status == 3 ? '已完成':'未完成'} (系统自动生成) { allowEdit && } { showCannotDeletePop && }
KR{data.index}
this.basicInfo = r} infoTipView={infoTipView} /> this.shareInfo = r}>
this.changeTab(1)}> 进展 {shareLists? `(${shareLists})`:''} this.changeTab(2)}>操作记录
{(operations || []).map((comment:any,index:number) => { return (
{(index==0||operations[index - 1].createTime.split(/\s+/)[0] != comment.createTime.split(/\s+/)[0]) && comment.createTime.split(/\s+/)[0].substring(5)} {comment.createTime.split(/\s+/)[1]}

{comment.publishUser.name}{comment.content}

) })}
this.comments = r as HTMLDivElement}>
} { // 任务删除之后的显示情况 deleteKr &&

该KR已被删除~

}
); } }