import React, { Component } from 'react' import { WorkInfo} from './type' import styled from 'styled-components' import MultiLineEllipsis from '&/components/common/multiLineEllipsis' import moment from 'moment' import {KR} from './type' import { taker, getApiUrl2,getToUserId} from '&/components/helper' import KrItem from './krItem' import {Collapse} from 'react-collapse'; interface Props { data:WorkInfo, routerData:{ FeedId: number appId: String appType: String app_id: String app_type: String pageIndex: Number relation: String taskType: Number to_user_id: String workType?: String } } interface State { isOpen:Boolean, krs:KR[] } const okrBackCol =(data:1|2|3) =>{ switch(data){ case 3: return '#FFA91D' case 2: return '#1BBD05' case 1:return '#C68FFF' } } const Box = styled.div` margin-bottom:10px; ` const ItemBox = styled.div` padding:19px 0 19px 16px; display:flex; background:#fff; border-radius:4px; align-items:center; line-height:17px; position:relative; ` const OkrTypeLogo = styled.div` width:38px; height:17px; line-height:18px; border-radius: 2px; background:${(props:{okrType:1|2|3})=>okrBackCol(props.okrType)}; color:#fff; text-align:center; font-size:12px; margin-right:7px; ` const OkrProgress = styled.div` font-size:13px; width:16% ` const OkrName = styled.div` font-size:14px; color:#33383D ; width:80%; ` const OkeNameCont = styled.div` width: 40%; min-width: 340px; display: flex; align-items: center; ` const LastUpdate = styled.div` font-size: 13px; color: #33383D; width:18%; ` const PrincipalName = styled.div` width:12%; span{ display:inline-block; max-width:52px; font-size: 13px; color: #33383D; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } ` const OkrType = styled.div` width:14%; span{ display:inline-block; max-width:65px; font-size: 13px; color: #33383D; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } ` const UporDownProgress = styled.span` padding:0 7px; height:17px; line-height:17px; background:${(props:any)=>props.data >0? 'rgba(12,201,145,0.1)':'rgba(255,19,0,0.1) '}; color:${(p:any)=>p.data?'#0CC991':'#FF1300'}; display:inline-block; border-radius:8px; margin:0 3px; span{ font-size:12px; } ` const HasKr = styled.div` width:16px; height:16px; position:absolute; border-radius:2px; color:#85C2FF ; line-height:20px; font-size:12px; border:1px solid #85C2FF; right:16px; cursor: pointer; text-align:center; .tu-icon-sort-down{ color:#85C2FF ; margin-top:0px; float:none; } ` const SelectArrow = styled.span` transition: transform .3s ease; display:inline-block; line-height: 18px; width: 16px; height: 16px; ` const KrItemBox = styled.div` background:#fff; ` const KrItemLine = styled.div` height: 1px; border-top: 1px dashed transparent; background: linear-gradient(white,white) padding-box, repeating-linear-gradient(-45deg,#F0F2F5 0, #F0F2F5 0.25em,white 0,white 0.75em); margin-bottom:18px; margin:0 43px 0 45px; ` export default class ListItem extends Component { state = { isOpen:false, krs:[] } handelUp =()=>{ this.setState({ isOpen:!this.state.isOpen },()=>{ if(this.state.isOpen){ this.getKrList() }else{ this.setState({ krs:[] }) } }); } getKrList = ()=>{ const {workId} = this.props.data; //获取kr列表 const url = getApiUrl2('work/task/kr?workId='+workId); const {routerData} = this.props; taker(url,'POST',{ sortType: 1, work_id: workId, startNum: 1, count: 20, relation: routerData.relation, app_id: routerData.app_id, app_type: routerData.app_type, to_user_id: getToUserId(), workType: routerData.workType, appId: routerData.appId, appType: routerData.appType, taskType: routerData.taskType, detail_type: 'pq' }).then((resp)=>{ this.setState({ krs:resp.Data }) }) } render() { const {data} = this.props; const {isOpen,krs} = this.state; const map=['','个人','部门','公司']; let progress:JSX.Element; if(data.status == 2){ progress = 已完成; }else{ if(moment(new Date()).isBefore(data.startDate)){ //还没有开始目标 progress = 未开始 }else{ progress= {data.progress} % { data.progressGrow !== 0 && 0 ? 'tu-icon-simple-sort-up':'tu-icon-simple-sort-down'}`}> {data.progressGrow} } } } const {okrType} = data return ( {map[okrType]} {data.workName} { progress } {data.startDate}~{data.endDate} {data.principalUser.name} { okrType == 2 ? data.departmentName:map[okrType] } { data.counter.krTotal ? :null } { krs.map((item,index)=>(
)) }
) } }