import React, { Component } from 'react'; // import ScrollBar from '../../../components/common/scrollWrap' // import BeisenScrollBar from '@beisen/beisen-scroll-bar' import './index.scss' import Avatar from '../../../components/avatar' interface Props { pushScreen: any item: TaskInfo tipId?:string } interface State { taskName:string, remainDay:number, deadLine:string, taskId:string, priority:number, status:number, Color:string, HasAvatar:boolean, Small?:string, name:string isDeadLine: boolean } interface TaskInfo { taskId: string; id: number; parentTaskId?: any; appId: string; userId: number; principalId: number; user: User; principalUser: User; taskName: string; status: number; taskType: number; isPrivate: boolean; isSuperior: boolean; createDate: string; startDate: string; deadLine: string; finishDate: string; editable: boolean; editLableable: boolean; deleteable: boolean; editStatusable: boolean; isAddExperience: boolean; isMark: boolean; priority: number; priorityTitle: string; editPriorityAble: boolean; isRemind: boolean; isApply: boolean; isDeadLine: boolean; isShowWorkLable: boolean; userRelation: number; labelId: string; labelName: string; labelType: number; isLongTerm: boolean; cycleId: number; isPush: boolean; taskUrl?: any; departmentId: number; counter: Counter; remainDay: number; isAddMenu: boolean; hasSubTask: boolean; evaluateModel?: any; mileStoneId: number; cycleable: boolean; isExternal: boolean; progress: number; riskLevel: number; newExperience?: any; isQuantify: boolean; medalDetail?: any; } interface Counter { taskTotal: number; finishTaskTotal: number; experienceTotal: number; commentTotal: number; operationTotal: number; meetTotal: number; businessTripTotal: number; applyTotal: number; workTimeTotal: number; attachmentTotal: number; dashangTotal: number; rewardTotal: number; } interface User { userId: number; userGenre: number; name: string; email: string; mobile?: any; avatar: UserAvatar; type: number; userType: number; userStatus: number; jobState: number; weixinPayDimensionCode?: any; } interface UserAvatar { Original: string; Small: string; Medium: string; Big: string; Large: string; Normal: string; HasAvatar: boolean; Color?: any; } export default class taskItem extends Component { constructor (props:Props) { super (props); const { item } = this.props const { taskName, remainDay, deadLine, priority,status,taskId,isDeadLine } = item const { Color, HasAvatar, Small } = item.principalUser.avatar const { name } = item.principalUser this.state = { taskName: taskName, remainDay: remainDay, status: status, deadLine: deadLine, priority: priority, Color: Color, HasAvatar: HasAvatar, Small: Small, name: name, taskId: taskId, isDeadLine } } upDataPushScreen = (data:any) => { const {taskName, remainDay, deadLine, priority,status,isDeadLine} = data.attributes // const {Color,HasAvatar,Small} = data.attributes.principalUser.avatar // const {name} = data.attributes.principalUser let newState = { taskName, remainDay, deadLine, priority,status,isDeadLine } if(data.attributes.principalUser){ const {name,avatar:{Color,HasAvatar,Small}} = data.attributes.principalUser //@ts-ignore newState={...newState,name,Color,HasAvatar,Small} } this.setState (newState) } render() { const { taskName, remainDay, deadLine, taskId, priority,status,Color,HasAvatar,Small,name,isDeadLine } = this.state const {pushScreen,tipId} = this.props const taskItemData = {taskName, remainDay, deadLine, priority,status,Color,HasAvatar,Small,name} const {upDataPushScreen} = this const avatarConfig = { size: '30', right: '15', hasAvatar: HasAvatar, userName: name, bgColor: Color, avatarImg: Small, position: 'right' } var myDate = new Date(); var newDeadLine = deadLine&&deadLine.slice(0, 4) if (newDeadLine == myDate.getFullYear()+'') { newDeadLine = deadLine&&deadLine.slice(5, 10) } else { newDeadLine = deadLine&&deadLine.slice(0, 10) } var expiration = `${newDeadLine} 截止` var dateColor = '#33383D' if(status == 2){ expiration = `已完成` } else if (!isDeadLine && remainDay <= 3) { expiration = `剩余 ${remainDay} 天` }else if (isDeadLine && remainDay <= 30) { expiration = `过期 ${remainDay} 天` dateColor = '#FF6952' } else if (remainDay > 30) { expiration = `${newDeadLine} 截止` } let priorityColor = "#55C6C6"; switch (priority) { case 1: priorityColor = "#FF3E3E" break; case 2: priorityColor = "#F69E17" break; case 3: priorityColor = "#55C6C6" break; case 4: priorityColor = "#6CC95C" break; case 5: priorityColor = "#647481" break; } var iconClassName = 'tu-icon-checkbox-have' switch (status) { case 0: iconClassName = 'tu-icon-checkbox-have' break; case 1: iconClassName = 'tu-icon-ing' break; case 2: iconClassName = 'tu-icon-check-active' break; case 3: iconClassName = "tu-icon-delay" break; case 4: iconClassName = "tu-icon-cross2" break; case 6: iconClassName = 'tu-icon-pause' break; } return (
{taskName} {expiration}
) } }