ReceiveProductCell.m 13.4 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
//
//  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
{
    
35
    CGFloat headWidth = (ScreenSize.width - LeftWidth*2 - SpaceMargin* (4 -1))/4;
陈俊俊's avatar
陈俊俊 committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
    
    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;
    
51 52 53 54 55 56
    self.qpcLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.titleLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
    self.qpcLabel.textAlignment = NSTextAlignmentCenter;
    self.qpcLabel.textColor = GXF_CONTENT_COLOR;
    self.qpcLabel.font = GXF_SIXTEENTEH_SIZE;
    
    self.dscountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.qpcLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
陈俊俊's avatar
陈俊俊 committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
    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
80 81 82 83 84 85 86 87 88 89 90 91 92 93
    
    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
94 95 96 97
    self.showbzCountLabel.textAlignment = NSTextAlignmentLeft;
    self.showbzCountLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showbzCountLabel.font = GXF_THREETEENTH_SIZE;
    
陈俊俊's avatar
陈俊俊 committed
98
    self.showshCountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showbzdwLabel.frame), CGRectGetMaxY(self.showjcPriceLabel.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
    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
115
    self.showTotalLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showjcCountLabel.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
116 117 118 119
    self.showTotalLabel.textAlignment = NSTextAlignmentLeft;
    self.showTotalLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showTotalLabel.font = GXF_THREETEENTH_SIZE;
    
陈俊俊's avatar
陈俊俊 committed
120
    self.showshTotalLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showbzdwLabel.frame), CGRectGetMaxY(self.showjcCountLabel.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
121 122 123 124 125
    self.showshTotalLabel.textAlignment = NSTextAlignmentLeft;
    self.showshTotalLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showshTotalLabel.font = GXF_THREETEENTH_SIZE;
    
    
Sandy's avatar
Sandy committed
126 127 128 129 130 131
    self.showCounterNum = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showTotalLabel.frame), ShowWidth*2, ShowHeight))];
    self.showCounterNum.textAlignment = NSTextAlignmentLeft;
    self.showCounterNum.textColor = GXF_PLACEHOLDER_COLOR;
    self.showCounterNum.font = GXF_THREETEENTH_SIZE;
    
    self.showNoteLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showbzdwLabel.frame), CGRectGetMaxY(self.showTotalLabel.frame), ShowWidth*2, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
132 133 134 135
    self.showNoteLabel.textAlignment = NSTextAlignmentLeft;
    self.showNoteLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showNoteLabel.font = GXF_THREETEENTH_SIZE;
    
136 137 138 139 140 141 142 143 144 145 146 147
    self.showCheckPrice = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showCounterNum.frame), ShowWidth*2, ShowHeight))];
    self.showCheckPrice.textAlignment = NSTextAlignmentLeft;
    self.showCheckPrice.textColor = GXF_PLACEHOLDER_COLOR;
    self.showCheckPrice.font = GXF_THREETEENTH_SIZE;
    self.showCheckPrice.text = @"考核单价:0.00";
    
    self.showCheckTotal = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showbzdwLabel.frame), CGRectGetMaxY(self.showCounterNum.frame), ShowWidth*2, ShowHeight))];
    self.showCheckTotal.textAlignment = NSTextAlignmentLeft;
    self.showCheckTotal.textColor = GXF_PLACEHOLDER_COLOR;
    self.showCheckTotal.font = GXF_THREETEENTH_SIZE;
    self.showCheckTotal.text = @"考核总金额:0.00";
    
陈俊俊's avatar
陈俊俊 committed
148 149 150 151 152 153 154 155 156 157 158
    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];
159
    [self.contentView addSubview:self.qpcLabel];
陈俊俊's avatar
陈俊俊 committed
160 161 162 163 164 165 166 167 168 169 170
    [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];
Sandy's avatar
Sandy committed
171
    [self.showView addSubview:self.showCounterNum];
陈俊俊's avatar
陈俊俊 committed
172
    [self.showView addSubview:self.showjcPriceLabel];
173 174
    [self.showView addSubview:self.showCheckPrice];
    [self.showView addSubview:self.showCheckTotal];
陈俊俊's avatar
陈俊俊 committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188
    
    [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;
189
    self.qpcLabel.text = [transferProduct.qpcStr stringByAppendingString:transferProduct.baseUnit];
Sandy's avatar
Sandy committed
190
    self.dscountLabel.text = [NSString stringWithFormat:@"%lu%@",transferProduct.qty.integerValue - transferProduct.rctQty.integerValue,transferProduct.unit];
陈俊俊's avatar
陈俊俊 committed
191 192
    self.yscountLabel.text = [NSString stringWithFormat:@"%@%@",transferProduct.rctQty?[transferProduct.rctQty stringValue]:@"0",transferProduct.unit];
    self.showStandLabel.text = [NSString stringWithFormat:@"包装规格:1*%@%@",[transferProduct.qpc stringValue],transferProduct.baseUnit];
陈俊俊's avatar
陈俊俊 committed
193 194
    self.showbzdwLabel.text = [NSString stringWithFormat:@"包装单位:%@",transferProduct.unit];
    
陈俊俊's avatar
陈俊俊 committed
195 196
    self.showbzCountLabel.text =[NSString stringWithFormat:@"包装数量:%@%@",[transferProduct.qty stringValue],transferProduct.unit];
    self.showshCountLabel.text =[NSString stringWithFormat:@"包装数量[实收]:%@%@",transferProduct.rctQty?([transferProduct.rctQty stringValue]):@"0",transferProduct.unit];
Sandy's avatar
Sandy committed
197 198 199
    if (transferProduct.rctQty == nil) {
        self.showshCountLabel.text = @"包装数量[实收]:空";
    }
陈俊俊's avatar
陈俊俊 committed
200
    
陈俊俊's avatar
陈俊俊 committed
201
    self.showjcCountLabel.text = [NSString stringWithFormat:@"基础数量:%@%@",[transferProduct.baseQty stringValue],transferProduct.baseUnit];
陈俊俊's avatar
陈俊俊 committed
202
    
陈俊俊's avatar
陈俊俊 committed
203
    self.showshjcCountLabel.text = [NSString stringWithFormat:@"基础数量[实收]:%@%@",transferProduct.rctBaseQty?[transferProduct.rctBaseQty stringValue]:@"0",transferProduct.baseUnit];
Sandy's avatar
Sandy committed
204 205 206
    if (transferProduct.rctBaseQty == nil) {
        self.showshjcCountLabel.text = @"基础数量[实收]:空";
    }
Sandy's avatar
Sandy committed
207 208
    self.showbzPriceLabel.text = [NSString stringWithFormat:@"包装单价:%.4f元",[transferProduct.packprice floatValue]];
    self.showjcPriceLabel.text = [NSString stringWithFormat:@"基础单价:%.4f元",[transferProduct.price floatValue]];
陈俊俊's avatar
陈俊俊 committed
209
    
Sandy's avatar
Sandy committed
210
    self.showshTotalLabel.text = [NSString stringWithFormat:@"总金额[实收]:%.4f元",
Sandy's avatar
Sandy committed
211
                                  transferProduct.rctQty.doubleValue * transferProduct.packprice.doubleValue];
Sandy's avatar
Sandy committed
212 213 214
    if (transferProduct.rctTotal == nil) {
        self.showshTotalLabel.text = @"总金额[实收]:空";
    }
陈俊俊's avatar
陈俊俊 committed
215
    
Sandy's avatar
Sandy committed
216 217
    self.showCounterNum.text = [NSString stringWithFormat:@"柜号:%@", transferProduct.vnum ? transferProduct.vnum : @""];
    
Sandy's avatar
Sandy committed
218
    self.showTotalLabel.text = [NSString stringWithFormat:@"总金额:%.4f元",
Sandy's avatar
Sandy committed
219
                                transferProduct.packprice.doubleValue * transferProduct.qty.doubleValue];
陈俊俊's avatar
陈俊俊 committed
220
    self.showNoteLabel.text =[NSString stringWithFormat:@"备注:%@",transferProduct.note ? transferProduct.note :@"无" ];
Sandy's avatar
Sandy committed
221
    self.showCheckPrice.text = [NSString stringWithFormat:@"考核单价:%.4f元", transferProduct.checkPrice.doubleValue];
222
    
Sandy's avatar
Sandy committed
223
    self.showCheckTotal.text = [NSString stringWithFormat:@"考核总金额:%.4f元", transferProduct.checkTotal.doubleValue];
224
    
陈俊俊's avatar
陈俊俊 committed
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
    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