zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
//
//  PBExamineListMorePicCell.m
//  IphoneBIMe
//
//  Created by zjf on 2020/11/5.
//  Copyright © 2020 ProBIM. All rights reserved.
//
 
#import "PBExamineListMorePicCell.h"
#import "PBExamineListModel.h"
#import "PBImageCollectionViewCell.h"
static NSString *const ImageCellID = @"ImageCellID";
@interface PBExamineListMorePicCell()<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 PBExamineListMorePicCell
 
- (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 + 3) * 2) / 3, 92);
    layout.minimumLineSpacing = 3.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(@92);
    }];
    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;
    if (self.examineListModel.FirstCheck_Attachments.count > 3 & indexPath.item == 2) {
        cell.countStr = [NSString stringWithFormat:@"%zd", self.examineListModel.FirstCheck_Attachments.count];
    }else {
        cell.countStr = nil;
    }
    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