OtherInStorageGoodsDetailListVC.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. //
  2. // OtherInStorageGoodsDetailListVC.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/4/23.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "OtherInStorageGoodsDetailListVC.h"
  9. @interface OtherInStorageGoodsDetailListVC ()
  10. @end
  11. @implementation OtherInStorageGoodsDetailListVC
  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,CGRectGetMaxY(_topSeparatorView.frame),Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height-CGRectGetMaxY(_topSeparatorView.frame) );
  29. [super viewSafeAreaInsetsDidChange];
  30. }
  31. /**
  32. 内存警告函数
  33. */
  34. - (void)didReceiveMemoryWarning {
  35. [super didReceiveMemoryWarning];
  36. }
  37. #pragma mark - 委托函数
  38. /**
  39. 入库列表明细数据加载成功回调
  40. @param sender <#sender description#>
  41. */
  42. - (void)onInStorageListDetailFinish:(ASIDownManager *)sender {
  43. NSDictionary *dic = [sender.mWebStr JSONValue];
  44. _vTableView.backgroundView = nil;
  45. [self stopLoading];
  46. // 服务器返回数据是否正确
  47. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  48. // 服务器返回数据状态值
  49. int iStatus = [[dic objectForKey:@"Status"] intValue];
  50. // 服务器返回数据消息
  51. NSString *message=[dic objectForKey:@"Message"];
  52. // 服务器返回数据状态值正确
  53. if (iStatus == 0) {
  54. NSArray * infoArr=[dic objectForKey:@"Result"];
  55. // 返回结果
  56. if(infoArr!=nil&& infoArr.count>0)
  57. {
  58. for(int i=0;i<infoArr.count;i++){
  59. NSDictionary *dic= infoArr[i];
  60. OtherInStorageGoodsListDetailModel *goodsListDetailModel=[OtherInStorageGoodsListDetailModel new];
  61. [goodsListDetailModel parseDic:dic];
  62. goodsListDetailModel.enterNo=_enterNo;
  63. [_dataList addObject:goodsListDetailModel];
  64. }
  65. [_vTableView reloadData];
  66. }
  67. else{
  68. [self showAlertViewText:@"无数据"];
  69. return;
  70. }
  71. }
  72. // 服务器返回数据状态值异常
  73. else if(iStatus==ActionResultStatusAuthError
  74. ||iStatus==ActionResultStatusNoLogin
  75. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  76. [self showReLoginDialog:message];
  77. }
  78. else{
  79. [self showAlertViewText:message];
  80. }
  81. }
  82. }
  83. /**
  84. 入库列表明细加载失败回调
  85. @param sender <#sender description#>
  86. */
  87. - (void)onInStorageListDetailFail:(ASIDownManager *)sender {
  88. [self stopLoading];
  89. [self showAlertViewText:@"加载失败"];
  90. }
  91. /**
  92. 单元格cell个数
  93. @param tableView <#tableView description#>
  94. @param section <#section description#>
  95. @return <#return value description#>
  96. */
  97. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  98. {
  99. return [_dataList count];
  100. }
  101. /**
  102. tableview的分区数
  103. @param tableView <#tableView description#>
  104. @return <#return value description#>
  105. */
  106. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  107. return 1;
  108. }
  109. /**
  110. 高度
  111. @param tableView <#tableView description#>
  112. @param indexPath <#indexPath description#>
  113. @return <#return value description#>
  114. */
  115. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  116. return 1184;
  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 = @"SalesInStorageListDetailCell";
  127. SalesInStorageListDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
  128. if (!cell) {
  129. cell=[[SalesInStorageListDetailCell 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. _goodsListDetailModel= [_dataList objectAtIndex:indexPath.row];
  140. [cell setSalesInStorageListDetailModel:_goodsListDetailModel];
  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. _topSeparatorView= [UIView new];
  165. _topSeparatorView.frame = CGRectMake(0, 0, Screen_Width, 10);
  166. _topSeparatorView.backgroundColor=LineBackgroundColor;
  167. [self.view addSubview:_topSeparatorView];
  168. _vTableView = [[UITableView alloc]
  169. initWithFrame:CGRectMake(0,
  170. CGRectGetMaxY(_topSeparatorView.frame),
  171. self.view.frame.size.width,
  172. self.view.frame.size.height)];
  173. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  174. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  175. _vTableView.backgroundColor = [UIColor whiteColor];
  176. _vTableView.delegate = self;
  177. _vTableView.dataSource=self;
  178. [self.view addSubview: _vTableView];
  179. _dataList=[[NSMutableArray alloc]init];
  180. [self loadData];
  181. }
  182. /**
  183. 加载数据源
  184. */
  185. -(void)loadData{
  186. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  187. [dict setObject:@"GetEnterDataDetailIphone" forKey:@"Action"];
  188. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  189. [dict setObject:kkUserCode forKey:@"UserCode"];
  190. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  191. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  192. [dict setObject:_enterId forKey:@"EnterID"];
  193. _downManager = [[ASIDownManager alloc] init];
  194. [self startLoading];
  195. _downManager.delegate = self;
  196. _downManager.OnImageDown = @selector(onInStorageListDetailFinish:);
  197. _downManager.OnImageFail = @selector(onInStorageListDetailFail:);
  198. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  199. }
  200. /**
  201. 返回函数
  202. */
  203. - (void)goBack
  204. {
  205. [self.navigationController popViewControllerAnimated:YES];
  206. }
  207. @end