| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- //
- // DailyReconciDetailViewController.m
- // IBOSSmini
- //
- // Created by apple on 2017/5/16.
- // Copyright © 2017年 elongtian. All rights reserved.
- //
- #import "DailyReconciDetailViewController.h"
- #import "DailyReconciliationDetailCell.h"
- #import "DayAccountDetailModel.h"
- @interface DailyReconciDetailViewController ()<UITableViewDataSource, UITableViewDelegate>
- @property(nonatomic,strong) ASIDownManager *downManager;
- @property(nonatomic,strong) UITableView * vTableView;
- @property(nonatomic,strong) NSMutableArray *dataArr;
- @property(nonatomic,strong) NSMutableArray *dataModelArr;
- /**
- 数据源高度数据
- */
- @property (strong, nonatomic) NSMutableDictionary *heights;
- @end
- @implementation DailyReconciDetailViewController
- #pragma mark - 公共函数
- /**
- viewDidLoad函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self showTitle:@""];
- [self initUI];
- [self reloadData];
- }
- /**
- 修改:2017-9-26
- 适配机型
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- _vTableView.frame = self.view.safeAreaLayoutGuide.layoutFrame;
- [super viewSafeAreaInsetsDidChange];
- }
- /**
- didReceiveMemoryWarning函数
- */
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- #pragma mark - 数据源list属性
- /**
- 原始数据源
-
- @return <#return value description#>
- */
- - (NSMutableArray *)dataArr{
- if(_dataArr== nil){
- _dataArr = [NSMutableArray new];
- }
- return _dataArr;
-
- }
- /**
- 原始Model数据源
-
- @return <#return value description#>
- */
- - (NSMutableArray *)dataModelArr{
- if(_dataModelArr== nil){
- _dataModelArr = [NSMutableArray new];
- }
- return _dataModelArr;
-
- }
- /**
- 高度
-
- @return <#return value description#>
- */
- - (NSMutableDictionary *)heights{
- if (_heights == nil){
- _heights = [NSMutableDictionary dictionary];
- }
- return _heights;
- }
- #pragma mark - 委托回调函数
- #pragma mark 委托接口回调函数
- /**
- 调用接口成功回调
-
- @param sender sender description
- */
- - (void)onLoadFinish:(ASIDownManager *)sender
- {
- // 服务器返回数据
- NSDictionary *dic = [sender.mWebStr JSONValue];
- [self Cancel];
- // 服务器返回数据是否正确
- if (dic && [dic isKindOfClass:[NSDictionary class]])
- {
- // 服务器返回数据状态值
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- // 服务器返回数据消息
- NSString *message=[dic objectForKey:@"Message"];
- // 服务器返回数据状态值正确
- if (iStatus == 0)
- {
- NSArray * approvArr =[dic objectForKey:@"Result"];
- if(approvArr!=nil)
- {
- [self.dataArr addObjectsFromArray:approvArr];
-
- if(self.dataArr.count==0)
- {
- [self showAlertViewText:@"未找到匹配结果"];
- }
- for (int i = 0; i < approvArr.count; i++)
- {
- NSString *str = approvArr[i];
- DayAccountDetailModel *model=[DayAccountDetailModel new];
- NSArray *strArr = [str componentsSeparatedByString:@" "];
- if (strArr!=nil && strArr.count<3) {
- continue;
- }
- model.typeNo = strArr[1];
- model.businessNumber = strArr[2];
- model.billOperation = strArr[3];
- for (int j = 0; j < strArr.count -3 -1; j++)
- {
- int count = (int) strArr.count - j -1;
- if ([strArr[count] rangeOfString: @"销售货款总额:"].location !=NSNotFound) {
- model.receivableAmount = strArr[count];
- continue;
- }
- if ([strArr[count] rangeOfString:@"结算方式:"].location !=NSNotFound) {
- model.settleWay = strArr[count];
- continue;
- }
- if ([strArr[count] rangeOfString:@"收款额:"].location !=NSNotFound) {
- model.receiptAmount = strArr[count];
- continue;
- }
- if ([strArr[count] rangeOfString:@"使用定金:"].location !=NSNotFound) {
- model.earnestAmount = strArr[count];
- continue;
- }
- if ([strArr[count] rangeOfString:@"使用预存:"].location !=NSNotFound) {
- model.depositAmount = strArr[count];
- continue;
- }
- }
-
- [self.dataModelArr addObject:model];
- }
-
- [_vTableView reloadData];
- }
- }
- // 服务器返回数据状态值异常
- else if(iStatus==ActionResultStatusAuthError
- ||iStatus==ActionResultStatusNoLogin
- ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
- [self showReLoginDialog:message];
- }
- else {
- [_vTableView reloadData];
- [self showAlertViewText:message];
-
- }
-
- }
- }
- /**
- 调用接口失败回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self Cancel];
- [_vTableView reloadData];
- [self showAlertViewText:@"加载失败"];
- }
- #pragma mark 委托tablview回调函数
- /**
- 行数
-
- @param tableView tableView description
- @param section section description
- @return return value description
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_dataArr count];
- }
- /**
- Sections数
-
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- /**
- 高度
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return [self.heights[@(indexPath.row)] doubleValue];
- }
- /**
- 估测高度
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 300;
- }
- /**
- 单元格
-
- @param tableView tableView description
- @param indexPath <#indexPath description#>
- @return return value description
- */
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- DailyReconciliationDetailCell *cell = [[ DailyReconciliationDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- cell.dModel = [_dataModelArr objectAtIndex:indexPath.row];
- // 强制布局 xib时调用
- //[cell layoutIfNeeded];
- // 存储高度
- self.heights[@(indexPath.row)] = @(cell.height);
- return cell;
- }
- #pragma mark - 私有函数
- /**
- 初始化ui
- */
- - (void)initUI { ;
- self.navigationItem.title=@"日结对账表明细";
- self.view.backgroundColor = [UIColor whiteColor];
-
- _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height )];
- _vTableView.rowHeight = UITableViewAutomaticDimension;
- _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vTableView.backgroundColor = [UIColor whiteColor];
- _vTableView.delegate = self;
- _vTableView.dataSource=self;
- _vTableView.tableHeaderView = nil;
- [self.view addSubview:_vTableView];
-
- }
- /**
- 进度条隐藏
- */
- - (void)Cancel {
- [self stopLoading];
- }
- /**
- 加载数据
- */
- -(void)reloadData
- {
- [self startLoading];
- NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetDailyReconciliationDetailIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:_organizationId forKey:@"OrganizationID"];
- [dict setObject:_accountDate forKey:@"AccountDate"];
- [dict setObject:_businessType forKey:@"BusinessType"];
-
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.OnImageDown = @selector(onLoadFinish:);
- _downManager.OnImageFail = @selector(onLoadFail:);
- [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- @end
|