OtherInStorageGoodsSearchCell.m 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //
  2. // OtherInStorageGoodsSearchCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/4/25.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "OtherInStorageGoodsSearchCell.h"
  9. @implementation OtherInStorageGoodsSearchCell
  10. #pragma mark 公共函数
  11. /**
  12. 加载tableview 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. return self;
  20. }
  21. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  22. [super setSelected:selected animated:animated];
  23. }
  24. #pragma mark 私有函数
  25. /**
  26. 初始化cell UI和数据
  27. @param goodsSearchListModel <#goodsSearchListModel description#>
  28. */
  29. -(void) setOtherInStorageGoodsSearchModel:(OtherInStorageGoodsSearchListModel*)goodsSearchListModel{
  30. _otherGoodsSearchListModel=goodsSearchListModel;
  31. if(_otherGoodsSearchListModel==nil){
  32. return;
  33. }
  34. CGFloat heightLine = 1;
  35. CGFloat heightRow = 40;
  36. CGFloat lblx = 20;
  37. CGFloat lbly = 8;
  38. CGFloat lblwidth = 70;
  39. CGFloat lblheight = 25;
  40. CGFloat valuey = 8;
  41. CGFloat valueheight = 25;
  42. UIView *vGoodsName = [UIView new];
  43. vGoodsName.frame=CGRectMake(0, valuey, Screen_Width, heightRow);
  44. [self.contentView addSubview:vGoodsName];
  45. _btnCheck=[UIButton buttonWithType:UIButtonTypeCustom];
  46. _btnCheck.frame=CGRectMake(lblx,valuey, 25, 25);
  47. [_btnCheck addTarget:self action:@selector(btnGoCheck) forControlEvents:UIControlEventTouchUpInside];
  48. [vGoodsName addSubview:_btnCheck];
  49. _lblGoodsName = [UILabel new];
  50. _lblGoodsName.frame=CGRectMake(CGRectGetMaxX(_btnCheck.frame)+10, valuey, Screen_Width-CGRectGetMaxX(_btnCheck.frame), valueheight);
  51. _lblGoodsName.textColor = [UIColor blackColor];
  52. _lblGoodsName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  53. [vGoodsName addSubview:_lblGoodsName];
  54. _lblGoodsName.text = _otherGoodsSearchListModel.goodsName;
  55. //分割线
  56. _topSeparator= [UIView new];
  57. _topSeparator.frame = CGRectMake(0, CGRectGetMaxY(vGoodsName.frame), Screen_Width, heightLine);
  58. [self.contentView addSubview:_topSeparator];
  59. UIButton *btnLine = [UIButton buttonWithType:UIButtonTypeCustom];
  60. [btnLine setBackgroundImage:[UIImage imageNamed:@"dash"] forState:UIControlStateNormal];
  61. btnLine.frame = CGRectMake(0 ,0 , Screen_Width, heightLine);
  62. [_topSeparator addSubview:btnLine];
  63. //商品编码
  64. UIView *vGoodsCode = [UIView new];
  65. vGoodsCode.frame=CGRectMake(0, CGRectGetMaxY(_topSeparator.frame), Screen_Width/2, heightRow);
  66. [self.contentView addSubview:vGoodsCode];
  67. UILabel *lblGoodsCodeTitle=[UILabel new];
  68. lblGoodsCodeTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  69. lblGoodsCodeTitle.text=@"商品编码:";
  70. lblGoodsCodeTitle.textColor = [UIColor blackColor];
  71. lblGoodsCodeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  72. [vGoodsCode addSubview:lblGoodsCodeTitle];
  73. _lblGoodsCode = [UILabel new];
  74. _lblGoodsCode.frame=CGRectMake(CGRectGetMaxX(lblGoodsCodeTitle.frame), valuey, Screen_Width/2 -CGRectGetMaxX(lblGoodsCodeTitle.frame), valueheight);
  75. _lblGoodsCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  76. [vGoodsCode addSubview:_lblGoodsCode];
  77. _lblGoodsCode.text = _otherGoodsSearchListModel.code;
  78. UIView *vOnlyCode = [UIView new];
  79. vOnlyCode.frame=CGRectMake(Screen_Width / 2, CGRectGetMaxY(_topSeparator.frame), Screen_Width / 2, heightRow);
  80. [self.contentView addSubview: vOnlyCode];
  81. UILabel *lblOnlyCodeTitle=[UILabel new];
  82. lblOnlyCodeTitle.frame=CGRectMake(5, lbly, lblwidth, lblheight);
  83. lblOnlyCodeTitle.text=@"唯一编码:";
  84. lblOnlyCodeTitle.textColor = [UIColor blackColor];
  85. lblOnlyCodeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  86. [vOnlyCode addSubview:lblOnlyCodeTitle];
  87. _lblOnlyCode= [UILabel new];
  88. _lblOnlyCode.frame=CGRectMake(CGRectGetMaxX(lblOnlyCodeTitle.frame), valuey, Screen_Width/2-lblwidth-5 , valueheight);
  89. _lblOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  90. [vOnlyCode addSubview:_lblOnlyCode];
  91. _lblOnlyCode.text = _otherGoodsSearchListModel.onlyCode;
  92. UIView *vBrand = [UIView new];
  93. vBrand.frame=CGRectMake(0, CGRectGetMaxY(vGoodsCode.frame), Screen_Width/2, heightRow);
  94. [self.contentView addSubview:vBrand];
  95. UILabel *lblBrandTitle=[UILabel new];
  96. lblBrandTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  97. lblBrandTitle.text=@"品 牌:";
  98. lblBrandTitle.textColor = [UIColor blackColor];
  99. lblBrandTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  100. [vBrand addSubview:lblBrandTitle];
  101. _lblBrand = [UILabel new];
  102. _lblBrand.frame=CGRectMake(CGRectGetMaxX(lblBrandTitle.frame), valuey, Screen_Width/2 -CGRectGetMaxX(lblBrandTitle.frame), valueheight);
  103. _lblBrand.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  104. [vBrand addSubview:_lblBrand];
  105. _lblBrand.text = _otherGoodsSearchListModel.brandName;
  106. UIView *vKind = [UIView new];
  107. vKind.frame=CGRectMake(Screen_Width / 2, CGRectGetMaxY(vGoodsCode.frame), Screen_Width / 2, heightRow);
  108. [self.contentView addSubview: vKind];
  109. UILabel *lblKindTitle=[UILabel new];
  110. lblKindTitle.frame=CGRectMake(5, lbly, lblwidth, lblheight);
  111. lblKindTitle.text=@"种 类:";
  112. lblKindTitle.textColor = [UIColor blackColor];
  113. lblKindTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  114. [vKind addSubview:lblKindTitle];
  115. _lblKind= [UILabel new];
  116. _lblKind.frame=CGRectMake(CGRectGetMaxX(lblKindTitle.frame), valuey, Screen_Width/2-lblwidth-5 , valueheight);
  117. _lblKind.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  118. [vKind addSubview:_lblKind];
  119. _lblKind.text = _otherGoodsSearchListModel.kindName;
  120. UIView *vVariety = [UIView new];
  121. vVariety.frame=CGRectMake(0, CGRectGetMaxY(vBrand.frame), Screen_Width / 2, heightRow);
  122. [self.contentView addSubview: vVariety];
  123. UILabel *lblVarietyTitle=[UILabel new];
  124. lblVarietyTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  125. lblVarietyTitle.text=@"品 种:";
  126. lblVarietyTitle.textColor = [UIColor blackColor];
  127. lblVarietyTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  128. [vVariety addSubview:lblVarietyTitle];
  129. _lblVariety= [UILabel new];
  130. _lblVariety.frame=CGRectMake(CGRectGetMaxX(lblVarietyTitle.frame), valuey, Screen_Width/2-lblwidth-5 , valueheight);
  131. _lblVariety.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  132. [vVariety addSubview:_lblVariety];
  133. _lblVariety.text = _otherGoodsSearchListModel.varietyName;
  134. UIView *vSeries = [UIView new];
  135. vSeries.frame=CGRectMake(Screen_Width / 2, CGRectGetMaxY(vBrand.frame), Screen_Width / 2, heightRow);
  136. [self.contentView addSubview: vSeries];
  137. UILabel *lblSeriesTitle=[UILabel new];
  138. lblSeriesTitle.frame=CGRectMake(5, lbly, lblwidth, lblheight);
  139. lblSeriesTitle.text=@"系 列:";
  140. lblSeriesTitle.textColor = [UIColor blackColor];
  141. lblSeriesTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  142. [vSeries addSubview:lblSeriesTitle];
  143. _lblSeries= [UILabel new];
  144. _lblSeries.frame=CGRectMake(CGRectGetMaxX(lblSeriesTitle.frame), valuey, Screen_Width/2-lblwidth-5 , valueheight);
  145. _lblSeries.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  146. [vSeries addSubview:_lblSeries];
  147. _lblSeries.text = _otherGoodsSearchListModel.seriesName;
  148. UIView *vSpecification= [UIView new];
  149. vSpecification.frame=CGRectMake(0, CGRectGetMaxY(vVariety.frame), Screen_Width, heightRow);
  150. [self.contentView addSubview:vSpecification];
  151. UILabel *lblSpecificationTitle=[UILabel new];
  152. lblSpecificationTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  153. lblSpecificationTitle.text=@"规 格:";
  154. lblSpecificationTitle.textColor = [UIColor blackColor];
  155. lblSpecificationTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  156. [vSpecification addSubview:lblSpecificationTitle];
  157. _lblSpecification = [UILabel new];
  158. _lblSpecification.frame=CGRectMake(CGRectGetMaxX(lblSpecificationTitle.frame), valuey, vSpecification.frame.size.width -lblwidth-10, valueheight);
  159. _lblSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  160. [vSpecification addSubview:_lblSpecification];
  161. _lblSpecification.text = _otherGoodsSearchListModel.specification;
  162. _bottomSeparator= [UIView new];
  163. _bottomSeparator.frame=CGRectMake(0, CGRectGetMaxY(vSpecification.frame)+5, Screen_Width, 10);
  164. _bottomSeparator.backgroundColor = LineBackgroundColor;
  165. [self.contentView addSubview:_bottomSeparator];
  166. }
  167. /**
  168. check box点击事件
  169. */
  170. -(void)btnGoCheck
  171. {
  172. if([self.inStorageDelegate respondsToSelector:@selector(btnCheckPressed:)])
  173. {
  174. [self.inStorageDelegate btnCheckPressed:_index];
  175. }
  176. }
  177. //设置checkbox背景图片
  178. - (void) setCheckBackground: (BOOL) checked
  179. {
  180. if(!checked)
  181. {
  182. [_btnCheck setImage:[UIImage imageNamed:@"uncheck_round"] forState:UIControlStateNormal];
  183. }
  184. else
  185. {
  186. [_btnCheck setImage:[UIImage imageNamed:@"check_round"] forState:UIControlStateNormal];
  187. }
  188. }
  189. @end