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
//
//  PBTaskHeaderView.m
//  IphoneBIMe
//
//  Created by ZhangJF on 2022/9/20.
//  Copyright © 2022 ProBIM. All rights reserved.
//
 
#import "PBTaskHeaderView.h"
#import "PBSchedulePlanModel.h"
 
@interface PBTaskHeaderView()<UITextFieldDelegate>
@property (nonatomic, weak) UILabel *nameL;
@property (nonatomic, weak) UILabel *dateL;
@property (nonatomic, copy) NSString *currentDate;
@property (nonatomic, weak) UITextField *unitTF;
@end
@implementation PBTaskHeaderView
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    self.backgroundColor = [UIColor whiteColor];
    UIView *iconV = [[UIView alloc] init];
    iconV.backgroundColor = PBColor(95, 158, 249);
    [self addSubview:iconV];
    [iconV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(20);
        make.size.mas_equalTo(CGSizeMake(6, 20));
        make.left.equalTo(self);
    }];
    UILabel *titleL = [UILabel z_labelWithText:@"基本信息" Color:[UIColor z_colorWithR:95 G:158 B:249] isBold:YES Font:18];
    [self addSubview:titleL];
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(iconV);
        make.left.equalTo(iconV.mas_right).offset(5);
    }];
    UILabel *planNameL = [UILabel z_labelWithText:@"计划名称: " Color:[UIColor z_colorWithR:51 G:51 B:51] isBold:YES Font:14];
    [self addSubview:planNameL];
    [planNameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(iconV.mas_bottom).offset(14);
        make.left.equalTo(self).offset(12);
        make.height.equalTo(@16);
    }];
    UILabel *nameL = [UILabel z_labelWithText:@"新建隆子机场总进度" Color:[UIColor z_colorWithR:108 G:108 B:108] isBold:NO Font:14];
    [self addSubview:nameL];
    [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(planNameL);
        make.left.equalTo(planNameL.mas_right);
        make.height.equalTo(@16);
    }];
    
    UILabel *unitL = [UILabel z_labelWithText:@"施工单位: " Color:[UIColor z_colorWithR:51 G:51 B:51] isBold:YES Font:14];
    [self addSubview:unitL];
    [unitL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(planNameL.mas_bottom).offset(8);
        make.left.equalTo(self).offset(12);
        make.height.equalTo(@44);
    }];
    UITextField *unitTF = [[UITextField alloc] init];
    unitTF.placeholder = @"请输入...";
    unitTF.textAlignment= NSTextAlignmentLeft;
    unitTF.textColor = PBColor(108, 108, 108);
    unitTF.font = [UIFont fontWithName:Coarse size:14.0];
    unitTF.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    unitTF.delegate = self;
    unitTF.layer.cornerRadius = 4;
    unitTF.layer.borderWidth = 1.f;
    unitTF.layer.borderColor = [[UIColor z_colorWithR:108 G:108 B:108] CGColor];
    unitTF.leftViewMode = UITextFieldViewModeAlways;
    unitTF.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 12, 44)];
    [self addSubview:unitTF];
    [unitTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(unitL);
        make.right.equalTo(self).offset(-12);
        make.height.equalTo(@44);
        make.width.equalTo(@(self.width - 98));
    }];
    
    UILabel *fillDateL = [UILabel z_labelWithText:@"填报日期: " Color:[UIColor z_colorWithR:51 G:51 B:51] isBold:YES Font:14];
    [self addSubview:fillDateL];
    [fillDateL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(unitL.mas_bottom).offset(8);
        make.left.equalTo(self).offset(12);
        make.height.equalTo(@44);
    }];
    UIButton *borderV = [[UIButton alloc] init];
    [borderV addTarget:self action:@selector(chooseDate) forControlEvents:UIControlEventTouchUpInside];
    borderV.layer.cornerRadius = 4;
    borderV.layer.borderWidth = 1.f;
    borderV.layer.borderColor = [[UIColor z_colorWithR:108 G:108 B:108] CGColor];
    [self addSubview:borderV];
    [borderV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(fillDateL);
//        make.left.equalTo(fillDateL.mas_right);
        make.right.equalTo(self).offset(-12);
        make.height.equalTo(@44);
        make.width.equalTo(@(self.width - 98));
    }];
    
    UILabel *dateL = [UILabel z_labelWithText:@"" Color:[UIColor z_colorWithR:108 G:108 B:108] isBold:NO Font:14];
    [self addSubview:dateL];
    [dateL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(borderV).offset(12);
        make.centerY.equalTo(borderV);
    }];
    UIImageView *chooseDateV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"date_btn"]];
    [self addSubview:chooseDateV];
    [chooseDateV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(borderV).offset(10);
        make.right.equalTo(borderV).offset(-10);
        make.size.mas_equalTo(CGSizeMake(24, 24));
    }];
    UIView *linV = [[UIView alloc] init];
    linV.backgroundColor = PBColor(243, 243, 244);
    [self addSubview:linV];
    [linV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@2);
        make.left.right.bottom.equalTo(self);
    }];
    self.nameL = nameL;
    self.dateL = dateL;
    self.unitTF = unitTF;
}
- (void)chooseDate {
    if (self.ChooseDate) {
        self.ChooseDate();
    }
}
- (void)setSchedulePlanModel:(PBSchedulePlanModel *)schedulePlanModel {
    _schedulePlanModel = schedulePlanModel;
    self.nameL.text = schedulePlanModel.Name;
}
- (void)setFillDate:(NSString *)fillDate {
    _fillDate = fillDate;
    self.dateL.text = fillDate;
}
- (void)setUnitText:(NSString *)unitText {
    _unitText = unitText;
    self.unitTF.text = unitText;
}
#pragma mark - UITextFieldDelegate
- (void)textFieldDidEndEditing:(UITextField *)textField{
    self.unitText = textField.text;
    if (self.textEditBlock) {
        self.textEditBlock(textField.text);
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
 
@end