// // DeliveryRequirementDetailControllerViewController.m // IBOSSHSH // // Created by ssl on 2018/1/16. // Copyright © 2018年 elongtian. All rights reserved. // #import "DeliveryRequirementDetailController.h" #import "DeliveryImg.h" #import "XHImageViewer.h" #import "AlbumPhotoCollectionViewCell.h" #import "NSString+Tools.h" #import "DeliveryRequirementDetailHeadModel.h" #import "DateFormat.h" #import "DeliveryRequirementListDetailModel.h" #import "DeliveryRequirementDetailListCell.h" #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize] @implementation DeliveryRequirementDetailController @synthesize scroll; @synthesize contentView; @synthesize mHeight; #pragma mark - 公共函数 - (void)viewDidLoad { [super viewDidLoad]; mHeight = 31; [self initUI]; [self initData]; } /** 安全区视图发生变化 */ -(void)viewSafeAreaInsetsDidChange{ scroll.frame = self.view.safeAreaLayoutGuide.layoutFrame; [super viewSafeAreaInsetsDidChange]; } #pragma mark - 回调函数 /** 数据加载完成方法 @param sender <#sender description#> */ - (void)onLoadFinish:(ASIDownManager *)sender { RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; [self cancel]; // 服务器返回数据状态值 int iStatus = resultModel.status; // 服务器返回数据消息 NSString *message = resultModel.message; if (iStatus == 0) { NSDictionary * approvArr=(NSDictionary *)resultModel.result; if(approvArr != nil&&approvArr.count>0) { NSArray *arr = [approvArr objectForKey:@"Table"]; NSArray *arr1 = [approvArr objectForKey:@"Table1"]; NSArray *imagePathArr = [approvArr objectForKey:@"ImagePath"]; NSArray *positionArr = [approvArr objectForKey:@"Position"]; if(arr != nil&&arr.count>0){ NSDictionary *dicValue = arr[0]; DeliveryRequirementDetailHeadModel *model = [DeliveryRequirementDetailHeadModel dk_modelWithDictionary:dicValue]; _arrangementNo.text = model.arrangementNo; _receiptNo.text = model.receiptNo; _deliveryNo.text = model.deliveryNo; _recReceiptType.text = model.recReceiptType; _customerName.text = model.customerName; _contacts.text = model.contacts; _telephone.text = model.telephone; _lbRemarks.text = [NSString stringWithFormat:@"回执备注: %@",model.remarks == nil?@"":model.remarks]; _lbAccountDate.text = [NSString stringWithFormat:@"账务日期: %@",model.accountDate]; _lbCreatetime.text = [NSString stringWithFormat:@"创建日期: %@",model.createTime]; _lbServiceStaffName.text =[NSString stringWithFormat:@"配送人员: %@",model.serviceStaffName == nil?@"":model.serviceStaffName ]; _deliveryAddress.text = model.deliveryAddress; _receivables.text = [NSString stringWithFormat:@"%.2f",[model.receivables doubleValue]]; _completeReceivables.text = [NSString stringWithFormat:@"%.2f",[model.completeReceivables doubleValue]]; _receiptAmount.text = [NSString stringWithFormat:@"%.2f",[model.receiptAmount doubleValue]]; _receivablesType.text = model.receivablesType; if([model.receiptType intValue] == 1){ _receiptType.text = @"完成"; }else if([model.receiptType intValue] == 2){ _receiptType.text =@"推迟送安"; } _nextDeliveryDate.text = [DateFormat dateFormatSplit: model.deliveryDate]; } if(arr1 != nil){ for (int i = 0; i < [arr1 count]; i++) { NSDictionary *infoDic=arr1[i]; DeliveryRequirementListDetailModel *info = [DeliveryRequirementListDetailModel dk_modelWithDictionary:infoDic]; [_infoList addObject:info]; } } if(imagePathArr != nil&&[imagePathArr count] > 0){ if( ! _photoList){ _photoList = [[NSMutableArray alloc]init]; } for (int i = 0; i < [imagePathArr count]; i++) { NSDictionary *imgDic = imagePathArr[i]; NSString *imgPath = [imgDic objectForKey:@"ImagePath"]; DeliveryImg *img = [DeliveryImg new]; img.imageName = imgPath; [_photoList addObject:img]; } } if(arr1 != nil){ self.tableView.frame=CGRectMake(10,10, self.view.bounds.size.width - 20, [self getArrayViewHeight:self.infoList] + _headerView.bounds.size.height) ; contentView.frame = CGRectMake(0,0,self.view.bounds.size.width,self.tableView.bounds.size.height); scroll.contentSize=CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + rectStatusHeight +rectNavHeight + 50); } [self.tableView reloadData]; if(imagePathArr != nil&&[imagePathArr count] > 0){ UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.itemSize = CGSizeMake(85, 85); flowLayout.minimumInteritemSpacing = 5; flowLayout.minimumLineSpacing = 10; flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; flowLayout.sectionInset = UIEdgeInsetsMake(7, 20, 0, 20); self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(20,CGRectGetMaxY(self.tableView.frame), self.view.bounds.size.width - 40, [Util getPhotoCollectionViewHeightWithPhotos:self.photoList]) collectionViewLayout:flowLayout]; self.collectionView.backgroundColor = [UIColor clearColor]; self.collectionView.dataSource = self; self.collectionView.delegate = self; self.collectionView.scrollEnabled = NO; [self.collectionView registerClass:[AlbumPhotoCollectionViewCell class] forCellWithReuseIdentifier:@"PhotoCollectionViewCellIdentifier"]; [contentView addSubview:self.collectionView]; contentView.frame = CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(self.collectionView.frame)); scroll.contentSize = CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + rectStatusHeight + rectNavHeight + 50); } if(positionArr != nil && [positionArr count] > 0){ NSDictionary *d1 = positionArr[0]; //位置信息-------------- UIView *vLocation = [UIView new]; if(imagePathArr != nil&&[imagePathArr count] > 0){ vLocation.frame = CGRectMake(0, CGRectGetMaxY(self.collectionView.frame), Screen_Width, mHeight); } else{ vLocation.frame = CGRectMake(0, CGRectGetMaxY(self.tableView.frame), Screen_Width, mHeight); } [contentView addSubview:vLocation]; UIImageView *positionImg = [[UIImageView alloc]init]; positionImg.frame = CGRectMake(20,16, 13, 15); [positionImg setImage:[UIImage imageNamed:@"icon_position"]]; [vLocation addSubview:positionImg]; _location = [UILabel new]; _location.frame = CGRectMake(CGRectGetMaxX(positionImg.frame) + 3, 11, Screen_Width - 105, 25); _location.font = kTextFont; [vLocation addSubview:_location]; _location.text = [d1 objectForKey:@"Position"]; if(_location.text != nil){ [vLocation setHidden:NO]; }else{ [vLocation setHidden:YES]; } contentView.frame = CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(vLocation.frame)); scroll.contentSize = CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + rectStatusHeight + rectNavHeight + 50); } } } else if(iStatus == ActionResultStatusAuthError ||iStatus == ActionResultStatusNoLogin ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){ [self showReLoginDialog:message]; return; } else { [self.tableView reloadData]; [self showAlertViewText:message]; } } /** 数据加载失败方法 @param sender <#sender description#> */ - (void)onLoadFail:(ASIDownManager *)sender { [self cancel]; [self.tableView reloadData]; [self showAlertViewText:@"网络异常"]; } /** tableview的分区数 @param tableView <#tableView description#> @return <#return value description#> */ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [_infoList count]; } /** tableview 分区的间隔高度 @param tableView <#tableView description#> @param section <#section description#> @return <#return value description#> */ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 10; } /** tableview的分区视图 @param tableView <#tableView description#> @param section <#section description#> @return <#return value description#> */ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView* myView = [[UIView alloc]init]; myView.backgroundColor = [UIColor clearColor]; return myView; } /** tableview每个分区的行数 @param tableView <#tableView description#> @param section <#section description#> @return <#return value description#> */ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 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 = @"DeliveryRequirementDetailListCell"; DeliveryRequirementDetailListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if(!cell) { NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:cellIdentifier owner:nil options:nil]; cell = [nibs lastObject]; self.tableView.rowHeight = UITableViewAutomaticDimension; cell.frame = CGRectMake(cell.frame.origin.x, cell.frame.origin.y,self.view.bounds.size.width , cell.frame.size.height); } NSMutableArray *dataArray = _infoList; DeliveryRequirementListDetailModel *model = [dataArray objectAtIndex:indexPath.section]; cell.layer.cornerRadius = CornerRadius; cell.layer.backgroundColor = [UIColor whiteColor].CGColor; cell.layer.masksToBounds = YES; cell.brandName.text = model.brandName; cell.seriesName.text= model.seriesName; cell.fackage.text= model.fackage; cell.acreage.text= model.acreage; cell.sourceFromName.text= model.sourceFromName; if([model.installationReceiptFlag intValue] == 0){ cell.installationReceiptFlag.text= @"否"; }else{ cell.installationReceiptFlag.text= @"是"; } cell.deliveryQuantity.text= model.deliveryQuantity; cell.gradeName.text= model.gradeName; cell.weight.text= model.weight; if([model.installationReceiptType intValue] == 1){ cell.installationReceiptType.text= @"完成"; }else if([model.installationReceiptType intValue] == 5){ cell.installationReceiptType.text= @"再安装"; } cell.warehouseName.text= model.warehouseName; cell.code.text= model.code; cell.kindName.text= model.kindName; cell.colorNumber.text= model.colorNumber; cell.installationQuantity.text= model.installationQuantity; cell.installationReceiptQuantity.text= model.installationReceiptQuantity; cell.returnQuantity.text= model.returnQuantity; cell.onlyCode.text= model.onlyCode;; cell.positionNumber.text= model.positionNumber;; if([model.circulateType intValue] == 1){ cell.circulateType.text= @"按整数流通"; }else if([model.circulateType intValue] == 2){ cell.circulateType.text= @"按平米流通"; }else if([model.circulateType intValue] == 3){ cell.circulateType.text= @"按延米流通"; } cell.varietyName.text= model.varietyName;; cell.outQuantity.text= model.outQuantity;; cell.recoverQuantity.text=model.recoverQuantity; cell.deliveryReceiptQuantity.text= model.deliveryReceiptQuantity;; if([model.deliveryReceiptFlag intValue] == 0){ cell.deliveryReceiptFlag.text= @"否"; }else{ cell.deliveryReceiptFlag.text= @"是"; } cell.remarks.text= (model.remarks == nil || [model.remarks isEqualToString: @""])?@" ":model.remarks; cell.goodsName.text= model.goodsName; cell.specification.text= model.specification; int type2 = [model.deliveryReceiptType intValue]; switch (type2) { case 1: cell.deliveryReceiptType.text = @"完成"; break; case 2: cell.deliveryReceiptType.text = @"再送"; break; case 3: cell.deliveryReceiptType.text = @"换货"; break; case 4: cell.deliveryReceiptType.text = @"退货"; break; default: break; } return cell; } /** cellection view的列表项 @param collectionView <#collectionView description#> @param section <#section description#> @return <#return value description#> */ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return self.photoList.count; } /** collection view的cell @param collectionView <#collectionView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ static NSString *PhotoCollectionViewCellIdentifier = @"PhotoCollectionViewCellIdentifier"; AlbumPhotoCollectionViewCell *cell1 = [collectionView dequeueReusableCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier forIndexPath:indexPath]; NSArray *Infoarray = _photoList; cell1.indexPath = indexPath; DeliveryImg *image1 = [Infoarray objectAtIndex:indexPath.row]; NSString *imagepath = [image1 imageName]; if(imagepath != nil && [imagepath length] > 0){ NSString *imageUrl = [NSString stringWithFormat:@"http://%@:%@/WebService/%@",kkServerUrl,kkServerPort,imagepath]; NSURL *url = [NSURL URLWithString:imageUrl]; [cell1.photoImageView setImageWithURL:url placeholderImage:nil]; } return cell1; }; /** 定义collectionview cell的大小 @param collectionView <#collectionView description#> @param collectionViewLayout <#collectionViewLayout description#> @param indexPath <#indexPath description#> @return <#return value description#> */ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake(85, 85); } /** 定义每个collectionview cell的间距 @param collectionView <#collectionView description#> @param collectionViewLayout <#collectionViewLayout description#> @param section <#section description#> @return <#return value description#> */ - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { return UIEdgeInsetsMake(5, 5, 5, 5); } /** 放大图片 @param collectionView <#collectionView description#> @param indexPath <#indexPath description#> */ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { [self showImageViewerAtIndexPath:indexPath]; } /** 放大图片委托 @param indexPath <#indexPath description#> */ - (void)showImageViewerAtIndexPath:(NSIndexPath *)indexPath { AlbumPhotoCollectionViewCell *cell = (AlbumPhotoCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; NSMutableArray *imageViews = [NSMutableArray array]; NSArray *visibleCell = [self.collectionView visibleCells]; NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"indexPath" ascending:YES]; visibleCell = [visibleCell sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]]; [visibleCell enumerateObjectsUsingBlock:^(AlbumPhotoCollectionViewCell *cell, NSUInteger idx, BOOL *stop) { [imageViews addObject:[[cell.contentView subviews] lastObject]]; }]; XHImageViewer *imageViewer = [[XHImageViewer alloc] init]; [imageViewer showWithImageViews:imageViews selectedView:[[cell.contentView subviews] lastObject]]; } /** 返回collection view是否可以被选择 @param collectionView <#collectionView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { return YES; } #pragma mark - 私有函数 /** 返回函数 */ - (void)goBack { [self.navigationController popViewControllerAnimated:YES]; } /** 初始化ui */ - (void)initUI{ self.navigationItem.title = @"送安回执明细"; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:[UIImage imageNamed:@"icon_back.png"] 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; contentView = [[UIView alloc]init]; contentView.frame = CGRectZero; contentView.backgroundColor = [UIColor clearColor]; self.tableView = [UITableView new]; self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.dataSource = self; self.tableView.delegate = self; self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone; self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.scrollEnabled = NO; self.tableView.estimatedRowHeight = 44.0f; self.tableView.frame = CGRectZero; [contentView addSubview:self.tableView]; scroll = [UIScrollView new]; scroll.frame = self.view.bounds; scroll.tag = 1000; [self.view addSubview:scroll]; if(Screen_Height2 <= 480){ scroll.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height + 80); } _headerView = [[UIView alloc]init]; _headerView.frame = CGRectZero; _headerView.layer.cornerRadius = CornerRadius; _headerView.backgroundColor = [UIColor whiteColor]; [scroll addSubview:contentView]; //回执单号-------------- UIView *vReceiptNoName = [UIView new]; vReceiptNoName.frame = CGRectMake(0, 1, Screen_Width, 51); [_headerView addSubview:vReceiptNoName]; UILabel *lblTxtCast = [UILabel new]; lblTxtCast.frame = CGRectMake(10, 16,70, 25); lblTxtCast.text = @"回执单号:"; lblTxtCast.font = kTextFont; [vReceiptNoName addSubview:lblTxtCast]; _receiptNo = [UILabel new]; _receiptNo.frame = CGRectMake(CGRectGetMaxX(lblTxtCast.frame), 16, 200, 25); _receiptNo.font = kTextFont; [vReceiptNoName addSubview:_receiptNo]; UIImageView *separatorImg = [[UIImageView alloc]initWithFrame:CGRectMake(0,50,Screen_Width, 1)]; [separatorImg setImage:[UIImage imageNamed:@"titlebotton"]]; [vReceiptNoName addSubview:separatorImg]; //安排单号-------------- UIView *vArrangementNo = [UIView new]; vArrangementNo.frame = CGRectMake(0,CGRectGetMaxY(vReceiptNoName.frame), Screen_Width, mHeight); [_headerView addSubview:vArrangementNo]; UILabel *lblTxtArrangementNo = [UILabel new]; lblTxtArrangementNo.frame = CGRectMake(10, 3, 70, 25); lblTxtArrangementNo.text = @"安排单号:"; lblTxtArrangementNo.font = kTextFont; [vArrangementNo addSubview:lblTxtArrangementNo]; _arrangementNo = [UILabel new]; _arrangementNo.frame = CGRectMake(CGRectGetMaxX(lblTxtArrangementNo.frame),3, 200, 25); _arrangementNo.font = kTextFont; [vArrangementNo addSubview:_arrangementNo]; //送货单号-------------- UIView *vDeliveryNo = [UIView new]; vDeliveryNo.frame = CGRectMake(0,CGRectGetMaxY(vArrangementNo.frame), Screen_Width, mHeight); [_headerView addSubview:vDeliveryNo]; UILabel *lblvDeliveryNo = [UILabel new]; lblvDeliveryNo.frame = CGRectMake(10,3, 70, 25); lblvDeliveryNo.text = @"送安单号:"; lblvDeliveryNo.font = kTextFont; [vDeliveryNo addSubview:lblvDeliveryNo]; _deliveryNo = [UILabel new]; _deliveryNo.frame = CGRectMake(CGRectGetMaxX(lblvDeliveryNo.frame),3, 200, 25); _deliveryNo.font = kTextFont; [vDeliveryNo addSubview:_deliveryNo]; //回执类型-------------- UIView *vRecReceiptType = [UIView new]; vRecReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryNo.frame), Screen_Width, mHeight); [_headerView addSubview:vRecReceiptType]; UILabel *lblRecReceiptType = [UILabel new]; lblRecReceiptType.frame = CGRectMake(10,3, 70, 25); lblRecReceiptType.text = @"回执类型:"; lblRecReceiptType.font = kTextFont; [vRecReceiptType addSubview:lblRecReceiptType]; _recReceiptType = [UILabel new]; _recReceiptType.frame = CGRectMake(CGRectGetMaxX(lblRecReceiptType.frame),3, 200, 25); _recReceiptType.font = kTextFont; [vRecReceiptType addSubview:_recReceiptType]; //客户名称-------------- UIView *vCustomerName = [UIView new]; vCustomerName.frame = CGRectMake(0,CGRectGetMaxY(vRecReceiptType.frame), Screen_Width, mHeight); [_headerView addSubview:vCustomerName]; UILabel *lblCustomerName = [UILabel new]; lblCustomerName.frame = CGRectMake(10,3, 70, 25); lblCustomerName.text = @"客户名称:"; lblCustomerName.font = kTextFont; [vCustomerName addSubview:lblCustomerName]; _customerName = [UILabel new]; _customerName.font = kTextFont; _customerName.frame = CGRectMake(CGRectGetMaxX(lblCustomerName.frame),3, 200, 25); [vCustomerName addSubview:_customerName]; //联系人-------------- UIView *vContacts = [UIView new]; vContacts.frame = CGRectMake(0,CGRectGetMaxY(vCustomerName.frame), Screen_Width, mHeight); [_headerView addSubview:vContacts]; UILabel *lblContacts = [UILabel new]; lblContacts.frame = CGRectMake(10,3,70, 25); lblContacts.text = @"联 系 人:"; lblContacts.font = kTextFont; [vContacts addSubview:lblContacts]; _contacts = [UILabel new]; _contacts.font = kTextFont; _contacts.frame = CGRectMake(CGRectGetMaxX(lblContacts.frame),3, 200, 25); [vContacts addSubview:_contacts]; //电话-------------- UIView *vTelephone = [UIView new]; vTelephone.frame = CGRectMake(0,CGRectGetMaxY(vContacts.frame), Screen_Width, mHeight); [_headerView addSubview:vTelephone]; UILabel *lblvTelephone = [UILabel new]; lblvTelephone.frame = CGRectMake(10,3,70, 25); lblvTelephone.font = kTextFont; lblvTelephone.text = @"联系电话:"; [vTelephone addSubview:lblvTelephone]; _telephone = [UILabel new]; _telephone.font = kTextFont; _telephone.frame=CGRectMake(CGRectGetMaxX(lblvTelephone.frame),3, 200, 25); [vTelephone addSubview:_telephone]; //地址-------------- UIView *vDeliveryAddress = [UIView new]; vDeliveryAddress.frame = CGRectMake(0,CGRectGetMaxY(vTelephone.frame), Screen_Width, mHeight); [_headerView addSubview:vDeliveryAddress]; UILabel *lblvDeliveryAddress = [UILabel new]; lblvDeliveryAddress.frame = CGRectMake(10,3,70, 25); lblvDeliveryAddress.text = @"送安地址:"; lblvDeliveryAddress.font = kTextFont; [vDeliveryAddress addSubview:lblvDeliveryAddress]; _deliveryAddress = [UILabel new]; _deliveryAddress.frame = CGRectMake(CGRectGetMaxX(lblvDeliveryAddress.frame),3, 200, 25); _deliveryAddress.font = kTextFont; [vDeliveryAddress addSubview:_deliveryAddress]; //应收金额-------------- UIView *vReceivables = [UIView new]; vReceivables.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryAddress.frame), Screen_Width, mHeight); [_headerView addSubview:vReceivables]; UILabel *lblvReceivables = [UILabel new]; lblvReceivables.frame = CGRectMake(10,3,70, 25); lblvReceivables.text = @"应收金额:"; lblvReceivables.font = kTextFont; [vReceivables addSubview:lblvReceivables]; _receivables = [UILabel new]; _receivables.font = kTextFont; _receivables.frame = CGRectMake(CGRectGetMaxX(lblvReceivables.frame),3, 200, 25); [vReceivables addSubview:_receivables]; //已回执金额-------------- UIView *vCompleteReceivables = [UIView new]; vCompleteReceivables.frame = CGRectMake(0,CGRectGetMaxY(vReceivables.frame), Screen_Width, mHeight); [_headerView addSubview:vCompleteReceivables]; UILabel *lblCompleteReceivables = [UILabel new]; lblCompleteReceivables.frame = CGRectMake(10,3,85, 25); lblCompleteReceivables.font = kTextFont; lblCompleteReceivables.text = @"已回执金额:"; [vCompleteReceivables addSubview:lblCompleteReceivables]; _completeReceivables = [UILabel new]; _completeReceivables.font = kTextFont; _completeReceivables.frame = CGRectMake(CGRectGetMaxX(lblCompleteReceivables.frame),3, 200, 25); [vCompleteReceivables addSubview:_completeReceivables]; //送货单回执类型-------------- UIView *vReceiptType = [UIView new]; vReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vCompleteReceivables.frame), Screen_Width, mHeight); [_headerView addSubview:vReceiptType]; UILabel *lblvReceiptType = [UILabel new]; lblvReceiptType.frame = CGRectMake(10,3,110, 25); lblvReceiptType.text = @"送安单回执类型:"; lblvReceiptType.font = kTextFont; [vReceiptType addSubview:lblvReceiptType]; _receiptType = [UILabel new]; _receiptType.font = kTextFont; _receiptType.frame = CGRectMake(CGRectGetMaxX(lblvReceiptType.frame),3, 200, 25); [vReceiptType addSubview:_receiptType]; //推迟送货日期-------------- UIView *vNextDeliveryDate = [UIView new]; vNextDeliveryDate.frame = CGRectMake(0,CGRectGetMaxY(vReceiptType.frame), Screen_Width, mHeight); [_headerView addSubview:vNextDeliveryDate]; UILabel *lblvNextDeliveryDate = [UILabel new]; lblvNextDeliveryDate.frame = CGRectMake(10,3, 72, 25); lblvNextDeliveryDate.text = @"送安日期:"; lblvNextDeliveryDate.font = kTextFont; [vNextDeliveryDate addSubview:lblvNextDeliveryDate]; _nextDeliveryDate = [UILabel new]; _nextDeliveryDate.font = kTextFont; _nextDeliveryDate.frame = CGRectMake(CGRectGetMaxX(lblvNextDeliveryDate.frame),3, 200, 25); [vNextDeliveryDate addSubview:_nextDeliveryDate]; _lbAccountDate = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(vNextDeliveryDate.frame)+5, SCREENWIDTH-30, 17)]; _lbAccountDate.text = @"账务日期:"; _lbAccountDate.font = kTextFont; [_headerView addSubview:_lbAccountDate]; _lbServiceStaffName = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(_lbAccountDate.frame)+10, SCREENWIDTH-30, 17)]; _lbServiceStaffName.text = @"配送人员:"; _lbServiceStaffName.font = kTextFont; [_headerView addSubview:_lbServiceStaffName]; _lbRemarks = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(_lbServiceStaffName.frame)+10, SCREENWIDTH-30, 17)]; _lbRemarks.text = @"回执备注:"; _lbRemarks.font = kTextFont; [_headerView addSubview:_lbRemarks]; _lbCreatetime = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(_lbRemarks.frame)+10, SCREENWIDTH-30, 17)]; _lbCreatetime.text = @"创建时间:"; _lbCreatetime.font = kTextFont; [_headerView addSubview:_lbCreatetime]; _headerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(_lbCreatetime.frame)+10); _tableView.tableHeaderView = _headerView; contentView.frame = CGRectMake(0,0,self.tableView.bounds.size.width, self.tableView.bounds.size.height); if(!_infoList){ _infoList = [[NSMutableArray alloc]init]; } } /** 数据加载 */ - (void)initData{ [self startLoading]; NSString *urlStr = ServerURL; NSMutableDictionary *dict = [NSMutableDictionary new]; [dict setObject:@"GetDeliveryRequirementReceiptDetailIphone" forKey:@"Action"]; [dict setObject:kkAccountCode forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:_deliveryId forKey:@"DeliveryID"]; [dict setObject:_recReceiptNo forKey:@"ReceiptNo"]; [dict setObject:_receiptID forKey:@"ReceiptID"]; self.mDownManager = [[ASIDownManager alloc] init]; _mDownManager.delegate = self; _mDownManager.onRequestSuccess = @selector(onLoadFinish:); _mDownManager.onRequestFail = @selector(onLoadFail:); [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } /** 取消进度条 */ - (void)cancel { [self stopLoading]; } /** 获取tableview的高度 @param Array <#Array description#> @return <#return value description#> */ - (CGFloat)getArrayViewHeight:(NSArray *)Array { // 上下间隔已经在frame上做了 NSInteger row = Array.count; CGFloat allheight = 0; for (int i = 0; i < Array.count; i++) { DeliveryRequirementListDetailModel *info = Array[i]; if([info.remarks isEqualToString:@""]){ //不加空格计算不出备注的高度 info.remarks = @" "; } CGFloat height = [info.remarks sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(SCREENWIDTH-110, MAXFLOAT)].height + 800; allheight += height; } return allheight; } @end