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
//
//  PBMoreChooseTableViewCell.m
//  IphoneBIMe
//
//  Created by zjf on 2018/12/13.
//  Copyright © 2018 ProBIM. All rights reserved.
//
 
#import "PBMoreChooseTableViewCell.h"
#import "PBExamineAddModel.h"
@interface PBMoreChooseTableViewCell()
@property (nonatomic, weak) UILabel *titleL;
@property (nonatomic, weak) UILabel *divisionL;
@property (nonatomic, weak) UILabel *itemizedL;
@property (nonatomic, weak) UILabel *inspectionL;
@end
@implementation PBMoreChooseTableViewCell
 
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    UILabel *titleL = [UILabel z_labelWithText:@"" Color:PromptColor isBold:NO Font:DescFontSize];
    titleL.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:titleL];
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(16);
        make.right.equalTo(self.contentView).offset(-16);
        make.height.equalTo(@20);
    }];
    
    UILabel *divisionL = [UILabel z_labelWithText:@"" Color:IgnoreColor isBold:NO Font:MarkedFontSize];
    divisionL.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:divisionL];
    [divisionL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleL.mas_bottom).offset(16);
        make.left.equalTo(self.contentView).offset(16);
        make.right.equalTo(self.contentView).offset(-16);
        make.height.equalTo(@25);
    }];
    UILabel *itemizedL = [UILabel z_labelWithText:@"" Color:TitleColor isBold:NO Font:MarkedFontSize];
    itemizedL.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:itemizedL];
    [itemizedL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(divisionL.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).offset(16);
        make.right.equalTo(self.contentView).offset(-16);
        make.height.equalTo(@25);
    }];
    UILabel *inspectionL = [UILabel z_labelWithText:@"" Color:TitleColor isBold:NO Font:MarkedFontSize];
    inspectionL.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:inspectionL];
    [inspectionL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(itemizedL.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).offset(16);
        make.right.equalTo(self.contentView).offset(-16);
        make.height.equalTo(@25);
    }];
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.bottom.equalTo(inspectionL.mas_bottom).offset(16);
    }];
    UIButton *clickBtn = [[UIButton alloc] init];
    [self.contentView addSubview:clickBtn];
    [clickBtn addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
    [clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.equalTo(self.contentView);
    }];
    self.titleL = titleL;
    self.divisionL = divisionL;
    self.itemizedL = itemizedL;
    self.inspectionL = inspectionL;
}
- (void)clickAction {
    if (self.ChooseBlock) {
        self.ChooseBlock();
    }
}
 
- (void)setDataArr:(NSArray<PBExamineAddModel *> *)dataArr {
    _dataArr = dataArr;
    if (dataArr.count == 3) {
        PBExamineAddModel *divisionModel = dataArr[0];
        PBExamineAddModel *itemizedModel = dataArr[1];
        PBExamineAddModel *inspectionModel = dataArr[2];
        self.titleL.text = [NSString stringWithFormat:@"%@-%@-%@(选填)",divisionModel.title, itemizedModel.title, inspectionModel.title];
        if (divisionModel.dataDict) {
            if (!itemizedModel.dataDict) {
                NSDictionary *dict = @{
                                       @"name":@"<无分项工程>",
                                       @"value":@"",
                                       @"children":@""
                                       };
                itemizedModel.dataDict = dict;
            }
            if (!inspectionModel.dataDict) {
                NSDictionary *dict = @{
                                       @"name":@"<无检验批>",
                                       @"value":@"",
                                       @"children":@""
                                       };
                inspectionModel.dataDict = dict;
            }
            self.itemizedL.hidden = NO;
            self.inspectionL.hidden = NO;
            self.divisionL.text = [divisionModel.dataDict valueForKey:@"name"];
            self.itemizedL.text = [itemizedModel.dataDict valueForKey:@"name"];
            self.inspectionL.text = [inspectionModel.dataDict valueForKey:@"name"];
            self.divisionL.textColor = TitleColor;
            [self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.left.right.equalTo(self);
                make.bottom.equalTo(self.inspectionL.mas_bottom).offset(16);
            }];
        }else {
            self.itemizedL.hidden = YES;
            self.inspectionL.hidden = YES;
            self.divisionL.textColor = DescColor;
            self.divisionL.text = divisionModel.prompt;
            [self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.left.right.equalTo(self);
                make.bottom.equalTo(self.divisionL.mas_bottom).offset(16);
            }];
        }
    }else {
        NSLog(@"数据错误");
    }
}
 
@end