PurchaseCell.m 6.52 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;
32 33
//    self.stateBtn.backgroundColor = [UIColor redColor];

陈俊俊's avatar
陈俊俊 committed
34 35 36 37
    [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
38
    self.billNumberLabel.textColor = GXF_CONTENT_COLOR;
陈俊俊's avatar
陈俊俊 committed
39
    self.billNumberLabel.font = GXF_SIXTEENTEH_SIZE;
陈俊俊's avatar
陈俊俊 committed
40
    
陈俊俊's avatar
陈俊俊 committed
41
    self.noticeNumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.billNumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
42
    self.noticeNumberLabel.numberOfLines = 0;
陈俊俊's avatar
陈俊俊 committed
43
    self.noticeNumberLabel.textColor = GXF_CELL_COLOR;
陈俊俊's avatar
陈俊俊 committed
44
    self.noticeNumberLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
45
    
陈俊俊's avatar
陈俊俊 committed
46 47 48 49 50
    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
51
    self.createOperNameLabel.textColor = GXF_CELL_COLOR;
陈俊俊's avatar
陈俊俊 committed
52
    self.createOperNameLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
53 54 55
    
    
    self.createTimeLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.createOperNameLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
陈俊俊's avatar
陈俊俊 committed
56
    self.createTimeLabel.textColor = GXF_CELL_COLOR;
陈俊俊's avatar
陈俊俊 committed
57
    self.createTimeLabel.font = GXF_FOURTEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
58 59
    
    self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin,TableHeight-1, ScreenSize.width - LeftMargin - TopMargin * 2, 1))];;
陈俊俊's avatar
陈俊俊 committed
60
    self.lineLabel.backgroundColor = GXF_LINE_COLOR;
陈俊俊's avatar
陈俊俊 committed
61 62 63 64
    
    [self.contentView addSubview:self.stateBtn];
    [self.contentView addSubview:self.billNumberLabel];
    [self.contentView addSubview:self.noticeNumberLabel];
陈俊俊's avatar
陈俊俊 committed
65
    [self.contentView addSubview:self.vendorLabel];
陈俊俊's avatar
陈俊俊 committed
66 67 68 69 70 71 72 73
    [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
74 75
    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
76 77 78
    self.createOperNameLabel.text = [NSString stringWithFormat:@"创建人:%@",purchaseBill.create_operName] ;
    self.createTimeLabel.text =[NSString stringWithFormat:@"创建时间:%@",purchaseBill.create_time];
    NSString *stateStr = @"";
79 80 81
//    if ([purchaseBill.vendor_code isEqualToString:@"0000"]) {
//        purchaseBill.state = PURCHASE_STATE_PROCESS;
//    }
n22's avatar
n22 committed
82
    if ([purchaseBill.state isEqualToString:PURCHASE_STATE_INITIAL]) {
83
        self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
陈俊俊's avatar
陈俊俊 committed
84 85
        stateStr = @"未提交";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"initial"]  forState:UIControlStateDisabled];
n22's avatar
n22 committed
86
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_SUBMITTED]) {
87
         self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
陈俊俊's avatar
陈俊俊 committed
88
        stateStr = @"未审批";
陈俊俊's avatar
陈俊俊 committed
89
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
n22's avatar
n22 committed
90
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_REJECTED]) {
91
         self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
陈俊俊's avatar
陈俊俊 committed
92
        stateStr = @"已拒绝";
陈俊俊's avatar
陈俊俊 committed
93
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"initial"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
94
        
95
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_SHIPPING]) {
96
         self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
陈俊俊's avatar
陈俊俊 committed
97 98
        stateStr = @"发运中";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
99 100
    }
    else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_FINISHED]) {
101
         self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
陈俊俊's avatar
陈俊俊 committed
102 103
        stateStr = @"已完成";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
104
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_ABORTED]) {
105
         self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
陈俊俊's avatar
陈俊俊 committed
106 107
        stateStr = @"已作废";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
108 109 110 111 112 113 114 115
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_PROCESS]) {
//         self.stateBtn.frame = CGRectMake(0 , TopMargin, LeftMargin - TopMargin, 20);
        stateStr = @"提交系统处理";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
    }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_PROCESSFAIL]) {
//         self.stateBtn.frame = CGRectMake(0 , TopMargin, LeftMargin - TopMargin, 20);
        stateStr = @"系统处理失败";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
116
    }
117
    
陈俊俊's avatar
陈俊俊 committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
    [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