InventoryCell.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. //
  2. // InventoryCell.m
  3. // IBOSSmini
  4. //
  5. // Created by apple on 2017/5/16.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "InventoryCell.h"
  9. #import "NSString+Tools.h"
  10. @implementation InventoryCell
  11. /**
  12. 后台代码创建单元cell
  13. @param style <#style description#>
  14. @param reuseIdentifier <#reuseIdentifier description#>
  15. @return <#return value description#>
  16. */
  17. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  18. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  19. self.layer.cornerRadius = 10;
  20. self.backgroundColor = [UIColor whiteColor];
  21. return self;
  22. }
  23. /**
  24. model
  25. @param m <#m description#>
  26. */
  27. - (void)setModel:(InventoryModel *)m{
  28. CGFloat heightLine = 1;
  29. CGFloat heightRow = 40;
  30. CGFloat lblx = 20;
  31. CGFloat lbly = 8;
  32. CGFloat lblwidth = 70;
  33. CGFloat lblsubwidth = 40;
  34. CGFloat lblheight = 25;
  35. CGFloat valuex = 90;
  36. CGFloat valuey = 8;
  37. CGFloat valuewidth = 120;
  38. CGFloat valueheight = 25;
  39. //title==================
  40. UIView *vTitle = [UIView new];
  41. vTitle.frame=CGRectMake(0, 0, Screen_Width, 0);
  42. vTitle.backgroundColor = LineBackgroundColor;
  43. [self.contentView addSubview:vTitle];
  44. //商品编码==================
  45. UIView *vcode = [UIView new];
  46. vcode.frame=CGRectMake(0, CGRectGetMaxY(vTitle.frame), Screen_Width, heightRow);
  47. [self.contentView addSubview:vcode];
  48. UILabel *lblcode=[UILabel new];
  49. lblcode.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  50. lblcode.text=@"商品编码:";
  51. lblcode.textColor = [UIColor blackColor];
  52. lblcode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  53. [vcode addSubview:lblcode];
  54. _code = [UILabel new];
  55. _code.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  56. _code.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  57. _code.text = m.code;
  58. [vcode addSubview:_code];
  59. //分割线
  60. UIView *viewBackgroud = [UIView new];
  61. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vcode.frame), Screen_Width, heightLine);
  62. viewBackgroud.backgroundColor = LineBackgroundColor;
  63. [self.contentView addSubview:viewBackgroud];
  64. UIView *vgoodname = [UIView new];
  65. vgoodname.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, heightRow);
  66. [self.contentView addSubview:vgoodname];
  67. UILabel *lblgoodname =[UILabel new];
  68. lblgoodname.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  69. lblgoodname.text=@"商品名称:";
  70. lblgoodname.textColor = LabelGrayTextColor;
  71. lblgoodname.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  72. [vgoodname addSubview:lblgoodname];
  73. _goodName = [UILabel new];
  74. _goodName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  75. _goodName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  76. _goodName.text = m.goodsName;
  77. [vgoodname addSubview:_goodName];
  78. //品牌 唯一编码==================
  79. UIView *vOnlyCodeAndBrand = [UIView new];
  80. vOnlyCodeAndBrand.frame=CGRectMake(0, CGRectGetMaxY(vgoodname.frame), Screen_Width, heightRow);
  81. [self.contentView addSubview:vOnlyCodeAndBrand];
  82. UIView *vBrand = [UIView new];
  83. vBrand.frame=CGRectMake(0, 0, Screen_Width/3, heightRow);
  84. [vOnlyCodeAndBrand addSubview:vBrand];
  85. UILabel *lblBrand=[UILabel new];
  86. lblBrand.frame=CGRectMake(lblx, lbly, lblsubwidth, lblheight);
  87. lblBrand.text=@"品牌:";
  88. lblBrand.textColor = LabelGrayTextColor;
  89. lblBrand.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  90. [vBrand addSubview:lblBrand];
  91. _brandName = [UILabel new];
  92. _brandName.frame=CGRectMake(CGRectGetMaxX(lblBrand.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblBrand.frame), valueheight);
  93. _brandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  94. _brandName.text = m.brandName;
  95. [vBrand addSubview:_brandName];
  96. UIView *vOnlyCode = [UIView new];
  97. vOnlyCode.frame=CGRectMake(Screen_Width/3, 0, Screen_Width/3*2, heightRow);
  98. [vOnlyCodeAndBrand addSubview:vOnlyCode];
  99. UILabel *lblOnlyCode=[UILabel new];
  100. lblOnlyCode.frame=CGRectMake(2, lbly, lblwidth, lblheight);
  101. lblOnlyCode.text=@"唯一编码:";
  102. lblOnlyCode.textColor = LabelGrayTextColor;
  103. lblOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  104. [vOnlyCode addSubview:lblOnlyCode];
  105. _onlyCode = [UILabel new];
  106. _onlyCode.frame = CGRectMake(CGRectGetMaxX(lblOnlyCode.frame), valuey, Screen_Width/3*2 - CGRectGetMaxX(lblOnlyCode.frame) - lblx/2, valueheight);
  107. _onlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  108. _onlyCode.text = m.onlyCode;
  109. [vOnlyCode addSubview:_onlyCode];
  110. //色号 规格 等级==================
  111. UIView *vColorAndSpecificationAndGrade = [UIView new];
  112. vColorAndSpecificationAndGrade.frame=CGRectMake(0, CGRectGetMaxY(vOnlyCodeAndBrand.frame), Screen_Width, heightRow);
  113. [self.contentView addSubview:vColorAndSpecificationAndGrade];
  114. UIView *vColor = [UIView new];
  115. vColor.frame=CGRectMake(0, 0, Screen_Width/3, heightRow);
  116. [vColorAndSpecificationAndGrade addSubview:vColor];
  117. UILabel *lblColor=[UILabel new];
  118. lblColor.frame=CGRectMake(lblx, lbly, lblsubwidth, lblheight);
  119. lblColor.text=@"色号:";
  120. lblColor.textColor = LabelGrayTextColor;
  121. lblColor.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  122. [vColor addSubview:lblColor];
  123. _colorNumber = [UILabel new];
  124. _colorNumber.frame=CGRectMake(CGRectGetMaxX(lblColor.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblColor.frame), valueheight);
  125. _colorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  126. _colorNumber.text = m.colorNumber;
  127. [vColor addSubview:_colorNumber];
  128. UIView *vSpecification = [UIView new];
  129. vSpecification.frame=CGRectMake(Screen_Width/3, 0, Screen_Width/3, heightRow);
  130. [vColorAndSpecificationAndGrade addSubview:vSpecification];
  131. UILabel *lblSpecification=[UILabel new];
  132. lblSpecification.frame=CGRectMake(2, lbly, lblsubwidth, lblheight);
  133. lblSpecification.text=@"规格:";
  134. lblSpecification.textColor = LabelGrayTextColor;
  135. lblSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  136. [vSpecification addSubview:lblSpecification];
  137. _specification = [UILabel new];
  138. _specification.frame=CGRectMake(CGRectGetMaxX(lblSpecification.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblSpecification.frame), valueheight);
  139. _specification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  140. _specification.text = m.specification;
  141. [vSpecification addSubview:_specification];
  142. UIView *vGrade = [UIView new];
  143. vGrade.frame=CGRectMake(Screen_Width*2/3, 0, Screen_Width/3, heightRow);
  144. [vColorAndSpecificationAndGrade addSubview:vGrade];
  145. UILabel *lblGrade=[UILabel new];
  146. lblGrade.frame=CGRectMake(2, lbly, lblsubwidth, lblheight);
  147. lblGrade.text=@"等级:";
  148. lblGrade.textColor = LabelGrayTextColor;
  149. lblGrade.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  150. [vGrade addSubview:lblGrade];
  151. _gradeName = [UILabel new];
  152. _gradeName.frame=CGRectMake(CGRectGetMaxX(lblGrade.frame), valuey, Screen_Width/3 - CGRectGetMaxX(lblGrade.frame)-lblx/2, valueheight);
  153. _gradeName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  154. _gradeName.text = m.gradeName;
  155. [vGrade addSubview:_gradeName];
  156. //库区 仓位==================
  157. UIView *vWareAndPos = [UIView new];
  158. vWareAndPos.frame=CGRectMake(0, CGRectGetMaxY(vColorAndSpecificationAndGrade.frame), Screen_Width, heightRow);
  159. [self.contentView addSubview:vWareAndPos];
  160. UIView *vWare = [UIView new];
  161. vWare.frame=CGRectMake(0, 0, Screen_Width*2/3, heightRow);
  162. [vWareAndPos addSubview:vWare];
  163. UILabel *lblWare=[UILabel new];
  164. lblWare.frame=CGRectMake(lblx, lbly, lblsubwidth, lblheight);
  165. lblWare.text=@"库区:";
  166. lblWare.textColor = LabelGrayTextColor;
  167. lblWare.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  168. [vWare addSubview:lblWare];
  169. _wareHouseName = [UILabel new];
  170. _wareHouseName.frame=CGRectMake(CGRectGetMaxX(lblWare.frame), valuey, Screen_Width*2/3 -CGRectGetMaxX(lblWare.frame) , valueheight);
  171. _wareHouseName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  172. _wareHouseName.text = m.wareHouseName;
  173. [vWare addSubview:_wareHouseName];
  174. UIView *vPos = [UIView new];
  175. vPos.frame=CGRectMake(Screen_Width/3*2, 0, Screen_Width/3, heightRow);
  176. [vWareAndPos addSubview:vPos];
  177. UILabel *lblPos=[UILabel new];
  178. lblPos.frame=CGRectMake(2, lbly, lblsubwidth, lblheight);
  179. lblPos.text=@"仓位:";
  180. lblPos.textColor = LabelGrayTextColor;
  181. lblPos.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  182. [vPos addSubview:lblPos];
  183. _positionNumber = [UILabel new];
  184. _positionNumber.frame=CGRectMake(CGRectGetMaxX(lblPos.frame), valuey, valuewidth, valueheight);
  185. _positionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  186. _positionNumber.text = m.positionNumber;
  187. [vPos addSubview:_positionNumber];
  188. if(m.boxPieceFlag){
  189. UIView *vBoxAndPiece = [UIView new];
  190. vBoxAndPiece.frame=CGRectMake(0, CGRectGetMaxY(vWareAndPos.frame), Screen_Width, heightRow);
  191. [self.contentView addSubview:vBoxAndPiece];
  192. UIView *vBox = [UIView new];
  193. vBox.frame=CGRectMake(0, 0, Screen_Width/3, heightRow);
  194. [vBoxAndPiece addSubview:vBox];
  195. UILabel *titleBox = [[UILabel alloc] init];
  196. titleBox.text = @"可售箱:";
  197. titleBox.frame = CGRectMake(lblx, lbly,50, lblheight);
  198. titleBox.textColor = LabelGrayTextColor;
  199. titleBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  200. [vBox addSubview:titleBox];
  201. UILabel *lBox = [[UILabel alloc] init];
  202. lBox.frame = CGRectMake(CGRectGetMaxX(titleBox.frame), lbly, Screen_Width/3 -CGRectGetMaxX(titleBox.frame) , lblheight);
  203. lBox.text =m.box;
  204. lBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  205. [vBox addSubview:lBox];
  206. UIView *vPiece = [UIView new];
  207. vPiece.frame=CGRectMake(Screen_Width/3, 0, Screen_Width/3, heightRow);
  208. [vBoxAndPiece addSubview:vPiece];
  209. UILabel *titlepic = [[UILabel alloc] init];
  210. titlepic.text = @"可售片:";
  211. titlepic.textColor = LabelGrayTextColor;
  212. titlepic.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  213. titlepic.frame = CGRectMake(2, lbly,50, lblheight);
  214. [vPiece addSubview:titlepic];
  215. UILabel *lpic = [[UILabel alloc] init];
  216. lpic.frame = CGRectMake(CGRectGetMaxX(titlepic.frame), lbly, valuewidth, lblheight);
  217. lpic.text = m.piece;
  218. lpic.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  219. [vPiece addSubview:lpic];
  220. UIView *vPackage = [UIView new];
  221. vPackage.frame=CGRectMake(Screen_Width/3*2, 0, Screen_Width/3, heightRow);
  222. [vBoxAndPiece addSubview:vPackage];
  223. UILabel *titlePackage = [[UILabel alloc] init];
  224. titlePackage.text = @"包装:";
  225. titlePackage.textColor = LabelGrayTextColor;
  226. titlePackage.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  227. titlePackage.frame = CGRectMake(2, lbly,50, lblheight);
  228. [vPackage addSubview:titlePackage];
  229. UILabel *lPackage = [[UILabel alloc] init];
  230. lPackage.frame = CGRectMake(CGRectGetMaxX(titlePackage.frame), lbly, valuewidth, lblheight);
  231. lPackage.text = m.package;
  232. lPackage.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  233. [vPackage addSubview:lPackage];
  234. //分割线
  235. viewBackgroud = [UIView new];
  236. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vBoxAndPiece.frame), Screen_Width, heightLine);
  237. viewBackgroud.backgroundColor = LineBackgroundColor;
  238. [self.contentView addSubview:viewBackgroud];
  239. }
  240. else{
  241. //分割线
  242. viewBackgroud = [UIView new];
  243. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vWareAndPos.frame), Screen_Width, heightLine);
  244. viewBackgroud.backgroundColor = LineBackgroundColor;
  245. [self.contentView addSubview:viewBackgroud];
  246. }
  247. UIView *vBottom = [UIView new];
  248. vBottom.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, heightRow);
  249. [self.contentView addSubview:vBottom];
  250. //结存量:%@;标价
  251. NSString *str = @"";
  252. if (m.price == nil || m.price.length == 0) {
  253. str = [NSString stringWithFormat:@"(结存量:%@)",m.inventoryQuantity];
  254. }else{
  255. str = [NSString stringWithFormat:@"(结存量:%@;标价:¥%@)",m.inventoryQuantity,(m.price == nil || [m.price isEqual: @"0"]) ?m.price = @"0.00":m.price];
  256. }
  257. NSDictionary *attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: SubLabelAndTextFontOfSize]};
  258. CGRect fra = [str textRectWithSize:CGSizeMake(300, MAXFLOAT) attributes:attributesDict];
  259. UILabel *lblInventoryAndPrice=[UILabel new];
  260. lblInventoryAndPrice.frame=CGRectMake(Screen_Width - 10 - fra.size.width, lbly, fra.size.width, lblheight);
  261. lblInventoryAndPrice.text = str;
  262. lblInventoryAndPrice.textColor = [UIColor blackColor];
  263. lblInventoryAndPrice.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  264. [vBottom addSubview:lblInventoryAndPrice];
  265. str = [NSString stringWithFormat:@"%@",m.canSaleQuantity];
  266. attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: TitleFontOfSize]};
  267. fra = [str textRectWithSize:CGSizeMake(300, MAXFLOAT) attributes:attributesDict];
  268. UILabel *lblCanSaleQuantity=[UILabel new];
  269. lblCanSaleQuantity.frame=CGRectMake(CGRectGetMinX(lblInventoryAndPrice.frame) - fra.size.width, lbly, fra.size.width, lblheight);
  270. lblCanSaleQuantity.text = str;
  271. lblCanSaleQuantity.textColor = [UIColor redColor];
  272. lblCanSaleQuantity.font = [UIFont systemFontOfSize: TitleFontOfSize];
  273. [vBottom addSubview:lblCanSaleQuantity];
  274. str = @"可售量:";
  275. attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: SubLabelAndTextFontOfSize]};
  276. fra = [str textRectWithSize:CGSizeMake(300, MAXFLOAT) attributes:attributesDict];
  277. UILabel *lblCanSaleQuantityTitle=[UILabel new];
  278. lblCanSaleQuantityTitle.frame=CGRectMake(CGRectGetMinX(lblCanSaleQuantity.frame) - fra.size.width, lbly, fra.size.width, lblheight);
  279. lblCanSaleQuantityTitle.text = str;
  280. lblCanSaleQuantityTitle.textColor = LabelGrayTextColor;
  281. lblCanSaleQuantityTitle.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  282. [vBottom addSubview:lblCanSaleQuantityTitle];
  283. //分割线
  284. viewBackgroud = [UIView new];
  285. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vBottom.frame), Screen_Width, 10);
  286. viewBackgroud.backgroundColor = LineBackgroundColor;
  287. [self.contentView addSubview:viewBackgroud];
  288. }
  289. @end