PurchaseCell.m 5.15 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
//
//  PurchaseCell.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/8/23.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "PurchaseCell.h"
#define TitleSize 16
#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);
陈俊俊's avatar
陈俊俊 committed
31
    self.stateBtn.titleLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
32 33 34 35
    [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
36
    self.billNumberLabel.textColor = GXF_CONTENT_COLOR;
陈俊俊's avatar
陈俊俊 committed
37
    self.billNumberLabel.font = GXF_SIXTEENTEH_SIZE;
陈俊俊's avatar
陈俊俊 committed
38
    
陈俊俊's avatar
陈俊俊 committed
39
    self.noticeNumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.billNumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
40
    self.noticeNumberLabel.numberOfLines = 0;
陈俊俊's avatar
陈俊俊 committed
41
    self.noticeNumberLabel.textColor = GXF_CELL_COLOR;
陈俊俊's avatar
陈俊俊 committed
42
    self.noticeNumberLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
43
    
陈俊俊's avatar
陈俊俊 committed
44 45 46 47 48
    self.vendorLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.noticeNumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
    self.vendorLabel.textColor = GXF_CELL_COLOR;
    self.vendorLabel.font = GXF_FOURTEENTH_SIZE;
    
    self.createOperNameLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.vendorLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
49
    self.createOperNameLabel.textColor = GXF_CELL_COLOR;
陈俊俊's avatar
陈俊俊 committed
50
    self.createOperNameLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
51 52 53
    
    
    self.createTimeLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.createOperNameLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
54
    self.createTimeLabel.textColor = GXF_CELL_COLOR;
陈俊俊's avatar
陈俊俊 committed
55
    self.createTimeLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
56 57
    
    self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin,TableHeight-1, ScreenSize.width - LeftMargin - TopMargin * 2, 1))];;
陈俊俊's avatar
陈俊俊 committed
58
    self.lineLabel.backgroundColor = GXF_LINE_COLOR;
陈俊俊's avatar
陈俊俊 committed
59 60 61 62
    
    [self.contentView addSubview:self.stateBtn];
    [self.contentView addSubview:self.billNumberLabel];
    [self.contentView addSubview:self.noticeNumberLabel];
陈俊俊's avatar
陈俊俊 committed
63
    [self.contentView addSubview:self.vendorLabel];
陈俊俊's avatar
陈俊俊 committed
64 65 66 67 68 69 70 71
    [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];
陈俊俊's avatar
陈俊俊 committed
72 73
    self.noticeNumberLabel.text = [NSString stringWithFormat:@"采购通知单号:%@",purchaseBill.noticeNumber.length > 0 ? purchaseBill.noticeNumber: @"无"];
    self.vendorLabel.text = [NSString stringWithFormat:@"供应商:%@[%@]",purchaseBill.vendor_name,purchaseBill.vendor_code] ;
陈俊俊's avatar
陈俊俊 committed
74 75 76
    self.createOperNameLabel.text = [NSString stringWithFormat:@"创建人:%@",purchaseBill.create_operName] ;
    self.createTimeLabel.text =[NSString stringWithFormat:@"创建时间:%@",purchaseBill.create_time];
    NSString *stateStr = @"";
n22's avatar
n22 committed
77
    if ([purchaseBill.state isEqualToString:PURCHASE_STATE_INITIAL]) {
陈俊俊's avatar
陈俊俊 committed
78 79
        stateStr = @"未提交";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"initial"]  forState:UIControlStateDisabled];
n22's avatar
n22 committed
80
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_SUBMITTED]) {
陈俊俊's avatar
陈俊俊 committed
81
        stateStr = @"未审批";
陈俊俊's avatar
陈俊俊 committed
82
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
n22's avatar
n22 committed
83
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_REJECTED]) {
陈俊俊's avatar
陈俊俊 committed
84
        stateStr = @"已拒绝";
陈俊俊's avatar
陈俊俊 committed
85
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"initial"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
86
        
87
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_SHIPPING]) {
陈俊俊's avatar
陈俊俊 committed
88 89 90
        stateStr = @"发运中";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
        
陈俊俊's avatar
陈俊俊 committed
91 92
    }
    else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_FINISHED]) {
陈俊俊's avatar
陈俊俊 committed
93 94
        stateStr = @"已完成";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
95 96 97
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_ABORTED]) {
        stateStr = @"已作废";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
    }
    [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