//
|
// PBExamineListTwoPicCell.m
|
// IphoneBIMe
|
//
|
// Created by zjf on 2020/11/5.
|
// Copyright © 2020 ProBIM. All rights reserved.
|
//
|
|
#import "PBExamineListTwoPicCell.h"
|
#import "PBExamineListModel.h"
|
#import "PBImageCollectionViewCell.h"
|
static NSString *const ImageCellID = @"ImageCellID";
|
@interface PBExamineListTwoPicCell()<UICollectionViewDataSource, UICollectionViewDelegate, SDPhotoBrowserDelegate>
|
@property (nonatomic, weak) UILabel *referredL;//检查人 简称
|
@property (nonatomic, weak) UILabel *checkNameL;//检查人
|
@property (nonatomic, weak) UIImageView *stateImageV;//状态
|
@property (nonatomic, weak) UILabel *originatorL;//发起人
|
@property (nonatomic, weak) UILabel *timeL;//发起时间
|
@property (nonatomic, weak) UILabel *titleL;//标题
|
@property (nonatomic, weak) UILabel *typeL;//类型
|
@property (nonatomic, weak) UIView *stateBgV;//级别背景
|
@property (nonatomic, weak) UILabel *stateL;//级别
|
@property (nonatomic, weak) UILabel *checkL;//检查内容
|
@property (nonatomic, weak) UILabel *limitL;//期限
|
@property (nonatomic, weak) UIView *checkBgV;
|
@property (nonatomic, weak) UILabel *timeLimitL;
|
@property (nonatomic, weak) UIView *leftView;
|
@property (nonatomic, strong) UICollectionView *collectionView;
|
@end
|
@implementation PBExamineListTwoPicCell
|
|
- (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 *bgV = [[UIView alloc] init];
|
bgV.backgroundColor = [UIColor whiteColor];
|
[self.contentView addSubview:bgV];
|
[bgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.left.equalTo(self.contentView).offset(10);
|
make.right.equalTo(self.contentView).offset(-10);
|
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(13);
|
make.left.equalTo(bgV).offset(10);
|
make.size.mas_equalTo(CGSizeMake(40, 40));
|
}];
|
[portraitImageV circleViewWithRadius:20];
|
|
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.top.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(10);
|
make.right.equalTo(bgV);
|
make.size.mas_equalTo(CGSizeMake(60, 22));
|
}];
|
|
UILabel *originatorL = [UILabel z_labelWithText:@"" Color:PBColor(97, 111, 125) isBold:YES Font:13];
|
[self.contentView addSubview:originatorL];
|
[originatorL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(checkNameL.mas_bottom).offset(4);
|
make.left.equalTo(checkNameL);
|
make.height.equalTo(@16);
|
}];
|
UILabel *timeL = [UILabel z_labelWithText:@"" Color:PBColor(166, 174, 182) isBold:YES Font:13];
|
[self.contentView addSubview:timeL];
|
[timeL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.equalTo(originatorL);
|
make.left.equalTo(originatorL.mas_right).offset(8);
|
}];
|
|
UILabel *titleL = [UILabel z_labelWithText:@"" Color:PBColor(40, 58, 79) isBold:YES Font:14];
|
titleL.numberOfLines = 3;
|
[self.contentView addSubview:titleL];
|
[titleL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(timeL.mas_bottom).offset(15);
|
make.left.equalTo(bgV).offset(10);
|
make.right.equalTo(bgV).offset(-10);
|
}];
|
UIImageView *typeImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"typebg"]];
|
[self.contentView addSubview:typeImageV];
|
[typeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(titleL);
|
make.left.equalTo(titleL);
|
make.size.mas_equalTo(CGSizeMake(62, 22));
|
}];
|
UILabel *typeL = [UILabel z_labelWithText:@"设计问题" Color:[UIColor whiteColor] isBold:YES Font:12];
|
typeL.textAlignment = NSTextAlignmentCenter;
|
[self.contentView addSubview:typeL];
|
[typeL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.left.right.equalTo(typeImageV);
|
}];
|
UIView *leftView = [[UIView alloc] init];
|
[self.contentView addSubview:leftView];
|
UIView *stateBgV = [[UIView alloc] init];
|
stateBgV.backgroundColor = PBColor(0, 122, 255);
|
[self.contentView addSubview:stateBgV];
|
UILabel *stateL = [UILabel z_labelWithText:@"" Color:PBColor(0, 122, 255) isBold:YES Font:12];
|
stateL.numberOfLines = 0;
|
stateL.textAlignment = NSTextAlignmentCenter;
|
[self.contentView addSubview:stateL];
|
UIView *rightView = [[UIView alloc] init];
|
rightView.backgroundColor = PBColor(244, 245, 246);
|
[self.contentView addSubview:rightView];
|
|
UIView *checkBgV = [[UIView alloc] init];
|
checkBgV.backgroundColor = PBColor(244, 245, 246);
|
[self.contentView addSubview:checkBgV];
|
UILabel *checkL = [UILabel z_labelWithText:@"" Color:PBColor(40, 58, 79) isBold:NO Font:14];
|
checkL.numberOfLines = 3;
|
[self.contentView addSubview:checkL];
|
[checkL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(checkBgV).offset(15);
|
make.left.equalTo(checkBgV).offset(8);
|
make.right.equalTo(checkBgV).offset(-8);
|
}];
|
[checkBgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(titleL.mas_bottom).offset(10);
|
make.left.equalTo(bgV).offset(50);
|
make.right.equalTo(bgV).offset(-10);
|
make.bottom.equalTo(checkL).offset(15);
|
}];
|
|
[stateBgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.equalTo(checkBgV);
|
make.left.equalTo(bgV).offset(10);
|
make.right.equalTo(checkBgV.mas_left);
|
}];
|
[stateL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(stateBgV).offset(10);
|
make.bottom.equalTo(stateBgV).offset(-10);
|
make.left.right.equalTo(stateBgV);
|
}];
|
[leftView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.right.bottom.equalTo(stateBgV);
|
make.width.equalTo(@10);
|
}];
|
[rightView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.left.equalTo(checkBgV);
|
make.width.equalTo(@10);
|
}];
|
|
UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout.alloc init];
|
layout.itemSize = CGSizeMake((MainScreenWidth - (20 * 2) - 1) / 2, 184);
|
layout.minimumLineSpacing = 1.f;
|
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
self.collectionView = [UICollectionView.alloc initWithFrame:CGRectZero collectionViewLayout:layout];
|
[self.collectionView registerClass:[PBImageCollectionViewCell class] forCellWithReuseIdentifier:ImageCellID];
|
self.collectionView.delegate = self;
|
self.collectionView.dataSource = self;
|
self.collectionView.bounces = NO;
|
self.collectionView.scrollEnabled = NO;
|
self.collectionView.showsHorizontalScrollIndicator = NO;
|
self.collectionView.backgroundColor = [UIColor whiteColor];
|
[self.contentView addSubview:self.collectionView];
|
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(checkBgV.mas_bottom).offset(10);
|
make.left.equalTo(self.contentView).offset(20);
|
make.right.equalTo(self.contentView).offset(-20);
|
make.height.equalTo(@184);
|
}];
|
UILabel *timeLimitL = [UILabel z_labelWithText:@"任务期限" Color:PBColor(166, 174, 182) isBold:YES Font:13];
|
[self.contentView addSubview:timeLimitL];
|
[timeLimitL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(self.collectionView.mas_bottom).offset(15);
|
make.left.equalTo(bgV).offset(10);
|
make.size.mas_equalTo(CGSizeMake(52, 16));
|
make.bottom.equalTo(bgV).offset(-10);
|
}];
|
UILabel *limitL = [UILabel z_labelWithText:@"" Color:PBColor(97, 111, 125) isBold:YES Font:13];
|
[self.contentView addSubview:limitL];
|
[limitL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(timeLimitL);
|
make.left.equalTo(timeLimitL.mas_right).offset(18);
|
}];
|
self.referredL = referredL;
|
self.checkNameL = checkNameL;
|
self.stateImageV = stateImageV;
|
self.originatorL = originatorL;
|
self.timeL = timeL;
|
self.titleL = titleL;
|
self.typeL = typeL;
|
self.stateBgV = stateBgV;
|
self.stateL = stateL;
|
self.checkL = checkL;
|
self.limitL = limitL;
|
self.checkBgV = checkBgV;
|
self.timeLimitL = timeLimitL;
|
self.leftView = leftView;
|
}
|
#pragma mark - UICollectionViewDataSource
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
return self.examineListModel.FirstCheck_Attachments.count;
|
}
|
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
NSDictionary *dict = self.examineListModel.FirstCheck_Attachments[indexPath.row];
|
PBImageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ImageCellID forIndexPath:indexPath];
|
NSString *url = [NSString stringWithFormat:@"%@%@",BaseUrl,[dict valueForKey:@"AttachmentUrl"]];
|
cell.roleType = PARTICIPANT;
|
cell.imageUrl = url;
|
return cell;
|
}
|
|
#pragma mark - UICollectionViewDelegate
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
SDPhotoBrowser *photoBrowser = [SDPhotoBrowser new];
|
photoBrowser.delegate = self;
|
photoBrowser.currentImageIndex = indexPath.item;
|
photoBrowser.imageCount = self.examineListModel.FirstCheck_Attachments.count;
|
photoBrowser.sourceImagesContainerView = self.collectionView;
|
[photoBrowser show];
|
}
|
|
#pragma mark SDPhotoBrowserDelegate
|
// 返回临时占位图片(即原来的小图)
|
- (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index
|
{
|
// 不建议用此种方式获取小图,这里只是为了简单实现展示而已
|
PBImageCollectionViewCell *cell = (PBImageCollectionViewCell *)[self collectionView:self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0]];
|
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:cell.imageUrl]];
|
UIImage *image = [UIImage imageWithData:data];;
|
return image;
|
}
|
- (void)setExamineListModel:(PBExamineListModel *)examineListModel {
|
_examineListModel = examineListModel;
|
BOOL isChiness = [self IsChinese:examineListModel.bu_checker_RealName];
|
if (isChiness) {
|
self.referredL.text = [examineListModel.bu_checker_RealName substringFromIndex:examineListModel.bu_checker_RealName.length - 1];
|
}else {
|
self.referredL.text = [examineListModel.bu_checker_RealName substringToIndex:1];
|
}
|
self.checkNameL.text = examineListModel.bu_checker_RealName;
|
NSString *flagStr = [examineListModel.ExamineResult substringToIndex:1];
|
if ([flagStr isEqualToString:@"A"]) {
|
self.stateImageV.image = [UIImage imageNamed:@"Rectify_ check"];
|
}else if ([flagStr isEqualToString:@"B"]) {
|
self.stateImageV.image = [UIImage imageNamed:@"Rectify_ rectification"];
|
}else if ([flagStr isEqualToString:@"C"]) {
|
self.stateImageV.image = [UIImage imageNamed:@"Rectify_ acceptance"];
|
}else if ([flagStr isEqualToString:@"D"]) {
|
self.stateImageV.image = [UIImage imageNamed:@"Rectify_ qualified"];
|
}else {
|
self.stateImageV.image = [UIImage imageNamed:@""];
|
}
|
self.originatorL.text = examineListModel.bu_examiner_name;
|
NSString *time = [examineListModel.CreateDate stringByReplacingOccurrencesOfString:@"T" withString:@" "];
|
self.timeL.text = [NSString stringWithFormat:@"于%@发起任务",time];
|
self.titleL.text = [NSString stringWithFormat:@"------- %@",examineListModel.ExamineRemark];
|
self.typeL.text = examineListModel.aedt_name;
|
NSRange range1 = [examineListModel.ExamineDate rangeOfString:@"T"];
|
NSRange range2 = [examineListModel.RectificateDate rangeOfString:@"T"];
|
NSString *start = [examineListModel.ExamineDate substringToIndex:range1.location];
|
NSString *end = [examineListModel.RectificateDate substringToIndex:range2.location];
|
self.limitL.text = [NSString stringWithFormat:@"%@ - %@",start, end];
|
if ([examineListModel.aede_severitylevel isEqualToString:@"一般"]) {
|
self.stateBgV.backgroundColor = PBColor(219, 232, 246);
|
self.leftView.backgroundColor = PBColor(219, 232, 246);
|
}else if ([examineListModel.aede_severitylevel isEqualToString:@"严重"]) {
|
self.stateBgV.backgroundColor = PBColor(245, 232, 220);
|
self.leftView.backgroundColor = PBColor(245, 232, 220);
|
}else if ([examineListModel.aede_severitylevel isEqualToString:@"非常严重"]) {
|
self.stateBgV.backgroundColor = PBColor(243, 222, 222);
|
self.leftView.backgroundColor = PBColor(243, 222, 222);
|
}else {
|
self.stateBgV.backgroundColor = PBColor(243, 222, 222);
|
self.leftView.backgroundColor = PBColor(243, 222, 222);
|
}
|
self.stateL.text = examineListModel.aede_severitylevel;
|
if (examineListModel.CacheRecordList.count > 0) {
|
self.checkL.text = [examineListModel.CacheRecordList[examineListModel.CacheRecordList.count - 1] valueForKey:@"RectificationRemark"];
|
}else {
|
self.checkL.text = @"内容错误";
|
}
|
[self.stateBgV circleViewWithRadius:6];
|
[self.checkBgV circleViewWithRadius:6];
|
[self.collectionView reloadData];
|
}
|
- (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;
|
}
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
[super setSelected:selected animated:animated];
|
|
// Configure the view for the selected state
|
}
|
@end
|