InventoryFrozenOrderListViewController.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. //
  2. // InventoryFrozenOrderListViewController.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/5/13.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "InventoryFrozenOrderListViewController.h"
  9. @interface InventoryFrozenOrderListViewController ()
  10. @end
  11. @implementation InventoryFrozenOrderListViewController
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. [self initUI];
  15. [self loadNavStyle];
  16. _orderList=[[NSMutableArray alloc]init];
  17. [self loadData];
  18. }
  19. /**
  20. 安全区视图发生变化
  21. */
  22. -(void)viewSafeAreaInsetsDidChange{
  23. _tableView.frame =CGRectMake(0, 0, self.view.frame.size.width,self.view.safeAreaLayoutGuide.layoutFrame.size.height);
  24. [super viewSafeAreaInsetsDidChange];
  25. }
  26. /**
  27. 导航按钮样式
  28. */
  29. - (void)loadNavStyle
  30. {
  31. self.navigationItem.title = @"冻结订单列表";
  32. //返回
  33. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  34. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  35. [button addTarget:self action:@selector(goBack)
  36. forControlEvents:UIControlEventTouchUpInside];
  37. button.frame = CGRectMake(0, 0,45,22);
  38. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  39. self.navigationItem.leftBarButtonItem = menuButton;
  40. }
  41. /**
  42. * 返回函数
  43. */
  44. - (void)goBack
  45. {
  46. [self.navigationController popViewControllerAnimated:YES];
  47. }
  48. -(void)initUI
  49. {
  50. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, self.view.frame.size.height)];
  51. _tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  52. _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  53. _tableView.delegate = self;
  54. _tableView.dataSource=self;
  55. [self.view addSubview:_tableView];
  56. }
  57. -(void)loadData
  58. {
  59. [self startLoading];
  60. _downManager = [[ASIDownManager alloc] init];
  61. _downManager.delegate = self;
  62. _downManager.onRequestSuccess = @selector(onDataLoadFinish:);
  63. _downManager.onRequestFail = @selector(onDataLoadFail:);
  64. NSString *urlStr = ServerURL;
  65. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  66. [dict setObject:@"GetFreezeDataSearchIPhone" forKey:@"Action"];
  67. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  68. [dict setObject:kkUserCode forKey:@"UserCode"];
  69. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  70. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  71. [dict setObject:(_contacts==nil?@"":_contacts) forKey:@"Contacts"];
  72. [dict setObject:(_telephone==nil?@"":_telephone) forKey:@"Telephone"];
  73. [dict setObject:(_customerCode==nil?@"":_customerCode) forKey:@"CustomerCode"];
  74. [dict setObject:(_staffName==nil?@"":_staffName) forKey:@"SalesmanName"];
  75. [dict setObject:(_freezeReasonName==nil?@"":_freezeReasonName) forKey:@"FreezeReason"];
  76. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  77. }
  78. -(void)onDataLoadFinish:(ASIDownManager*)sender {
  79. [self cancel];
  80. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  81. int iStatus = resultModel.status;
  82. NSString *message=resultModel.message;
  83. if(iStatus==0)
  84. {
  85. NSArray *resultArray=(NSArray*)resultModel.result;
  86. if(resultArray!=nil&&resultArray.count>0)
  87. {
  88. for(int i=0;i<resultArray.count;i++)
  89. {
  90. NSDictionary *resultDic=[resultArray objectAtIndex:i];
  91. InventoryFreezeOrderListModel *orderListModel=[InventoryFreezeOrderListModel dk_modelWithDictionary:resultDic];
  92. [_orderList addObject:orderListModel];
  93. }
  94. [_tableView reloadData];
  95. }
  96. }
  97. // 服务器返回数据状态值异常
  98. else if(iStatus == ActionResultStatusAuthError
  99. ||iStatus == ActionResultStatusNoLogin
  100. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  101. [self showReLoginDialog:message];
  102. }
  103. else{
  104. [self showAlertViewText:message];
  105. }
  106. }
  107. -(void)onDataLoadFail:(ASIDownManager *)sender {
  108. [self cancel];
  109. [self showAlertViewText:@"网络异常"];
  110. }
  111. /**
  112. 单元格cell个数
  113. @param tableView <#tableView description#>
  114. @param section <#section description#>
  115. @return <#return value description#>
  116. */
  117. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  118. {
  119. return [_orderList count];
  120. }
  121. /**
  122. table view 分区数
  123. @param tableView <#tableView description#>
  124. @return <#return value description#>
  125. */
  126. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  127. return 1;
  128. }
  129. /**
  130. cell 高度
  131. @param tableView <#tableView description#>
  132. @param indexPath <#indexPath description#>
  133. @return <#return value description#>
  134. */
  135. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  136. return [self.heights[@(indexPath.row)] doubleValue];;
  137. }
  138. /**
  139. 点击单元格事件
  140. @param tableView tableView description
  141. @param indexPath indexPath description
  142. */
  143. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  144. {
  145. InventoryFreezeOrderListModel *orderListModel= [_orderList objectAtIndex:indexPath.row];
  146. if([self.inventoryDelegate respondsToSelector:@selector(getInventoryFrozenGoodsDetail:unfreezeId:)])
  147. {
  148. [self.inventoryDelegate getInventoryFrozenGoodsDetail:orderListModel.freezeId unfreezeId:orderListModel.unfreezeId];
  149. [self.navigationController popViewControllerAnimated:YES];
  150. }
  151. }
  152. /**
  153. 高度
  154. @return <#return value description#>
  155. */
  156. - (NSMutableDictionary *)heights{
  157. if (_heights == nil){
  158. _heights = [NSMutableDictionary dictionary];
  159. }
  160. return _heights;
  161. }
  162. /**
  163. 预防高度
  164. @param tableView <#tableView description#>
  165. @param indexPath <#indexPath description#>
  166. @return <#return value description#>
  167. */
  168. -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  169. return 250;
  170. }
  171. /**
  172. 每个单元格cell
  173. @param tableView <#tableView description#>
  174. @param indexPath <#indexPath description#>
  175. @return <#return value description#>
  176. */
  177. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  178. {
  179. static NSString *cellIdentifier = @"InventoryFrozenOrderListCell";
  180. InventoryFrozenOrderListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  181. cell = [[InventoryFrozenOrderListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  182. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  183. InventoryFreezeOrderListModel *orderModel= [_orderList objectAtIndex:indexPath.row];
  184. [cell setInventoryFrozenOrderListCell:orderModel];
  185. cell.position = (int)indexPath.row;
  186. self.heights[@(indexPath.row)] = @(cell.height);
  187. return cell;
  188. }
  189. /**
  190. 隐藏进度条
  191. */
  192. - (void)cancel {
  193. [self stopLoading];
  194. }
  195. @end