import * as React from 'react'; import styled from 'styled-components' import { WorkInfo } from './types'; import Progress from '&/components/common/progress' import NoTask from '&/components/quadrant/noTask' import OkrItem from '&/components/quadrant/okritem' import tubiao from '&/components/quadrant/panelimages/1.png' import okr from '&/components/quadrant/panelimages/okrnotask.png' import { taker, getApiUrl2, getApiUrl, getBSGlobal, getToUserId, getUserInfo } from '&/components/helper' // import Avatar from 'ux-feature-avatar'; import PerfectScrollbar from 'react-perfect-scrollbar' import 'react-perfect-scrollbar/dist/css/styles.css'; const PushContainer = styled.div` width: 820px; height: 100%; position: fixed; display: flex; flex-direction: column; right: 0; background: #FAFBFC; box-shadow: -4px 0 6px 0 rgba(0,0,0,0.06); z-index: 100; box-sizing: border-box; padding: 0 20px; transition: transform .3s ease-in; transform: translateX(100%); ` const Header = styled.div` display: flex; width: 100%; height: 65px; align-items: center; justify-content: space-between; border-bottom: 1px solid #E9ECEE; ` const HeaderLeft = styled.div` width: 100%; flex:1; display: flex; align-items: center; height: 65px; ` const LinkIcon = styled.span` font-size: 18px; color: #319DFF; margin-right: 15px; ` const CloseBtn = styled.a` font-size: 14px; color: #667580; ` const Title = styled.p` font-size: 20px; color: #666666; padding-right: 30px; word-break: break-all; flex:1; font-weight: 600; cursor: pointer; &:hover { color: #319DFF; } transition: all .3s ease-in; ` const Card = styled.div` background: #FFFFFF; border-radius: 4px; padding: 20px 45px 30px 24px; margin-bottom: 12px; .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 SmallIcon = styled.span` color: #BFC3C7; font-size: 16px; margin-right: 5px; ` const SmallTitle = styled.span` font-size: 14px; color: #BFC3C7; margin-right: 12px; ` const SmallText = styled.span` font-size: 14px; color: #33383D; ` const CardTitle = styled.div` display: flex; align-items: center; font-size: 16px; color: #333333; line-height: 20px; margin-bottom: 16px; &::before { display: block; content: ''; margin-right: 10px; width: 5px; height: 16px; background: ${(props:any) => props.color} } ` const DashLine = styled.div` background-image: linear-gradient(to right, #ccc 0%, #ccc 50%, transparent 50%); background-size: 8px 1px; background-repeat: repeat-x; height: 2px; margin: 11px 0; margin-left: 44px; ` const Radio = styled.div` display: inline-block; padding: 0px 15px; font-size: 14px; border-radius: 12px; margin-right: 5px; margin-bottom: 8px; 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:#C2CBD1; } ` export interface PushScreenProps { data?: WorkInfo widget: any talent: any } interface PushScreenState { keyResultes:any[] comments:any operations:any parent?:WorkInfo contactType: number } export default class PushScreen extends React.Component { container:HTMLDivElement; // pub:HTMLDivElement; // PublistMblogView:any; feedItemCompositeView:any; comments: HTMLDivElement; constructor(p:PushScreenProps){ super(p) this.state = { keyResultes:[], comments:{}, operations:{}, contactType:0 } } public show = () => { this.container.style.transform = 'translateX(0)' document.addEventListener('mousedown',this.hide) } 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) } private getColorByRisk = () => { //1正常2有风险3过期4完成5过期完成 const { data } = this.props; if(!data) return '#FFF'; switch (data.riskLevel) { case 1: { return '#3FD1A3' } case 2: { return '#FEB222' } case 3: { return '#FE7189' } case 4: { return '#7BDD1E' } case 5: { return '#7BDD1E' } } return '#3FD1A3' } componentDidMount(){ } componentWillUnmount(){ document.removeEventListener('mousedown',this.hide) } componentWillReceiveProps(newProps:PushScreenProps){ const {data} = newProps; if(data && (!this.props.data || data.workId!=this.props.data.workId)){ this.getKeyResults(data.workId); this.renderFeed(data.feedId); this.getParentInfo(data.parentId) } } componentDidUpdate(){ // this.pub && !this.PublistMblogView && this.renderPublish() } getParentInfo(okrId:number){ if(!okrId) return; taker(getApiUrl(`okr/subOkrs?okrId=${okrId}&getType=1`), 'GET').then(res=>{ let p = res && res.Data && res.Data.currentOkr; this.setState({ parent: p }) }) } renderFeed = (feedId:string) => { const url = getApiUrl2('user/feed/GetById?feed_id='+feedId+'&comment_count=4'); taker(url,'GET').then(res => { this.setState({ comments:res.Data.feedComments, operations: res.Data.feedOperations },() => { this.renderCommentList() }) }) } //@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()}`) } renderCommentList = () => { const {widget,data,talent} = this.props; const {comments} = this.state; if(!data) return; this.feedItemCompositeView && this.feedItemCompositeView.close(); this.feedItemCompositeView = new widget.CommentListView({ isInAppPage: false, //true,在项目页等一些其它页面时,头像全部为人的头像 onlyComment: true, //只有回复列表 mBlogOptions: { defaultHide: false, defaultValue: "", isShowSendSms: false, }, //回复框设置 custom: { more: true, remind: true, collect: true, reply: true, }, actionMore: { detail: true, deleted: true, setTop: true, }, isPrivate: false, privateTipText: "", feedId: data.feedId, //如果onlyComment 为true时,就必需传feedid,否则添加回复时自己触发 defaultCount: 5, //默认显示几条回复 model: new talent.Model({ total: comments.total, comments: comments.comments, }), }); if(this.comments){ this.comments.appendChild(this.feedItemCompositeView.render().el); this.feedItemCompositeView.onShow() } } public render() { const {data} = this.props; const {keyResultes,operations,parent,contactType} = this.state; const apiPath = getBSGlobal('apiPath') const toUserId = getToUserId() const noTaskConfig = { noTaskText: '请先制定衡量目标达成的关键成果', linkText: '去制定', gotoLink: (getUserInfo() as any).Id == toUserId ? `${apiPath}/u/${toUserId}/Home#okr/manage?relation=1&work_id=${data&&data.workId}` :'javascript:;', taNoTaskText: "尚未制定关键成果", taLinkText: '提醒ta制定', toUserId: toUserId, workId: data && data.workId, workName: data && data.workName, status: status, titaimg:okr, tubiao:tubiao, isSuper:true, xiangxian:1, isSelf:getUserInfo().Id == toUserId } return ( this.container = r} onMouseDown={(e:any)=>{e.nativeEvent.stopImmediatePropagation();}}> {!!data &&
关联目标: {parent? {parent.workName} : '无'}
{data.workName}
进度
{data.progress}
时间 {data.startDate+'-'+data.endDate} 负责人 {data.principalUser.name} · {data.principalUser.departmentName}
关键成果 { keyResultes.length == 0 ? : keyResultes.map((item,index) =>{ return (
{index !== keyResultes.length - 1 && }
) }) }
协作
this.setState({contactType:0})}>全部 this.setState({contactType:1})}>沟通 this.setState({contactType:2})}>操作记录
{(operations && operations.comments || []).map((comment:any,index:number) => { return (
{(index==0||operations.comments[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}

) })}
{/* { (comments && comments.comments || []).map((comment:any) => { return (
{comment.publishUser.name}: {comment.createDate}
) }) } */}
this.comments = r as HTMLDivElement}>
{/*
this.pub = r as HTMLDivElement}>
*/}
}
); } }