// // EleTwoCell.m // JSJPCoach // // Created by EchoShacolee on 2018/1/31. // Copyright © 2018年 Danson. All rights reserved. // #import "EleTwoCell.h" @implementation EleTwoCell - (void)awakeFromNib { [super awakeFromNib]; self.time.adjustsFontSizeToFitWidth = YES; NSMutableDictionary*attr = [NSMutableDictionary dictionary]; attr[NSFontAttributeName] = [UIFont systemFontOfSize:15.0]; attr[NSForegroundColorAttributeName] = RGB_COLOR(40, 152, 255); attr[NSUnderlineStyleAttributeName] = [NSNumber numberWithInteger:NSUnderlineStyleSingle]; attr[NSUnderlineColorAttributeName] = RGB_COLOR(40, 152, 255); NSAttributedString *attributedStr = [[NSAttributedString alloc]initWithString:@"查看评价" attributes:attr]; [_ckBtn setAttributedTitle:attributedStr forState:UIControlStateNormal]; _ckBtn.hidden = YES; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } -(void)setDataDic:(NSDictionary *)dataDic{ self.name.text = [dataDic[@"CRI_STARTTIME"] substringToIndex:10]; self.history.attributedText = [self getHistoryWithStatus:dataDic[@"HISTORY"]]; self.type.text = [self getTypeWithKemu:dataDic[@"CRI_TRAIN_SUBJECT"] pxName:dataDic[@"PXLX_NAME"]]; self.time.text = [self getTimeWithStart:dataDic[@"CRI_STARTTIME"] end:dataDic[@"CRI_ENDTIME"]]; self.allTime.text = [NSString stringWithFormat:@"总时长:%@分",dataDic[@"CRI_DURATION"]]; self.validTime.text = [NSString stringWithFormat:@"有效时长:%@分",dataDic[@"CRI_VAILD_TIME"]]; self.percent.text = [NSString stringWithFormat:@"占比:%@",dataDic[@"PERCENT"]]; self.car.text = [NSString stringWithFormat:@"培训车辆: %@",dataDic[@"CAR_LICNUM"]]; self.mileage.text = [NSString stringWithFormat:@"里程: %@m",dataDic[@"CRI_MILEAGE"]]; CGFloat mile = [[NSString stringWithFormat:@"%@",dataDic[@"CRI_MILEAGE"]] floatValue]; if (mile > 1000) { self.mileage.text = [NSString stringWithFormat:@"里程: %.1fkm",mile/1000]; } self.coach.text = [NSString stringWithFormat:@"带教教练: %@",dataDic[@"COACH_NAME"]]; //二次审核相关 self.checkMan.text = [NSString stringWithFormat:@"审核人 : %@",dataDic[@"CRI_AUDIT_USERNAME"]]; self.checkTime.text = [NSString stringWithFormat:@"审核时间: %@",dataDic[@"CRI_AUDIT_TIME"]]; self.reason.text = [NSString stringWithFormat:@"审核原因: %@",dataDic[@"CRI_SECOND_AUDIT_REASON"]]; //状态 [self getStastusWithHz:dataDic[@"CRI_COUNT"] sb:dataDic[@"CRI_RECORD_STATUS"] sh:dataDic[@"CRI_AUDIT_RESULT"] secondSH:dataDic[@"CRI_SECOND_AUDIT_RESULT"]]; } -(NSMutableAttributedString *)getHistoryWithStatus:(id)status{ NSInteger zz = [status integerValue]; NSString *str = [NSString stringWithFormat:@"历史学员: %@",zz==1?@"是":@"否"]; NSMutableAttributedString *aStr = [[NSMutableAttributedString alloc]initWithString:str]; if (zz==1) { [aStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(str.length-1, 1)]; } return aStr; } -(NSString*)getTypeWithKemu:(id)kemu pxName:(NSString *)pxName{ NSArray *arr = @[@"科一",@"科二",@"科三",@"科四"]; NSString * kemuStr = arr[[kemu integerValue]-1];//[kemu integerValue] return [NSString stringWithFormat:@"%@%@",kemuStr,[pxName substringToIndex:2]]; } -(NSString *)getTimeWithStart:(NSString *)start end:(NSString *)end{ return [NSString stringWithFormat:@"训练时段: %@至%@",[start substringFromIndex:11],[end substringFromIndex:11]]; } -(void)getStastusWithHz:(id)hz sb:(id)sb sh:(id)sh secondSH:(id)secondSh{ // NSString *hStr = @"未汇总"; _status1.textColor = [UIColor lightGrayColor]; if ([hz integerValue]==1) { hStr = @"已汇总"; _status1.textColor = RGB_COLOR(76, 75, 76); }else if ([hz integerValue]==2){ hStr = @"汇总失败"; _status1.textColor = [UIColor redColor]; } _status1.text = hStr; // NSString *sStr = [sb integerValue]==1?@"已上报":@"未上报"; _stauts2.text = sStr; _stauts2.textColor = [sb integerValue]==1?RGB_COLOR(76, 75, 76):[UIColor lightGrayColor]; // NSString *eStr = @"合格"; _status3.textColor = RGB_COLOR(76, 75, 76); if ([sh integerValue]==1) { eStr = @"不合格"; _status3.textColor = [UIColor redColor]; }else if ([sh integerValue]==2){ eStr = @"待审核"; _status3.textColor = [UIColor lightGrayColor]; } _status3.text = eStr; // NSString *shStr = @"审核通过"; _status4.textColor = RGB_COLOR(76, 75, 76); self.statusTop.constant = -64; _checkMan.hidden = YES; _checkTime.hidden = YES; _reason.hidden = YES; if ([secondSh integerValue]==1) { shStr = @"异常记录"; _status4.textColor = [UIColor redColor]; self.statusTop.constant = 5; _checkMan.hidden = NO; _checkTime.hidden = NO; _reason.hidden = NO; }else if ([secondSh integerValue]==2){ shStr = @"待审核"; _status4.textColor = [UIColor lightGrayColor]; } _status4.text = shStr; } - (IBAction)chakanBtnclick:(id)sender { } @end