| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305 |
- // 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 () <UITextFieldDelegate,DKPhotoPickerBrowserViewControllerDelegate,DKPhotoPickerBrowserViewControllerDataSource,DKPhotoPickerViewControllerDelegate,UITableViewDelegate,StatusInfoTextDelegate,SettlementTypeProtocol,NewCustomReceiptCellDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource,UIScrollViewDelegate> {
-
- /**
- 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 - <DKPhotoPickerBrowserViewControllerDelegate>
- - (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<self.assets.count; i++) {
- id asset=self.assets[i];
- if ([asset isKindOfClass:[DKCamera class]]) {
- count++;
- }
- }
- return count;
- }
- /**
- 图片返回
-
- @param assets <#assets description#>
- */
- - (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<self.assets.count; i++) {
- ////////////////////
- //图片转化成document的路径。。。。。。。。
- // 判断类型来获取Image
- DKPhotoAssets *asset = self.assets[i];
- DKCamera * c;
- if ([asset isKindOfClass:[DKPhotoAssets class]]) {
- c = [self saveImage:asset.originImage withName:nil];
-
- }else if ([asset isKindOfClass:[NSString class]]){
-
- }else if([asset isKindOfClass:[UIImage class]]){
-
- }else if ([asset isKindOfClass:[DKCamera class]]){
-
- c=(DKCamera *)asset;
- c= [self saveImage:c.thumbImage withName:nil];
-
- }
- //延时
- [NSThread sleepForTimeInterval:0.5];
-
- NSString* retValue= [_downManager syncPostHttpRequestUrl:urlStr dic:dict path:c.imagePath filename:nil fileType:@"image/jpeg"];
- if (retValue == nil || retValue.length == 0){
-
- [super showAlertViewText:@"上传图片失败"];
- self.navigationItem.rightBarButtonItem.enabled=YES;
- return NO;
- }
- NSDictionary *dicRetValue = [retValue JSONValue];
- if (dicRetValue && [dicRetValue isKindOfClass:[NSDictionary class]]) {
- int iStatus = [[dicRetValue objectForKey:@"Status"] intValue];
- if (iStatus == 0) {
- NSString * imgPath = [dicRetValue objectForKey:@"Result"];
- [self.arrImagePaths addObject:imgPath];
-
- }
- else{
- return NO;
- }
- }
- }
- return YES;
- }
- /**
- 保存图片至沙盒
-
- @param currentImage
- @param imageName
- @return
- */
- - (DKCamera *)saveImage:(UIImage *)currentImage withName:(NSString *)imageName {
- if (!currentImage) {
- return nil;
- }
-
- NSDateFormatter *formater = [[NSDateFormatter alloc] init];
- formater.dateFormat = @"yyyyMMddHHmmss";
- NSString *currentTimeStr = [[formater stringFromDate:[NSDate date]] stringByAppendingFormat:@"_%d_.jpg" ,arc4random_uniform(10000)];
-
- NSData *imageData = [LeslieAsyncImageDownloader resetSizeOfImageData:currentImage maxSize:500];
- // 获取沙盒目录
- NSString *fullPath ;
- if([imageName isEqualToString:@""] || imageName == nil){
- fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:currentTimeStr];
- }
- else{
- fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
- }
-
- // 将图片写入文件
- [imageData writeToFile:fullPath atomically:NO];
-
- UIImage *savedImage = [[UIImage alloc] initWithContentsOfFile:fullPath];
-
- //NSData *data = UIImageJPEGRepresentation(savedImage, 0.3);
- DKCamera *camera = [[DKCamera alloc] init];
- camera.imagePath = fullPath;
- camera.thumbImage =savedImage;// [UIImage imageWithData:data];
- return camera;
- }
- #pragma mark - 初始化
- /**
- 初始化布局
- */
- - (void)initUI{
- _strCustomerName = @"";
- _strTelephone = @"";
- _strTollAmount = @"";
- _strReceivedAmount = @"";
- _strReceiptedAmount = @"";
- self.view.backgroundColor = [UIColor whiteColor];
- 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;
- }
- /**
- 界面展示
- */
- - (void)loadUI{
- self.view.frame = CGRectMake(0, 0, SCREENWIDTH, Screen_Height-rectNavHeight-rectStatusHeight);
- _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, Screen_Height-rectNavHeight-rectStatusHeight-50)];
- _scrollView.delegate = self;
- [self.view addSubview:_scrollView];
- CGFloat lineHeight = 5;
- CGFloat fixedNoHeight = 14;
- CGFloat spacing = 13;
- CGFloat leftSpacing = 15;
- CGFloat CustomerNameHeight = 13;
- UIColor *textColor = [UIColor colorWithRed:180.0/255 green:180.0/255 blue:180.0/255 alpha:1];
- UIColor *lineColor = [UIColor colorWithRed:234.0/255 green:235.0/255 blue:236.0/255 alpha:1];
- UIView *lineTop = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, lineHeight)];
- lineTop.backgroundColor = lineColor;
- [_scrollView addSubview: lineTop];
-
- UILabel *fixedNo = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight+spacing , SCREENWIDTH-30,fixedNoHeight)];
- fixedNo.text = [NSString stringWithFormat:@"售前回执:%@",_fixedNo];
- fixedNo.font = [UIFont systemFontOfSize:fixedNoHeight];
- [_scrollView addSubview: fixedNo];
-
- UIView *lineBottom = [[UIView alloc]initWithFrame:CGRectMake(0,lineHeight+fixedNoHeight+spacing*2, SCREENWIDTH, lineHeight)];
- lineBottom.backgroundColor = lineColor;
- [_scrollView addSubview: lineBottom];
-
- _lblCustomerName = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*3+fixedNoHeight, SCREENWIDTH-30,CustomerNameHeight)];
- _lblCustomerName.text = [NSString stringWithFormat:@"客户名称:%@",_strCustomerName];
- _lblCustomerName.font = [UIFont systemFontOfSize:fixedNoHeight-1];
- [_scrollView addSubview: _lblCustomerName];
-
- _lblTollAmount = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*5+fixedNoHeight+CustomerNameHeight, SCREENWIDTH-30,CustomerNameHeight)];
- _lblTollAmount.text = [NSString stringWithFormat:@"收费金额:%@",_strTollAmount];
- _lblTollAmount.font = [UIFont systemFontOfSize:CustomerNameHeight];
- [_scrollView addSubview: _lblTollAmount];
-
- _lblReceivedAmount = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*7+fixedNoHeight+CustomerNameHeight*2, SCREENWIDTH-30,CustomerNameHeight)];
- _lblReceivedAmount.text = [NSString stringWithFormat:@"已回执金额:%@",_strReceivedAmount];
- _lblReceivedAmount.font = [UIFont systemFontOfSize:CustomerNameHeight];
- [_scrollView addSubview: _lblReceivedAmount];
-
- UILabel *receiptAmount = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*9+fixedNoHeight+CustomerNameHeight*3, 70,CustomerNameHeight)];
- receiptAmount.text = @"回执金额:";
- receiptAmount.font = [UIFont systemFontOfSize:CustomerNameHeight];
- [_scrollView addSubview: receiptAmount];
-
- _fieldReceiptAmount = [[UITextField alloc]initWithFrame:CGRectMake(70+leftSpacing, lineHeight*2+spacing*9+fixedNoHeight+CustomerNameHeight*3, SCREENWIDTH-85,CustomerNameHeight)];
- _fieldReceiptAmount.delegate = self;
- NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"请输入回执金额" attributes:
- @{NSForegroundColorAttributeName: textColor,
- NSFontAttributeName:_fieldReceiptAmount.font
- }];
- [_fieldReceiptAmount addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
- _fieldReceiptAmount.tag = 101;
- _fieldReceiptAmount.delegate = self;
- _fieldReceiptAmount.attributedPlaceholder = attrString;
- _fieldReceiptAmount.font = [UIFont systemFontOfSize:CustomerNameHeight];
- [_scrollView addSubview: _fieldReceiptAmount];
-
-
- UILabel *settlement = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*11+fixedNoHeight+CustomerNameHeight*4, 70,CustomerNameHeight)];
- settlement.text = @"结算方式:";
- settlement.font = [UIFont systemFontOfSize:CustomerNameHeight];
- [_scrollView addSubview: settlement];
-
- _btnSettlement = [UIButton buttonWithType:UIButtonTypeSystem];
- _btnSettlement.frame = CGRectMake(85, lineHeight*2+spacing*11+fixedNoHeight+CustomerNameHeight*4, SCREENWIDTH-85,CustomerNameHeight);
- [_btnSettlement setTitle:@"请选择结算方式" forState:UIControlStateNormal];
- [_btnSettlement addTarget:self action:@selector(showSettlement:) forControlEvents:(UIControlEventTouchUpInside)];
- [_btnSettlement setTintColor:textColor];
- _btnSettlement.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- _btnSettlement.font = [UIFont systemFontOfSize:CustomerNameHeight];
- [_scrollView addSubview: _btnSettlement];
-
- UILabel *receiptStatus = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*13+fixedNoHeight+CustomerNameHeight*5, 70,CustomerNameHeight)];
- receiptStatus.text = @"回执状态:";
- receiptStatus.font = [UIFont systemFontOfSize:CustomerNameHeight];
- [_scrollView addSubview: receiptStatus];
-
- _btnReceiptStatus = [UIButton buttonWithType:UIButtonTypeSystem];
- _btnReceiptStatus.frame = CGRectMake(85, lineHeight*2+spacing*13+fixedNoHeight+CustomerNameHeight*5, SCREENWIDTH-85,CustomerNameHeight);
- [_btnReceiptStatus setTitle:@"完成" forState:UIControlStateNormal];
- _statusID= @"2";
- [_btnReceiptStatus setTintColor:[UIColor blackColor]];
-
- [_btnReceiptStatus addTarget:self action:@selector(showReceiptType:) forControlEvents:(UIControlEventTouchUpInside)];
-
- _btnReceiptStatus.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- _btnReceiptStatus.font = [UIFont systemFontOfSize:CustomerNameHeight];
- [_scrollView addSubview: _btnReceiptStatus];
-
- _lblTelePhone = [[UILabel alloc]initWithFrame:CGRectMake(leftSpacing, lineHeight*2+spacing*15+fixedNoHeight+CustomerNameHeight*6, SCREENWIDTH-30,CustomerNameHeight)];
- _lblTelePhone.text = [NSString stringWithFormat:@"联系电话:%@",_strTelephone];
- _lblTelePhone.font = [UIFont systemFontOfSize:CustomerNameHeight];
- [_scrollView addSubview: _lblTelePhone];
- _line = [[UIView alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(_lblTelePhone.frame)+10,SCREENWIDTH, 5)];
- _line.backgroundColor = [UIColor colorWithRed:234.0/255 green:235.0/255 blue:236.0/255 alpha:1];
- [_scrollView addSubview:_line];
- //TableView
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_line.frame), SCREENWIDTH, 200) style:UITableViewStylePlain];
- _tableView.scrollEnabled=NO;
- _tableView.delegate = self;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.dataSource = self;
- [_scrollView addSubview:_tableView];
- 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);
- _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_tableView.frame)+10
- , SCREENWIDTH, 0) collectionViewLayout:flowLayout];
- [self.collectionView registerNib:[UINib nibWithNibName:@"DKUICollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"DKUICollectionViewCell"];
- _collectionView.dataSource = self;
- _collectionView.scrollEnabled = NO;
- _collectionView.delegate = self;
- [_scrollView addSubview:_collectionView];
-
-
- //位置view
- _positionImage = [[UIView alloc]init];
- _positionImage.frame = CGRectMake(0, CGRectGetMaxY(_collectionView.frame), Screen_Width, 0);
- _positionImage.hidden = YES;
- [_scrollView addSubview:_positionImage];
- //星号
- UIImageView *ivposition = [UIImageView new];
- ivposition.image = [UIImage imageNamed:@"log_position"];
- ivposition.frame = CGRectMake(10,2,13,16);
- [_positionImage addSubview:ivposition];
-
- _lblPosition = [UILabel new];
- _lblPosition.font = [UIFont systemFontOfSize:14];
- _lblPosition.frame = CGRectMake(30, 0, Screen_Width-32, 20);
- [_positionImage addSubview:_lblPosition];
- _positionImage.hidden = YES;
- _center = [[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(_positionImage.frame), SCREENWIDTH, 30)];
- _center.backgroundColor = [UIColor whiteColor];
- [_scrollView addSubview: _center];
- CGFloat width = (SCREENWIDTH-70)/2;
-
- CustomButton *btnPhoto = [[CustomButton alloc]initWithFrame:CGRectMake(width-90, 10, 70, 20) andImage:[UIImage imageNamed:@"icon_takephoto"] addText:@"照相" addImageWidth:15 addImageHeight:12];
- [btnPhoto addTarget:self action:@selector(pushPhotograph) forControlEvents:(UIControlEventTouchUpInside)];
- [_center addSubview:btnPhoto];
-
- CustomButton *btn = [[CustomButton alloc]initWithFrame:CGRectMake(width, 10,70 , 20) andImage:[UIImage imageNamed:@"icon_photo"] addText:@"相册" addImageWidth:14 addImageHeight:15];
- [btn addTarget:self action:@selector(pushAlbum) forControlEvents:(UIControlEventTouchUpInside)];
-
- [_center addSubview:btn];
-
- CustomButton *btnLoaction = [[CustomButton alloc]initWithFrame:CGRectMake(width+85, 10,100 , 20) andImage:[UIImage imageNamed:@"icon_position"] addText:@"所在位置" addImageWidth:13 addImageHeight:16];
- [btnLoaction addTarget:self action:@selector(pushMap) forControlEvents:(UIControlEventTouchUpInside)];
- [_center addSubview:btnLoaction];
-
- //保存
- _btnSave = [UIButton buttonWithType:UIButtonTypeCustom];
- _btnSave.frame=CGRectMake(20, self.view.frame.size.height-59, Screen_Width-40,44) ;
- [_btnSave setBackgroundImage:[UIImage imageNamed:@"bt_datasave"] forState:UIControlStateNormal];
- [_btnSave addTarget:self action:@selector(dataSave) forControlEvents:UIControlEventTouchUpInside];
-
- [self.view addSubview:_btnSave];
-
- }
- /**
- 状态初始化
- */
- - (void)initStatus{
- _arrayDStatus = [[NSMutableArray alloc] init];
- StatusInfo* s = [[StatusInfo alloc]init];
- s.tagName = @"status";
- s.statusId = @"1";
- s.name = @"再次安排";
- [_arrayDStatus addObject:s];
- s = [[StatusInfo alloc]init];
- s.tagName = @"status";
- s.statusId = @"2";
- s.name = @"完成";
- [_arrayDStatus addObject:s];
- }
- @end
|