SurveyListCell.m 4.43 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9
//
//  SurveyListCell.m
//  XFFurit
//
//  Created by 陈俊俊 on 15/8/1.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "SurveyListCell.h"
10
#define LeftMargin 90
陈俊俊's avatar
陈俊俊 committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#define TopMargin 10
#define TitleHeight 20
#define TableHeight 120
@implementation SurveyListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self bulidLayout];
    }
    return self;
}

- (void)bulidLayout
{
    self.stateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
28
    self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
陈俊俊's avatar
陈俊俊 committed
29
    self.stateBtn.titleLabel.font = GXF_FOURTEENTH_SIZE;
n22's avatar
n22 committed
30
    [self.stateBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
陈俊俊's avatar
陈俊俊 committed
31 32 33
    self.stateBtn.enabled = NO;
    
    self.titleLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, TopMargin, ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
34 35
    self.titleLabel.textColor = GXF_CONTENT_COLOR;
    self.titleLabel.font = GXF_SIXTEENTEH_SIZE;
陈俊俊's avatar
陈俊俊 committed
36 37
    
    self.billnumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.titleLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
38 39
    self.billnumberLabel.textColor = GXF_CELL_COLOR;
    self.billnumberLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
40 41
    
    self.productnameLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.billnumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
42 43
    self.productnameLabel.textColor = GXF_CELL_COLOR;
    self.productnameLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
44 45 46
    
    
    self.begindateLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.productnameLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
47 48
    self.begindateLabel.textColor = GXF_CELL_COLOR;
    self.begindateLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
49 50
    
    self.enddateLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.begindateLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
51 52
    self.enddateLabel.textColor = GXF_CELL_COLOR;
    self.enddateLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
53 54
    
    self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin,TableHeight-1, ScreenSize.width - LeftMargin - TopMargin * 2, 1))];;
陈俊俊's avatar
陈俊俊 committed
55
    self.lineLabel.backgroundColor = GXF_LINE_COLOR;
陈俊俊's avatar
陈俊俊 committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69
    
    [self.contentView addSubview:self.stateBtn];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.billnumberLabel];
    [self.contentView addSubview:self.productnameLabel];
    [self.contentView addSubview:self.begindateLabel];
    [self.contentView addSubview:self.enddateLabel];
    [self.contentView addSubview:self.lineLabel];

}


- (void)setSurvey:(Survey *)survey{
    self.titleLabel.text = survey.title;
陈俊俊's avatar
陈俊俊 committed
70 71
    self.billnumberLabel.text = [NSString stringWithFormat:@"单号:%@",survey.billNumber];
    self.productnameLabel.text = [NSString stringWithFormat:@"商品:%@[%@]",survey.productName,survey.productCode];
72 73
    self.begindateLabel.text = [NSString stringWithFormat:@"开始时间:%@",survey.beginDate.length > 10 ? [survey.beginDate substringToIndex:10] :survey.beginDate];
    self.enddateLabel.text = [NSString stringWithFormat:@"结束时间:%@",survey.endDate.length > 10 ? [survey.endDate substringToIndex:10] :survey.endDate];
n22's avatar
n22 committed
74
    NSString *stateStr = @"";
n22's avatar
n22 committed
75
    if ([survey.state isEqualToString:SURVEY_STATE_INITIAL]) {
n22's avatar
n22 committed
76 77
        stateStr = @"未提交";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"initial"]  forState:UIControlStateDisabled];
n22's avatar
n22 committed
78
    }else if ([survey.state isEqualToString:SURVEY_STATE_SUBMITTED]) {
n22's avatar
n22 committed
79 80
        stateStr = @"已提交";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
n22's avatar
n22 committed
81
    }else if ([survey.state isEqualToString:SURVEY_STATE_INSURVEY]) {
n22's avatar
n22 committed
82 83
        stateStr = @"调研中";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
84
        
n22's avatar
n22 committed
85
    }else if ([survey.state isEqualToString:SURVEY_STATE_FINISHED]) {
n22's avatar
n22 committed
86 87
        stateStr = @"已完成";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
88
    }
n22's avatar
n22 committed
89
    [self.stateBtn setTitle:stateStr forState:UIControlStateNormal];
陈俊俊's avatar
陈俊俊 committed
90 91 92 93 94 95 96
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end