InventoryGoodsSearchCell.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. //
  2. // InventoryGoodsSearchCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/2/2.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "InventoryGoodsSearchCell.h"
  9. @implementation InventoryGoodsSearchCell
  10. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. return self;
  13. }
  14. - (void)setInventoryGoods:(InventoryListModel *)inventoryGoodsModel{
  15. int xPadding=10;
  16. int yPadding=10;
  17. int titleWidth=70;
  18. CGFloat valueheight = 25;
  19. NSDictionary *orderDict = @{NSFontAttributeName:orderTextFont};
  20. _inventoryModel=inventoryGoodsModel;
  21. _btnCheck=[UIButton buttonWithType:UIButtonTypeCustom];
  22. _btnCheck.frame=CGRectMake(xPadding, yPadding, 25, 25);
  23. [_btnCheck addTarget:self action:@selector(btnGoCheck) forControlEvents:UIControlEventTouchUpInside];
  24. [self.contentView addSubview:_btnCheck];
  25. _lblGoodsName=[[UILabel alloc]init];
  26. _lblGoodsName.frame=CGRectMake(CGRectGetMaxX(_btnCheck.frame)+3, yPadding, Screen_Width-CGRectGetMaxX(_btnCheck.frame)-10, valueheight);
  27. _lblGoodsName.text=inventoryGoodsModel.goodsName;
  28. _lblGoodsName.font=orderTextFont;
  29. [self.contentView addSubview:_lblGoodsName];
  30. _topSeparator=[UIView new];
  31. _topSeparator.frame = CGRectMake(0, CGRectGetMaxY(_btnCheck.frame)+yPadding, Screen_Width, 1);
  32. UIButton *btnLine = [UIButton buttonWithType:UIButtonTypeCustom];
  33. [btnLine setBackgroundImage:[UIImage imageNamed:@"dash"] forState:UIControlStateNormal];
  34. btnLine.frame = CGRectMake(0 ,0 , Screen_Width,1);
  35. [_topSeparator addSubview:btnLine];
  36. NSString *goodsCodeTitle=@"商品编码:";
  37. UILabel *lblGoodsCodeTitle=[[UILabel alloc]init];
  38. lblGoodsCodeTitle.frame=CGRectMake(xPadding,CGRectGetMaxY(_topSeparator.frame)+yPadding, titleWidth, valueheight);
  39. lblGoodsCodeTitle.textColor=LabelGrayTextColor;
  40. lblGoodsCodeTitle.font=orderTextFont;
  41. lblGoodsCodeTitle.text=goodsCodeTitle;
  42. [self.contentView addSubview:lblGoodsCodeTitle];
  43. NSString *code=inventoryGoodsModel.code;
  44. _lblGoodsCode=[[UILabel alloc]init];
  45. _lblGoodsCode.frame=CGRectMake(CGRectGetMaxX(lblGoodsCodeTitle.frame)+3,CGRectGetMaxY(_topSeparator.frame)+yPadding,Screen_Width/2-CGRectGetMaxX(lblGoodsCodeTitle.frame)-3, valueheight);
  46. _lblGoodsCode.font=orderTextFont;
  47. _lblGoodsCode.text=code;
  48. [self.contentView addSubview:_lblGoodsCode];
  49. NSString *onlyCodeTitle=@"唯一编码:";
  50. UILabel *lblOnlyCodeTitle=[[UILabel alloc]init];
  51. lblOnlyCodeTitle.frame=CGRectMake(Screen_Width/2,CGRectGetMaxY(_topSeparator.frame)+yPadding, titleWidth, valueheight);
  52. lblOnlyCodeTitle.textColor=LabelGrayTextColor;
  53. lblOnlyCodeTitle.font=orderTextFont;
  54. lblOnlyCodeTitle.text=onlyCodeTitle;
  55. [self.contentView addSubview:lblOnlyCodeTitle];
  56. NSString *onlyCode=inventoryGoodsModel.onlyCode;
  57. _lblOnlyCode=[[UILabel alloc]init];
  58. _lblOnlyCode.frame=CGRectMake(CGRectGetMaxX(lblOnlyCodeTitle.frame)+3,CGRectGetMaxY(_topSeparator.frame)+yPadding,Screen_Width/2-lblOnlyCodeTitle.frame.size.width-3, valueheight);
  59. _lblOnlyCode.font=orderTextFont;
  60. _lblOnlyCode.text=onlyCode;
  61. [self.contentView addSubview:_lblOnlyCode];
  62. NSString *colorNumberTitle=@"色号:";
  63. UILabel *lblColorNumberTitle=[[UILabel alloc]init];
  64. lblColorNumberTitle.frame=CGRectMake(xPadding,CGRectGetMaxY(lblGoodsCodeTitle.frame)+yPadding, 40, valueheight);
  65. lblColorNumberTitle.textColor=LabelGrayTextColor;
  66. lblColorNumberTitle.text=colorNumberTitle;
  67. lblColorNumberTitle.font=orderTextFont;
  68. [self.contentView addSubview:lblColorNumberTitle];
  69. NSString *colorNumber=inventoryGoodsModel.colorNumber;
  70. _lblColorNumber=[[UILabel alloc]init];
  71. _lblColorNumber.frame=CGRectMake(CGRectGetMaxX(lblColorNumberTitle.frame)+3,CGRectGetMaxY(lblGoodsCodeTitle.frame)+yPadding,Screen_Width/3-CGRectGetMaxX(lblColorNumberTitle.frame)-3, valueheight);
  72. _lblColorNumber.font=orderTextFont;
  73. _lblColorNumber.text=colorNumber;
  74. [self.contentView addSubview:_lblColorNumber];
  75. NSString *specificationTitle=@"规格:";
  76. UILabel *lblSpecificationTitle=[[UILabel alloc]init];
  77. lblSpecificationTitle.frame=CGRectMake(Screen_Width/3,CGRectGetMaxY(lblGoodsCodeTitle.frame)+yPadding,40, valueheight);
  78. lblSpecificationTitle.textColor=LabelGrayTextColor;
  79. lblSpecificationTitle.font=orderTextFont;
  80. lblSpecificationTitle.text=specificationTitle;
  81. [self.contentView addSubview:lblSpecificationTitle];
  82. NSString *specification=inventoryGoodsModel.specification;
  83. _lblSpecification=[[UILabel alloc]init];
  84. _lblSpecification.frame=CGRectMake(CGRectGetMaxX(lblSpecificationTitle.frame)+3,CGRectGetMaxY(lblGoodsCodeTitle.frame)+yPadding,Screen_Width/3-lblSpecificationTitle.frame.size.width-3, valueheight);
  85. _lblSpecification.font=orderTextFont;
  86. _lblSpecification.text=specification;
  87. [self.contentView addSubview:_lblSpecification];
  88. NSString *gradeTitle=@"等级:";
  89. UILabel *lblGradeTitle=[[UILabel alloc]init];
  90. lblGradeTitle.frame=CGRectMake(Screen_Width/3*2,CGRectGetMaxY(lblGoodsCodeTitle.frame)+yPadding,40, valueheight);
  91. lblGradeTitle.textColor=LabelGrayTextColor;
  92. lblGradeTitle.font=orderTextFont;
  93. lblGradeTitle.text=gradeTitle;
  94. [self.contentView addSubview:lblGradeTitle];
  95. NSString *grade=inventoryGoodsModel.gradeName;
  96. _lblGrade=[[UILabel alloc]init];
  97. _lblGrade.frame=CGRectMake(CGRectGetMaxX(lblGradeTitle.frame)+3,CGRectGetMaxY(lblGoodsCodeTitle.frame)+yPadding,Screen_Width/3-lblGradeTitle.frame.size.width-3, valueheight);
  98. _lblGrade.font=orderTextFont;
  99. _lblGrade.text=grade;
  100. [self.contentView addSubview:_lblGrade];
  101. NSString *warehouseAreaTitle=@"库区:";
  102. UILabel *lblWarehouseAreaTitle=[[UILabel alloc]init];
  103. lblWarehouseAreaTitle.frame=CGRectMake(xPadding,CGRectGetMaxY(lblColorNumberTitle.frame)+yPadding,40, valueheight);
  104. lblWarehouseAreaTitle.textColor=LabelGrayTextColor;
  105. lblWarehouseAreaTitle.font=orderTextFont;
  106. lblWarehouseAreaTitle.text=warehouseAreaTitle;
  107. [self.contentView addSubview:lblWarehouseAreaTitle];
  108. NSString *warehouseAreaName=inventoryGoodsModel.wareHouseName;
  109. _lblWarehouseArea=[[UILabel alloc]init];
  110. _lblWarehouseArea.frame=CGRectMake(CGRectGetMaxX(lblWarehouseAreaTitle.frame)+3,CGRectGetMaxY(lblColorNumberTitle.frame)+yPadding,Screen_Width-CGRectGetMaxX(lblWarehouseAreaTitle.frame)-3, valueheight);
  111. _lblWarehouseArea.font=orderTextFont;
  112. _lblWarehouseArea.text=warehouseAreaName;
  113. [self.contentView addSubview:_lblWarehouseArea];
  114. _middleSeparator=[UIView new];
  115. _middleSeparator.frame = CGRectMake(0, CGRectGetMaxY(lblWarehouseAreaTitle.frame)+yPadding, Screen_Width, 1);
  116. _middleSeparator.backgroundColor=LineBackgroundColor;
  117. [self.contentView addSubview:_middleSeparator];
  118. NSString *inventoryQuantity=inventoryGoodsModel.inventoryQuantity;
  119. _lblEndStocking=[[UILabel alloc]init];
  120. CGRect endStockingFrame = [inventoryQuantity textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:orderDict];
  121. endStockingFrame.origin.x =Screen_Width-endStockingFrame.size.width-10;
  122. endStockingFrame.origin.y = CGRectGetMaxY(_middleSeparator.frame)+yPadding;
  123. _lblEndStocking.frame=endStockingFrame;
  124. _lblEndStocking.textColor=LabelGrayTextColor;
  125. _lblEndStocking.text=inventoryQuantity;
  126. _lblEndStocking.font=orderTextFont;
  127. _lblEndStocking.font=orderTextFont;
  128. [self.contentView addSubview:_lblEndStocking];
  129. NSString *inventoryQuantityTitle=@"结存量:";
  130. UILabel *lblEndStockingTitle=[[UILabel alloc]init];
  131. CGRect endStockingTitleFrame = [inventoryQuantityTitle textRectWithSize:CGSizeMake(150, MAXFLOAT) attributes:orderDict];
  132. endStockingTitleFrame.origin.x =CGRectGetMinX(_lblEndStocking.frame)-endStockingTitleFrame.size.width-10;
  133. endStockingTitleFrame.origin.y = CGRectGetMaxY(_middleSeparator.frame)+yPadding;
  134. lblEndStockingTitle.frame=endStockingTitleFrame;
  135. lblEndStockingTitle.textColor=LabelGrayTextColor;
  136. lblEndStockingTitle.text=inventoryQuantityTitle;
  137. lblEndStockingTitle.font=orderTextFont;
  138. [self.contentView addSubview:lblEndStockingTitle];
  139. NSString *canSalesQuantity=inventoryGoodsModel.canSaleQuantity;
  140. _lblPermitSalesQuantity=[[UILabel alloc]init];
  141. CGRect permitSalesQuantityFrame = [canSalesQuantity textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:orderDict];
  142. permitSalesQuantityFrame.origin.x =CGRectGetMinX(lblEndStockingTitle.frame)-permitSalesQuantityFrame.size.width-3;
  143. permitSalesQuantityFrame.origin.y = CGRectGetMaxY(_middleSeparator.frame)+yPadding;
  144. _lblPermitSalesQuantity.frame=permitSalesQuantityFrame;
  145. _lblPermitSalesQuantity.text=canSalesQuantity;
  146. _lblPermitSalesQuantity.textColor=LabelGrayTextColor;
  147. _lblPermitSalesQuantity.font=orderTextFont;
  148. [self.contentView addSubview:_lblPermitSalesQuantity];
  149. NSString *canSalesQuantityTitle=@"可售量:";
  150. UILabel *lblCanSalesQuantityTitle=[[UILabel alloc]init];
  151. CGRect canSalesQuantityTitleFrame = [canSalesQuantityTitle textRectWithSize:CGSizeMake(150, MAXFLOAT) attributes:orderDict];
  152. canSalesQuantityTitleFrame.origin.x =CGRectGetMinX(_lblPermitSalesQuantity.frame)-canSalesQuantityTitleFrame.size.width-3;
  153. canSalesQuantityTitleFrame.origin.y = CGRectGetMaxY(_middleSeparator.frame)+yPadding;
  154. lblCanSalesQuantityTitle.frame=canSalesQuantityTitleFrame;
  155. lblCanSalesQuantityTitle.font=orderTextFont;
  156. lblCanSalesQuantityTitle.textColor=LabelGrayTextColor;
  157. lblCanSalesQuantityTitle.text=canSalesQuantityTitle;
  158. [self.contentView addSubview:lblCanSalesQuantityTitle];
  159. _bottomSeparator=[UIView new];
  160. _bottomSeparator.frame = CGRectMake(0, CGRectGetMaxY(lblCanSalesQuantityTitle.frame)+yPadding, Screen_Width, 10);
  161. _bottomSeparator.backgroundColor=LineBackgroundColor;
  162. [self.contentView addSubview:_bottomSeparator];
  163. }
  164. //checkbox切换函数
  165. -(void)btnGoCheck
  166. {
  167. if([self.delegate respondsToSelector:@selector(btnInventoryListCheckPressed:)])
  168. {
  169. [self.delegate btnInventoryListCheckPressed:self];
  170. }
  171. }
  172. //设置checkbox背景图片
  173. - (void) setCheckBackground: (BOOL) checked
  174. { if(!checked)
  175. {
  176. [_btnCheck setImage:[UIImage imageNamed:@"order_unchecked"] forState:UIControlStateNormal];
  177. }
  178. else
  179. {
  180. [_btnCheck setImage:[UIImage imageNamed:@"order_checked"] forState:UIControlStateNormal];
  181. }
  182. }
  183. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  184. [super setSelected:selected animated:animated];
  185. }
  186. @end