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