// NewReceiptViewController.m // IOBSS 2.0 // // Created by 刘瀚璘 on 2017.7.14 // Copyright 2017 沈阳东科云信软件有限公司. All rights reserved. // // 系统名称: // 功能描述:新增定制品回执页面 #import "NewReceiptViewController.h" #import "CustomButton.h" #import "DKPhotoAssets.h" #import "DKUICollectionViewCell.h" #import "DKPhotoPickerBrowserViewController.h" #import "DKPhotoPickerViewController.h" #import "ReceiptDetailViewController.h" #import "NewCustomReceiptCell.h" #import "NewCustomerModel.h" //#import "MapViewController.h" #import "StatusInfo.h" #import "StatusInfoTextVC.h" #import "SettlementTypeVC.h" #import "LeslieAsyncImageDownloader.h" @interface NewReceiptViewController () { /** UIScrollView */ UIScrollView *_scrollView; /** UITableView */ UITableView *_tableView; /** 回执金额 */ UITextField *_fieldReceiptAmount; /** 已回执金额 */ UILabel *_lblReceivedAmount; /** 客户名称 */ UILabel *_lblCustomerName; /** 电话 */ UILabel *_lblTelePhone; /** 收费金额 */ UILabel *_lblTollAmount; /** 位置 */ UILabel *_lblPosition; /** 拍照,相册,位置 */ UIView *_center; /** 线 */ UIView *_line; /** 位置 */ UIView *_positionImage; /** 结算方式 */ UIButton *_btnSettlement; /** 回执状态 */ UIButton *_btnReceiptStatus; /** 客户名称 */ NSString *_strCustomerName; /** 收费金额 */ NSString *_strTollAmount; /** 回执金额 */ NSString *_strReceiptedAmount; /** 已回执金额 */ NSString *_strReceivedAmount; /** 联系电话 */ NSString *_strTelephone; /** 回执状态ID */ NSString *_statusID; /** 售前ID */ NSString *_fixedID; /** 安排单号ID */ NSString *_arrangementID; /** 结算方式ID */ NSString *_settlementType; /** 用户ID */ NSString *_strCustomerID; /** 上传参数 */ NSString *_strBusinessOrganization; /** 备注 */ NSString *_strRemarks; /** 业务员 */ NSString *_strSalesMan; /** 结算方式回调的备注 */ NSString *_listRemarks; /** 结算方式回调的参数 */ NSString *_strEarnestFee; /** 上传的图片 */ NSMutableArray *_arrImagePaths; /** 当前图片数 */ NSMutableArray *_assets; /** 回执状态 */ NSMutableArray *_arrayDStatus; /** 键盘弹起标识 */ BOOL _keyboardShow; /** 键盘弹起View是否执行动画 */ BOOL isCancelAnimation; } @end @implementation NewReceiptViewController #pragma mark - 公共函数 - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil]; [self initUI]; [self loadUI]; [self reloadData]; } /** 安全区视图发生变化 */ -(void)viewSafeAreaInsetsDidChange{ _scrollView.frame = CGRectMake(0, 0, SCREENWIDTH,self.view.safeAreaLayoutGuide.layoutFrame.size.height-44); _btnSave.frame=CGRectMake(20,self.view.safeAreaLayoutGuide.layoutFrame.size.height-44-15, Screen_Width-40,44) ; [super viewSafeAreaInsetsDidChange]; } /** 销毁 */ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:UIKeyboardWillShowNotification]; [[NSNotificationCenter defaultCenter] removeObserver:UIKeyboardWillHideNotification]; } /** 请求数据 */ - (void)reloadData{ _dataArray = [[NSMutableArray alloc] init]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetFixedForNewReceiptIphone" 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:_fixedNo forKey:@"FixedNo"]; _downManager = [[ASIDownManager alloc] init]; _downManager.delegate = self; _downManager.onRequestSuccess = @selector(onLoadFinish:); _downManager.onRequestFail = @selector(onLoadFail:); [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil]; } #pragma mark - 数据解析 /** 请求成功 @param sender <#sender description#> */ - (void)onLoadFinish:(ASIDownManager *) sender{ // 服务器返回数据 RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; // 服务器返回数据状态值 int iStatus = resultModel.status; // 服务器返回数据消息 NSString *message = resultModel.message; // 服务器返回数据状态值正确 if (iStatus == 0) { // 服务器返回数据结果 NSDictionary * dictionary = (NSDictionary *)resultModel.result; NSArray *table = [dictionary objectForKey:@"Table"]; NSArray *table1 = [dictionary objectForKey:@"Table1"]; if(table == nil ||table.count == 0){ [self showAlertViewText:@"加载数据失败"]; return; } BOOL receiptFlag = NO; for (int i = 0; i < table.count; i++) { NSDictionary *dic = table[i]; receiptFlag = [[dic objectForKey:@"ReceiptFlag"] boolValue]; if (receiptFlag) { break; } _strCustomerName = [dic objectForKey:@"CustomerName"]; _strTollAmount = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"Receivables"] doubleValue]] ; _strReceivedAmount = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"ReceiptedAmount"] doubleValue]] ; _strReceiptedAmount = [NSString stringWithFormat:@"%.2f",[[dic objectForKey:@"ReceiptSum"] doubleValue]] ; _strTelephone = [dic objectForKey:@"Telephone"]; _strSalesMan = [dic objectForKey:@"SalesMan"]; _fieldReceiptAmount.text = _strReceiptedAmount; if(_strTelephone == nil){ _strTelephone = @""; } _lblTelePhone.text = [NSString stringWithFormat:@"联系电话:%@",_strTelephone]; _lblTollAmount.text = [NSString stringWithFormat:@"收费金额:%@",_strTollAmount]; _lblReceivedAmount.text = [NSString stringWithFormat:@"已回执金额:%@",_strReceivedAmount]; _lblCustomerName.text = [NSString stringWithFormat:@"客户名称:%@",_strCustomerName]; _fixedID = [dic objectForKey:@"FixedID"]; _arrangementID = [dic objectForKey:@"ArrangementID"]; _strCustomerID = [dic objectForKey:@"CustomerID"]; _strBusinessOrganization = [dic objectForKey:@"BusinessOrganization"]; _strRemarks = [dic objectForKey:@"Remarks"]; } if(receiptFlag){ receiptFlag = NO; } if([_strTollAmount doubleValue]>0){ _fieldReceiptAmount.enabled = YES; }else{ _fieldReceiptAmount.enabled = NO; } for (int i = 0; i < table1.count; i++) { NSDictionary *dic = table1[i]; NewCustomerModel *model = [NewCustomerModel dk_modelWithDictionary:dic]; [_dataArray addObject:model] ; } [self reloadTableViewHeight:_dataArray]; [_tableView reloadData]; }else if(iStatus == ActionResultStatusAuthError ||iStatus == ActionResultStatusNoLogin ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){ [self showReLoginDialog:message]; return; }else { // [[UserInfoManager Share] ClearUserData]; [self showAlertViewText:message]; return; } } /** 请求失败 @param sender */ - (void)onLoadFail:(ASIDownManager *) sender{ [self stopLoading]; } /** 保存成功 @param sender */ - (void)onSaveFinish: (ASIDownManager *)sender { [self stopLoading]; // 服务器返回数据 RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; // 服务器返回数据状态值 int status = resultModel.status; // 服务器返回数据消息 NSString *message = resultModel.message; // 服务器返回数据状态值正确 if(status == 0){ [self showAlertViewText:@"保存成功"]; }else if(status == ActionResultStatusAuthError ||status == ActionResultStatusNoLogin ||status == ActionResultStatusLogined||status==ActionResultSessionOverdue){ [self showReLoginDialog:message]; return; } else { [self showAlertViewText:message]; return; } } /** 保存失败 @param sender */ - (void)onSaveFail: (ASIDownManager *)sender{ [self stopLoading]; } /** 保存退出 @param text */ - (void) showAlertViewText:(NSString *)text{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:text preferredStyle:UIAlertControllerStyleAlert ]; [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ if([text isEqualToString:@"保存成功"]){ [_noReceiptVC popViewReLoadData]; } [self.navigationController popViewControllerAnimated:true]; }]]; [self presentViewController:alert animated:YES completion:nil]; } #pragma mark - 事件 /** 回执类型 @param btn */ - (void)showReceiptType:(UIButton *)btn{ self.hidesBottomBarWhenPushed=YES; [self initStatus]; StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init]; tc.sdelegate = self; [tc.arrFilter addObjectsFromArray: _arrayDStatus]; [self.navigationController pushViewController:tc animated:YES]; self.hidesBottomBarWhenPushed=NO; } /** 结算方式 @param btn */ - (void)showSettlement:(UIButton *) btn{ if ([_strTollAmount isEqualToString:@""] || [_strTollAmount doubleValue]== 0) { return; } [self.view endEditing:YES]; self.hidesBottomBarWhenPushed = YES; SettlementTypeVC *tc = [[SettlementTypeVC alloc] init]; tc.sDelegate = self; [self.navigationController pushViewController:tc animated:YES]; self.hidesBottomBarWhenPushed = NO; } /** 跳转到相机 */ - (void)pushPhotograph{ DKCameraViewController *cameraVc = [[DKCameraViewController alloc] init]; __weak typeof(self) weakSelf = self; // 多选相册+相机多拍 回调 [cameraVc startCameraOrPhotoFileWithViewController:self complate:^(NSArray *object){ // 选择完照片、拍照完回调 [object enumerateObjectsUsingBlock:^(id asset, NSUInteger idx, BOOL *stop){ if(weakSelf.assets.count < 9) { if ([asset isKindOfClass:[DKCamera class]]) { [weakSelf.assets addObject:asset]; }else{ [weakSelf.assets addObject:asset]; } }else{ [self showAlertViewText:@"最多只能选择9张图片"]; } }]; [weakSelf.collectionView reloadData]; }]; weakSelf.cameraVc = cameraVc; } /** 跳转到相机 */ - (void)pushAlbum{ // 创建控制器 DKPhotoPickerViewController *pickerVc = [[DKPhotoPickerViewController alloc] init]; // 默认显示相册里面的内容SavePhotos pickerVc.status = PickerViewShowStatusCameraRoll; pickerVc.selectPickers = self.assets; // 最多能选9张图片 pickerVc.minCount = 9; pickerVc.cameraCount = [self cameraCount]; pickerVc.delegate = self; [pickerVc show]; /** * 传值可以用代理,或者用block来接收,以下是block的传值 __weak typeof(self) weakSelf = self; pickerVc.callBack = ^(NSArray *assets){ weakSelf.assets = assets; [weakSelf.tableView reloadData]; }; */ } /** 跳转到地图 关宏厚删除高德地图 2018-11-14 */ - (void)pushMap{ self.hidesBottomBarWhenPushed=YES; // MapViewController *mc = [MapViewController new]; // mc.pDelegate=self; // [self.navigationController pushViewController:mc animated:YES]; //self.hidesBottomBarWhenPushed=NO; } /** 保存按钮 */ - (void)dataSave{ for (int i = 0; i<_dataArray.count; i++) { NewCustomerModel *model = [_dataArray objectAtIndex:i]; if(model.receiptSpecification == NULL || [model.receiptSpecification isEqualToString:@""]){ [super showAlertViewText:@"回执规格不能为空!"]; return; } } [self startLoading]; dispatch_async(dispatch_get_global_queue(0, 0), ^{ if ([self savePicsManager]) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"SaveFixedReceiptIphone" 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:_fixedID forKey:@"FixedID"]; [dict setObject:_arrangementID forKey:@"ArrangementID"]; if(_lblPosition.text == nil){ [dict setObject:@"" forKey:@"Position"]; }else{ [dict setObject:_lblPosition.text forKey:@"Position"]; } [dict setObject:kkLicenseCode forKey:@"LicenseCode"]; NSMutableDictionary *dicHead = [[NSMutableDictionary alloc] init]; NSMutableArray *arrHead = [[NSMutableArray alloc]init]; [dicHead setObject:_strCustomerID forKeyedSubscript:@"CustomerID"]; [dicHead setObject:_strBusinessOrganization forKeyedSubscript:@"BusinessOrganization"]; [dicHead setObject:_statusID forKeyedSubscript:@"ReceiptStatus"]; [dicHead setObject:_strRemarks forKeyedSubscript:@"Remarks"]; [dicHead setObject:_strSalesMan forKeyedSubscript:@"SalesMan"]; [dicHead setObject:_fieldReceiptAmount.text forKeyedSubscript:@"ReceivableSum"]; if(_settlementType == NULL){ _settlementType = @""; } [dicHead setObject:_settlementType forKeyedSubscript:@"SettlementType"]; [arrHead addObject:dicHead]; [dict setObject:[Util objectToJson:arrHead] forKey:@"ReceiptData"]; NSMutableArray *arrList = [[NSMutableArray alloc]init]; for(int i = 0; i < _dataArray.count; i++){ NewCustomerModel *model = [_dataArray objectAtIndex:i]; NSMutableDictionary *dic = [[NSMutableDictionary alloc] init]; [dic setObject:model.detailID forKeyedSubscript:@"FixedDetailID"]; if(model.receiptRemarks == NULL){ [dic setObject: @"" forKeyedSubscript:@"ReceiptRemarks"]; }else{ [dic setObject:model.receiptRemarks forKeyedSubscript:@"ReceiptRemarks"]; } if(model.receiptSpecification == nil){ [dic setObject:@"" forKeyedSubscript:@"ReceiptSpecification"]; } else{ [dic setObject:model.receiptSpecification forKeyedSubscript:@"ReceiptSpecification"]; } [dic setObject:_settlementType forKeyedSubscript:@"SettlementType"]; [arrList addObject:dic]; } [dict setObject:[Util objectToJson:arrList] forKey:@"ReceiptDetailData"]; if(_settlementType == NULL || _settlementType.length == 0){ [dict setObject:@"" forKey:@"ReceiptEarnestData"]; }else{ NSMutableArray *arrList = [[NSMutableArray alloc]init]; NSMutableDictionary *dic = [[NSMutableDictionary alloc] init]; [dic setObject:_strTollAmount forKeyedSubscript:@"ReceivableSum"]; if(_strEarnestFee == nil){ [dic setObject:@"0" forKeyedSubscript:@"EarnestFee"]; }else{ [dic setObject:_strEarnestFee forKeyedSubscript:@"EarnestFee"]; } [dic setObject:_listRemarks forKeyedSubscript:@"Remarks"]; [dic setObject:_settlementType forKeyedSubscript:@"SettlementType"]; [arrList addObject:dic]; [dict setObject:[Util objectToJson:arrList] forKey:@"ReceiptEarnestData"]; } if (_assets && self.arrImagePaths.count > 0) { [dict setObject:[self.arrImagePaths componentsJoinedByString:@"," ] forKey:@"ImagePath"]; } _downManager = [[ASIDownManager alloc] init]; _downManager.delegate = self; _downManager.onRequestSuccess = @selector(onSaveFinish:); _downManager.onRequestFail = @selector(onSaveFail:); [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil]; } }); } #pragma mark - 回调 /** 键盘弹起 */ - (void) keyboardWillShow{ if(!_keyboardShow){ if(isCancelAnimation){ [UIView animateWithDuration:0.3f animations:^ { self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y-210, self.view.frame.size.width, self.view.frame.size.height); }];} } _keyboardShow=YES; } /** 键盘收起 */ - (void) keyboardWillHide{ if(_keyboardShow){ if(isCancelAnimation){ [UIView animateWithDuration:0.1f animations:^ { self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y+210, self.view.frame.size.width, self.view.frame.size.height); }];} } _keyboardShow=NO; } /** 地理位置 @param name */ - (void)relocationData:(NSString *)name{ _lblPosition.text= name; _positionImage.hidden = NO; _lblPosition.hidden = NO; [self refreshView]; } /** 回执状态回调 @param s */ - (void)showStatusValue:(StatusInfo*)s{ [_btnReceiptStatus setTitle:s.name forState:UIControlStateNormal]; _statusID= s.statusId; [_btnReceiptStatus setTintColor:[UIColor blackColor]]; } /** 结算方式回调 @param model */ - (void)showProtocolValue:(SettlementTypeModel *)model{ _settlementType=model.settlementId; _listRemarks=model.remark; _strEarnestFee = model.receivables; [_btnSettlement setTitle:model.settlementName forState:UIControlStateNormal]; [_btnSettlement setTintColor:[UIColor blackColor]]; } #pragma mark - 懒加载 - (NSMutableArray *)assets{ if (!_assets) { _assets = [NSMutableArray array]; } return _assets; } - (NSMutableArray *)arrImagePaths{ if (!_arrImagePaths) { _arrImagePaths = [NSMutableArray array]; } return _arrImagePaths; } #pragma mark - 网格状图片列表 /** 组数 @param collectionView <#collectionView description#> @return <#return value description#> */ - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ return 1; } /** 每组几个 @param collectionView <#collectionView description#> @param section <#section description#> @return <#return value description#> */ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ CGFloat collectionheight = [Util getPhotoCollectionViewHeightWithPhotos:self.assets]; self.collectionView.frame=CGRectMake(0, CGRectGetMaxY(_tableView.frame)+10, Screen_Width, collectionheight); [self refreshView]; return [self.assets count]; } /** 刷新布局 */ - (void)refreshView{ if(_positionImage.isHidden){ _positionImage.frame = CGRectMake(0, CGRectGetMaxY(_collectionView.frame), Screen_Width, 0); }else{ _positionImage.frame = CGRectMake(0, CGRectGetMaxY(_collectionView.frame)+8, Screen_Width, 30); } _center.frame = CGRectMake(0, CGRectGetMaxY(_positionImage.frame), Screen_Width, 30); self.collectionView.backgroundColor = [UIColor whiteColor]; _scrollView.contentSize = CGSizeMake(SCREENWIDTH, CGRectGetMaxY(_center.frame)+30); } /** cell返回 @param collectionView <#collectionView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ DKUICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DKUICollectionViewCell" forIndexPath:indexPath]; // 判断类型来获取Image DKPhotoAssets *asset = self.assets[indexPath.item]; if ([asset isKindOfClass:[DKPhotoAssets class]]) { cell.imageView.image = asset.originImage; }else if ([asset isKindOfClass:[NSString class]]){ [cell.imageView sd_setImageWithURL:[NSURL URLWithString:(NSString *)asset] placeholderImage:[UIImage imageNamed:@"wallpaper_placeholder"]]; }else if([asset isKindOfClass:[UIImage class]]){ cell.imageView.image = (UIImage *)asset; }else if ([asset isKindOfClass:[DKCamera class]]){ cell.imageView.image = [(DKCamera*)asset thumbImage]; } return cell; } /** 网格状点击事件 @param collectionView <#collectionView description#> @param indexPath <#indexPath description#> */ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; // 图片游览器 DKPhotoPickerBrowserViewController *pickerBrowser = [[DKPhotoPickerBrowserViewController alloc] init]; // 传入点击图片View的话,会有微信朋友圈照片的风格 pickerBrowser.toView = cell.imageView; // 数据源/delegate pickerBrowser.delegate = self; pickerBrowser.dataSource = self; // 是否可以删除照片 pickerBrowser.editing = YES; // 当前选中的值 pickerBrowser.currentIndexPath = [NSIndexPath indexPathForItem:indexPath.row inSection:0]; // 展示控制器 [pickerBrowser show]; } #pragma mark - 拍照回调 - (NSInteger)numberOfSectionInPhotosInPickerBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser{ return 1; } - (NSInteger)photoBrowser:(DKPhotoPickerBrowserViewController *)photoBrowser numberOfItemsInSection:(NSUInteger)section{ return [self.assets count]; } - (DKPhotoPickerBrowserPhoto *)photoBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser photoAtIndexPath:(NSIndexPath *)indexPath{ id imageObj = [self.assets objectAtIndex:indexPath.item]; DKPhotoPickerBrowserPhoto *photo = [DKPhotoPickerBrowserPhoto photoAnyImageObjWith:imageObj]; // 包装下imageObj 成 DKPhotoPickerBrowserPhoto 传给数据源 DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; // 缩略图 photo.thumbImage = cell.imageView.image; return photo; } #pragma mark - - (void)photoBrowser:(DKPhotoPickerBrowserViewController *)photoBrowser removePhotoAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row > [self.assets count]) return; [self.assets removeObjectAtIndex:indexPath.row]; [self.collectionView reloadData]; } /** 图片的个数 @return <#return value description#> */ - (NSInteger)cameraCount{ NSInteger count=0; for (int i=0; i */ - (void)pickerViewControllerDoneAsstes:(NSArray *)assets{ for (int i=(int)self.assets.count-1;i>=0;i-- ) { if ([self.assets[i] isKindOfClass:[DKPhotoAssets class]]) { [self.assets removeObject:self.assets[i]]; } } for (DKPhotoAssets* asset in assets ) { if ([asset isKindOfClass:[DKPhotoAssets class]]) { [self.assets addObject:asset]; } } [self.collectionView reloadData]; } #pragma mark - tableView实现的方法 /** 组数 @param tableView @return */ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } /** 返回cell @param tableView @param indexPath @return */ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *str = @"NewCustomReceiptCell"; NewCustomReceiptCell *cell = [tableView dequeueReusableCellWithIdentifier:str]; if(cell == nil){ cell = [[NewCustomReceiptCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str]; } NewCustomerModel *model = [_dataArray objectAtIndex:indexPath.row]; cell.model = model; cell.delegate = self; [cell loadCell]; return cell; } /** cell的高度 @param tableView @param indexPath @return */ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 197; } /** 每组多少行 @param tableView @param section @return */ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return _dataArray.count; } /** 计算tableView的高度 @param array */ - (void)reloadTableViewHeight:(NSArray *)array{ // 上下间隔已经在frame上做了 NSInteger row = array.count; _tableView.frame = CGRectMake(0,CGRectGetMaxY(_line.frame), SCREENWIDTH,202 * array.count); _collectionView.frame = CGRectMake(0, CGRectGetMaxY(_tableView.frame) , SCREENWIDTH, 0); _center.frame = CGRectMake(0,CGRectGetMaxY(_collectionView.frame), SCREENWIDTH, 30); _scrollView.contentSize = CGSizeMake(SCREENWIDTH, CGRectGetMaxY(_center.frame)+30); } #pragma mark - 键盘 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { [self.view endEditing:YES]; } /** 键盘收起 @param textField @return */ - (BOOL)textFieldShouldReturn:(UITextField *)textField { // 回收键盘 [textField resignFirstResponder]; return YES; } /** cell回调保存输入框里面的值 @param textField <#textField description#> */ - (void)cellTextFieldDidEndEditing:(UITextField *)textField { UITableViewCell *cell = (UITableViewCell *)[[textField superview] superview]; NSIndexPath *indexPath = [_tableView indexPathForCell:cell]; NewCustomerModel *model = [_dataArray objectAtIndex:indexPath.row]; if(textField.tag == 10){ model.receiptSpecification = textField.text; } if(textField.tag == 20){ model.receiptRemarks = textField.text; } } /** 结束编辑回调 @param textField <#textField description#> */ -(void)textFieldDidBeginEditing:(UITextField *)textField{ if(textField.tag == 101){ isCancelAnimation = NO; } } /** 开始编辑回调 @param textField <#textField description#> */ - (void)cellTextFieldDidBeginEditing:(UITextField *)textField{ isCancelAnimation = YES; } /** 回执金额输入监听 @param textField */ - (void)textFieldDidChange :(UITextField *) textField{ if([textField.text isEqualToString:@""]){ return; } if([textField.text rangeOfString:@"."].location != NSNotFound){ if(textField.text.length -1 - [textField.text rangeOfString:@"."].location > 6){ NSString *str = [textField.text substringFromIndex:[textField.text rangeOfString:@"."].location+7]; textField.text = str; } } if ([[textField.text substringFromIndex:0] isEqualToString:@"."]){ textField.text = [NSString stringWithFormat:@"%@%@", @"0",textField.text]; } NSString *str = _strTollAmount; if([str isEqualToString:@""]){ str = @"0"; } if([textField.text doubleValue]>[str doubleValue]){ textField.text = str; [super showAlertViewText:[NSString stringWithFormat:@"%@%@%@",@"输入的最大值不能大于收费金额(",str,@")"]]; } } #pragma mark - 图片上传 /** 上传图片 @return */ - (BOOL)savePicsManager{ _downManager = [[ASIDownManager alloc] init]; _downManager.delegate = self; //////////////上传图片 NSString *urlStr = ServerURL; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"SaveImg" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [self.arrImagePaths removeAllObjects]; for (int i=0; i