| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- //
- // SingleProfitAnalyseListDetailVc.m
- // IBOSS
- //
- // Created by 关宏厚 on 2019/4/12.
- // Copyright © 2019 elongtian. All rights reserved.
- //
- #import "SingleProfitAnalyseListDetailVc.h"
- @interface SingleProfitAnalyseListDetailVc ()
- @end
- @implementation SingleProfitAnalyseListDetailVc
- - (void)viewDidLoad {
- [super viewDidLoad];
- _dataDetailList=[[NSMutableArray alloc]init];
- [self initUI];
- [self loadNavStyle];
- [self reloadData];
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- _vTableView.frame=CGRectMake(0, 0, Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height);
- [super viewSafeAreaInsetsDidChange];
- }
- /**
- 导航按钮样式
- */
- - (void)loadNavStyle {
- self.navigationItem.title = @"每单利润分析表明细";
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,45,22);
-
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
-
- }
- -(void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- /**
- 加载数据
- */
- - (void)reloadData
- {
- [self startLoading];
- NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetSingleProfitOrgIphone" 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:_analyseListModel.organizationCode forKeyedSubscript:@"OrganizationCode"];
-
- [dict setObject:_startDate==nil?@"":_startDate forKeyedSubscript:@"AccountDateFrom"];
- [dict setObject:_endDate==nil?@"":_endDate forKeyedSubscript:@"AccountDateTo"];
- [dict setObject:_businessType forKeyedSubscript:@"BusinessType"];
- [dict setObject:@"1" forKeyedSubscript:@"IsSearchDetail"];
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onLoadFinish:);
- _downManager.onRequestFail = @selector(onLoadFail:);
- [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- -(void)initUI{
- _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];
- }
- #pragma mark 委托接口回调函数
- /**
- 调用接口成功回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFinish:(ASIDownManager *)sender {
- // 取消进度条
- [self cancel];
- // 服务器返回数据
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- NSString *message = resultModel.message;
- _vTableView.backgroundView = nil;
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- NSArray *infoArray = (NSArray *)resultModel.result;
-
- if(infoArray!=nil&&infoArray.count>0){
-
- for(int i=0;i<infoArray.count;i++){
- NSDictionary *infoDic=[infoArray objectAtIndex:i];
- SingleProfitAnalyseDetailModel *model = [SingleProfitAnalyseDetailModel dk_modelWithDictionary:infoDic];
- [_dataDetailList addObject:model];
- }
-
- [_vTableView reloadData];
- }
-
-
- else
- {
- _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- // 未找到匹配结果
- if(_dataDetailList == nil || _dataDetailList.count == 0){
- _vTableView.backgroundView = [self noDataViewByFrame:_vTableView.bounds];
- [self showAlertViewBackText:@"未找到匹配结果"];
- }
- }
- }
-
-
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
-
- [self showReLoginDialog:message];
- }
- else{
- [self showAlertViewText:message];
- return;
- }
- }
- /**
- 调用接口失败回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"网络异常"];
- }
- /**
- 单元格cell个数
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_dataDetailList count];
- }
- /**
- <#Description#>
-
- @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 761;
-
- }
- /**
- 每个单元格cell
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellIdentifier = @"SingleProfitAnalyseListDetailCell";
- SingleProfitAnalyseListDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
- if (!cell) {
- cell = [[SingleProfitAnalyseListDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
-
- SingleProfitAnalyseDetailModel *analyseDetailModel= [_dataDetailList objectAtIndex:indexPath.row];
- [cell setSingleProfitAnalyseListDetailCell:analyseDetailModel];
- return cell;
- }
- @end
|