ProductBillCell.m 12.1 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
//
//  ProductCell.m
//  XFFruit
//
//  Created by n22 on 15/8/21.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

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

陈俊俊's avatar
陈俊俊 committed
18
#define ShowWidth (ScreenSize.width  - LeftMargin*2 - SmallSize)/2
陈俊俊's avatar
陈俊俊 committed
19
#define ShowHeight 20
陈俊俊's avatar
陈俊俊 committed
20

陈俊俊's avatar
陈俊俊 committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
@implementation ProductBillCell



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

- (void)bulidLayout
{
Sandy's avatar
Sandy committed
36
    CGFloat headWidth = (ScreenSize.width - LeftWidth*2 - SpaceMargin* (3 -1))/3;
陈俊俊's avatar
陈俊俊 committed
37 38 39 40 41 42 43 44 45 46 47
    
    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))];
陈俊俊's avatar
陈俊俊 committed
48
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
陈俊俊's avatar
陈俊俊 committed
49 50 51 52
    self.titleLabel.textColor = GXF_CONTENT_COLOR;
    self.titleLabel.font = GXF_SIXTEENTEH_SIZE;
    
    self.priceLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.titleLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
陈俊俊's avatar
陈俊俊 committed
53
    self.priceLabel.textAlignment = NSTextAlignmentCenter;
陈俊俊's avatar
陈俊俊 committed
54 55 56 57
    self.priceLabel.textColor = GXF_CONTENT_COLOR;
    self.priceLabel.font = GXF_SIXTEENTEH_SIZE;
    
    self.countLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.priceLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
陈俊俊's avatar
陈俊俊 committed
58
    self.countLabel.textAlignment = NSTextAlignmentCenter;
陈俊俊's avatar
陈俊俊 committed
59 60
    self.countLabel.textColor = GXF_CONTENT_COLOR;
    self.countLabel.font = GXF_SIXTEENTEH_SIZE;
陈俊俊's avatar
陈俊俊 committed
61
    
Sandy's avatar
Sandy committed
62 63 64 65
//    self.shippedQtyLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.countLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
//    self.shippedQtyLabel.textAlignment = NSTextAlignmentCenter;
//    self.shippedQtyLabel.textColor = GXF_CONTENT_COLOR;
//    self.shippedQtyLabel.font = GXF_SIXTEENTEH_SIZE;
陈俊俊's avatar
陈俊俊 committed
66 67 68 69 70

    
    self.showView = [[UIView alloc]initWithFrame:CGRectMake(0, TableHeight, ScreenSize.width, 0)];
    self.showView.clipsToBounds = YES;
    
陈俊俊's avatar
陈俊俊 committed
71 72 73 74 75 76
    self.showNameLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.seqLabel.frame), 0, ShowWidth*2, ShowHeight))];
    self.showNameLabel.textAlignment = NSTextAlignmentLeft;
    self.showNameLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showNameLabel.font = GXF_THREETEENTH_SIZE;
    
    self.showStandLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.seqLabel.frame), CGRectGetMaxY(self.showNameLabel.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
77 78 79 80
    self.showStandLabel.textAlignment = NSTextAlignmentLeft;
    self.showStandLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showStandLabel.font = GXF_THREETEENTH_SIZE;
    
陈俊俊's avatar
陈俊俊 committed
81
    self.showCountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.showStandLabel.frame), CGRectGetMaxY(self.showNameLabel.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
    self.showCountLabel.textAlignment = NSTextAlignmentLeft;
    self.showCountLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showCountLabel.font = GXF_THREETEENTH_SIZE;
    
    self.showBaseCountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showStandLabel.frame), ShowWidth, ShowHeight))];
    self.showBaseCountLabel.textAlignment = NSTextAlignmentLeft;
    self.showBaseCountLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showBaseCountLabel.font = GXF_THREETEENTH_SIZE;
    
    self.showPriceLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showCountLabel.frame), CGRectGetMaxY(self.showStandLabel.frame), ShowWidth, ShowHeight))];
    self.showPriceLabel.textAlignment = NSTextAlignmentLeft;
    self.showPriceLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showPriceLabel.font = GXF_THREETEENTH_SIZE;
    
    self.showBasePriceLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showBaseCountLabel.frame), ShowWidth, ShowHeight))];
    self.showBasePriceLabel.textAlignment = NSTextAlignmentLeft;
    self.showBasePriceLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showBasePriceLabel.font = GXF_THREETEENTH_SIZE;
    
    self.showTotalLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showCountLabel.frame), CGRectGetMaxY(self.showBaseCountLabel.frame), ShowWidth, ShowHeight))];
    self.showTotalLabel.textAlignment = NSTextAlignmentLeft;
    self.showTotalLabel.textColor = GXF_PLACEHOLDER_COLOR;
    self.showTotalLabel.font = GXF_THREETEENTH_SIZE;
    
Sandy's avatar
Sandy committed
106 107 108 109 110 111
    self.showCounterNum = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showBasePriceLabel.frame), ShowWidth, 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.showStandLabel.frame), CGRectGetMaxY(self.showCounterNum.frame), ShowWidth, ShowHeight))];
陈俊俊's avatar
陈俊俊 committed
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
    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.priceLabel];
    [self.contentView addSubview:self.countLabel];
陈俊俊's avatar
陈俊俊 committed
131 132
    [self.contentView addSubview:self.shippedQtyLabel];

陈俊俊's avatar
陈俊俊 committed
133 134 135
    [self.contentView addSubview:self.editBtn];
    [self.contentView addSubview:self.showView];
    
陈俊俊's avatar
陈俊俊 committed
136
    [self.showView addSubview:self.showNameLabel];
陈俊俊's avatar
陈俊俊 committed
137 138 139 140 141 142
    [self.showView addSubview:self.showStandLabel];
    [self.showView addSubview:self.showCountLabel];
    [self.showView addSubview:self.showBaseCountLabel];
    [self.showView addSubview:self.showPriceLabel];
    [self.showView addSubview:self.showBasePriceLabel];
    [self.showView addSubview:self.showTotalLabel];
Sandy's avatar
Sandy committed
143
    [self.showView addSubview:self.showCounterNum];
陈俊俊's avatar
陈俊俊 committed
144 145 146 147
    [self.showView addSubview:self.showNoteLabel];
    [self.contentView addSubview:self.lineLabel];
    
}
zhu's avatar
zhu committed
148

陈俊俊's avatar
陈俊俊 committed
149 150
- (void)setBillProduct:(PurchaseBillProduct *)billProduct row:(NSInteger)row
{
151
    //查看采购单cell上面顶上的商品、单价、包装数量等
陈俊俊's avatar
陈俊俊 committed
152 153
    self.seqLabel.text = [NSString stringWithFormat:@"%@",@(row+1)];
    self.titleLabel.text = billProduct.product_name;
陈俊俊's avatar
陈俊俊 committed
154
    self.priceLabel.text = [NSString stringWithFormat:@"%.2f元",[billProduct.basePrice floatValue]];
陈俊俊's avatar
陈俊俊 committed
155
    self.countLabel.text = [NSString stringWithFormat:@"%@%@",[billProduct.qty stringValue],billProduct.unit];
156
    self.shippedQtyLabel.text = [NSString stringWithFormat:@"%@%@",billProduct.shippedQty ? [billProduct.shippedQty stringValue]:@"0",billProduct.unit];
陈俊俊's avatar
陈俊俊 committed
157 158
    
    self.showNameLabel.text = [NSString stringWithFormat:@"商品:%@[%@]",billProduct.product_name,billProduct.product_code];
陈俊俊's avatar
陈俊俊 committed
159
    self.showStandLabel.text = [NSString stringWithFormat:@"包装规格:1*%@%@",[billProduct.qpc stringValue],billProduct.baseUnit];
Sandy's avatar
Sandy committed
160 161
    self.showCountLabel.text = [NSString stringWithFormat:@"包装数量:%@%@",billProduct.qty,billProduct.unit];
    self.showBaseCountLabel.text =[NSString stringWithFormat:@"基础数量:%@%@",billProduct.baseQty ,billProduct.baseUnit];
162
    self.showPriceLabel.text = [NSString stringWithFormat:@"包装单价:%.4f元",[billProduct.price floatValue]];
163
    self.showBasePriceLabel.text = [NSString stringWithFormat:@"基础单价:%.4f元",[billProduct.basePrice floatValue]];
Sandy's avatar
Sandy committed
164
    self.showTotalLabel.text = [NSString stringWithFormat:@"总金额:%@元",[billProduct.total stringValue]];
陈俊俊's avatar
陈俊俊 committed
165
    self.showNoteLabel.text =[NSString stringWithFormat:@"备注:%@",billProduct.remark ? billProduct.remark :@"无" ];
Sandy's avatar
Sandy committed
166
    self.showCounterNum.text = [NSString stringWithFormat:@"柜号:%@", billProduct.vnum];
陈俊俊's avatar
陈俊俊 committed
167 168 169 170
    [self isShowShippingQty:billProduct];
}

- (void)isShowShippingQty:(PurchaseBillProduct *)billProduct{
陈俊俊's avatar
陈俊俊 committed
171
    if(self.editBtn.hidden){
Sandy's avatar
Sandy committed
172
        self.showShippedFlag.frame = CGRectMake(CGRectGetMinX(self.showCountLabel.frame), CGRectGetMaxY(self.showTotalLabel.frame), ShowWidth, ShowHeight);
陈俊俊's avatar
陈俊俊 committed
173 174 175 176
        self.showShippedFlag.textAlignment = NSTextAlignmentLeft;
        self.showShippedFlag.textColor = GXF_PLACEHOLDER_COLOR;
        self.showShippedFlag.text = @"是否发运:未";
        self.showShippedFlag.font = GXF_THREETEENTH_SIZE;
Sandy's avatar
Sandy committed
177 178 179 180 181 182
        //showStandLabel是包装规格,showCountLabel是包装数量
        self.showShippedBaseQty.frame = (CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showCounterNum.frame), ShowWidth, ShowHeight));
        self.showShippedBaseQty.textAlignment = NSTextAlignmentLeft;
        self.showShippedBaseQty.textColor = GXF_PLACEHOLDER_COLOR;
        self.showShippedBaseQty.text = @"发运基础数量:";
        self.showShippedBaseQty.font = GXF_THREETEENTH_SIZE;
陈俊俊's avatar
陈俊俊 committed
183
        
Sandy's avatar
Sandy committed
184
        self.showShippedQty.frame = (CGRectMake(CGRectGetMinX(self.showCountLabel.frame), CGRectGetMaxY(self.showShippedFlag.frame), ShowWidth, ShowHeight));
陈俊俊's avatar
陈俊俊 committed
185 186 187 188 189 190
        self.showShippedQty.textAlignment = NSTextAlignmentLeft;
        self.showShippedQty.textColor = GXF_PLACEHOLDER_COLOR;
        self.showShippedQty.text = @"发运包装数量:";
        self.showShippedQty.font = GXF_THREETEENTH_SIZE;
        
        
Sandy's avatar
Sandy committed
191
        self.showNoteLabel.frame = CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showShippedBaseQty.frame), ShowWidth, ShowHeight);
陈俊俊's avatar
陈俊俊 committed
192 193 194 195 196 197
    }
    NSMutableAttributedString *attributeStr1 = [IBTCommon setTextViewFontOfString:@"发运状态:" paragraphStyle:0 fontSize:13 color:GXF_CELL_COLOR];
    NSString *str = [NSString stringWithFormat:@"%@",[billProduct.shippedFlag integerValue] == 0 ? @"未完成":@"已完成"];
    [attributeStr1 appendAttributedString:[IBTCommon setTextViewFontOfString:str paragraphStyle:0 fontSize:13 color:[UIColor redColor]]];
    self.showShippedFlag.attributedText = attributeStr1;

198 199
    self.showShippedBaseQty.text = [NSString stringWithFormat:@"发运包装数量:%@%@",billProduct.shippedQty ? [billProduct.shippedQty stringValue]:@"0",billProduct.unit];
    self.showShippedQty.text = [NSString stringWithFormat:@"发运基础数量:%@%@",billProduct.shippedBaseQty ? [billProduct.shippedBaseQty stringValue]:@"0",billProduct.baseUnit];
陈俊俊's avatar
陈俊俊 committed
200 201 202
    [self.showView addSubview:self.showShippedFlag];
    [self.showView addSubview:self.showShippedQty];
    [self.showView addSubview:self.showShippedBaseQty];
陈俊俊's avatar
陈俊俊 committed
203 204
}

Sandy's avatar
Sandy committed
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
- (UILabel *)showShippedFlag {
    if (!_showShippedFlag) {
        _showShippedFlag = [UILabel new];
        [_showView addSubview:_showShippedFlag];
    }
    return _showShippedFlag;
}

- (UILabel *)showShippedQty {
    if (!_showShippedQty) {
        _showShippedQty = [UILabel new];
        [_showView addSubview:_showShippedQty];
    }
    return _showShippedQty;
}

- (UILabel *)showShippedBaseQty {
    if (!_showShippedBaseQty) {
        _showShippedBaseQty = [UILabel new];
        [_showView addSubview:_showShippedBaseQty];
    }
    return _showShippedBaseQty;
}
陈俊俊's avatar
陈俊俊 committed
228 229 230 231 232 233 234 235
- (void)awakeFromNib {
}

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

@end