OrderSalesDetailViewController.m 7.8 KB

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