LookOnLineTableViewCell.m 11.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
//
//  LookOnLineTableViewCell.m
//  redstar
//
//  Created by admin on 15/11/28.
//  Copyright © 2015年 ZWF. All rights reserved.
//

#import "LookOnLineTableViewCell.h"

@implementation LookOnLineTableViewCell

admin's avatar
admin committed
13 14 15 16 17
- (void)setLookOnLine:(LookOnLineModel *)lookOnLine
{
    _lookOnLine = lookOnLine;
    self.titleLabel.text = [NSString stringWithFormat:@"%@", lookOnLine.title];
    //self.peopleLabel.text = [NSString stringWithFormat:@"发起人:%@", lookOnLine.]
18 19 20 21
    self.peopleLabel.text = [NSString stringWithFormat:@"发起人:%@", lookOnLine.create_operName];
    //self.startDateLabel.text = [NSString stringWithFormat:@"%@", lookOnLine.create_time];
    
   // self.peopleLabel.text = @"发起人:王XX 集团XX总";
admin's avatar
admin committed
22
    
admin's avatar
admin committed
23
    if (lookOnLine.create_time == nil || lookOnLine.create_time == NULL || [lookOnLine.create_time isEqual:[NSNull null]] || lookOnLine.create_time == Nil || [lookOnLine.create_time isEqualToString:@"(null)"]) {
admin's avatar
admin committed
24 25
        self.startDate.text = [NSString stringWithFormat:@"发起时间:"];
    } else {
admin's avatar
admin committed
26
        self.startDate.text = [[NSString stringWithFormat:@"发起时间:%@", lookOnLine.create_time] substringToIndex:15];
admin's avatar
admin committed
27 28 29 30 31 32 33 34 35
    }
    
    if (lookOnLine.endDate == nil || lookOnLine.endDate == NULL || [lookOnLine.endDate isEqual:[NSNull null]] || lookOnLine.endDate == Nil || [lookOnLine.endDate isEqualToString:@"(null)"]) {
        self.overDate.text = [NSString stringWithFormat:@"截止时间:"];
    } else {
        self.overDate.text = [[NSString stringWithFormat:@"截止时间:%@", lookOnLine.endDate] substringToIndex:15];
    }

    
admin's avatar
admin committed
36
    //self.progressLabel.text = @"临检进度:进行中";
admin's avatar
admin committed
37 38
    
    if ([lookOnLine.state isEqualToString:@"initial"]) {
admin's avatar
admin committed
39
        NSString *str = [NSString stringWithFormat:@"任务状态:未处理"];
admin's avatar
admin committed
40 41 42 43 44
        NSMutableAttributedString *strAttr = [[NSMutableAttributedString alloc] initWithString:str];
        [strAttr addAttributes:@{NSForegroundColorAttributeName:kCellDetailColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,5)];
        [strAttr addAttributes:@{NSForegroundColorAttributeName:kProgressUnSettledColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(5,str.length - 5)];
        [self.progressLabel setAttributedText:strAttr];
    } else if ([lookOnLine.state isEqualToString:@"reported"]) {
admin's avatar
admin committed
45
        NSString *str = [NSString stringWithFormat:@"任务状态:已上报"];
admin's avatar
admin committed
46 47 48 49 50
        NSMutableAttributedString *strAttr = [[NSMutableAttributedString alloc] initWithString:str];
        [strAttr addAttributes:@{NSForegroundColorAttributeName:kCellDetailColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,5)];
        [strAttr addAttributes:@{NSForegroundColorAttributeName:kProgressDealWithColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(5,str.length - 5)];
        [self.progressLabel setAttributedText:strAttr];
    } else if ([lookOnLine.state isEqualToString:@"finished"]) {
admin's avatar
admin committed
51
        NSString *str = [NSString stringWithFormat:@"任务状态:已完成"];
admin's avatar
admin committed
52 53 54 55 56
        NSMutableAttributedString *strAttr = [[NSMutableAttributedString alloc] initWithString:str];
        [strAttr addAttributes:@{NSForegroundColorAttributeName:kCellDetailColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,5)];
        [strAttr addAttributes:@{NSForegroundColorAttributeName:kProgressDealWithColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(5,str.length - 5)];
        [self.progressLabel setAttributedText:strAttr];
    } else {
admin's avatar
admin committed
57
        NSString *str = [NSString stringWithFormat:@"任务状态:"];
admin's avatar
admin committed
58 59 60 61 62
        self.progressLabel.text = str;
    }
}


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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
#pragma mark - lazy Loading
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = kCellTitleColor;
        _titleLabel.font = [UIFont systemFontOfSize:19.0];
        _titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
        [self.contentView addSubview:_titleLabel];
        
        NSLayoutConstraint *titleLabelTop = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
        [self.contentView addConstraint:titleLabelTop];
        
        NSLayoutConstraint *titleLabelLeft = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self.contentView addConstraint:titleLabelLeft];
        
        NSLayoutConstraint *startDateRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self.contentView addConstraint:startDateRight];
        
        NSLayoutConstraint *titleLabelHeight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
        [self.contentView addConstraint:titleLabelHeight];
    }
    return _titleLabel;
}

- (UILabel *)peopleLabel
{
    if (!_peopleLabel) {
        _peopleLabel = [[UILabel alloc] init];
        _peopleLabel.translatesAutoresizingMaskIntoConstraints = NO;
        _peopleLabel.font = [UIFont systemFontOfSize:14.0];
        _peopleLabel.textColor = kCellDetailColor;
        [self.contentView addSubview:_peopleLabel];
        
        NSLayoutConstraint *startDateTop = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:2];
        [self.contentView addConstraint:startDateTop];
        
        NSLayoutConstraint *startDateLeft = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self.contentView addConstraint:startDateLeft];
        
        NSLayoutConstraint *startDateRight = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self.contentView addConstraint:startDateRight];
        
        NSLayoutConstraint *startDateHeight = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:20];
        [self.contentView addConstraint:startDateHeight];
        
    }
    return _peopleLabel;

}

- (UILabel *)startDate
{
    if (!_startDate) {
        _startDate = [[UILabel alloc] init];
        _startDate.translatesAutoresizingMaskIntoConstraints = NO;
        _startDate.font = [UIFont systemFontOfSize:14.0];
        _startDate.textColor = kCellDetailColor;
        [self.contentView addSubview:_startDate];
        
        NSLayoutConstraint *startDateTop = [NSLayoutConstraint constraintWithItem:_startDate attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.peopleLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:2];
        [self.contentView addConstraint:startDateTop];
        
        NSLayoutConstraint *startDateLeft = [NSLayoutConstraint constraintWithItem:_startDate attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self.contentView addConstraint:startDateLeft];
        
        NSLayoutConstraint *startDateRight = [NSLayoutConstraint constraintWithItem:_startDate attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self.contentView addConstraint:startDateRight];
        
        NSLayoutConstraint *startDateHeight = [NSLayoutConstraint constraintWithItem:_startDate attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:20];
        [self.contentView addConstraint:startDateHeight];
        
    }
    return _startDate;
}

- (UILabel *)overDate
{
    if (!_overDate) {
        _overDate = [[UILabel alloc] init];
        _overDate.font = [UIFont systemFontOfSize:14.0];
        _overDate.textColor = kCellDetailColor;
        _overDate.translatesAutoresizingMaskIntoConstraints = NO;
        [self.contentView addSubview:_overDate];
        
        NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_overDate attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.startDate attribute:NSLayoutAttributeBottom multiplier:1.0 constant:2];
        [self.contentView addConstraint:overDateTop];
        
        NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_overDate attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self.contentView addConstraint:overDateLeft];
        
        NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_overDate attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self.contentView addConstraint:overDateRight];
        
        NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_overDate attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:20];
        [self.contentView addConstraint:overDateHeight];
    }
    return _overDate;
}

- (UILabel *)progressLabel
{
    if (!_progressLabel) {
        _progressLabel = [[UILabel alloc] init];
        _progressLabel.translatesAutoresizingMaskIntoConstraints = NO;
        _progressLabel.font = [UIFont systemFontOfSize:14.0];
        _progressLabel.textColor = kCellDetailColor;
        [self.contentView addSubview:_progressLabel];
        
        NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_progressLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.overDate attribute:NSLayoutAttributeBottom multiplier:1.0 constant:2];
        [self.contentView addConstraint:overDateTop];
        
        NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_progressLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self.contentView addConstraint:overDateLeft];
        
        NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_progressLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
        [self.contentView addConstraint:overDateRight];

        
        NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_progressLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:20];
        [self.contentView addConstraint:overDateHeight];
        
        NSLayoutConstraint *overDateBottom = [NSLayoutConstraint constraintWithItem:_progressLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
        [self.contentView addConstraint:overDateBottom];
    }
    return _progressLabel;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end