// // PBRecordTableViewCell.m // IphoneBIMe // // Created by zjf on 2019/1/31. // Copyright © 2019 ProBIM. All rights reserved. // #import "PBRecordTableViewCell.h" #import "PBRecordModel.h" @interface PBRecordTableViewCell() @property (nonatomic, weak) UILabel *referredL; @property (nonatomic, weak) UILabel *checkNameL; @property (nonatomic, weak) UILabel *contentL; @property (nonatomic, weak) UIImageView *stateImageV; @property (nonatomic, weak) UIView *topView; @property (nonatomic, weak) UIView *contentbgV; @end @implementation PBRecordTableViewCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self setupUI]; } return self; } - (void)setupUI { self.contentView.backgroundColor = PBColor(244, 245, 246); UIView *topView = [[UIView alloc] init]; topView.backgroundColor = [UIColor blackColor]; [self.contentView addSubview:topView]; [topView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.right.equalTo(self.contentView); make.height.equalTo(@16); }]; UIView *bgV = [[UIView alloc] init]; bgV.backgroundColor = [UIColor whiteColor]; [self.contentView addSubview:bgV]; [bgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView).offset(10); make.left.right.equalTo(self.contentView); make.bottom.equalTo(self.contentView); }]; // [bgV circleViewWithRadius:6]; UIView *portraitImageV = [[UIView alloc] init]; portraitImageV.backgroundColor = PBColor(40, 58, 79); [self.contentView addSubview:portraitImageV]; [portraitImageV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(bgV).offset(10); make.left.equalTo(bgV).offset(10); make.size.mas_equalTo(CGSizeMake(30, 30)); }]; [portraitImageV circleViewWithRadius:15]; UILabel *referredL = [UILabel z_labelWithText:@"" Color:[UIColor whiteColor] isBold:YES Font:16]; referredL.textAlignment = NSTextAlignmentCenter; [self.contentView addSubview:referredL]; [referredL mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(portraitImageV); make.left.right.equalTo(portraitImageV); }]; UILabel *checkNameL = [UILabel z_labelWithText:@"" Color:PBColor(40, 58, 79) isBold:YES Font:14]; [self.contentView addSubview:checkNameL]; [checkNameL mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(portraitImageV); make.left.equalTo(portraitImageV.mas_right).offset(8); make.right.equalTo(bgV).offset(-70); make.height.equalTo(@20); }]; UIImageView *stateImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Rectify_ qualified"]]; [self.contentView addSubview:stateImageV]; [stateImageV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(bgV).offset(12); make.right.equalTo(bgV); make.size.mas_equalTo(CGSizeMake(60, 22)); }]; UIView *contentbgV = [[UIView alloc] init]; contentbgV.backgroundColor = PBColor(244, 245, 246); [self.contentView addSubview:contentbgV]; UILabel *contentL = [UILabel z_labelWithText:@"" Color:PBColor(40, 58, 79) isBold:NO Font:14]; contentL.numberOfLines = 0; [self.contentView addSubview:contentL]; [contentL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(portraitImageV.mas_bottom).offset(25); make.left.equalTo(bgV).offset(25); make.right.equalTo(bgV).offset(-25); make.bottom.equalTo(bgV).offset(-15); }]; [contentbgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(portraitImageV.mas_bottom).offset(10); make.left.equalTo(bgV).offset(10); make.right.equalTo(bgV).offset(-10); make.bottom.equalTo(contentL.mas_bottom).offset(15); }]; // [contentbgV circleViewWithRadius:6]; self.topView = topView; self.referredL = referredL; self.checkNameL = checkNameL; self.contentL = contentL; self.stateImageV = stateImageV; self.contentbgV = contentbgV; } - (void)setRecordModel:(PBRecordModel *)recordModel { _recordModel = recordModel; if (recordModel.isOneIndex) { self.topView.backgroundColor = [UIColor blackColor]; }else { self.topView.backgroundColor = PBColor(244, 245, 246); } BOOL isChiness = [self IsChinese:recordModel.RectificationOperator]; if (isChiness) { self.referredL.text = [recordModel.RectificationOperator substringFromIndex:recordModel.RectificationOperator.length - 1]; }else { self.referredL.text = [recordModel.RectificationOperator substringToIndex:1]; } if ([recordModel.indexFlag isEqualToString:@"0"]) { self.stateImageV.image = [UIImage imageNamed:@"Rectify_ check"]; self.checkNameL.text = [NSString stringWithFormat:@"%@ 创建了任务", recordModel.RectificationOperator]; }else if ([recordModel.indexFlag isEqualToString:@"1"]) { self.stateImageV.image = [UIImage imageNamed:@"Rectify_ rectification"]; self.checkNameL.text = [NSString stringWithFormat:@"%@ 检查了任务", recordModel.RectificationOperator]; }else if ([recordModel.RectificationOperateFlag isEqualToString:@"1"]) { self.checkNameL.text = [NSString stringWithFormat:@"%@ 进行了验收", recordModel.RectificationOperator]; if([recordModel.RectificationCheckResult isEqualToString:@"合格"]) { self.stateImageV.image = [UIImage imageNamed:@"Rectify_ qualified"]; }else { self.stateImageV.image = [UIImage imageNamed:@"Rectify_ rectification"]; } }else if ([recordModel.RectificationOperateFlag isEqualToString:@"2"]){ self.checkNameL.text = [NSString stringWithFormat:@"%@ 申请复检", recordModel.RectificationOperator]; self.stateImageV.image = [UIImage imageNamed:@"Rectify_ acceptance"]; }else { self.checkNameL.text = @""; self.stateImageV.image = [UIImage imageNamed:@""]; } self.contentL.text = recordModel.RectificationRemark; [self.contentbgV circleViewWithRadius:6]; } - (BOOL)IsChinese:(NSString *)str { for(int i=0; i< [str length];i++){ int a = [str characterAtIndex:i]; if( a > 0x4e00 && a < 0x9fff){ return YES; } } return NO; } @end