DailyReconciDetailViewController.m 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. //
  2. // DailyReconciDetailViewController.m
  3. // IBOSSmini
  4. //
  5. // Created by apple on 2017/5/16.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "DailyReconciDetailViewController.h"
  9. #import "DailyReconciliationDetailCell.h"
  10. #import "DayAccountDetailModel.h"
  11. @interface DailyReconciDetailViewController ()<UITableViewDataSource, UITableViewDelegate>
  12. @property(nonatomic,strong) ASIDownManager *downManager;
  13. @property(nonatomic,strong) UITableView * vTableView;
  14. @property(nonatomic,strong) NSMutableArray *dataArr;
  15. @property(nonatomic,strong) NSMutableArray *dataModelArr;
  16. /**
  17. 数据源高度数据
  18. */
  19. @property (strong, nonatomic) NSMutableDictionary *heights;
  20. @end
  21. @implementation DailyReconciDetailViewController
  22. #pragma mark - 公共函数
  23. /**
  24. viewDidLoad函数
  25. */
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. [self showTitle:@""];
  29. [self initUI];
  30. [self reloadData];
  31. }
  32. /**
  33. 修改:2017-9-26
  34. 适配机型
  35. 安全区视图发生变化
  36. */
  37. -(void)viewSafeAreaInsetsDidChange{
  38. _vTableView.frame = self.view.safeAreaLayoutGuide.layoutFrame;
  39. [super viewSafeAreaInsetsDidChange];
  40. }
  41. /**
  42. didReceiveMemoryWarning函数
  43. */
  44. - (void)didReceiveMemoryWarning {
  45. [super didReceiveMemoryWarning];
  46. }
  47. #pragma mark - 数据源list属性
  48. /**
  49. 原始数据源
  50. @return <#return value description#>
  51. */
  52. - (NSMutableArray *)dataArr{
  53. if(_dataArr== nil){
  54. _dataArr = [NSMutableArray new];
  55. }
  56. return _dataArr;
  57. }
  58. /**
  59. 原始Model数据源
  60. @return <#return value description#>
  61. */
  62. - (NSMutableArray *)dataModelArr{
  63. if(_dataModelArr== nil){
  64. _dataModelArr = [NSMutableArray new];
  65. }
  66. return _dataModelArr;
  67. }
  68. /**
  69. 高度
  70. @return <#return value description#>
  71. */
  72. - (NSMutableDictionary *)heights{
  73. if (_heights == nil){
  74. _heights = [NSMutableDictionary dictionary];
  75. }
  76. return _heights;
  77. }
  78. #pragma mark - 委托回调函数
  79. #pragma mark 委托接口回调函数
  80. /**
  81. 调用接口成功回调
  82. @param sender sender description
  83. */
  84. - (void)onLoadFinish:(ASIDownManager *)sender
  85. {
  86. // 服务器返回数据
  87. NSDictionary *dic = [sender.mWebStr JSONValue];
  88. [self Cancel];
  89. // 服务器返回数据是否正确
  90. if (dic && [dic isKindOfClass:[NSDictionary class]])
  91. {
  92. // 服务器返回数据状态值
  93. int iStatus = [[dic objectForKey:@"Status"] intValue];
  94. // 服务器返回数据消息
  95. NSString *message=[dic objectForKey:@"Message"];
  96. // 服务器返回数据状态值正确
  97. if (iStatus == 0)
  98. {
  99. NSArray * approvArr =[dic objectForKey:@"Result"];
  100. if(approvArr!=nil)
  101. {
  102. [self.dataArr addObjectsFromArray:approvArr];
  103. if(self.dataArr.count==0)
  104. {
  105. [self showAlertViewText:@"未找到匹配结果"];
  106. }
  107. for (int i = 0; i < approvArr.count; i++)
  108. {
  109. NSString *str = approvArr[i];
  110. DayAccountDetailModel *model=[DayAccountDetailModel new];
  111. NSArray *strArr = [str componentsSeparatedByString:@" "];
  112. if (strArr!=nil && strArr.count<3) {
  113. continue;
  114. }
  115. model.typeNo = strArr[1];
  116. model.businessNumber = strArr[2];
  117. model.billOperation = strArr[3];
  118. for (int j = 0; j < strArr.count -3 -1; j++)
  119. {
  120. int count = (int) strArr.count - j -1;
  121. if ([strArr[count] rangeOfString: @"销售货款总额:"].location !=NSNotFound) {
  122. model.receivableAmount = strArr[count];
  123. continue;
  124. }
  125. if ([strArr[count] rangeOfString:@"结算方式:"].location !=NSNotFound) {
  126. model.settleWay = strArr[count];
  127. continue;
  128. }
  129. if ([strArr[count] rangeOfString:@"收款额:"].location !=NSNotFound) {
  130. model.receiptAmount = strArr[count];
  131. continue;
  132. }
  133. if ([strArr[count] rangeOfString:@"使用定金:"].location !=NSNotFound) {
  134. model.earnestAmount = strArr[count];
  135. continue;
  136. }
  137. if ([strArr[count] rangeOfString:@"使用预存:"].location !=NSNotFound) {
  138. model.depositAmount = strArr[count];
  139. continue;
  140. }
  141. }
  142. [self.dataModelArr addObject:model];
  143. }
  144. [_vTableView reloadData];
  145. }
  146. }
  147. // 服务器返回数据状态值异常
  148. else if(iStatus==ActionResultStatusAuthError
  149. ||iStatus==ActionResultStatusNoLogin
  150. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  151. [self showReLoginDialog:message];
  152. }
  153. else {
  154. [_vTableView reloadData];
  155. [self showAlertViewText:message];
  156. }
  157. }
  158. }
  159. /**
  160. 调用接口失败回调
  161. @param sender <#sender description#>
  162. */
  163. - (void)onLoadFail:(ASIDownManager *)sender {
  164. [self Cancel];
  165. [_vTableView reloadData];
  166. [self showAlertViewText:@"加载失败"];
  167. }
  168. #pragma mark 委托tablview回调函数
  169. /**
  170. 行数
  171. @param tableView tableView description
  172. @param section section description
  173. @return return value description
  174. */
  175. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  176. {
  177. return [_dataArr count];
  178. }
  179. /**
  180. Sections数
  181. @param tableView <#tableView description#>
  182. @return <#return value description#>
  183. */
  184. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  185. return 1;
  186. }
  187. /**
  188. 高度
  189. @param tableView <#tableView description#>
  190. @param indexPath <#indexPath description#>
  191. @return <#return value description#>
  192. */
  193. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  194. return [self.heights[@(indexPath.row)] doubleValue];
  195. }
  196. /**
  197. 估测高度
  198. @param tableView <#tableView description#>
  199. @param indexPath <#indexPath description#>
  200. @return <#return value description#>
  201. */
  202. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  203. return 300;
  204. }
  205. /**
  206. 单元格
  207. @param tableView tableView description
  208. @param indexPath <#indexPath description#>
  209. @return return value description
  210. */
  211. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  212. {
  213. DailyReconciliationDetailCell *cell = [[ DailyReconciliationDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
  214. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  215. cell.dModel = [_dataModelArr objectAtIndex:indexPath.row];
  216. // 强制布局 xib时调用
  217. //[cell layoutIfNeeded];
  218. // 存储高度
  219. self.heights[@(indexPath.row)] = @(cell.height);
  220. return cell;
  221. }
  222. #pragma mark - 私有函数
  223. /**
  224. 初始化ui
  225. */
  226. - (void)initUI { ;
  227. self.navigationItem.title=@"日结对账表明细";
  228. self.view.backgroundColor = [UIColor whiteColor];
  229. _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height )];
  230. _vTableView.rowHeight = UITableViewAutomaticDimension;
  231. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  232. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  233. _vTableView.backgroundColor = [UIColor whiteColor];
  234. _vTableView.delegate = self;
  235. _vTableView.dataSource=self;
  236. _vTableView.tableHeaderView = nil;
  237. [self.view addSubview:_vTableView];
  238. }
  239. /**
  240. 进度条隐藏
  241. */
  242. - (void)Cancel {
  243. [self stopLoading];
  244. }
  245. /**
  246. 加载数据
  247. */
  248. -(void)reloadData
  249. {
  250. [self startLoading];
  251. NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
  252. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  253. [dict setObject:@"GetDailyReconciliationDetailIphone" forKey:@"Action"];
  254. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  255. [dict setObject:kkUserCode forKey:@"UserCode"];
  256. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  257. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  258. [dict setObject:_organizationId forKey:@"OrganizationID"];
  259. [dict setObject:_accountDate forKey:@"AccountDate"];
  260. [dict setObject:_businessType forKey:@"BusinessType"];
  261. _downManager = [[ASIDownManager alloc] init];
  262. _downManager.delegate = self;
  263. _downManager.OnImageDown = @selector(onLoadFinish:);
  264. _downManager.OnImageFail = @selector(onLoadFail:);
  265. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  266. }
  267. @end