InventoryFreezeGoodsDetailViewController.m 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //
  2. // InventoryFreezeGoodsDetailViewController.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/5/8.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "InventoryFreezeGoodsDetailViewController.h"
  9. #import "OrderQuantity.h"
  10. @interface InventoryFreezeGoodsDetailViewController ()
  11. @end
  12. @implementation InventoryFreezeGoodsDetailViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. _goodsDetailArray=[[NSMutableArray alloc]init];
  16. [self loadNavStyle];
  17. [self initUI];
  18. [self reloadData];
  19. }
  20. /**
  21. 导航按钮样式
  22. */
  23. - (void)loadNavStyle
  24. {
  25. self.navigationItem.title =@"冻结产品明细";
  26. //返回
  27. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  28. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  29. [button addTarget:self action:@selector(goBack)
  30. forControlEvents:UIControlEventTouchUpInside];
  31. button.frame = CGRectMake(0, 0,45,22);
  32. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  33. self.navigationItem.leftBarButtonItem = menuButton;
  34. }
  35. -(void)goBack
  36. {
  37. [self.navigationController popViewControllerAnimated:YES];
  38. }
  39. -(void)initUI
  40. {
  41. self.view.backgroundColor = [UIColor whiteColor];
  42. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height)];
  43. _tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  44. _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  45. _tableView.delegate = self;
  46. _tableView.dataSource=self;
  47. [self.view addSubview:_tableView];
  48. }
  49. /**
  50. 安全区视图发生变化
  51. */
  52. -(void)viewSafeAreaInsetsDidChange{
  53. _tableView.frame =CGRectMake(0,0, self.view.frame.size.width,self.view.safeAreaLayoutGuide.layoutFrame.size.height);
  54. [super viewSafeAreaInsetsDidChange];
  55. }
  56. -(void)reloadData
  57. {
  58. _downManager = [[ASIDownManager alloc] init];
  59. _downManager.delegate = self;
  60. _downManager.onRequestSuccess = @selector(onDataLoadFinish:);
  61. _downManager.onRequestFail = @selector(onDataLoadFail:);
  62. NSString *urlStr = ServerURL;
  63. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  64. [dict setObject:@"GetFreezeDetailData" forKey:@"Action"];
  65. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  66. [dict setObject:kkUserCode forKey:@"UserCode"];
  67. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  68. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  69. [dict setObject:_freezeId forKey:@"FreezeID"];
  70. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  71. }
  72. -(void)onDataLoadFail:(ASIDownManager *)sender {
  73. [self cancel];
  74. [self showAlertViewText:@"网络异常"];
  75. }
  76. -(void)onDataLoadFinish:(ASIDownManager*)sender {
  77. [self cancel];
  78. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  79. int iStatus = resultModel.status;
  80. // 服务器返回数据消息
  81. NSString *message = resultModel.message;
  82. if(iStatus==0)
  83. {
  84. NSArray *resultArray=(NSArray*)resultModel.result;
  85. if(resultArray!=nil&&resultArray.count>0)
  86. {
  87. for(int i=0;i<resultArray.count;i++)
  88. {
  89. NSDictionary *resultDic=[resultArray objectAtIndex:i];
  90. InventoryFreezeGoodsDetailModel *goodsDetailModel=
  91. [InventoryFreezeGoodsDetailModel dk_modelWithDictionary:resultDic];
  92. OrderQuantity *orderQuantity=[OrderQuantity new];
  93. [orderQuantity setFreezeDetailBoxAndPiece:[goodsDetailModel.freezeQuantitys doubleValue] model:goodsDetailModel ];
  94. [_goodsDetailArray addObject:goodsDetailModel];
  95. }
  96. [_tableView reloadData];
  97. }
  98. }
  99. }
  100. /**
  101. 单元格cell个数
  102. @param tableView <#tableView description#>
  103. @param section <#section description#>
  104. @return <#return value description#>
  105. */
  106. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  107. {
  108. return [_goodsDetailArray count];
  109. }
  110. /**
  111. table view 分区数
  112. @param tableView <#tableView description#>
  113. @return <#return value description#>
  114. */
  115. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  116. return 1;
  117. }
  118. /**
  119. cell 高度
  120. @param tableView <#tableView description#>
  121. @param indexPath <#indexPath description#>
  122. @return <#return value description#>
  123. */
  124. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  125. return [self.heights[@(indexPath.row)] doubleValue];;
  126. }
  127. /**
  128. 高度
  129. @return <#return value description#>
  130. */
  131. - (NSMutableDictionary *)heights{
  132. if (_heights == nil){
  133. _heights = [NSMutableDictionary dictionary];
  134. }
  135. return _heights;
  136. }
  137. /**
  138. 预防高度
  139. @param tableView <#tableView description#>
  140. @param indexPath <#indexPath description#>
  141. @return <#return value description#>
  142. */
  143. -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  144. return 250;
  145. }
  146. /**
  147. 每个单元格cell
  148. @param tableView <#tableView description#>
  149. @param indexPath <#indexPath description#>
  150. @return <#return value description#>
  151. */
  152. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  153. {
  154. static NSString *cellIdentifier = @"InventoryFreezeGoodsDetailListCell";
  155. InventoryFreezeGoodsDetailListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  156. cell = [[InventoryFreezeGoodsDetailListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  157. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  158. InventoryFreezeGoodsDetailModel *detailModel= [_goodsDetailArray objectAtIndex:indexPath.row];
  159. [cell setInventoryFreezeGoodsDetailListCell:detailModel];
  160. self.heights[@(indexPath.row)] = @(cell.height);
  161. return cell;
  162. }
  163. /**
  164. 进度条隐藏
  165. */
  166. - (void)cancel {
  167. [self stopLoading];
  168. }
  169. @end