| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- //
- // ProcurementApplyListDetailVc.m
- // IBOSS
- //
- // Created by guan hong hou on 2018/7/24.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "ProcurementApplyListDetailVc.h"
- @interface ProcurementApplyListDetailVc ()
- {
- NSMutableDictionary *_cellHeight;
- }
- @end
- @implementation ProcurementApplyListDetailVc
- #pragma mark -公共函数
- /**
- 视图加载完成函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self loadNavStyle];
- _detailArray=[[NSMutableArray alloc]init];
- _cellHeight = [[NSMutableDictionary alloc] init];
- [self initHeaderView];
- [self initUI];
- [self startLoading];
- [self loadData];
-
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- [self.view setBackgroundColor:[UIColor whiteColor]];
- _tableView.frame=CGRectMake(0, 0, Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height);
- [super viewSafeAreaInsetsDidChange];
- }
- #pragma mark -委托函数
- /**
- 加载列表数据成功回调
- @param sender <#sender description#>
- */
- - (void)onLoadFinish:(ASIDownManager *)sender {
-
- // 取消进度条
- [self stopLoading];
- // 服务器返回数据
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- NSString *message = resultModel.message;
- double totalApplyQuantity=0;
- double totalApprovedQuantity=0;
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- NSDictionary *infoDic=(NSDictionary*)resultModel.result;
- if(infoDic!=nil){
- NSArray *infoArray=[infoDic objectForKey:@"Table"];
- if(infoArray!=nil&&infoArray.count>0){
- _tableView.tableHeaderView=_procurementDetailHeadView;
- for(int i=0;i<infoArray.count;i++){
- NSDictionary *dic=[infoArray objectAtIndex:i];
- ProcurementApplyListDetailModel *detailModel = [ProcurementApplyListDetailModel dk_modelWithDictionary:dic];
- [_detailArray addObject:detailModel];
- }
- [_tableView reloadData];
-
- for(int i=0;i<_detailArray.count;i++){
- ProcurementApplyListDetailModel *detailModel=[_detailArray objectAtIndex:i];
-
- if([detailModel.orderNo isEqualToString:@"小计"]||[detailModel.applyNo isEqualToString:@"小计"])
- {
- continue;
- }
- totalApplyQuantity+=[detailModel.applyQuantity doubleValue];
- totalApprovedQuantity+=[detailModel.approvedQuantity doubleValue];
-
-
- }
-
-
- _lblProcurementQuantity.text=[NSString stringWithFormat:@"%.6f",totalApplyQuantity];
- _lblApprovedQuantity.text=[NSString stringWithFormat:@"%.6f",totalApprovedQuantity];
-
- }
- else{
- // 无数据的view
- UIView *noDataView = [self noDataViewByFrame:_tableView.bounds];
- _tableView.backgroundView=noDataView;
- [self showAlertViewText:@"未找到匹配结果"];
- return;
- }
- }
- }
- // 服务器返回数据状态值异常
- 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 stopLoading];
- [self showAlertViewText:@"网络异常"];
- }
- /**
- tableview的行数
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_detailArray count];
- }
- /**
- tableview的分区数
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- /**
- 获取tableview cell
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSString *cellIdentifier = @"CellId";
- ProcurementApplyListDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
- cell = [[ProcurementApplyListDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- NSUInteger row = [indexPath row];
- ProcurementApplyListDetailModel *detailModel = [_detailArray objectAtIndex:row];
- [cell setProcurementApplyListDetailCell:detailModel];
- _cellHeight[@(indexPath.row)] = @(cell.height);
- return cell;
-
- }
- /**
- 点击单元格事件
- @param tableView tableView description
- @param indexPath indexPath description
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- ProcurementApplyListDetailModel *detailModel= [_detailArray objectAtIndex:indexPath.row];
- if(!([detailModel.applyNo isEqualToString:@"小计"]||[detailModel.orderNo isEqualToString:@"小计"])){
- self.hidesBottomBarWhenPushed=YES;
- ProcurementApplyDetailVc *detailVc = [[ProcurementApplyDetailVc alloc] init];
-
- detailVc.detailModel = detailModel;
-
- [self.navigationController pushViewController:detailVc animated:YES];
- }
- }
- /**
- 预估高度
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 250;
- }
- /**
- tableview的高度
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- return [_cellHeight[@(indexPath.row)] floatValue];;
-
- }
- #pragma mark -私有函数
- /**
- 初始化UI
- */
- -(void)initUI
- {
- [self.view setBackgroundColor:[UIColor whiteColor]];
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width, self.view.frame.size.height)];
- _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
- _tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _tableView.backgroundColor = [UIColor clearColor];
- _tableView.delegate = self;
- _tableView.dataSource=self;
- [self.view addSubview:_tableView];
- }
- /**
- 初始化header
- */
- -(void)initHeaderView
- {
- CGFloat height = 170;
- CGFloat titleHeight = 50;
- CGFloat lblx = 20;
- CGFloat lblwidth = 130;
- CGFloat fontsize = 14;
- CGFloat valuey = 10;
- CGFloat valueheight = 25;
- CGFloat heightLine =1;
- _procurementDetailHeadView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, height)];
- [_procurementDetailHeadView setBackgroundColor:[UIColor whiteColor]];
-
- //总合计 —————————
- UIView *vtotal = [UIView new];
- vtotal.frame=CGRectMake(0, 0, Screen_Width, titleHeight);
- [_procurementDetailHeadView addSubview:vtotal];
- UILabel *lbtotal = [UILabel new];
- lbtotal.frame=CGRectMake(lblx, valuey, lblwidth, valueheight);
- lbtotal.font = [UIFont boldSystemFontOfSize:fontsize];
- lbtotal.text = @"合计";
- [vtotal addSubview:lbtotal];
-
- //分割线
- _viewBackground = [UIView new];
- _viewBackground.frame = CGRectMake(0, CGRectGetMaxY(vtotal.frame), Screen_Width, heightLine);
- _viewBackground.backgroundColor = LineBackgroundColor;
- [_procurementDetailHeadView addSubview:_viewBackground];
-
- //货物金额 —————————
- UIView *vtotalProcurementQuantity = [UIView new];
- vtotalProcurementQuantity.frame=CGRectMake(0, CGRectGetMaxY(_viewBackground.frame), Screen_Width, titleHeight);
- [_procurementDetailHeadView addSubview:vtotalProcurementQuantity];
- UIImageView *imgview = [UIImageView new];
- imgview.frame=CGRectMake(lblx, valuey + 5,25,25);
- [imgview setImage:[UIImage imageNamed:@"apply_quantity"]];
- [vtotalProcurementQuantity addSubview:imgview];
-
- UILabel *lbltotalProcurementQuantityTitle = [UILabel new];
- lbltotalProcurementQuantityTitle.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+5, valuey+5, lblwidth, valueheight);
- lbltotalProcurementQuantityTitle.font = [UIFont systemFontOfSize:fontsize];
- lbltotalProcurementQuantityTitle.text = @"请购数量";
- [vtotalProcurementQuantity addSubview:lbltotalProcurementQuantityTitle];
-
- _lblProcurementQuantity = [UILabel new];
- _lblProcurementQuantity.frame=CGRectMake(CGRectGetMaxX(lbltotalProcurementQuantityTitle.frame), valuey+5,Screen_Width-CGRectGetMaxX(lbltotalProcurementQuantityTitle.frame)-20, valueheight);
- _lblProcurementQuantity.font = [UIFont systemFontOfSize:fontsize];
- _lblProcurementQuantity.textAlignment = NSTextAlignmentRight;
- [vtotalProcurementQuantity addSubview:_lblProcurementQuantity];
-
-
- _viewBackground = [UIView new];
- _viewBackground.frame = CGRectMake(0, CGRectGetMaxY(vtotalProcurementQuantity.frame), Screen_Width, heightLine);
- _viewBackground.backgroundColor = LineBackgroundColor;
- [_procurementDetailHeadView addSubview:_viewBackground];
-
-
- UIView *vtotalApprovedQuantity = [UIView new];
- vtotalApprovedQuantity.frame=CGRectMake(0,CGRectGetMaxY(_viewBackground.frame), Screen_Width, titleHeight);
- [_procurementDetailHeadView addSubview:vtotalApprovedQuantity];
- UIImageView *imgviewReceivable = [UIImageView new];
- imgviewReceivable.frame=CGRectMake(lblx, valuey+5,25,25);
- [imgviewReceivable setImage:[UIImage imageNamed:@"approved_quantity"]];
- [vtotalApprovedQuantity addSubview:imgviewReceivable];
-
- UILabel *lbtotalApprovedQuantityTitle = [UILabel new];
- lbtotalApprovedQuantityTitle.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey+5, lblwidth, valueheight);
- lbtotalApprovedQuantityTitle.font = [UIFont systemFontOfSize:fontsize];
- lbtotalApprovedQuantityTitle.text = @"核准数量";
- [vtotalApprovedQuantity addSubview:lbtotalApprovedQuantityTitle];
-
- _lblApprovedQuantity = [UILabel new];
- _lblApprovedQuantity.frame=CGRectMake(CGRectGetMaxX(lbtotalApprovedQuantityTitle.frame), valuey+5, Screen_Width-CGRectGetMaxX(lbtotalApprovedQuantityTitle.frame)-20, valueheight);
- _lblApprovedQuantity.font = [UIFont systemFontOfSize:fontsize];
- _lblApprovedQuantity.textAlignment = NSTextAlignmentRight;
- [vtotalApprovedQuantity addSubview:_lblApprovedQuantity];
- //分割线
- _topSeparator = [UIView new];
- _topSeparator.backgroundColor = LineBackgroundColor;
- [_procurementDetailHeadView addSubview:_topSeparator];
- _topSeparator.frame = CGRectMake(0, CGRectGetMaxY(vtotalApprovedQuantity.frame), Screen_Width, 10);
-
- _procurementDetailHeadView.frame = CGRectMake(0, 0, Screen_Width, CGRectGetMaxY(vtotalApprovedQuantity.frame));
-
-
- }
- /**
- 加载数据源
- */
- -(void)loadData
- {
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetProcurementApplyReportDetailIphone" 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:_applyId == nil?@"":_applyId forKey:@"ApplyID"];
- [dict setObject:_sortType == nil?@"":_sortType forKey:@"SortType"];
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onLoadFinish:);
- _downManager.onRequestFail = @selector(onLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- /**
- 导航按钮样式
- */
- - (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;
-
- }
- @end
|