| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- //
- // InventoryCell.m
- // IBOSSmini
- //
- // Created by apple on 2017/5/16.
- // Copyright © 2017年 elongtian. All rights reserved.
- //
- #import "InventoryCell.h"
- #import "NSString+Tools.h"
- @implementation InventoryCell
- /**
- 后台代码创建单元cell
-
- @param style <#style description#>
- @param reuseIdentifier <#reuseIdentifier description#>
- @return <#return value description#>
- */
- - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- self.layer.cornerRadius = 10;
- self.backgroundColor = [UIColor whiteColor];
- return self;
- }
- /**
- model
- @param m <#m description#>
- */
- - (void)setModel:(InventoryModel *)m{
- CGFloat heightLine = 1;
- CGFloat heightRow = 40;
- CGFloat lblx = 20;
- CGFloat lbly = 8;
- CGFloat lblwidth = 70;
- CGFloat lblsubwidth = 40;
- CGFloat lblheight = 25;
-
- CGFloat valuex = 90;
- CGFloat valuey = 8;
- CGFloat valuewidth = 120;
- CGFloat valueheight = 25;
-
- //title==================
- UIView *vTitle = [UIView new];
- vTitle.frame=CGRectMake(0, 0, Screen_Width, 0);
- vTitle.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:vTitle];
-
- //商品编码==================
- UIView *vcode = [UIView new];
- vcode.frame=CGRectMake(0, CGRectGetMaxY(vTitle.frame), Screen_Width, heightRow);
- [self.contentView addSubview:vcode];
- UILabel *lblcode=[UILabel new];
- lblcode.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
- lblcode.text=@"商品编码:";
- lblcode.textColor = [UIColor blackColor];
- lblcode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vcode addSubview:lblcode];
- _code = [UILabel new];
- _code.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
- _code.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _code.text = m.code;
- [vcode addSubview:_code];
-
- //分割线
- UIView *viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vcode.frame), Screen_Width, heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:viewBackgroud];
-
- UIView *vgoodname = [UIView new];
- vgoodname.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, heightRow);
- [self.contentView addSubview:vgoodname];
- UILabel *lblgoodname =[UILabel new];
- lblgoodname.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
- lblgoodname.text=@"商品名称:";
- lblgoodname.textColor = LabelGrayTextColor;
- lblgoodname.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vgoodname addSubview:lblgoodname];
- _goodName = [UILabel new];
- _goodName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
- _goodName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _goodName.text = m.goodsName;
- [vgoodname addSubview:_goodName];
- //品牌 唯一编码==================
- UIView *vOnlyCodeAndBrand = [UIView new];
- vOnlyCodeAndBrand.frame=CGRectMake(0, CGRectGetMaxY(vgoodname.frame), Screen_Width, heightRow);
- [self.contentView addSubview:vOnlyCodeAndBrand];
-
- UIView *vBrand = [UIView new];
- vBrand.frame=CGRectMake(0, 0, Screen_Width/3, heightRow);
- [vOnlyCodeAndBrand addSubview:vBrand];
-
- UILabel *lblBrand=[UILabel new];
- lblBrand.frame=CGRectMake(lblx, lbly, lblsubwidth, lblheight);
- lblBrand.text=@"品牌:";
- lblBrand.textColor = LabelGrayTextColor;
- lblBrand.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vBrand addSubview:lblBrand];
- _brandName = [UILabel new];
- _brandName.frame=CGRectMake(CGRectGetMaxX(lblBrand.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblBrand.frame), valueheight);
- _brandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _brandName.text = m.brandName;
- [vBrand addSubview:_brandName];
-
- UIView *vOnlyCode = [UIView new];
- vOnlyCode.frame=CGRectMake(Screen_Width/3, 0, Screen_Width/3*2, heightRow);
- [vOnlyCodeAndBrand addSubview:vOnlyCode];
-
- UILabel *lblOnlyCode=[UILabel new];
- lblOnlyCode.frame=CGRectMake(2, lbly, lblwidth, lblheight);
- lblOnlyCode.text=@"唯一编码:";
- lblOnlyCode.textColor = LabelGrayTextColor;
- lblOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vOnlyCode addSubview:lblOnlyCode];
- _onlyCode = [UILabel new];
- _onlyCode.frame = CGRectMake(CGRectGetMaxX(lblOnlyCode.frame), valuey, Screen_Width/3*2 - CGRectGetMaxX(lblOnlyCode.frame) - lblx/2, valueheight);
- _onlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _onlyCode.text = m.onlyCode;
- [vOnlyCode addSubview:_onlyCode];
-
- //色号 规格 等级==================
- UIView *vColorAndSpecificationAndGrade = [UIView new];
- vColorAndSpecificationAndGrade.frame=CGRectMake(0, CGRectGetMaxY(vOnlyCodeAndBrand.frame), Screen_Width, heightRow);
- [self.contentView addSubview:vColorAndSpecificationAndGrade];
-
- UIView *vColor = [UIView new];
- vColor.frame=CGRectMake(0, 0, Screen_Width/3, heightRow);
- [vColorAndSpecificationAndGrade addSubview:vColor];
-
- UILabel *lblColor=[UILabel new];
- lblColor.frame=CGRectMake(lblx, lbly, lblsubwidth, lblheight);
- lblColor.text=@"色号:";
- lblColor.textColor = LabelGrayTextColor;
- lblColor.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vColor addSubview:lblColor];
- _colorNumber = [UILabel new];
- _colorNumber.frame=CGRectMake(CGRectGetMaxX(lblColor.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblColor.frame), valueheight);
- _colorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _colorNumber.text = m.colorNumber;
- [vColor addSubview:_colorNumber];
-
- UIView *vSpecification = [UIView new];
- vSpecification.frame=CGRectMake(Screen_Width/3, 0, Screen_Width/3, heightRow);
- [vColorAndSpecificationAndGrade addSubview:vSpecification];
-
- UILabel *lblSpecification=[UILabel new];
- lblSpecification.frame=CGRectMake(2, lbly, lblsubwidth, lblheight);
- lblSpecification.text=@"规格:";
- lblSpecification.textColor = LabelGrayTextColor;
- lblSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vSpecification addSubview:lblSpecification];
- _specification = [UILabel new];
- _specification.frame=CGRectMake(CGRectGetMaxX(lblSpecification.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblSpecification.frame), valueheight);
- _specification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _specification.text = m.specification;
- [vSpecification addSubview:_specification];
-
- UIView *vGrade = [UIView new];
- vGrade.frame=CGRectMake(Screen_Width*2/3, 0, Screen_Width/3, heightRow);
- [vColorAndSpecificationAndGrade addSubview:vGrade];
-
- UILabel *lblGrade=[UILabel new];
- lblGrade.frame=CGRectMake(2, lbly, lblsubwidth, lblheight);
- lblGrade.text=@"等级:";
- lblGrade.textColor = LabelGrayTextColor;
- lblGrade.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vGrade addSubview:lblGrade];
- _gradeName = [UILabel new];
- _gradeName.frame=CGRectMake(CGRectGetMaxX(lblGrade.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblGrade.frame)-lblx/2, valueheight);
- _gradeName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _gradeName.text = m.gradeName;
- [vGrade addSubview:_gradeName];
-
- //库区 仓位==================
- UIView *vWareAndPos = [UIView new];
- vWareAndPos.frame=CGRectMake(0, CGRectGetMaxY(vColorAndSpecificationAndGrade.frame), Screen_Width, heightRow);
- [self.contentView addSubview:vWareAndPos];
-
- UIView *vWare = [UIView new];
- vWare.frame=CGRectMake(0, 0, Screen_Width*2/3, heightRow);
- [vWareAndPos addSubview:vWare];
-
- UILabel *lblWare=[UILabel new];
- lblWare.frame=CGRectMake(lblx, lbly, lblsubwidth, lblheight);
- lblWare.text=@"库区:";
- lblWare.textColor = LabelGrayTextColor;
- lblWare.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vWare addSubview:lblWare];
- _wareHouseName = [UILabel new];
- _wareHouseName.frame=CGRectMake(CGRectGetMaxX(lblWare.frame), valuey, Screen_Width*2/3 -CGRectGetMaxX(lblWare.frame) , valueheight);
- _wareHouseName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _wareHouseName.text = m.wareHouseName;
- [vWare addSubview:_wareHouseName];
-
- UIView *vPos = [UIView new];
- vPos.frame=CGRectMake(Screen_Width/3*2, 0, Screen_Width/3, heightRow);
- [vWareAndPos addSubview:vPos];
-
- UILabel *lblPos=[UILabel new];
- lblPos.frame=CGRectMake(2, lbly, lblsubwidth, lblheight);
- lblPos.text=@"仓位:";
- lblPos.textColor = LabelGrayTextColor;
- lblPos.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vPos addSubview:lblPos];
- _positionNumber = [UILabel new];
- _positionNumber.frame=CGRectMake(CGRectGetMaxX(lblPos.frame), valuey, valuewidth, valueheight);
- _positionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _positionNumber.text = m.positionNumber;
- [vPos addSubview:_positionNumber];
-
- if(m.boxPieceFlag){
-
- UIView *vBoxAndPiece = [UIView new];
- vBoxAndPiece.frame=CGRectMake(0, CGRectGetMaxY(vWareAndPos.frame), Screen_Width, heightRow);
- [self.contentView addSubview:vBoxAndPiece];
- UIView *vBox = [UIView new];
- vBox.frame=CGRectMake(0, 0, Screen_Width/3, heightRow);
- [vBoxAndPiece addSubview:vBox];
- UILabel *titleBox = [[UILabel alloc] init];
- titleBox.text = @"可售箱:";
- titleBox.frame = CGRectMake(lblx, lbly,50, lblheight);
- titleBox.textColor = LabelGrayTextColor;
- titleBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vBox addSubview:titleBox];
- UILabel *lBox = [[UILabel alloc] init];
- lBox.frame = CGRectMake(CGRectGetMaxX(titleBox.frame), lbly, Screen_Width/3 -CGRectGetMaxX(titleBox.frame) , lblheight);
- lBox.text =m.box;
- lBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vBox addSubview:lBox];
- UIView *vPiece = [UIView new];
- vPiece.frame=CGRectMake(Screen_Width/3, 0, Screen_Width/3, heightRow);
- [vBoxAndPiece addSubview:vPiece];
-
- UILabel *titlepic = [[UILabel alloc] init];
- titlepic.text = @"可售片:";
- titlepic.textColor = LabelGrayTextColor;
- titlepic.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- titlepic.frame = CGRectMake(2, lbly,50, lblheight);
- [vPiece addSubview:titlepic];
- UILabel *lpic = [[UILabel alloc] init];
- lpic.frame = CGRectMake(CGRectGetMaxX(titlepic.frame), lbly, valuewidth, lblheight);
- lpic.text = m.piece;
- lpic.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vPiece addSubview:lpic];
-
- UIView *vPackage = [UIView new];
- vPackage.frame=CGRectMake(Screen_Width/3*2, 0, Screen_Width/3, heightRow);
- [vBoxAndPiece addSubview:vPackage];
-
- UILabel *titlePackage = [[UILabel alloc] init];
- titlePackage.text = @"包装:";
- titlePackage.textColor = LabelGrayTextColor;
- titlePackage.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- titlePackage.frame = CGRectMake(2, lbly,50, lblheight);
- [vPackage addSubview:titlePackage];
-
- UILabel *lPackage = [[UILabel alloc] init];
- lPackage.frame = CGRectMake(CGRectGetMaxX(titlePackage.frame), lbly, valuewidth, lblheight);
- lPackage.text = m.package;
- lPackage.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vPackage addSubview:lPackage];
-
- //分割线
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vBoxAndPiece.frame), Screen_Width, heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:viewBackgroud];
- }
- else{
- //分割线
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vWareAndPos.frame), Screen_Width, heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:viewBackgroud];
- }
-
-
-
- UIView *vBottom = [UIView new];
- vBottom.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, heightRow);
- [self.contentView addSubview:vBottom];
- //结存量:%@;标价
- NSString *str = @"";
- if (m.price == nil || m.price.length == 0) {
- str = [NSString stringWithFormat:@"(结存量:%@)",m.inventoryQuantity];
- }else{
- str = [NSString stringWithFormat:@"(结存量:%@;标价:¥%@)",m.inventoryQuantity,(m.price == nil || [m.price isEqual: @"0"]) ?m.price = @"0.00":m.price];
- }
- NSDictionary *attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: SubLabelAndTextFontOfSize]};
- CGRect fra = [str textRectWithSize:CGSizeMake(300, MAXFLOAT) attributes:attributesDict];
-
- UILabel *lblInventoryAndPrice=[UILabel new];
- lblInventoryAndPrice.frame=CGRectMake(Screen_Width - 10 - fra.size.width, lbly, fra.size.width, lblheight);
- lblInventoryAndPrice.text = str;
- lblInventoryAndPrice.textColor = [UIColor blackColor];
- lblInventoryAndPrice.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
- [vBottom addSubview:lblInventoryAndPrice];
-
- str = [NSString stringWithFormat:@"%@",m.canSaleQuantity];
- attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: TitleFontOfSize]};
- fra = [str textRectWithSize:CGSizeMake(300, MAXFLOAT) attributes:attributesDict];
-
- UILabel *lblCanSaleQuantity=[UILabel new];
- lblCanSaleQuantity.frame=CGRectMake(CGRectGetMinX(lblInventoryAndPrice.frame) - fra.size.width, lbly, fra.size.width, lblheight);
- lblCanSaleQuantity.text = str;
- lblCanSaleQuantity.textColor = [UIColor redColor];
- lblCanSaleQuantity.font = [UIFont systemFontOfSize: TitleFontOfSize];
- [vBottom addSubview:lblCanSaleQuantity];
-
- str = @"可售量:";
- attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: SubLabelAndTextFontOfSize]};
- fra = [str textRectWithSize:CGSizeMake(300, MAXFLOAT) attributes:attributesDict];
-
- UILabel *lblCanSaleQuantityTitle=[UILabel new];
- lblCanSaleQuantityTitle.frame=CGRectMake(CGRectGetMinX(lblCanSaleQuantity.frame) - fra.size.width, lbly, fra.size.width, lblheight);
- lblCanSaleQuantityTitle.text = str;
- lblCanSaleQuantityTitle.textColor = LabelGrayTextColor;
- lblCanSaleQuantityTitle.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
- [vBottom addSubview:lblCanSaleQuantityTitle];
-
- //分割线
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vBottom.frame), Screen_Width, 10);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:viewBackgroud];
-
- }
- @end
|