InventoryUnfreezeGoodsDetailViewController.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. //
  2. // InventoryUnfreezeGoodsDetailViewController.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/5/22.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "InventoryUnfreezeGoodsDetailViewController.h"
  9. #import "OrderQuantity.h"
  10. @interface InventoryUnfreezeGoodsDetailViewController ()
  11. @end
  12. @implementation InventoryUnfreezeGoodsDetailViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. [self loadNavStyle];
  16. [self initUI];
  17. _unfreezeGoodsList=[[NSMutableArray alloc]init];
  18. [self loadDetailData];
  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)initUI
  36. {
  37. self.view.backgroundColor = [UIColor whiteColor];
  38. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height)];
  39. _tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  40. _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  41. _tableView.delegate = self;
  42. _tableView.dataSource=self;
  43. [self.view addSubview:_tableView];
  44. }
  45. -(void)loadDetailData
  46. {
  47. [self startLoading];
  48. _mDownManager = [[ASIDownManager alloc] init];
  49. _mDownManager.delegate = self;
  50. _mDownManager.onRequestSuccess = @selector(onGoodsDetailLoadFinish:);
  51. _mDownManager.onRequestFail = @selector(onGoodsDetailLoadFail:);
  52. NSString *urlStr = ServerURL;
  53. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  54. [dict setObject:@"GetUnFreezeDetailDataIPhone" forKey:@"Action"];
  55. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  56. [dict setObject:kkUserCode forKey:@"UserCode"];
  57. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  58. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  59. [dict setObject:_unfreezeId forKey:@"UnFreezeID"];
  60. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  61. }
  62. -(void)onGoodsDetailLoadFail:(ASIDownManager *)sender {
  63. [self cancel];
  64. [self showAlertViewText:@"网络异常"];
  65. }
  66. -(void)onGoodsDetailLoadFinish:(ASIDownManager *)sender {
  67. [self cancel];
  68. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  69. int iStatus = resultModel.status;
  70. // 服务器返回数据消息
  71. NSString *message = resultModel.message;
  72. if(iStatus==0)
  73. {
  74. NSArray *resultArray=(NSArray*)resultModel.result;
  75. if(resultArray!=nil&&resultArray.count>0)
  76. {
  77. for(int i=0;i<resultArray.count;i++)
  78. {
  79. NSDictionary *resultDic=[resultArray objectAtIndex:i];
  80. InventoryUnfreezeGoodsModel *goodsListModel=[InventoryUnfreezeGoodsModel dk_modelWithDictionary:resultDic];
  81. OrderQuantity *quantity=[OrderQuantity new];
  82. [quantity setUnfreezeDetailBoxAndPiece:[goodsListModel.unfreezeQuantity doubleValue] model:goodsListModel];
  83. [_unfreezeGoodsList addObject:goodsListModel];
  84. }
  85. [_tableView reloadData];
  86. }
  87. }
  88. // 服务器返回数据状态值异常
  89. else if(iStatus == ActionResultStatusAuthError
  90. ||iStatus == ActionResultStatusNoLogin
  91. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  92. [self showReLoginDialog:message];
  93. }
  94. else{
  95. [self showAlertViewText:message];
  96. }
  97. }
  98. /**
  99. 单元格cell个数
  100. @param tableView <#tableView description#>
  101. @param section <#section description#>
  102. @return <#return value description#>
  103. */
  104. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  105. {
  106. return [_unfreezeGoodsList count];
  107. }
  108. /**
  109. table view 分区数
  110. @param tableView <#tableView description#>
  111. @return <#return value description#>
  112. */
  113. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  114. return 1;
  115. }
  116. /**
  117. cell 高度
  118. @param tableView <#tableView description#>
  119. @param indexPath <#indexPath description#>
  120. @return <#return value description#>
  121. */
  122. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  123. return [self.heights[@(indexPath.row)] doubleValue];;
  124. }
  125. /**
  126. 高度
  127. @return <#return value description#>
  128. */
  129. - (NSMutableDictionary *)heights{
  130. if (_heights == nil){
  131. _heights = [NSMutableDictionary dictionary];
  132. }
  133. return _heights;
  134. }
  135. /**
  136. 预防高度
  137. @param tableView <#tableView description#>
  138. @param indexPath <#indexPath description#>
  139. @return <#return value description#>
  140. */
  141. -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  142. return 250;
  143. }
  144. /**
  145. 每个单元格cell
  146. @param tableView <#tableView description#>
  147. @param indexPath <#indexPath description#>
  148. @return <#return value description#>
  149. */
  150. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  151. {
  152. static NSString *cellIdentifier = @"InventoryUnfreezeGoodsDetailListCell";
  153. InventoryUnfreezeGoodsDetailListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  154. cell = [[InventoryUnfreezeGoodsDetailListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  155. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  156. InventoryUnfreezeGoodsModel *detailModel= [_unfreezeGoodsList objectAtIndex:indexPath.row];
  157. [cell setInventoryUnfreezeGoodsDetailListCell:detailModel];
  158. self.heights[@(indexPath.row)] = @(cell.height);
  159. return cell;
  160. }
  161. /**
  162. 安全区视图发生变化
  163. */
  164. -(void)viewSafeAreaInsetsDidChange{
  165. _tableView.frame =CGRectMake(0,0, self.view.frame.size.width,self.view.safeAreaLayoutGuide.layoutFrame.size.height);
  166. [super viewSafeAreaInsetsDidChange];
  167. }
  168. -(void)goBack
  169. {
  170. [self.navigationController popViewControllerAnimated:YES];
  171. }
  172. /**
  173. 进度条隐藏
  174. */
  175. - (void)cancel {
  176. [self stopLoading];
  177. }
  178. @end