PurchaseCell.m 4.71 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
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
//
//  PurchaseCell.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/8/23.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "PurchaseCell.h"
#define TitleSize 16
#define ContentSize 14
#define LeftMargin 90
#define TopMargin 10
#define TitleHeight 20
#define TableHeight 120

@implementation PurchaseCell

- (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];
    self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
    self.stateBtn.titleLabel.font = FontSize(ContentSize);
    [self.stateBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.stateBtn.enabled = NO;
    
    self.billNumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, TopMargin, ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
37
    self.billNumberLabel.textColor = GXF_CONTENT_COLOR;
陈俊俊's avatar
陈俊俊 committed
38 39 40 41
    self.billNumberLabel.font = FontSize(TitleSize);
    
    self.noticeNumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.billNumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight*2))];
    self.noticeNumberLabel.numberOfLines = 0;
陈俊俊's avatar
陈俊俊 committed
42
    self.noticeNumberLabel.textColor = GXF_CELL_COLOR;
陈俊俊's avatar
陈俊俊 committed
43 44 45
    self.noticeNumberLabel.font = FontSize(ContentSize);
    
    self.createOperNameLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.noticeNumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
46
    self.createOperNameLabel.textColor = GXF_CELL_COLOR;
陈俊俊's avatar
陈俊俊 committed
47 48 49 50
    self.createOperNameLabel.font = FontSize(ContentSize);
    
    
    self.createTimeLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.createOperNameLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
51
    self.createTimeLabel.textColor = GXF_CELL_COLOR;
陈俊俊's avatar
陈俊俊 committed
52 53 54
    self.createTimeLabel.font = FontSize(ContentSize);
    
    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 70 71
    
    [self.contentView addSubview:self.stateBtn];
    [self.contentView addSubview:self.billNumberLabel];
    [self.contentView addSubview:self.noticeNumberLabel];
    [self.contentView addSubview:self.createOperNameLabel];
    [self.contentView addSubview:self.createTimeLabel];
    [self.contentView addSubview:self.lineLabel];
    
}

- (void)setPurchaseBill:(PurchaseBill *)purchaseBill{
    self.billNumberLabel.text = [NSString stringWithFormat:@"单号:%@",purchaseBill.billNumber];
    self.noticeNumberLabel.text = [NSString stringWithFormat:@"采购通知单:%@",purchaseBill.noticeNumber];
    self.createOperNameLabel.text = [NSString stringWithFormat:@"创建人:%@",purchaseBill.create_operName] ;
    self.createTimeLabel.text =[NSString stringWithFormat:@"创建时间:%@",purchaseBill.create_time];
    NSString *stateStr = @"";
n22's avatar
n22 committed
72
    if ([purchaseBill.state isEqualToString:PURCHASE_STATE_INITIAL]) {
陈俊俊's avatar
陈俊俊 committed
73 74
        stateStr = @"未提交";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"initial"]  forState:UIControlStateDisabled];
n22's avatar
n22 committed
75
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_SUBMITTED]) {
陈俊俊's avatar
陈俊俊 committed
76 77
        stateStr = @"已提交";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
n22's avatar
n22 committed
78
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_REJECTED]) {
陈俊俊's avatar
陈俊俊 committed
79 80 81
        stateStr = @"已拒绝";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
        
n22's avatar
n22 committed
82
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_APPROVED]) {
陈俊俊's avatar
陈俊俊 committed
83 84 85
        stateStr = @"已审批";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
        
n22's avatar
n22 committed
86
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_SHIPPING]) {
陈俊俊's avatar
陈俊俊 committed
87 88 89
        stateStr = @"发运中";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
        
n22's avatar
n22 committed
90
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_FINISHED]) {
陈俊俊's avatar
陈俊俊 committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
        stateStr = @"已完成";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
    }
    [self.stateBtn setTitle:stateStr forState:UIControlStateNormal];
}







- (void)awakeFromNib {
    // Initialization code
}

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

    // Configure the view for the selected state
}

@end