// // DeliveryRequirementDetailControllerViewController.m // IBOSSHSH // // Created by ssl on 2018/1/16. // Copyright © 2018年 elongtian. All rights reserved. // #import "DispatchRequirementDetailController.h" #import "DeliveryImg.h" #import "XHImageViewer.h" #import "AlbumPhotoCollectionViewCell.h" #import "NSString+Tools.h" #import "DispatchRequirementDetailHeadModel.h" #import "DateFormat.h" #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize] @implementation DispatchRequirementDetailController @synthesize scroll; @synthesize contentView; @synthesize mHeight; #pragma mark - 公共函数 - (void)viewDidLoad { [super viewDidLoad]; mHeight = 31; [self initUI]; [self initData]; } /** 安全区视图发生变化 */ -(void)viewSafeAreaInsetsDidChange{ self.tableView.frame=CGRectMake(10,10, self.view.frame.size.width-20,self.view.safeAreaLayoutGuide.layoutFrame.size.height-50) ; _btnCancel.frame = CGRectMake(0, self.view.safeAreaLayoutGuide.layoutFrame.size.height -40, Screen_Width, 40); [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 *arr2=[approvArr objectForKey:@"Table2"]; if(arr != nil&&arr.count>0){ NSDictionary *dicValue = arr[0]; DispatchRequirementDetailHeadModel *model = [DispatchRequirementDetailHeadModel dk_modelWithDictionary:dicValue]; _lblDispatchNo.text = model.arrangementNo; _lblCustomerCode.text=model.customerCode; _lblDeliveryArea.text=model.deliveryArea; _lblCustomerTelephone.text=model.telephone; _lblDeliveryTime.text=model.deliveryPeriod; _lblChargeAmount.text=[NSString stringWithFormat:@"%.2f",[model.receivables doubleValue]]; _lblDeliveryChargeAmount.text=[NSString stringWithFormat:@"%.2f",[model.deliveryReceivables doubleValue]]; _lblInstallChargeAmount.text=[NSString stringWithFormat:@"%.2f",[model.installationReceivables doubleValue]]; _lblCollectionAmount.text=[NSString stringWithFormat:@"%.2f",[model.deliveryReceiptAmount doubleValue]]; _receiptNo.text = model.receiptNo; _deliveryNo.text = model.deliveryNo; _customerName.text = model.customerName; _contacts.text = model.contacts; _telephone.text = model.telephone; _lbRemarks.text = model.remarks == nil?@"":model.remarks; _lbAccountDate.text = model.accountDate; _lbCreatetime.text = model.createTime; _lblCreater.text=model.createUserName; _lbTruckNumber.text=model.truckNumber; _deliveryAddress.text = model.deliveryAddress; _nextDeliveryDate.text = [DateFormat dateFormatSplit: model.deliveryDate]; } if(arr1 != nil){ for (int i = 0; i < [arr1 count]; i++) { NSDictionary *infoDic=arr1[i]; DispatchRequirementListDetailModel *info = [DispatchRequirementListDetailModel dk_modelWithDictionary:infoDic]; [_infoList addObject:info]; } } if(arr2 != nil&&[arr2 count] > 0){ if(_photoList==nil){ _photoList = [[NSMutableArray alloc]init]; } if(_signList==nil) { _signList= [[NSMutableArray alloc]init]; } for (int i = 0; i < [arr2 count]; i++) { NSDictionary *imgDic = arr2[i]; int receiptType=[[imgDic objectForKey:@"ReceiptType"]intValue]; NSString *imgPath = [imgDic objectForKey:@"ThumbnailPath"]; if(receiptType==1) { DeliveryImg *img = [DeliveryImg new]; img.imageName = imgPath; [_photoList addObject:img]; } if(receiptType==2) { DeliveryImg *img = [DeliveryImg new]; img.imageName = imgPath; [_signList addObject:img]; } } } if(arr1 != nil){ self.tableView.frame=CGRectMake(10,10, self.view.frame.size.width - 20,self.view.frame.size.height-90) ; [self.tableView reloadData]; } if(_photoList != nil&&[_photoList 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(10,0, self.view.bounds.size.width - 20, [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"]; [_footerView addSubview:self.collectionView]; _footerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(self.collectionView.frame)+10); if(_signList!=nil&&_signList.count>0) { _signImgView=[[UIImageView alloc]init]; _signImgView.frame=CGRectMake(15, CGRectGetMaxY(self.collectionView.frame)+10, 150, 150); [_footerView addSubview:_signImgView]; _footerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(_signImgView.frame)+10); DeliveryImg *signImg= [_signList objectAtIndex:0]; NSString *signPath= signImg.imageName; if(signPath != nil && [signPath length] > 0){ NSString *imageUrl = [NSString stringWithFormat:@"http://%@:%@/WebService/%@",kkServerUrl,kkServerPort,signPath]; NSURL *url = [NSURL URLWithString:imageUrl]; [_signImgView setImageWithURL:url placeholderImage:nil]; } } _tableView.tableFooterView=_footerView; } else { if(_signList!=nil&&_signList.count>0) { _signImgView=[[UIImageView alloc]init]; _signImgView.frame=CGRectMake(15, 10, 150, 150); [_footerView addSubview:_signImgView]; _footerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(_signImgView.frame)+10); _tableView.tableFooterView=_footerView; DeliveryImg *signImg= [_signList objectAtIndex:0]; NSString *signPath= signImg.imageName; if(signPath != nil && [signPath length] > 0){ NSString *imageUrl = [NSString stringWithFormat:@"http://%@:%@/WebService/%@",kkServerUrl,kkServerPort,signPath]; NSURL *url = [NSURL URLWithString:imageUrl]; [_signImgView setImageWithURL:url placeholderImage:nil]; } } } } } 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:@"网络异常"]; } /** 请求撤销回执 @param receiptID <#receiptID description#> */ -(void) requestCancelDeliveryReceipt:(NSString *) receiptID{ [self startLoading]; NSString *urlStr = ServerURL; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"CancelInstallationDemandReceiptIphone" 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:kkLicenseCode forKey:@"LicenseCode"]; [dict setObject:receiptID forKeyedSubscript:@"ReceiptID"]; self.mDownManager = [[ASIDownManager alloc] init]; _mDownManager.delegate = self; _mDownManager.onRequestSuccess = @selector(onRequestCancelReceiptFinish:); _mDownManager.onRequestFail = @selector(onRequestCancelReceiptFail:); [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } /** 请求成功 @param sender <#sender description#> */ - (void)onRequestCancelReceiptFinish:(ASIDownManager *) sender{ RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; [self cancel]; int iNewCount = 0; int iStatus = resultModel.status; NSString *message = resultModel.message; if (iStatus == 0) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"撤销成功!" preferredStyle:UIAlertControllerStyleAlert ]; [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ if([self.refreshDelegate respondsToSelector:@selector(refreshData)]) { [self.refreshDelegate refreshData]; [self.navigationController popViewControllerAnimated:YES]; } }]]; // 3.显示alertController:presentViewController [self presentViewController:alert animated:YES completion:nil]; } else if(iStatus == ActionResultStatusAuthError ||iStatus == ActionResultStatusNoLogin ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){ [self showReLoginDialog:message]; return; } else{ [self showAlertViewText:message]; return; } } /** 请求失败 @param sender <#sender description#> */ - (void)onRequestCancelReceiptFail:(ASIDownManager *) sender{ [self cancel]; [self showAlertViewText:@"请求失败"]; } /** tableview的分区数 @param tableView <#tableView description#> @return <#return value description#> */ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [_infoList count]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 832; } /** 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 = @"DispatchRequirementDetailListCell"; DispatchRequirementDetailListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if(cell==nil) { NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:cellIdentifier owner:nil options:nil]; cell = [nibs lastObject]; } NSMutableArray *dataArray = _infoList; DispatchRequirementListDetailModel *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.sourceNo.text=model.invoiceNo; cell.package.text= model.package; 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.lblUnit.text=model.unitName; cell.lblDispatchType.text=model.requirementTypeName; 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.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; 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 setBackgroundImage:[UIImage imageNamed:@"icon_back.png"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(0, 0,15,18); UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button]; self.navigationItem.leftBarButtonItem = menuButton; 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 = YES; self.tableView.estimatedRowHeight = 44.0f; self.tableView.frame = CGRectZero; [self.view addSubview:self.tableView]; _headerView = [[UIView alloc]init]; _headerView.frame = CGRectZero; _headerView.layer.cornerRadius = CornerRadius; _headerView.backgroundColor = [UIColor whiteColor]; _footerView = [[UIView alloc]init]; _footerView.frame = CGRectZero; // _footerView.layer.cornerRadius = CornerRadius; // _footerView.backgroundColor = [UIColor whiteColor]; //回执单号-------------- 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 *vTruckNumber = [UIView new]; vTruckNumber.frame = CGRectMake(0,CGRectGetMaxY(vReceiptNoName.frame), Screen_Width, mHeight); [_headerView addSubview:vTruckNumber]; UILabel *lblTruckNumberTitle = [UILabel new]; lblTruckNumberTitle.frame = CGRectMake(10,3, 70, 25); lblTruckNumberTitle.text = @"车 牌 号:"; lblTruckNumberTitle.font = kTextFont; [vTruckNumber addSubview:lblTruckNumberTitle]; _lbTruckNumber = [UILabel new]; _lbTruckNumber.frame = CGRectMake(CGRectGetMaxX(lblTruckNumberTitle.frame),3, 200, 25); _lbTruckNumber.font = kTextFont; [vTruckNumber addSubview:_lbTruckNumber]; //送货单号-------------- UIView *vDispatchNo = [UIView new]; vDispatchNo.frame = CGRectMake(0,CGRectGetMaxY(vTruckNumber.frame), Screen_Width, mHeight); [_headerView addSubview:vDispatchNo]; UILabel *lblDispatchNoTitle = [UILabel new]; lblDispatchNoTitle.frame = CGRectMake(10,3, 70, 25); lblDispatchNoTitle.text = @"派工单号:"; lblDispatchNoTitle.font = kTextFont; [vDispatchNo addSubview:lblDispatchNoTitle]; _lblDispatchNo = [UILabel new]; _lblDispatchNo.frame = CGRectMake(CGRectGetMaxX(lblDispatchNoTitle.frame),3, 200, 25); _lblDispatchNo.font = kTextFont; [vDispatchNo addSubview:_lblDispatchNo]; UIView *vCustomerCode = [UIView new]; vCustomerCode.frame = CGRectMake(0,CGRectGetMaxY(vDispatchNo.frame), Screen_Width, mHeight); [_headerView addSubview:vCustomerCode]; UILabel *lblCustomerCodeTitle = [UILabel new]; lblCustomerCodeTitle.frame = CGRectMake(10,3, 70, 25); lblCustomerCodeTitle.text = @"客户编码:"; lblCustomerCodeTitle.font = kTextFont; [vCustomerCode addSubview:lblCustomerCodeTitle]; _lblCustomerCode = [UILabel new]; _lblCustomerCode.font = kTextFont; _lblCustomerCode.frame = CGRectMake(CGRectGetMaxX(lblCustomerCodeTitle.frame),3, 200, 25); [vCustomerCode addSubview:_lblCustomerCode]; //客户名称-------------- UIView *vCustomerName = [UIView new]; vCustomerName.frame = CGRectMake(0,CGRectGetMaxY(vCustomerCode.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 *vCustomerTelephone = [UIView new]; vCustomerTelephone.frame = CGRectMake(0,CGRectGetMaxY(vCustomerName.frame), Screen_Width, mHeight); [_headerView addSubview:vCustomerTelephone]; UILabel *lblCustomerTelephoneTitle = [UILabel new]; lblCustomerTelephoneTitle.frame = CGRectMake(10,3, 70, 25); lblCustomerTelephoneTitle.text = @"客户电话:"; lblCustomerTelephoneTitle.font = kTextFont; [vCustomerTelephone addSubview:lblCustomerTelephoneTitle]; _lblCustomerTelephone = [UILabel new]; _lblCustomerTelephone.font = kTextFont; _lblCustomerTelephone.frame = CGRectMake(CGRectGetMaxX(lblCustomerTelephoneTitle.frame),3, 200, 25); [vCustomerTelephone addSubview:_lblCustomerTelephone]; UIView *vDeliveryArea = [UIView new]; vDeliveryArea.frame = CGRectMake(0,CGRectGetMaxY(vCustomerTelephone.frame), Screen_Width, mHeight); [_headerView addSubview:vDeliveryArea]; UILabel *lblDeliveryAreaTitle = [UILabel new]; lblDeliveryAreaTitle.frame = CGRectMake(10,3, 70, 25); lblDeliveryAreaTitle.text = @"送货区域:"; lblDeliveryAreaTitle.font = kTextFont; [vDeliveryArea addSubview:lblDeliveryAreaTitle]; _lblDeliveryArea= [UILabel new]; _lblDeliveryArea.font = kTextFont; _lblDeliveryArea.frame = CGRectMake(CGRectGetMaxX(lblDeliveryAreaTitle.frame),3, 200, 25); [vDeliveryArea addSubview:_lblDeliveryArea]; //地址-------------- UIView *vDeliveryAddress = [UIView new]; vDeliveryAddress.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryArea.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 *vNextDeliveryDate = [UIView new]; vNextDeliveryDate.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryAddress.frame), Screen_Width, mHeight); [_headerView addSubview:vNextDeliveryDate]; UILabel *lblvNextDeliveryDate = [UILabel new]; lblvNextDeliveryDate.frame = CGRectMake(10,3, 70, 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]; UIView *vDeliveryTime = [UIView new]; vDeliveryTime.frame = CGRectMake(0,CGRectGetMaxY(vNextDeliveryDate.frame), Screen_Width, mHeight); [_headerView addSubview:vDeliveryTime]; UILabel *lblDeliveryTimeTitle = [UILabel new]; lblDeliveryTimeTitle.frame = CGRectMake(10,3, 72, 25); lblDeliveryTimeTitle.text = @"配送时段:"; lblDeliveryTimeTitle.font = kTextFont; [vDeliveryTime addSubview:lblDeliveryTimeTitle]; _lblDeliveryTime = [UILabel new]; _lblDeliveryTime.font = kTextFont; _lblDeliveryTime.frame = CGRectMake(CGRectGetMaxX(lblDeliveryTimeTitle.frame),3, 200, 25); [vDeliveryTime addSubview:_lblDeliveryTime]; UIView *vChargeAmount = [UIView new]; vChargeAmount.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryTime.frame), Screen_Width, mHeight); [_headerView addSubview:vChargeAmount]; UILabel *lblChargeAmountTitle = [UILabel new]; lblChargeAmountTitle.frame = CGRectMake(10,3, 72, 25); lblChargeAmountTitle.text = @"收费金额:"; lblChargeAmountTitle.font = kTextFont; [vChargeAmount addSubview:lblChargeAmountTitle]; _lblChargeAmount = [UILabel new]; _lblChargeAmount.font = kTextFont; _lblChargeAmount.frame = CGRectMake(CGRectGetMaxX(lblChargeAmountTitle.frame),3, 200, 25); [vChargeAmount addSubview:_lblChargeAmount]; UIView *vDeliveryChargeAmount = [UIView new]; vDeliveryChargeAmount.frame = CGRectMake(0,CGRectGetMaxY(vChargeAmount.frame), Screen_Width, mHeight); [_headerView addSubview:vDeliveryChargeAmount]; UILabel *lblDeliveryChargeAmountTitle = [UILabel new]; lblDeliveryChargeAmountTitle.frame = CGRectMake(10,3,90, 25); lblDeliveryChargeAmountTitle.text = @"送货收费金额:"; lblDeliveryChargeAmountTitle.font = kTextFont; [vDeliveryChargeAmount addSubview:lblDeliveryChargeAmountTitle]; _lblDeliveryChargeAmount = [UILabel new]; _lblDeliveryChargeAmount.font = kTextFont; _lblDeliveryChargeAmount.frame = CGRectMake(CGRectGetMaxX(lblDeliveryChargeAmountTitle.frame),3, 200, 25); [vDeliveryChargeAmount addSubview:_lblDeliveryChargeAmount]; UIView *vInstallChargeAmount = [UIView new]; vInstallChargeAmount.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryChargeAmount.frame), Screen_Width, mHeight); [_headerView addSubview:vInstallChargeAmount]; UILabel *lblInstallChargeAmountTitle = [UILabel new]; lblInstallChargeAmountTitle.frame = CGRectMake(10,3, 90, 25); lblInstallChargeAmountTitle.text = @"安装收费金额:"; lblInstallChargeAmountTitle.font = kTextFont; [vInstallChargeAmount addSubview:lblInstallChargeAmountTitle]; _lblInstallChargeAmount = [UILabel new]; _lblInstallChargeAmount.font = kTextFont; _lblInstallChargeAmount.frame = CGRectMake(CGRectGetMaxX(lblInstallChargeAmountTitle.frame),3, 200, 25); [vInstallChargeAmount addSubview:_lblInstallChargeAmount]; UIView *vCollectionAmount = [UIView new]; vCollectionAmount.frame = CGRectMake(0,CGRectGetMaxY(vInstallChargeAmount.frame), Screen_Width, mHeight); [_headerView addSubview:vCollectionAmount]; UILabel *lblCollectionAmountTitle = [UILabel new]; lblCollectionAmountTitle.frame = CGRectMake(10,3, 72, 25); lblCollectionAmountTitle.text = @"收款金额:"; lblCollectionAmountTitle.font = kTextFont; [vCollectionAmount addSubview:lblCollectionAmountTitle]; _lblCollectionAmount = [UILabel new]; _lblCollectionAmount.font = kTextFont; _lblCollectionAmount.frame = CGRectMake(CGRectGetMaxX(lblCollectionAmountTitle.frame),3, 200, 25); [vCollectionAmount addSubview:_lblCollectionAmount]; UIView *vAccountDate = [UIView new]; vAccountDate.frame = CGRectMake(0,CGRectGetMaxY(vCollectionAmount.frame), Screen_Width, mHeight); [_headerView addSubview:vAccountDate]; UILabel *lblAccountDateTitle= [UILabel new]; lblAccountDateTitle.frame = CGRectMake(10,3,70, 25); lblAccountDateTitle.text = @"账务日期:"; lblAccountDateTitle.font = kTextFont; [vAccountDate addSubview:lblAccountDateTitle]; _lbAccountDate = [UILabel new]; _lbAccountDate.font = kTextFont; _lbAccountDate.frame = CGRectMake(CGRectGetMaxX(lblAccountDateTitle.frame),3, 200, 25); [vAccountDate addSubview:_lbAccountDate]; UIView *vRemarks = [UIView new]; vRemarks.frame = CGRectMake(0,CGRectGetMaxY(vAccountDate.frame), Screen_Width, mHeight); [_headerView addSubview:vRemarks]; UILabel *lblRemarksTitle= [UILabel new]; lblRemarksTitle.frame = CGRectMake(10,3,70, 25); lblRemarksTitle.text = @"备 注:"; lblRemarksTitle.font = kTextFont; [vRemarks addSubview:lblRemarksTitle]; _lbRemarks = [UILabel new]; _lbRemarks.font = kTextFont; _lbRemarks.frame = CGRectMake(CGRectGetMaxX(lblRemarksTitle.frame),3, 200, 25); [vRemarks addSubview:_lbRemarks]; UIView *vCreater = [UIView new]; vCreater.frame = CGRectMake(0,CGRectGetMaxY(vRemarks.frame), Screen_Width, mHeight); [_headerView addSubview:vCreater]; UILabel *lblCreaterTitle= [UILabel new]; lblCreaterTitle.frame = CGRectMake(10,3,70, 25); lblCreaterTitle.text = @"创 建 者:"; lblCreaterTitle.font = kTextFont; [vCreater addSubview:lblCreaterTitle]; _lblCreater = [UILabel new]; _lblCreater.font = kTextFont; _lblCreater.frame = CGRectMake(CGRectGetMaxX(lblCreaterTitle.frame),3, 200, 25); [vCreater addSubview:_lblCreater]; UIView *vCreateTime = [UIView new]; vCreateTime.frame = CGRectMake(0,CGRectGetMaxY(vCreater.frame), Screen_Width, mHeight); [_headerView addSubview:vCreateTime]; UILabel *lblCreateTimeTitle= [UILabel new]; lblCreateTimeTitle.frame = CGRectMake(10,3,70, 25); lblCreateTimeTitle.text = @"创建时间:"; lblCreateTimeTitle.font = kTextFont; [vCreateTime addSubview:lblCreateTimeTitle]; _lbCreatetime = [UILabel new]; _lbCreatetime.font = kTextFont; _lbCreatetime.frame = CGRectMake(CGRectGetMaxX(lblCreateTimeTitle.frame),3, 200, 25); [vCreateTime addSubview:_lbCreatetime]; _headerView.frame = CGRectMake(0,0,self.tableView.bounds.size.width,CGRectGetMaxY(vCreateTime.frame)+10); _tableView.tableHeaderView = _headerView; _btnCancel = [UIButton buttonWithType:UIButtonTypeCustom]; _btnCancel.frame=CGRectMake(0, Screen_Height- 40- rectStatusHeight-rectNavHeight, Screen_Width,40) ; [_btnCancel setTitle:@"撤销" forState:UIControlStateNormal]; [_btnCancel setBackgroundColor:NavigationBarColor]; [_btnCancel addTarget:self action:@selector(cancelReceipt) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_btnCancel]; if([_receiptTypeFlag intValue]!=1) { _btnCancel.enabled=YES; } else{ _btnCancel.enabled=NO; } if(!_infoList){ _infoList = [[NSMutableArray alloc]init]; } } -(void)cancelReceipt { UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否要撤销回执?" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ [self requestCancelDeliveryReceipt: _receiptID]; }]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ }]; UIColor *cancelColor = [UIColor blackColor]; UIColor *sureColor = [UIColor redColor]; [cancelAction setValue:cancelColor forKey:@"titleTextColor"]; [okAction setValue:sureColor forKey:@"titleTextColor"]; [alert addAction:okAction]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; } /** 数据加载 */ - (void)initData{ [self startLoading]; NSString *urlStr = ServerURL; NSMutableDictionary *dict = [NSMutableDictionary new]; [dict setObject:@"GetInstallationDemandReceiptDetailIphone" forKey:@"Action"]; [dict setObject:kkAccountCode forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [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++) { CGFloat height=832; allheight += height; } return allheight; } @end