InventoryCostCell.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. //
  2. // InventoryCostCell.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/11/17.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "InventoryCostCell.h"
  9. @implementation InventoryCostCell
  10. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. return self;
  13. }
  14. -(void)setInventoryCostCell:(InventoryCostModel*)inventoryModel
  15. {
  16. CGFloat heightLine = 1;
  17. CGFloat heightRow = 31;
  18. CGFloat lblx = 20;
  19. CGFloat lbly = 0;
  20. CGFloat lblwidth = 70;
  21. CGFloat lblsubwidth = 40;
  22. CGFloat lblheight = 31;
  23. CGFloat valuex = 90;
  24. CGFloat valuey = 0;
  25. CGFloat valuewidth = 120;
  26. CGFloat valueheight = 31;
  27. //商品编码 —————————
  28. UIView *vCode = [UIView new];
  29. vCode.frame = CGRectMake(0, 8, Screen_Width, heightRow);
  30. [self.contentView addSubview:vCode];
  31. UILabel *lblTitleCode = [UILabel new];
  32. lblTitleCode.frame=CGRectMake(lblx, 0, lblwidth, lblheight);
  33. lblTitleCode.text = @"商品编码:";
  34. lblTitleCode.textColor = [UIColor blackColor];
  35. lblTitleCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  36. [vCode addSubview:lblTitleCode];
  37. _lblCode = [UILabel new];
  38. _lblCode.frame=CGRectMake(valuex, 0, Screen_Width - valuex - lblx, valueheight);
  39. _lblCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  40. _lblCode.text = inventoryModel.code;
  41. [vCode addSubview:_lblCode];
  42. //分割线
  43. UIView *viewBackgroud = [UIView new];
  44. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vCode.frame)+8, Screen_Width, heightLine);
  45. viewBackgroud.backgroundColor = LineBackgroundColor;
  46. [self.contentView addSubview:viewBackgroud];
  47. //品牌 唯一编码 —————————
  48. UIView *vOnlyCodeAndBrand = [UIView new];
  49. vOnlyCodeAndBrand.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, heightRow);
  50. [self.contentView addSubview:vOnlyCodeAndBrand];
  51. UIView *vOnlyCode = [UIView new];
  52. vOnlyCode.frame=CGRectMake(0, 0, Screen_Width/2, heightRow);
  53. [vOnlyCodeAndBrand addSubview:vOnlyCode];
  54. UILabel *lblTitleOnlyCode = [UILabel new];
  55. lblTitleOnlyCode.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  56. lblTitleOnlyCode.text = @"唯一编码:";
  57. lblTitleOnlyCode.textColor = LabelGrayTextColor;
  58. lblTitleOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  59. [vOnlyCode addSubview:lblTitleOnlyCode];
  60. _lblOnlyCode = [UILabel new];
  61. _lblOnlyCode.frame = CGRectMake(CGRectGetMaxX(lblTitleOnlyCode.frame), valuey, Screen_Width/2 - CGRectGetMaxX(lblTitleOnlyCode.frame) - lblx/2, valueheight);
  62. _lblOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  63. _lblOnlyCode.text = inventoryModel.onlyCode;
  64. [vOnlyCode addSubview:_lblOnlyCode];
  65. UIView *vBrand = [UIView new];
  66. vBrand.frame=CGRectMake( Screen_Width/2, 0, Screen_Width/2, heightRow);
  67. [vOnlyCodeAndBrand addSubview:vBrand];
  68. UILabel *lblTitleBrand = [UILabel new];
  69. lblTitleBrand.frame=CGRectMake(0, lbly, lblsubwidth, lblheight);
  70. lblTitleBrand.text = @"品牌:";
  71. lblTitleBrand.textColor = LabelGrayTextColor;
  72. lblTitleBrand.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  73. [vBrand addSubview:lblTitleBrand];
  74. _lblBrandName = [UILabel new];
  75. _lblBrandName.frame=CGRectMake(CGRectGetMaxX(lblTitleBrand.frame), valuey, Screen_Width/2 - CGRectGetWidth(lblTitleBrand.frame), valueheight);
  76. _lblBrandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  77. _lblBrandName.text = inventoryModel.brandName;
  78. [vBrand addSubview:_lblBrandName];
  79. //库区 仓位 —————————
  80. UIView *vWareAndPos = [UIView new];
  81. vWareAndPos.frame=CGRectMake(0, CGRectGetMaxY(vOnlyCodeAndBrand.frame), Screen_Width, heightRow);
  82. [self.contentView addSubview:vWareAndPos];
  83. UIView *vWare = [UIView new];
  84. vWare.frame=CGRectMake(0, 0, Screen_Width/2, heightRow);
  85. [vWareAndPos addSubview:vWare];
  86. UILabel *lblTitleWare = [UILabel new];
  87. lblTitleWare.frame=CGRectMake(lblx, lbly, lblsubwidth, lblheight);
  88. lblTitleWare.text = @"库区:";
  89. lblTitleWare.textColor = LabelGrayTextColor;
  90. lblTitleWare.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  91. [vWare addSubview:lblTitleWare];
  92. _lblWareHouseName = [UILabel new];
  93. _lblWareHouseName.frame=CGRectMake(CGRectGetMaxX(lblTitleWare.frame), valuey, Screen_Width/2 -CGRectGetMaxX(lblTitleWare.frame) , valueheight);
  94. _lblWareHouseName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  95. _lblWareHouseName.text = inventoryModel.wareHouseName;
  96. [vWare addSubview:_lblWareHouseName];
  97. UIView *vPos = [UIView new];
  98. vPos.frame=CGRectMake(Screen_Width/2, 0, Screen_Width/2, heightRow);
  99. [vWareAndPos addSubview:vPos];
  100. UILabel *lblTitlePos = [UILabel new];
  101. lblTitlePos.frame=CGRectMake(2, lbly, lblsubwidth, lblheight);
  102. lblTitlePos.text = @"仓位:";
  103. lblTitlePos.textColor = LabelGrayTextColor;
  104. lblTitlePos.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  105. [vPos addSubview:lblTitlePos];
  106. _lblPositionNumber = [UILabel new];
  107. _lblPositionNumber.frame=CGRectMake(CGRectGetMaxX(lblTitlePos.frame), valuey, valuewidth, valueheight);
  108. _lblPositionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  109. _lblPositionNumber.text = inventoryModel.positionNumber;
  110. [vPos addSubview:_lblPositionNumber];
  111. //色号 规格 等级 —————————
  112. UIView *vColorAndSpecificationAndGrade = [UIView new];
  113. vColorAndSpecificationAndGrade.frame=CGRectMake(0, CGRectGetMaxY(vWareAndPos.frame), Screen_Width, heightRow);
  114. [self.contentView addSubview:vColorAndSpecificationAndGrade];
  115. UIView *vColor = [UIView new];
  116. vColor.frame=CGRectMake(0, 0, Screen_Width/3, heightRow);
  117. [vColorAndSpecificationAndGrade addSubview:vColor];
  118. UILabel *lblTitleColor = [UILabel new];
  119. lblTitleColor.frame=CGRectMake(lblx, lbly, lblsubwidth, lblheight);
  120. lblTitleColor.text = @"色号:";
  121. lblTitleColor.textColor = LabelGrayTextColor;
  122. lblTitleColor.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  123. [vColor addSubview:lblTitleColor];
  124. _lblColorNumber = [UILabel new];
  125. _lblColorNumber.frame=CGRectMake(CGRectGetMaxX(lblTitleColor.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblTitleColor.frame), valueheight);
  126. _lblColorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  127. _lblColorNumber.text = inventoryModel.colorNumber;
  128. [vColor addSubview:_lblColorNumber];
  129. UIView *vSpecification = [UIView new];
  130. vSpecification.frame=CGRectMake(Screen_Width/3, 0, Screen_Width/3, heightRow);
  131. [vColorAndSpecificationAndGrade addSubview:vSpecification];
  132. UILabel *lblTitleSpecification = [UILabel new];
  133. lblTitleSpecification.frame=CGRectMake(0, lbly, lblsubwidth, lblheight);
  134. lblTitleSpecification.text = @"规格:";
  135. lblTitleSpecification.textColor = LabelGrayTextColor;
  136. lblTitleSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  137. [vSpecification addSubview:lblTitleSpecification];
  138. _lblSpecification = [UILabel new];
  139. _lblSpecification.frame=CGRectMake(CGRectGetMaxX(lblTitleSpecification.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblTitleSpecification.frame), valueheight);
  140. _lblSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  141. _lblSpecification.text = inventoryModel.specification;
  142. [vSpecification addSubview:_lblSpecification];
  143. UIView *vGrade = [UIView new];
  144. vGrade.frame=CGRectMake(Screen_Width*2/3, 0, Screen_Width/3, heightRow);
  145. [vColorAndSpecificationAndGrade addSubview:vGrade];
  146. UILabel *lblTitleGrade = [UILabel new];
  147. lblTitleGrade.frame=CGRectMake(0, lbly, lblsubwidth, lblheight);
  148. lblTitleGrade.text = @"等级:";
  149. lblTitleGrade.textColor = LabelGrayTextColor;
  150. lblTitleGrade.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  151. [vGrade addSubview:lblTitleGrade];
  152. _lblGradeName= [UILabel new];
  153. _lblGradeName.frame=CGRectMake(CGRectGetMaxX(lblTitleGrade.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblTitleGrade.frame)-lblx/2, valueheight);
  154. _lblGradeName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  155. _lblGradeName.text = inventoryModel.gradeName;
  156. [vGrade addSubview:_lblGradeName];
  157. //分割线
  158. UIView *viewline = [UIView new];
  159. viewline.frame = CGRectMake(0,CGRectGetMaxY(vColorAndSpecificationAndGrade.frame)+8, Screen_Width, heightLine);
  160. viewline.backgroundColor = LineBackgroundColor;
  161. [self.contentView addSubview:viewline];
  162. UIView *vBottom = [UIView new];
  163. vBottom.frame=CGRectMake(0, CGRectGetMaxY(viewline.frame)+8, Screen_Width, heightRow-1);
  164. [self.contentView addSubview:vBottom];
  165. NSString *str = [NSString stringWithFormat:@"(库存成本:%@;库存金额:%@)",inventoryModel.timelyCost,inventoryModel.inventoryAmount];
  166. NSDictionary *attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: SubLabelAndTextFontOfSize]};
  167. CGRect fra = [str textRectWithSize:CGSizeMake(600, MAXFLOAT) attributes:attributesDict];
  168. UILabel *lblInventoryAndPrice = [UILabel new];
  169. lblInventoryAndPrice.frame=CGRectMake(Screen_Width - 10 - fra.size.width, 0, fra.size.width, lblheight-1);
  170. lblInventoryAndPrice.text = str;
  171. lblInventoryAndPrice.textColor = [UIColor blackColor];
  172. lblInventoryAndPrice.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  173. [vBottom addSubview:lblInventoryAndPrice];
  174. attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: TitleFontOfSize]};
  175. fra = [inventoryModel.inventoryQuantity textRectWithSize:CGSizeMake(300, MAXFLOAT) attributes:attributesDict];
  176. UILabel *lblCanSaleQuantity = [UILabel new];
  177. lblCanSaleQuantity.frame=CGRectMake(CGRectGetMinX(lblInventoryAndPrice.frame) - fra.size.width, 0, fra.size.width, lblheight-1);
  178. lblCanSaleQuantity.text = inventoryModel.inventoryQuantity;
  179. lblCanSaleQuantity.textColor = [UIColor redColor];
  180. lblCanSaleQuantity.font = [UIFont systemFontOfSize: TitleFontOfSize];
  181. [vBottom addSubview:lblCanSaleQuantity];
  182. NSString *canSalesQuantityTitle = @"可售量:";
  183. attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: SubLabelAndTextFontOfSize]};
  184. fra = [canSalesQuantityTitle textRectWithSize:CGSizeMake(300, MAXFLOAT) attributes:attributesDict];
  185. UILabel *lblCanSaleQuantityTitle = [UILabel new];
  186. lblCanSaleQuantityTitle.frame=CGRectMake(CGRectGetMinX(lblCanSaleQuantity.frame) - fra.size.width, 0, fra.size.width, lblheight-1);
  187. lblCanSaleQuantityTitle.text = canSalesQuantityTitle;
  188. lblCanSaleQuantityTitle.textColor = LabelGrayTextColor;
  189. lblCanSaleQuantityTitle.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  190. [vBottom addSubview:lblCanSaleQuantityTitle];
  191. //分割线
  192. viewBackgroud = [UIView new];
  193. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vBottom.frame)+8, Screen_Width, 10);
  194. viewBackgroud.backgroundColor = LineBackgroundColor;
  195. [self.contentView addSubview:viewBackgroud];
  196. _cellHeight = CGRectGetMaxY(viewBackgroud.frame);
  197. }
  198. @end