SingleProfitAnalyseListDetailVc.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //
  2. // SingleProfitAnalyseListDetailVc.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2019/4/12.
  6. // Copyright © 2019 elongtian. All rights reserved.
  7. //
  8. #import "SingleProfitAnalyseListDetailVc.h"
  9. @interface SingleProfitAnalyseListDetailVc ()
  10. @end
  11. @implementation SingleProfitAnalyseListDetailVc
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. _dataDetailList=[[NSMutableArray alloc]init];
  15. [self initUI];
  16. [self loadNavStyle];
  17. [self reloadData];
  18. }
  19. /**
  20. 安全区视图发生变化
  21. */
  22. -(void)viewSafeAreaInsetsDidChange{
  23. _vTableView.frame=CGRectMake(0, 0, Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height);
  24. [super viewSafeAreaInsetsDidChange];
  25. }
  26. /**
  27. 导航按钮样式
  28. */
  29. - (void)loadNavStyle {
  30. self.navigationItem.title = @"每单利润分析表明细";
  31. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  32. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  33. [button addTarget:self action:@selector(goBack)
  34. forControlEvents:UIControlEventTouchUpInside];
  35. button.frame = CGRectMake(0, 0,45,22);
  36. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  37. self.navigationItem.leftBarButtonItem = menuButton;
  38. }
  39. -(void)goBack
  40. {
  41. [self.navigationController popViewControllerAnimated:YES];
  42. }
  43. /**
  44. 加载数据
  45. */
  46. - (void)reloadData
  47. {
  48. [self startLoading];
  49. NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
  50. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  51. [dict setObject:@"GetSingleProfitOrgIphone" forKey:@"Action"];
  52. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  53. [dict setObject:kkUserCode forKey:@"UserCode"];
  54. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  55. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  56. [dict setObject:_analyseListModel.organizationCode forKeyedSubscript:@"OrganizationCode"];
  57. [dict setObject:_startDate==nil?@"":_startDate forKeyedSubscript:@"AccountDateFrom"];
  58. [dict setObject:_endDate==nil?@"":_endDate forKeyedSubscript:@"AccountDateTo"];
  59. [dict setObject:_businessType forKeyedSubscript:@"BusinessType"];
  60. [dict setObject:@"1" forKeyedSubscript:@"IsSearchDetail"];
  61. _downManager = [[ASIDownManager alloc] init];
  62. _downManager.delegate = self;
  63. _downManager.onRequestSuccess = @selector(onLoadFinish:);
  64. _downManager.onRequestFail = @selector(onLoadFail:);
  65. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  66. }
  67. -(void)initUI{
  68. _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height )];
  69. _vTableView.rowHeight = UITableViewAutomaticDimension;
  70. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  71. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  72. _vTableView.backgroundColor = [UIColor whiteColor];
  73. _vTableView.delegate = self;
  74. _vTableView.dataSource=self;
  75. _vTableView.tableHeaderView = nil;
  76. [self.view addSubview:_vTableView];
  77. }
  78. /**
  79. 进度条隐藏
  80. */
  81. - (void)cancel {
  82. [self stopLoading];
  83. }
  84. #pragma mark 委托接口回调函数
  85. /**
  86. 调用接口成功回调
  87. @param sender <#sender description#>
  88. */
  89. - (void)onLoadFinish:(ASIDownManager *)sender {
  90. // 取消进度条
  91. [self cancel];
  92. // 服务器返回数据
  93. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  94. // 服务器返回数据状态值
  95. int iStatus = resultModel.status;
  96. // 服务器返回数据消息
  97. NSString *message = resultModel.message;
  98. _vTableView.backgroundView = nil;
  99. // 服务器返回数据状态值正确
  100. if (iStatus == 0) {
  101. NSArray *infoArray = (NSArray *)resultModel.result;
  102. if(infoArray!=nil&&infoArray.count>0){
  103. for(int i=0;i<infoArray.count;i++){
  104. NSDictionary *infoDic=[infoArray objectAtIndex:i];
  105. SingleProfitAnalyseDetailModel *model = [SingleProfitAnalyseDetailModel dk_modelWithDictionary:infoDic];
  106. [_dataDetailList addObject:model];
  107. }
  108. [_vTableView reloadData];
  109. }
  110. else
  111. {
  112. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  113. // 未找到匹配结果
  114. if(_dataDetailList == nil || _dataDetailList.count == 0){
  115. _vTableView.backgroundView = [self noDataViewByFrame:_vTableView.bounds];
  116. [self showAlertViewBackText:@"未找到匹配结果"];
  117. }
  118. }
  119. }
  120. // 服务器返回数据状态值异常
  121. else if(iStatus == ActionResultStatusAuthError
  122. ||iStatus == ActionResultStatusNoLogin
  123. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  124. [self showReLoginDialog:message];
  125. }
  126. else{
  127. [self showAlertViewText:message];
  128. return;
  129. }
  130. }
  131. /**
  132. 调用接口失败回调
  133. @param sender <#sender description#>
  134. */
  135. - (void)onLoadFail:(ASIDownManager *)sender {
  136. [self cancel];
  137. [self showAlertViewText:@"网络异常"];
  138. }
  139. /**
  140. 单元格cell个数
  141. @param tableView <#tableView description#>
  142. @param section <#section description#>
  143. @return <#return value description#>
  144. */
  145. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  146. {
  147. return [_dataDetailList count];
  148. }
  149. /**
  150. <#Description#>
  151. @param tableView <#tableView description#>
  152. @return <#return value description#>
  153. */
  154. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  155. return 1;
  156. }
  157. /**
  158. 高度
  159. @param tableView <#tableView description#>
  160. @param indexPath <#indexPath description#>
  161. @return <#return value description#>
  162. */
  163. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  164. return 761;
  165. }
  166. /**
  167. 每个单元格cell
  168. @param tableView <#tableView description#>
  169. @param indexPath <#indexPath description#>
  170. @return <#return value description#>
  171. */
  172. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  173. {
  174. static NSString *cellIdentifier = @"SingleProfitAnalyseListDetailCell";
  175. SingleProfitAnalyseListDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  176. if (!cell) {
  177. cell = [[SingleProfitAnalyseListDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  178. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  179. }
  180. else
  181. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  182. {
  183. while ([cell.contentView.subviews lastObject] != nil) {
  184. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  185. }
  186. }
  187. SingleProfitAnalyseDetailModel *analyseDetailModel= [_dataDetailList objectAtIndex:indexPath.row];
  188. [cell setSingleProfitAnalyseListDetailCell:analyseDetailModel];
  189. return cell;
  190. }
  191. @end