InventoryCell.m 18 KB

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