| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- //
- // InventoryCell.m
- // IBOSS
- //
- // Created by apple on 2017/5/16.
- // Copyright © 2017年 沈阳东科云信软件有限公司. 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 = 31;
- CGFloat lblx = 20;
- CGFloat lbly = 0;
- CGFloat lblwidth = 70;
- CGFloat lblsubwidth = 40;
- CGFloat lblheight = 31;
-
- CGFloat valuex = 90;
- CGFloat valuey = 0;
- CGFloat valuewidth = 120;
- CGFloat valueheight = 31;
-
- //商品编码 —————————
- UIView *vcode = [UIView new];
- vcode.frame = CGRectMake(0, 8, Screen_Width, heightRow);
- [self.contentView addSubview:vcode];
- UILabel *lblcode = [UILabel new];
- lblcode.frame=CGRectMake(lblx, 0, lblwidth, lblheight);
- lblcode.text = @"商品编码:";
- lblcode.textColor = [UIColor blackColor];
- lblcode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vcode addSubview:lblcode];
- _code = [UILabel new];
- _code.frame=CGRectMake(valuex, 0, 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)+8, Screen_Width, heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:viewBackgroud];
-
- UIView *vgoodname = [UIView new];
- vgoodname.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame)+8, Screen_Width/3*2, 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/3*2 - valuex - lblx, valueheight);
- _goodName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _goodName.text = m.goodName;
- [vgoodname addSubview:_goodName];
-
- NSString *occupyQuantity= m.occupyQuantity;
- if(occupyQuantity!=nil&&occupyQuantity.length>0){
- UIView *vOccupyQuantity = [UIView new];
- vOccupyQuantity.frame=CGRectMake(Screen_Width/3*2, CGRectGetMaxY(viewBackgroud.frame)+8, Screen_Width/3, heightRow);
- [self.contentView addSubview:vOccupyQuantity];
- UILabel *lblTitleOccupyQuantity = [UILabel new];
- lblTitleOccupyQuantity.frame=CGRectMake(2, lbly, lblwidth, lblheight);
- lblTitleOccupyQuantity.text = @"占库量:";
- lblTitleOccupyQuantity.textColor = LabelGrayTextColor;
- lblTitleOccupyQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vOccupyQuantity addSubview:lblTitleOccupyQuantity];
- _lblOccupyQuantity = [UILabel new];
- _lblOccupyQuantity.frame=CGRectMake(lblwidth, valuey, Screen_Width/3 -CGRectGetWidth(lblTitleOccupyQuantity.frame)-lblx, valueheight);
- _lblOccupyQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _lblOccupyQuantity.text =occupyQuantity;
- _lblOccupyQuantity.textAlignment=NSTextAlignmentLeft;
- [vOccupyQuantity addSubview:_lblOccupyQuantity];
- }
- //品牌 唯一编码 —————————
- UIView *vOnlyCodeAndBrand = [UIView new];
- vOnlyCodeAndBrand.frame=CGRectMake(0, CGRectGetMaxY(vgoodname.frame), Screen_Width, heightRow);
- [self.contentView addSubview:vOnlyCodeAndBrand];
-
-
- UIView *vOnlyCode = [UIView new];
- vOnlyCode.frame=CGRectMake(0, 0, Screen_Width/3*2, heightRow);
- [vOnlyCodeAndBrand addSubview:vOnlyCode];
-
- UILabel *lblOnlyCode = [UILabel new];
- lblOnlyCode.frame=CGRectMake(lblx, 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 *vBrand = [UIView new];
- vBrand.frame=CGRectMake( Screen_Width/3*2, 0, Screen_Width/3, heightRow);
- [vOnlyCodeAndBrand addSubview:vBrand];
-
- UILabel *lblBrand = [UILabel new];
- lblBrand.frame=CGRectMake(2, 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 - CGRectGetWidth(lblBrand.frame)-lblx, valueheight);
- _brandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _brandName.text = m.brandName;
- [vBrand addSubview:_brandName];
-
-
-
- //库区 仓位 —————————
- UIView *vWareAndPos = [UIView new];
- vWareAndPos.frame=CGRectMake(0, CGRectGetMaxY(vOnlyCodeAndBrand.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];
-
- //色号 规格 等级 —————————
- UIView *vColorAndSpecificationAndGrade = [UIView new];
- vColorAndSpecificationAndGrade.frame=CGRectMake(0, CGRectGetMaxY(vWareAndPos.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(20, 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];
-
- CGFloat height = CGRectGetMaxY(vColorAndSpecificationAndGrade.frame)+8;
- if(m.boxPieceFlag){
-
- UILabel *titleBox = [[UILabel alloc] init];
- titleBox.text = @"可售箱:";
- titleBox.frame = CGRectMake(20, height, 70,20);
- [titleBox sizeToFit];
- titleBox.textColor = LabelGrayTextColor;
- titleBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [self.contentView addSubview:titleBox];
-
- UILabel *lBox = [[UILabel alloc] init];
- lBox.frame = CGRectMake(CGRectGetMaxX(titleBox.frame)+5, height+3, Screen_Width/2-90,20);
- lBox.text =m.box;
- lBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [lBox sizeToFit];
- [self.contentView addSubview:lBox];
-
- UILabel *titlepic = [[UILabel alloc] init];
- titlepic.text = @"可售片:";
- titlepic.textColor = LabelGrayTextColor;
- titlepic.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- titlepic.frame = CGRectMake(SCREENWIDTH/3+20, height+3, 70,20);
- [titlepic sizeToFit];
- [self.contentView addSubview:titlepic];
-
- UILabel *lpic = [[UILabel alloc] init];
- lpic.frame = CGRectMake(CGRectGetMaxX(titlepic.frame)+5, height+3, Screen_Width/3-90,20);
- lpic.text = m.piece;
- lpic.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [lpic sizeToFit];
- [self.contentView addSubview:lpic];
-
-
- UILabel *titlePackage = [[UILabel alloc] init];
- titlePackage.text = @"包装:";
- titlePackage.textColor = LabelGrayTextColor;
- titlePackage.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- titlePackage.frame = CGRectMake(SCREENWIDTH/3*2+2, height+3, 70,20);
- [titlePackage sizeToFit];
- [self.contentView addSubview:titlePackage];
-
- UILabel *lpackage = [[UILabel alloc] init];
- lpackage.frame = CGRectMake(CGRectGetMaxX(titlePackage.frame)+5, height+3, Screen_Width/3-70,20);
- lpackage.text = m.package;
- lpackage.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [lpackage sizeToFit];
- [self.contentView addSubview:lpackage];
- height = CGRectGetMaxY(lBox.frame)+8;
-
-
-
- }
-
-
- if([kkAppName isEqualToString:@"顺城"])
- {
- UILabel *titleWeight = [[UILabel alloc] init];
- titleWeight.text = @"重量:";
- titleWeight.textColor = LabelGrayTextColor;
- titleWeight.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- titleWeight.frame = CGRectMake(20, height+3, 70,20);
- [titleWeight sizeToFit];
- [self.contentView addSubview:titleWeight];
-
- UILabel *lblWeight = [[UILabel alloc] init];
- lblWeight.frame = CGRectMake(CGRectGetMaxX(titleWeight.frame)+5, height+3, Screen_Width- CGRectGetMaxX(titleWeight.frame),20);
- lblWeight.text = m.weight;
- lblWeight.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [lblWeight sizeToFit];
- [self.contentView addSubview:lblWeight];
- height = CGRectGetMaxY(lblWeight.frame)+8;
- }
-
-
- //分割线
- UIView *viewline = [UIView new];
- viewline.frame = CGRectMake(0,height, Screen_Width, heightLine);
- viewline.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:viewline];
-
- UIView *vBottom = [UIView new];
- vBottom.frame=CGRectMake(0, CGRectGetMaxY(viewline.frame)+8, Screen_Width, heightRow-1);
- [self.contentView addSubview:vBottom];
- NSString *str;
- if((m.price == nil || [m.price isEqualToString:@""])&&([m.settingValues isEqualToString:@"0"])){
- //结存量:%@;标价
- str = [NSString stringWithFormat:@"(结存量:%@)",m.inventoryQuantity];
- if(m.inventoryQuantity == nil || [m.inventoryQuantity isEqualToString:@""]){
- str = @"";
- }
- }
-
- if((m.price == nil || [m.price isEqualToString:@""])&&([m.settingValues isEqualToString:@"1"])){
- //结存量:%@;标价//结存量:%@;标价
- str = [NSString stringWithFormat:@"(结存量:%@;成本价:¥%@)",m.inventoryQuantity,m.costPrice];
- if(m.inventoryQuantity == nil || [m.inventoryQuantity isEqualToString:@""]){
- str = [NSString stringWithFormat:@"(成本价:¥%@)",m.costPrice];
- }
- }
-
- if(!(m.price == nil || [m.price isEqualToString:@""])&&([m.settingValues isEqualToString:@"0"])){
- //结存量:%@;标价
- str = [NSString stringWithFormat:@"(结存量:%@;标价:¥%@)",m.inventoryQuantity,m.price];
- if(m.inventoryQuantity == nil || [m.inventoryQuantity isEqualToString:@""]){
- str = [NSString stringWithFormat:@"(标价:¥%@)",m.price];
- }
- }
-
-
- if(!(m.price == nil || [m.price isEqualToString:@""])&&([m.settingValues isEqualToString:@"1"])){
- //结存量:%@;标价
- str = [NSString stringWithFormat:@"(结存量:%@;标价:¥%@;成本价:¥%@)",m.inventoryQuantity,m.price,m.costPrice];
- if(m.inventoryQuantity == nil || [m.inventoryQuantity isEqualToString:@""]){
- str = [NSString stringWithFormat:@"(标价:¥%@;成本价:¥%@)",m.price,m.costPrice];
- }
- }
-
- NSDictionary *attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: SubLabelAndTextFontOfSize]};
- CGRect fra = [str textRectWithSize:CGSizeMake(600, MAXFLOAT) attributes:attributesDict];
-
- UILabel *lblInventoryAndPrice = [UILabel new];
- lblInventoryAndPrice.frame=CGRectMake(Screen_Width - 10 - fra.size.width, 0, fra.size.width, lblheight-1);
- lblInventoryAndPrice.text = str;
- lblInventoryAndPrice.textColor = [UIColor blackColor];
- lblInventoryAndPrice.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
- [vBottom addSubview:lblInventoryAndPrice];
- NSString *strCanSaleQuantity;
- if(m.canSaleQuantity != nil && ![m.canSaleQuantity isEqualToString:@""]){
- strCanSaleQuantity = [NSString stringWithFormat:@"%@",m.canSaleQuantity];
- attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: TitleFontOfSize]};
- fra = [strCanSaleQuantity textRectWithSize:CGSizeMake(300, MAXFLOAT) attributes:attributesDict];
-
- UILabel *lblCanSaleQuantity = [UILabel new];
- lblCanSaleQuantity.frame=CGRectMake(CGRectGetMinX(lblInventoryAndPrice.frame) - fra.size.width, 0, fra.size.width, lblheight-1);
- lblCanSaleQuantity.text = strCanSaleQuantity;
- lblCanSaleQuantity.textColor = [UIColor redColor];
- lblCanSaleQuantity.font = [UIFont systemFontOfSize: TitleFontOfSize];
- [vBottom addSubview:lblCanSaleQuantity];
-
- NSString *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, 0, fra.size.width, lblheight-1);
- lblCanSaleQuantityTitle.text = str;
- lblCanSaleQuantityTitle.textColor = LabelGrayTextColor;
- lblCanSaleQuantityTitle.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
- [vBottom addSubview:lblCanSaleQuantityTitle];
- }
-
- if((m.canSaleQuantity == nil || [m.canSaleQuantity isEqualToString:@""])&&(m.inventoryQuantity == nil || [m.inventoryQuantity isEqualToString:@""]) && (m.price == nil || [m.price isEqualToString:@""])){
-
- //分割线
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(viewline.frame), Screen_Width, 10);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:viewBackgroud];
- _cellHeight = CGRectGetMaxY(viewBackgroud.frame);
- }else{
- //分割线
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vBottom.frame)+8, Screen_Width, 10);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:viewBackgroud];
- _cellHeight = CGRectGetMaxY(viewBackgroud.frame);
- }
-
- }
- @end
|