NewSalesOutStorageGoodsListCell.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. //
  2. // NewSalesOutStorageGoodsListCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/4/18.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "NewSalesOutStorageGoodsListCell.h"
  9. @implementation NewSalesOutStorageGoodsListCell
  10. #pragma mark 公共函数
  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. return self;
  20. }
  21. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  22. [super setSelected:selected animated:animated];
  23. }
  24. #pragma 委托函数
  25. /**
  26. textfield结束编辑回调函数
  27. @param field <#field description#>
  28. */
  29. - (void) textFieldDidEndEditing:(UITextField *) field
  30. {
  31. if(field.tag==1000){
  32. NSString *remarks=field.text;
  33. _goodsListModel.remark=remarks;
  34. return;
  35. }
  36. else if(field.tag==1001){
  37. NSString *outGoingQuantity=field.text;
  38. if(outGoingQuantity!=nil){
  39. double quantityValue=outGoingQuantity.doubleValue;
  40. NSInteger circulateType= _goodsListModel.circulateType;
  41. NSString *quantity= [NSString stringWithFormat:@"%lf",quantityValue];
  42. double acreage=[_goodsListModel.acreage doubleValue];
  43. OrderQuantity *orderQuantity=[OrderQuantity new];
  44. NSInteger decimalPlaces= _goodsListModel.decimalPlaces;
  45. NSString *calculateQuantity= [orderQuantity calculateOrderQuantity:circulateType decimalPlaces:[NSString stringWithFormat:@"%ld",(long)decimalPlaces] quantity:quantity acreage:acreage];
  46. _goodsListModel.outGoingQuantity=calculateQuantity;
  47. _txtDeliveryQuantity.text=calculateQuantity;
  48. }
  49. else{
  50. _goodsListModel.outGoingQuantity=@"0";
  51. _txtDeliveryQuantity.text=@"0";
  52. }
  53. return;
  54. }
  55. }
  56. #pragma mark 私有函数
  57. /**
  58. 初始化cell UI和数据
  59. @param salesOutStorageGoodsListModel <#salesOutStorageGoodsListModel description#>
  60. */
  61. - (void)setNewSalesOutStorageGoodsDetailListModel:(SalesOutStorageSalesSlipGoodsListModel *)salesOutStorageGoodsListModel{
  62. _goodsListModel=salesOutStorageGoodsListModel;
  63. if(_goodsListModel==nil){
  64. return;
  65. }
  66. CGFloat heightLine = 1;
  67. CGFloat heightRow = 40;
  68. CGFloat lblx = 20;
  69. CGFloat lbly = 8;
  70. CGFloat lblwidth = 70;
  71. CGFloat lblheight = 25;
  72. CGFloat valuey = 8;
  73. CGFloat valueheight = 25;
  74. UIView *vGoodsName = [UIView new];
  75. vGoodsName.frame=CGRectMake(0, valuey, Screen_Width, heightRow);
  76. [self.contentView addSubview:vGoodsName];
  77. _lblGoodsName=[[UILabel alloc]init];
  78. _lblGoodsName.frame=CGRectMake(lblx, lbly+2,Screen_Width-85, valueheight);
  79. _lblGoodsName.text=salesOutStorageGoodsListModel.goodsName;
  80. _lblGoodsName.font=orderTextFont;
  81. [self.contentView addSubview:_lblGoodsName];
  82. _btnDelete=[UIButton buttonWithType:UIButtonTypeCustom];
  83. _btnDelete.frame=CGRectMake(Screen_Width-80,lbly-5,80, valueheight);
  84. [vGoodsName addSubview:_btnDelete];
  85. [_btnDelete addTarget:self action:@selector(deleteGoods) forControlEvents:UIControlEventTouchUpInside];
  86. UIImageView *deleteImg=[[UIImageView alloc]init];
  87. deleteImg.frame=CGRectMake(0,5,15,15);
  88. [deleteImg setImage:[UIImage imageNamed:@"icon_delete"]];
  89. deleteImg.userInteractionEnabled=NO;
  90. [_btnDelete addSubview:deleteImg];
  91. UILabel *deleteTitle=[[UILabel alloc]init];
  92. deleteTitle.frame=CGRectMake(CGRectGetMaxX(deleteImg.frame)+3,0,40, 25);
  93. deleteTitle.text=@"删除";
  94. deleteTitle.font=orderTextFont;
  95. [_btnDelete addSubview:deleteTitle];
  96. //分割线
  97. _topSeparator= [UIView new];
  98. _topSeparator.frame = CGRectMake(0, CGRectGetMaxY(vGoodsName.frame), Screen_Width, heightLine);
  99. [self.contentView addSubview:_topSeparator];
  100. UIButton *btnLine = [UIButton buttonWithType:UIButtonTypeCustom];
  101. [btnLine setBackgroundImage:[UIImage imageNamed:@"dash"] forState:UIControlStateNormal];
  102. btnLine.frame = CGRectMake(0 ,0 , Screen_Width, heightLine);
  103. [_topSeparator addSubview:btnLine];
  104. //商品编码
  105. UIView *vGoodsCode = [UIView new];
  106. vGoodsCode.frame=CGRectMake(0, CGRectGetMaxY(_topSeparator.frame), Screen_Width/2, heightRow);
  107. [self.contentView addSubview:vGoodsCode];
  108. UILabel *lblGoodsCodeTitle=[UILabel new];
  109. lblGoodsCodeTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  110. lblGoodsCodeTitle.text=@"商品编码:";
  111. lblGoodsCodeTitle.textColor = LabelGrayTextColor;
  112. lblGoodsCodeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  113. [vGoodsCode addSubview:lblGoodsCodeTitle];
  114. _lblGoodsCode = [UILabel new];
  115. _lblGoodsCode.frame=CGRectMake(CGRectGetMaxX(lblGoodsCodeTitle.frame), valuey, Screen_Width/2 -CGRectGetMaxX(lblGoodsCodeTitle.frame), valueheight);
  116. _lblGoodsCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  117. [vGoodsCode addSubview:_lblGoodsCode];
  118. _lblGoodsCode.text = salesOutStorageGoodsListModel.goodsCode;
  119. //唯一编码
  120. UIView *vOnlyCode = [UIView new];
  121. vOnlyCode.frame=CGRectMake(Screen_Width / 2, CGRectGetMaxY(_topSeparator.frame), Screen_Width / 2, heightRow);
  122. [self.contentView addSubview: vOnlyCode];
  123. UILabel *lblOnlyCodeTitle=[UILabel new];
  124. lblOnlyCodeTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
  125. lblOnlyCodeTitle.text=@"唯一编码:";
  126. lblOnlyCodeTitle.textColor = LabelGrayTextColor;
  127. lblOnlyCodeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  128. [vOnlyCode addSubview:lblOnlyCodeTitle];
  129. _lblOnlyCode= [UILabel new];
  130. _lblOnlyCode.frame=CGRectMake(CGRectGetMaxX(lblOnlyCodeTitle.frame), valuey, Screen_Width/2-lblwidth-5 , valueheight);
  131. _lblOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  132. [vOnlyCode addSubview:_lblOnlyCode];
  133. _lblOnlyCode.text = salesOutStorageGoodsListModel.onlyCode;
  134. UIView *vColorNumber= [UIView new];
  135. vColorNumber.frame=CGRectMake(0, CGRectGetMaxY(vGoodsCode.frame), Screen_Width/3, heightRow);
  136. [self.contentView addSubview: vColorNumber];
  137. UILabel *lblColorNumberTitle=[UILabel new];
  138. lblColorNumberTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  139. lblColorNumberTitle.text=@"色 号:";
  140. lblColorNumberTitle.textColor = [UIColor redColor];
  141. lblColorNumberTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  142. [vColorNumber addSubview:lblColorNumberTitle];
  143. _lblColorNumber= [UILabel new];
  144. _lblColorNumber.frame=CGRectMake(CGRectGetMaxX(lblColorNumberTitle.frame), valuey, vColorNumber.frame.size.width-lblwidth-5 , valueheight);
  145. _lblColorNumber.userInteractionEnabled=YES;
  146. _lblColorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  147. [vColorNumber addSubview:_lblColorNumber];
  148. _lblColorNumber.text = salesOutStorageGoodsListModel.colorNumber;
  149. UITapGestureRecognizer *tapRecognizerColorNumber=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goColorNumber:)];
  150. _lblColorNumber.userInteractionEnabled=YES;
  151. [_lblColorNumber addGestureRecognizer:tapRecognizerColorNumber];
  152. UIView *vSpecification= [UIView new];
  153. vSpecification.frame=CGRectMake(Screen_Width/3, CGRectGetMaxY(vGoodsCode.frame), Screen_Width/3, heightRow);
  154. [self.contentView addSubview:vSpecification];
  155. UILabel *lblSpecificationTitle=[UILabel new];
  156. lblSpecificationTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
  157. lblSpecificationTitle.text=@"规 格:";
  158. lblSpecificationTitle.textColor = LabelGrayTextColor;
  159. lblSpecificationTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  160. [vSpecification addSubview:lblSpecificationTitle];
  161. _lblSpecification = [UILabel new];
  162. _lblSpecification.frame=CGRectMake(CGRectGetMaxX(lblSpecificationTitle.frame), valuey, vSpecification.frame.size.width -lblwidth, valueheight);
  163. _lblSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  164. [vSpecification addSubview:_lblSpecification];
  165. _lblSpecification.text = salesOutStorageGoodsListModel.goodsSpecification;
  166. UIView *vGrade= [UIView new];
  167. vGrade.frame=CGRectMake(CGRectGetMaxX(vSpecification.frame), CGRectGetMaxY(vGoodsCode.frame),Screen_Width-CGRectGetMaxX(vSpecification.frame), heightRow);
  168. [self.contentView addSubview:vGrade];
  169. UILabel *lblGradeTitle=[UILabel new];
  170. lblGradeTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
  171. lblGradeTitle.text=@"等 级:";
  172. lblGradeTitle.textColor = LabelGrayTextColor;
  173. lblGradeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  174. [vGrade addSubview:lblGradeTitle];
  175. _lblGrade = [UILabel new];
  176. _lblGrade.frame=CGRectMake(CGRectGetMaxX(lblGradeTitle.frame), lbly,vGrade.frame.size.width-lblwidth-5, valueheight);
  177. _lblGrade.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  178. [vGrade addSubview:_lblGrade];
  179. _lblGrade.text = salesOutStorageGoodsListModel.gradeName;
  180. UIView *vRemarks= [UIView new];
  181. vRemarks.frame=CGRectMake(0, CGRectGetMaxY(vColorNumber.frame), Screen_Width, heightRow);
  182. [self.contentView addSubview:vRemarks];
  183. UILabel *lblRemarksTitle=[UILabel new];
  184. lblRemarksTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  185. lblRemarksTitle.text=@"备 注:";
  186. lblRemarksTitle.textColor = LabelGrayTextColor;
  187. lblRemarksTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  188. [vRemarks addSubview:lblRemarksTitle];
  189. _txtRemarks =[UITextField new];
  190. _txtRemarks.placeholder=@"请输入备注";
  191. _txtRemarks.delegate=self;
  192. _txtRemarks.tag=1000;
  193. _txtRemarks.text=salesOutStorageGoodsListModel.remark;
  194. _txtRemarks.frame=CGRectMake(CGRectGetMaxX(lblRemarksTitle.frame), valuey, Screen_Width-CGRectGetMaxX(lblRemarksTitle.frame)-5, valueheight);
  195. _txtRemarks.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  196. [vRemarks addSubview:_txtRemarks];
  197. _middleSeparator= [UIView new];
  198. _middleSeparator.frame = CGRectMake(0, CGRectGetMaxY(vRemarks.frame), Screen_Width,1);
  199. [_middleSeparator setBackgroundColor:LineBackgroundColor];
  200. [self.contentView addSubview:_middleSeparator];
  201. NSDictionary *outStorageDict = @{NSFontAttributeName:orderTextFont};
  202. UIView *vQuantity=[UIView new];
  203. vQuantity.frame=CGRectMake(0,CGRectGetMaxY(_middleSeparator.frame),Screen_Width, heightRow);
  204. [self.contentView addSubview:vQuantity];
  205. NSString *outQuantityStr = salesOutStorageGoodsListModel.outQuantity;
  206. CGRect outQuantityFrame = [outQuantityStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:outStorageDict];
  207. outQuantityFrame.origin.x =Screen_Width-outQuantityFrame.size.width-20;
  208. outQuantityFrame.origin.y = lbly;
  209. _lblOutQuantity=[UILabel new];
  210. _lblOutQuantity.frame=outQuantityFrame;
  211. _lblOutQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  212. _lblOutQuantity.textColor=[UIColor redColor];
  213. [vQuantity addSubview:_lblOutQuantity];
  214. _lblOutQuantity.text = salesOutStorageGoodsListModel.outQuantity;
  215. NSString *outQuantityTitleStr =@"已出数量:";
  216. CGRect outQuantityTitleFrame = [outQuantityTitleStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:outStorageDict];
  217. outQuantityTitleFrame.origin.x =Screen_Width-outQuantityFrame.size.width-outQuantityTitleFrame.size.width-3-20;
  218. outQuantityTitleFrame.origin.y = lbly;
  219. UILabel *lblOutQuantityTitle=[UILabel new];
  220. lblOutQuantityTitle.frame=outQuantityTitleFrame;
  221. lblOutQuantityTitle.textColor=[UIColor redColor];
  222. lblOutQuantityTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  223. lblOutQuantityTitle.text=outQuantityTitleStr;
  224. [vQuantity addSubview:lblOutQuantityTitle];
  225. NSString *salesQuantityStr = salesOutStorageGoodsListModel.salesQuantity;
  226. CGRect salesQuantityFrame = [salesQuantityStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:outStorageDict];
  227. salesQuantityFrame.origin.x =Screen_Width-outQuantityFrame.size.width-outQuantityTitleFrame.size.width-salesQuantityFrame.size.width-20-3-5;
  228. salesQuantityFrame.origin.y = lbly;
  229. _lblSalesQuantity=[UILabel new];
  230. _lblSalesQuantity.frame=salesQuantityFrame;
  231. _lblSalesQuantity.text=salesQuantityStr;
  232. _lblSalesQuantity.textColor=[UIColor redColor];
  233. _lblSalesQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  234. [vQuantity addSubview:_lblSalesQuantity];
  235. NSString *salesQuantityTitle=@"销售数量";
  236. CGRect salesQuantityTitleFrame = [salesQuantityTitle textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:outStorageDict];
  237. salesQuantityTitleFrame.origin.x =Screen_Width-outQuantityFrame.size.width-outQuantityTitleFrame.size.width-salesQuantityFrame.size.width-salesQuantityTitleFrame.size.width-20-3*2-5;
  238. salesQuantityTitleFrame.origin.y = lbly;
  239. UILabel *lblSalesQuantityTitle=[UILabel new];
  240. lblSalesQuantityTitle.frame=salesQuantityTitleFrame;
  241. lblSalesQuantityTitle.textColor=[UIColor redColor];
  242. lblSalesQuantityTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  243. lblSalesQuantityTitle.text=salesQuantityTitle;
  244. [vQuantity addSubview:lblSalesQuantityTitle];
  245. UIView *vOutQuantity=[UIView new];
  246. vOutQuantity.frame=CGRectMake(0,CGRectGetMaxY(vQuantity.frame),Screen_Width, heightRow);
  247. [self.contentView addSubview:vOutQuantity];
  248. _txtDeliveryQuantity=[UITextField new];
  249. _txtDeliveryQuantity.frame=CGRectMake(Screen_Width-110,0,90, valueheight);
  250. _txtDeliveryQuantity.text=salesOutStorageGoodsListModel.outGoingQuantity;
  251. _txtDeliveryQuantity.delegate=self;
  252. _txtDeliveryQuantity.keyboardType=UIKeyboardTypeDecimalPad;
  253. _txtDeliveryQuantity.layer.borderWidth=0.5f;
  254. _txtDeliveryQuantity.tag=1001;
  255. _txtDeliveryQuantity.textAlignment=NSTextAlignmentCenter;
  256. _txtDeliveryQuantity.layer.borderColor=[UIColor blackColor].CGColor;
  257. _txtDeliveryQuantity.font=orderTextFont;
  258. [vOutQuantity addSubview:_txtDeliveryQuantity];
  259. _lblSalesPrice=[UILabel new];
  260. _lblSalesPrice.frame=CGRectMake(Screen_Width-210,0,100, valueheight);
  261. _lblSalesPrice.text=[NSString stringWithFormat:@"¥%@",salesOutStorageGoodsListModel.salesPrice];
  262. _lblSalesPrice.layer.borderWidth=0.5f;
  263. _lblSalesPrice.textColor=LabelGrayTextColor;
  264. _lblSalesPrice.textAlignment=NSTextAlignmentCenter;
  265. _lblSalesPrice.layer.borderColor=[UIColor blackColor].CGColor;
  266. _lblSalesPrice.font=orderTextFont;
  267. [vOutQuantity addSubview:_lblSalesPrice];
  268. _bottomSeparator= [UIView new];
  269. _bottomSeparator.frame = CGRectMake(0, CGRectGetMaxY(vOutQuantity.frame), Screen_Width,10);
  270. [_bottomSeparator setBackgroundColor:LineBackgroundColor];
  271. [self.contentView addSubview:_bottomSeparator];
  272. }
  273. /**
  274. 跳转到色号页面
  275. @param gesture <#gesture description#>
  276. */
  277. -(void)goColorNumber:(UITapGestureRecognizer *)gesture{
  278. if([self.goodsDelegate respondsToSelector:@selector(goColorNumber:)])
  279. {
  280. [self.goodsDelegate goColorNumber:_index];
  281. }
  282. }
  283. /**
  284. 删除商品
  285. */
  286. -(void)deleteGoods{
  287. if([self.goodsDelegate respondsToSelector:@selector(deleteGoods:)])
  288. {
  289. [self.goodsDelegate deleteGoods:_index];
  290. }
  291. }
  292. @end