OrderSalesDetailViewController.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. //
  2. // OrderSalesDetailViewController.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2017/5/26.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "OrderSalesDetailViewController.h"
  9. #import "OrderSaleListDetailModel.h"
  10. #import "OrderSalesDetailTableViewCell.h"
  11. @interface OrderSalesDetailViewController ()
  12. @end
  13. @implementation OrderSalesDetailViewController
  14. /**
  15. viewDidLoad
  16. */
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self showTitle:@"订单销售单商品明细"];
  20. [self loadNavStyle];
  21. [self initUI];
  22. _details=[NSMutableArray new];
  23. [self reloadData];
  24. }
  25. /**
  26. 安全区视图发生变化
  27. */
  28. -(void)viewSafeAreaInsetsDidChange{
  29. _customTableView.frame = CGRectMake(10, 0, self.view.frame.size.width-20,self.view.safeAreaLayoutGuide.layoutFrame.size.height);
  30. [super viewSafeAreaInsetsDidChange];
  31. }
  32. #pragma mark - 代理函数
  33. /**
  34. * 查询正常数据
  35. *
  36. * @param sender sender description
  37. */
  38. - (void)onLoadFinish:(ASIDownManager *)sender {
  39. // 服务器返回数据
  40. NSDictionary *dic = [sender.mWebStr JSONValue];
  41. [self cancel];
  42. // 服务器返回数据是否正确
  43. if (dic && [dic isKindOfClass:[NSDictionary class]])
  44. {
  45. // 服务器返回数据状态值
  46. int iStatus = [[dic objectForKey:@"Status"] intValue];
  47. // 服务器返回数据消息
  48. NSString *message=[dic objectForKey:@"Message"];
  49. // 服务器返回数据状态值正确
  50. if (iStatus == 0)
  51. {
  52. NSArray * approvArr=[dic objectForKey:@"Result"];
  53. if(approvArr!=nil)
  54. {
  55. [_details removeAllObjects];
  56. if(approvArr.count==0)
  57. {
  58. [self showAlertViewText:@"未找到匹配结果"];
  59. }
  60. else
  61. {
  62. NSMutableArray *detailArray = [NSMutableArray array];
  63. for (NSDictionary *dic in approvArr)
  64. {
  65. OrderSaleListDetailModel *md = [OrderSaleListDetailModel orderSaleDetailWithDict:dic];
  66. [detailArray addObject:md];
  67. }
  68. _details = detailArray;
  69. [_customTableView reloadData];
  70. }
  71. }
  72. }
  73. // 服务器返回数据状态值异常
  74. else if(iStatus==ActionResultStatusAuthError
  75. ||iStatus==ActionResultStatusNoLogin
  76. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid)
  77. {
  78. [self showReLoginDialog:message];
  79. return;
  80. }
  81. else
  82. {
  83. [self showAlertViewText:message];
  84. }
  85. }
  86. }
  87. /**
  88. * 异常数据
  89. *
  90. * @param sender sender description
  91. */
  92. - (void)onLoadFail:(ASIDownManager *)sender {
  93. [self cancel];
  94. [self showAlertViewText:@"加载失败"];
  95. }
  96. #pragma mark - tableView代理函数
  97. /**
  98. Sections
  99. @param tableView <#tableView description#>
  100. @return <#return value description#>
  101. */
  102. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  103. return _details.count;
  104. }
  105. /**
  106. numberOfRowsInSection
  107. @param tableView <#tableView description#>
  108. @param section <#section description#>
  109. @return <#return value description#>
  110. */
  111. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  112. return 1;
  113. }
  114. /**
  115. 头高度
  116. @param tableView tableView description
  117. @param section section description
  118. @return <#return value description#>
  119. */
  120. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  121. {
  122. return 10;
  123. }
  124. /**
  125. 头布局
  126. @param tableView <#tableView description#>
  127. @param section <#section description#>
  128. @return <#return value description#>
  129. */
  130. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  131. {
  132. UIView* myView =[[UIView alloc]init];
  133. myView.backgroundColor = [UIColor clearColor];
  134. return myView;
  135. }
  136. /**
  137. 单元格高度
  138. @param tableView <#tableView description#>
  139. @param indexPath <#indexPath description#>
  140. @return <#return value description#>
  141. */
  142. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  143. return 770;
  144. }
  145. /**
  146. cell
  147. @param tableView <#tableView description#>
  148. @param indexPath <#indexPath description#>
  149. @return <#return value description#>
  150. */
  151. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  152. NSString *cellIdentifier=@"OrderSalesCell";
  153. OrderSalesDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  154. cell=[[OrderSalesDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  155. OrderSaleListDetailModel *model=_details[indexPath.section];
  156. [cell parseOrderSalesDetailInfo:model];
  157. return cell;
  158. }
  159. #pragma mark - 私有函数
  160. /**
  161. UITableView初始化
  162. */
  163. -(void)initUI{
  164. _customTableView = [[UITableView alloc] initWithFrame:CGRectMake(10, 0, self.view.frame.size.width-20, self.view.frame.size.height-10)];
  165. _customTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  166. _customTableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  167. _customTableView.backgroundColor=[UIColor clearColor];
  168. _customTableView.delegate = self;
  169. _customTableView.dataSource=self;
  170. _customTableView.showsVerticalScrollIndicator = NO;
  171. [self.view addSubview:_customTableView];
  172. }
  173. /**
  174. 加载数据
  175. */
  176. -(void)reloadData
  177. {
  178. [self startLoading];
  179. NSString *urlStr = ServerURL;
  180. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  181. [dict setObject:@"GetOrderSalesReportListDetailIphone" forKey:@"Action"];
  182. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  183. [dict setObject:kkUserCode forKey:@"UserCode"];
  184. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  185. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  186. [dict setObject:_invoiceNo forKey:@"InvoiceNo"];
  187. _downManager = [[ASIDownManager alloc] init];
  188. _downManager.delegate = self;
  189. _downManager.OnImageDown = @selector(onLoadFinish:);
  190. _downManager.OnImageFail = @selector(onLoadFail:);
  191. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  192. }
  193. /**
  194. * 隐藏进度条
  195. */
  196. - (void)cancel {
  197. [self stopLoading];
  198. }
  199. /**
  200. 导航栏
  201. */
  202. - (void)loadNavStyle
  203. {
  204. //返回
  205. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  206. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  207. forState:UIControlStateNormal];
  208. [button addTarget:self action:@selector(goBack)
  209. forControlEvents:UIControlEventTouchUpInside];
  210. button.frame = CGRectMake(0, 0, 15, 18);
  211. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  212. self.navigationItem.leftBarButtonItem = menuButton;
  213. }
  214. /**
  215. 返回
  216. */
  217. - (void)goBack
  218. {
  219. [self.navigationController popViewControllerAnimated:YES];
  220. }
  221. @end