SalesOutStorageListDetailVC.m 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. //
  2. // SalesOutStorageListDetailVC.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/4/11.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "SalesOutStorageListDetailVC.h"
  9. @interface SalesOutStorageListDetailVC ()
  10. @end
  11. @implementation SalesOutStorageListDetailVC
  12. #pragma mark 公共函数
  13. /**
  14. 视图加载完成函数
  15. */
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. [self loadNavStyle];
  19. [self initUI];
  20. }
  21. /**
  22. 修改:2017-9-25
  23. 适配机型
  24. 安全区视图发生变化
  25. */
  26. -(void)viewSafeAreaInsetsDidChange{
  27. self.view.backgroundColor = [UIColor whiteColor];
  28. _vTableView.frame = CGRectMake(0, 0,Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height);
  29. [super viewSafeAreaInsetsDidChange];
  30. }
  31. - (void)didReceiveMemoryWarning {
  32. [super didReceiveMemoryWarning];
  33. }
  34. #pragma mark 委托函数
  35. /**
  36. 销售出库列表明细加载成功回调
  37. @param sender <#sender description#>
  38. */
  39. - (void)onOutStorageListDetailFinish:(ASIDownManager *)sender {
  40. NSDictionary *dic = [sender.mWebStr JSONValue];
  41. _vTableView.backgroundView = nil;
  42. [self stopLoading];
  43. // 服务器返回数据是否正确
  44. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  45. // 服务器返回数据状态值
  46. int iStatus = [[dic objectForKey:@"Status"] intValue];
  47. // 服务器返回数据消息
  48. NSString *message=[dic objectForKey:@"Message"];
  49. // 服务器返回数据状态值正确
  50. if (iStatus == 0) {
  51. NSArray * infoArr=[dic objectForKey:@"Result"];
  52. // 返回结果
  53. if(infoArr!=nil&& infoArr.count>0)
  54. {
  55. for (int i = 0; i < infoArr.count; i++) {
  56. NSDictionary * dic=infoArr[i];
  57. SalesOutStorageListDetailModel *detailModel=[SalesOutStorageListDetailModel new];
  58. [detailModel parseDic:dic];
  59. detailModel.outStorageNo=_outStorageNo;
  60. [_dataList addObject:detailModel];
  61. }
  62. [_vTableView reloadData];
  63. }
  64. }
  65. // 服务器返回数据状态值异常
  66. else if(iStatus==ActionResultStatusAuthError
  67. ||iStatus==ActionResultStatusNoLogin
  68. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  69. [self showReLoginDialog:message];
  70. }
  71. else{
  72. [self showAlertViewText:message];
  73. }
  74. }
  75. }
  76. /**
  77. 销售出库列表明细加载失败回调
  78. @param sender <#sender description#>
  79. */
  80. - (void)onOutStorageListDetailFail:(ASIDownManager *)sender {
  81. [self stopLoading];
  82. [self showAlertViewText:@"加载失败"];
  83. }
  84. /**
  85. 单元格cell个数
  86. @param tableView <#tableView description#>
  87. @param section <#section description#>
  88. @return <#return value description#>
  89. */
  90. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  91. {
  92. return [_dataList count];
  93. }
  94. /**
  95. tableview的分区数
  96. @param tableView <#tableView description#>
  97. @return <#return value description#>
  98. */
  99. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  100. return 1;
  101. }
  102. /**
  103. 高度
  104. @param tableView <#tableView description#>
  105. @param indexPath <#indexPath description#>
  106. @return <#return value description#>
  107. */
  108. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath
  109. *)indexPath{
  110. SalesOutStorageListDetailModel *outStorageListDetailModel= [_dataList objectAtIndex:indexPath.row];
  111. if(outStorageListDetailModel.outStorageNo==nil||[outStorageListDetailModel.outStorageNo isEqualToString:@""]){
  112. return 1424;
  113. }
  114. else{
  115. return 1465;
  116. }
  117. }
  118. /**
  119. 每个单元格cell
  120. @param tableView <#tableView description#>
  121. @param indexPath <#indexPath description#>
  122. @return <#return value description#>
  123. */
  124. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  125. {
  126. static NSString *cellIdentifier = @"SalesOutStorageListDetailCell";
  127. SalesOutStorageListDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  128. if (!cell) {
  129. cell=[[SalesOutStorageListDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  130. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  131. }
  132. else
  133. // //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  134. {
  135. while ([cell.contentView.subviews lastObject] != nil) {
  136. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  137. }
  138. }
  139. SalesOutStorageListDetailModel *outStorageListDetailModel= [_dataList objectAtIndex:indexPath.row];
  140. [cell setSalesOutStorageListDetailModel:outStorageListDetailModel];
  141. return cell;
  142. }
  143. #pragma mark 私有函数
  144. /**
  145. 导航按钮样式
  146. */
  147. -(void)loadNavStyle
  148. {
  149. self.navigationItem.title=@"商品明细信息";
  150. //返回
  151. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  152. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  153. forState:UIControlStateNormal];
  154. [button addTarget:self action:@selector(goBack)
  155. forControlEvents:UIControlEventTouchUpInside];
  156. button.frame = CGRectMake(0, 0, 15, 18);
  157. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  158. self.navigationItem.leftBarButtonItem = menuButton;
  159. }
  160. /**
  161. 初始化UI
  162. */
  163. -(void)initUI{
  164. [self.view setBackgroundColor:[UIColor whiteColor]];
  165. _vTableView = [[UITableView alloc]
  166. initWithFrame:CGRectMake(0,
  167. 0,
  168. self.view.frame.size.width,
  169. self.view.frame.size.height)];
  170. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  171. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  172. _vTableView.backgroundColor = [UIColor whiteColor];
  173. _vTableView.delegate = self;
  174. _vTableView.dataSource=self;
  175. [self.view addSubview: _vTableView];
  176. _dataList=[[NSMutableArray alloc]init];
  177. [self loadData];
  178. }
  179. /**
  180. 返回函数
  181. */
  182. - (void)goBack
  183. {
  184. [self.navigationController popViewControllerAnimated:YES];
  185. }
  186. /**
  187. 加载数据源
  188. */
  189. -(void)loadData{
  190. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  191. [dict setObject:@"GetSalesInventoryDetailIphone" forKey:@"Action"];
  192. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  193. [dict setObject:kkUserCode forKey:@"UserCode"];
  194. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  195. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  196. [dict setObject:_deliveryId forKey:@"DeliveryID"];
  197. _downManager = [[ASIDownManager alloc] init];
  198. [self startLoading];
  199. _downManager.delegate = self;
  200. _downManager.OnImageDown = @selector(onOutStorageListDetailFinish:);
  201. _downManager.OnImageFail = @selector(onOutStorageListDetailFail:);
  202. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  203. }
  204. @end