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
//
//  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