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
//
//  PBPositionTableViewCell1.m
//  IphoneBIMe
//
//  Created by zjf on 2019/1/11.
//  Copyright © 2019 ProBIM. All rights reserved.
//
 
#import "PBPositionTableViewCell.h"
#import "PBIssueAddModel.h"
#import "PBViewPointModel.h"
 
@interface PBPositionTableViewCell ()
@property (nonatomic, weak) UILabel *titleL;
@property (nonatomic, weak) UILabel *nameL;
@property (nonatomic, weak) UIImageView *imageV;
@property (nonatomic, weak) UIButton *selectBtn;
@property (nonatomic, weak) UIButton *openBtn;
@end
@implementation PBPositionTableViewCell
 
- (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:TitleFontSize];
    [self.contentView addSubview:titleL];
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(16);
        make.left.equalTo(self.contentView).offset(16);
        make.height.equalTo(@22);
    }];
    UIButton *selectBtn = [UIButton z_textButton:@"请选择" fontSize:MarkedFontSize normalColor:TitleColor];
    [selectBtn addTarget:self action:@selector(selectbtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:selectBtn];
    [selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-16);
        make.centerY.equalTo(titleL);
    }];
    
    UIImageView *imageV = [[UIImageView alloc] init];
    [self.contentView addSubview:imageV];
    [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo (titleL.mas_bottom).offset(16);
        make.left.equalTo(self.contentView).offset(16);
        make.size.mas_equalTo(CGSizeMake(120, 120));
    }];
    
    UILabel *nameL = [UILabel z_labelWithText:@"图纸名称" Color:TitleColor isBold:NO Font:TitleFontSize];
    [self.contentView addSubview:nameL];
    [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imageV);
        make.left.equalTo(imageV.mas_right).offset(16);
        make.right.equalTo(self.contentView).offset(-16);
        make.height.equalTo(@22);
    }];
    
    UIButton *openBtn = [UIButton z_textButton:@"打开图纸" fontSize:MarkedFontSize normalColor:IndicatedColor];
    [openBtn addTarget:self action:@selector(openbtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:openBtn];
    [openBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-16);
        make.bottom.equalTo(imageV);
    }];
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.bottom.equalTo(titleL.mas_bottom).offset(26);
    }];
    
    self.titleL = titleL;
    self.nameL = nameL;
    self.imageV = imageV;
    self.selectBtn = selectBtn;
    self.openBtn = openBtn;
}
 
- (void)selectbtnAction:(UIButton *)button {
    if (self.issueAddModel.roleType != CREATOR) {
        return;
    }
    if (self.ChoosePositionBlock) {
        self.ChoosePositionBlock();
    }
}
 
- (void)openbtnAction:(UIButton *)button {
    if (self.OpenPositionBlock) {
        self.OpenPositionBlock();
    }
}
 
- (void)setIssueAddModel:(PBIssueAddModel *)issueAddModel {
    _issueAddModel = issueAddModel;
    self.titleL.text = issueAddModel.title;
    if (issueAddModel.roleType == CREATOR) {
        [self.selectBtn setTitleColor:TitleColor forState:UIControlStateNormal];
    }else {
        [self.selectBtn setTitleColor:PromptColor forState:UIControlStateNormal];
    }
    if ([issueAddModel.key isEqualToString:@"viewPoint"]) {
        if (issueAddModel.veiwPointModel == nil) {
            [self.selectBtn setTitle:issueAddModel.prompt forState:UIControlStateNormal];
            self.nameL.hidden = YES;
            self.imageV.hidden = YES;
            self.openBtn.hidden = YES;
            [self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.left.right.equalTo(self);
                make.bottom.equalTo(self.titleL.mas_bottom).offset(26);
            }];
        }else {
            self.nameL.hidden = NO;
            self.imageV.hidden = NO;
            self.openBtn.hidden = NO;
            [self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.left.right.equalTo(self);
                make.bottom.equalTo(self.imageV.mas_bottom).offset(26);
            }];
            [self.selectBtn setTitle:@"更多操作" forState:UIControlStateNormal];
            [self.openBtn setTitle:@"打开视点" forState:UIControlStateNormal];
            self.nameL.text = self.issueAddModel.veiwPointModel.Name;
            if (issueAddModel.veiwPointModel.Links.count == 0){
                self.imageV.image = [UIImage imageNamed:@"Issue_viewPoint_fail"];
            }else {
                NSString *thumbnail = [issueAddModel.veiwPointModel.Links[0] valueForKey:@"Content"];
                NSRange range = [thumbnail rangeOfString:@"base64,"];
                thumbnail = [thumbnail substringFromIndex:range.location + range.length];
                self.imageV.image = [NSString imageDecoding:thumbnail];
            }
        }
    }else {
        if (self.issueAddModel.drawingsInfoModel == nil) {
            [self.selectBtn setTitle:issueAddModel.prompt forState:UIControlStateNormal];
            self.nameL.hidden = YES;
            self.imageV.hidden = YES;
            self.openBtn.hidden = YES;
            [self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.left.right.equalTo(self);
                make.bottom.equalTo(self.titleL.mas_bottom).offset(26);
            }];
        }else {
            self.nameL.hidden = NO;
            self.imageV.hidden = NO;
            self.openBtn.hidden = NO;
            [self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.left.right.equalTo(self);
                make.bottom.equalTo(self.imageV.mas_bottom).offset(26);
            }];
            [self.selectBtn setTitle:@"更多操作" forState:UIControlStateNormal];
            [self.openBtn setTitle:@"打开图纸" forState:UIControlStateNormal];
            self.nameL.text = self.issueAddModel.drawingsInfoModel.name;
            self.imageV.image = [NSString imageDecoding:self.issueAddModel.drawingsInfoModel.imagebase64];
        }  
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
@end