ReceiveProductCell.m 10.7 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
//
//  ReceiveProductCell.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/10/15.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "ReceiveProductCell.h"
#define LeftMargin 13
#define TableHeight 44
#define SmallSize 10
#define SmallWidth 20
#define SpaceMargin 1
#define LeftWidth 45
#define RightWidth 30

#define ShowWidth (ScreenSize.width  - LeftMargin*2 - SmallSize)/2
#define ShowHeight 20


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

- (void)bulidLayout
{
    
    CGFloat headWidth = (ScreenSize.width - LeftWidth*2 - SpaceMargin* (3 -1))/3;
    
    self.smallImageView = [[UIImageView alloc]initWithFrame:CGRectMake(LeftMargin, (TableHeight - SmallSize)/2 , SmallSize, SmallSize)];
    self.smallImageView.image = [UIImage imageNamed:@"arrowright"];
    self.smallImageView.contentMode = UIViewContentModeScaleAspectFit;
    
    self.seqLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.smallImageView.frame), 0, SmallWidth, TableHeight))];
    self.seqLabel.textColor = GXF_CONTENT_COLOR;
    self.seqLabel.text = @"13";
    self.seqLabel.font = GXF_SIXTEENTEH_SIZE;
    
    self.titleLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftWidth, 0, headWidth, TableHeight))];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.textColor = GXF_CONTENT_COLOR;
    self.titleLabel.font = GXF_SIXTEENTEH_SIZE;
    
    self.dscountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.titleLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
    self.dscountLabel.textAlignment = NSTextAlignmentCenter;
    self.dscountLabel.textColor = GXF_CONTENT_COLOR;
    self.dscountLabel.font = GXF_SIXTEENTEH_SIZE;
    
    self.yscountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.dscountLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
    self.yscountLabel.textAlignment = NSTextAlignmentCenter;
    self.yscountLabel.textColor = GXF_CONTENT_COLOR;
    self.yscountLabel.font = GXF_SIXTEENTEH_SIZE;
    
    
    self.showView = [[UIView alloc]initWithFrame:CGRectMake(0, TableHeight, ScreenSize.width, 0)];
    self.showView.clipsToBounds = YES;
    
    self.showStandLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.seqLabel.frame), 0, ShowWidth, ShowHeight))];
    self.showStandLabel.textAlignment = NSTextAlignmentLeft;
    self.showStandLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showStandLabel.font = GXF_THREETEENTH_SIZE;
    
    self.showbzdwLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.showStandLabel.frame), 0, ShowWidth, ShowHeight))];
    self.showbzdwLabel.textAlignment = NSTextAlignmentLeft;
    self.showbzdwLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showbzdwLabel.font = GXF_THREETEENTH_SIZE;
    
陈俊俊's avatar
陈俊俊 committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88
    
    self.showjcPriceLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showStandLabel.frame), ShowWidth, ShowHeight))];
    self.showjcPriceLabel.textAlignment = NSTextAlignmentLeft;
    self.showjcPriceLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showjcPriceLabel.font = GXF_THREETEENTH_SIZE;
    
    
    self.showbzPriceLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showbzdwLabel.frame), CGRectGetMaxY(self.showStandLabel.frame), ShowWidth, ShowHeight))];
    self.showbzPriceLabel.textAlignment = NSTextAlignmentLeft;
    self.showbzPriceLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showbzPriceLabel.font = GXF_THREETEENTH_SIZE;
    
    
    self.showbzCountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showjcPriceLabel.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
89 90 91 92
    self.showbzCountLabel.textAlignment = NSTextAlignmentLeft;
    self.showbzCountLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showbzCountLabel.font = GXF_THREETEENTH_SIZE;
    
陈俊俊's avatar
陈俊俊 committed
93
    self.showshCountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showbzdwLabel.frame), CGRectGetMaxY(self.showjcPriceLabel.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
    self.showshCountLabel.textAlignment = NSTextAlignmentLeft;
    self.showshCountLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showshCountLabel.font = GXF_THREETEENTH_SIZE;
    
    self.showjcCountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showbzCountLabel.frame), ShowWidth, ShowHeight))];
    self.showjcCountLabel.textAlignment = NSTextAlignmentLeft;
    self.showjcCountLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showjcCountLabel.font = GXF_THREETEENTH_SIZE;
    
    self.showshjcCountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showbzdwLabel.frame), CGRectGetMaxY(self.showbzCountLabel.frame), ShowWidth, ShowHeight))];
    self.showshjcCountLabel.textAlignment = NSTextAlignmentLeft;
    self.showshjcCountLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showshjcCountLabel.font = GXF_THREETEENTH_SIZE;
    
    
    
陈俊俊's avatar
陈俊俊 committed
110
    self.showTotalLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showjcCountLabel.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
111 112 113 114
    self.showTotalLabel.textAlignment = NSTextAlignmentLeft;
    self.showTotalLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showTotalLabel.font = GXF_THREETEENTH_SIZE;
    
陈俊俊's avatar
陈俊俊 committed
115
    self.showshTotalLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showbzdwLabel.frame), CGRectGetMaxY(self.showjcCountLabel.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
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
    self.showshTotalLabel.textAlignment = NSTextAlignmentLeft;
    self.showshTotalLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showshTotalLabel.font = GXF_THREETEENTH_SIZE;
    
    
    self.showNoteLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showTotalLabel.frame), ShowWidth*2, ShowHeight))];
    self.showNoteLabel.textAlignment = NSTextAlignmentLeft;
    self.showNoteLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showNoteLabel.font = GXF_THREETEENTH_SIZE;
    
    self.editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.editBtn setImage:[UIImage imageNamed:@"edit"] forState:UIControlStateNormal];
    self.editBtn.frame = CGRectMake(ScreenSize.width - LeftWidth, 0, LeftWidth , TableHeight);
    self.editBtn.contentMode = UIViewContentModeScaleAspectFit;
    
    self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin,TableHeight-1, ScreenSize.width  - LeftMargin * 2, 1))];;
    self.lineLabel.backgroundColor = GXF_LINE_COLOR;
    
    [self.contentView addSubview:self.smallImageView];
    [self.contentView addSubview:self.seqLabel];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.dscountLabel];
    [self.contentView addSubview:self.yscountLabel];
    [self.contentView addSubview:self.editBtn];
    [self.contentView addSubview:self.showView];
    
    [self.showView addSubview:self.showStandLabel];
    [self.showView addSubview:self.showbzdwLabel];
    [self.showView addSubview:self.showbzCountLabel];
    [self.showView addSubview:self.showshCountLabel];
    [self.showView addSubview:self.showjcCountLabel];
    [self.showView addSubview:self.showshjcCountLabel];
    
    [self.showView addSubview:self.showjcPriceLabel];
    
    [self.showView addSubview:self.showbzPriceLabel];
    [self.showView addSubview:self.showTotalLabel];
    [self.showView addSubview:self.showshTotalLabel];

    [self.showView addSubview:self.showNoteLabel];
    [self.contentView addSubview:self.lineLabel];
    
}

- (void)setBillProduct:(TransferPdtDetail *)transferProduct row:(NSInteger)row defaultState:(NSString *)state
{
    self.seqLabel.text = [NSString stringWithFormat:@"%@",@(row+1)];
    self.titleLabel.text = transferProduct.productName;
    self.dscountLabel.text = [NSString stringWithFormat:@"%@%@",transferProduct.qty,transferProduct.unit];
    self.yscountLabel.text = [NSString stringWithFormat:@"%@%@",transferProduct.rctQty?transferProduct.rctQty:@"0",transferProduct.unit];
    self.showStandLabel.text = [NSString stringWithFormat:@"包装规格:1*%@%@",transferProduct.qpc,transferProduct.baseUnit];
    self.showbzdwLabel.text = [NSString stringWithFormat:@"包装单位:%@",transferProduct.unit];
    
    self.showbzCountLabel.text =[NSString stringWithFormat:@"包装数量:%@%@",transferProduct.qty,transferProduct.unit];
陈俊俊's avatar
陈俊俊 committed
170
    self.showshCountLabel.text =[NSString stringWithFormat:@"包装数量[实收]:%@%@",transferProduct.rctQty?(transferProduct.rctQty):@"0",transferProduct.unit];
陈俊俊's avatar
陈俊俊 committed
171 172 173
    
    self.showjcCountLabel.text = [NSString stringWithFormat:@"基础数量:%@%@",transferProduct.baseQty,transferProduct.baseUnit];
    
陈俊俊's avatar
陈俊俊 committed
174
    self.showshjcCountLabel.text = [NSString stringWithFormat:@"基础数量[实收]:%@%@",transferProduct.rctBaseQty?transferProduct.rctBaseQty:@"0",transferProduct.baseUnit];
陈俊俊's avatar
陈俊俊 committed
175 176 177 178
    
    self.showbzPriceLabel.text = [NSString stringWithFormat:@"包装单价:%@元",transferProduct.packprice];
    self.showjcPriceLabel.text = [NSString stringWithFormat:@"基础单价:%@元",transferProduct.price];
    
陈俊俊's avatar
陈俊俊 committed
179
    self.showshTotalLabel.text = [NSString stringWithFormat:@"总金额[实收]:%@元",transferProduct.rctTotal?transferProduct.rctTotal:@"0"];
陈俊俊's avatar
陈俊俊 committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
    
    self.showTotalLabel.text = [NSString stringWithFormat:@"总金额:%@元",transferProduct.total?transferProduct.total:@"0"];
    self.showNoteLabel.text =[NSString stringWithFormat:@"备注:%@",transferProduct.note ? transferProduct.note :@"无" ];
    if ([state isEqualToString:@"YES"]) {
        if ([transferProduct.qty floatValue] > [transferProduct.rctQty floatValue]) {
            self.yscountLabel.textColor = [UIColor redColor];
            self.showshCountLabel.textColor = [UIColor redColor];
        }else{
            self.yscountLabel.textColor = GXF_NAVIGAYION_COLOR;
            self.showshCountLabel.textColor = GXF_NAVIGAYION_COLOR;
        }
        if ([transferProduct.baseQty floatValue] > [transferProduct.rctBaseQty floatValue]) {
            self.showshjcCountLabel.textColor = [UIColor redColor];
        }else{
            self.showshjcCountLabel.textColor = GXF_NAVIGAYION_COLOR;
        }
        if ([transferProduct.total floatValue] > [transferProduct.rctTotal floatValue]) {
            self.showshTotalLabel.textColor = [UIColor redColor];
        }else{
            self.showshTotalLabel.textColor = GXF_NAVIGAYION_COLOR;
        }
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end