| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256 |
- //
- // NewDeliveryReceiptVC.m
- // IBOSS
- //
- // Created by Dongke on 16/1/7.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- // 功能描述:新增配送控制器
- #import "NewDeliveryReceiptVC.h"
- #import "NIDropDown.h"
- #import "StatusInfo.h"
- #import "StatusInfoTextVC.h"
- #import "PayTypeVC.h"
- #import "AlbumPhotoCollectionViewCell.h"
- #import "XHImageViewer.h"
- #import "DKPhotoPickerViewController.h"
- //#import "MapViewController.h"
- #import "DKCameraViewController.h"
- #import "DKUICollectionViewCell.h"
- #import "NewDeliveryKeyBoardDelegate.h"
- #import "RegularExpression.h"
- #import "Util.h"
- #import "NewDeliveryListTableViewCell.h"
- #import "CustomButton.h"
- #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
- #define kTitleFont [UIFont systemFontOfSize:14]
- @interface NewDeliveryReceiptVC ()<DataListTableViewCellDetegate,NewDeliveryKeyBoardDelegate,UITableViewDataSource,UIScrollViewDelegate, UITableViewDelegate>{
- NSInteger _positionHeight;
- UIView *_positionImage;
- UIView *_vImage;
- UILabel *_lblPosition;
- UIImageView *_ivPosition;
- BOOL _isHaveDian;
- UIView *_vCollectionView;
- NSIndexPath *_myRow;
- NewDeliveryListTableViewCell *_myCell;
- }
- @end
- @implementation NewDeliveryReceiptVC
- @synthesize scroll;
- @synthesize contentView;
- @synthesize refreshDelegate;
- @synthesize keyboardShow;
- #pragma mark - 公共函数
- /**
- 加载视图函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- _dataList = [[NSMutableArray alloc]init];
- [self initUI];
-
- _signName=@"";
- _deliveryAttributeId=@"";
- _goodsAttributeId=@"";
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onFocusPeopleEditingChanged:) name:@"UITextFieldTextDidChangeNotification" object:self.receiptAmount ];
- self.navigationItem.title = @"新增配送回执";
-
- //返回
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
-
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,45,22);
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- if(self.sReceiptCode != nil&&self.sReceiptCode.length > 0){
- self.receiptCode.enabled=NO;
- [self reloadDataWithOnlyCode:self.sReceiptCode];
- }
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- [self.view setBackgroundColor:[UIColor whiteColor]];
- UIImage *pic = [UIImage imageNamed:@"bt_datasave"];
- CGFloat h = (Screen_Width - 40) * pic.size.height / pic.size.width;
- scroll.frame =CGRectMake(0, 0, Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height -h);
- _saveBtn.frame = CGRectMake(20,
- self.view.safeAreaLayoutGuide.layoutFrame.size.height -h-15,
- Screen_Width-40,
- h);
- [super viewSafeAreaInsetsDidChange];
- }
- /**
- 初始化回执类型
- */
- - (void)initStatus2:(BOOL) flag{
- _arrayStatus = [[NSMutableArray alloc]init];
- StatusInfo *s = [[StatusInfo alloc]init];
- s.tagName = @"cell";
- s.statusId = @"1";
- s.name = @"完成";
- [_arrayStatus addObject:s];
- if(flag){
- s = [[StatusInfo alloc]init];
- s.tagName = @"cell";
- s.statusId = @"2";
- s.name = @"再送";
- [_arrayStatus addObject:s];
- s = [[StatusInfo alloc]init];
- s.tagName = @"cell";
- s.statusId = @"3";
- s.name = @"换货";
- [_arrayStatus addObject:s];
- s = [[StatusInfo alloc]init];
- s.tagName = @"cell";
- s.statusId = @"4";
- s.name = @"退货";
- [_arrayStatus addObject:s];
- }
-
- }
- -(void)initSignData
- {
- _signArray=[[NSMutableArray alloc]init];
- StatusInfo *s = [[StatusInfo alloc]init];
- s.tagName = @"sign";
- s.statusId = @"1";
- s.name = @"是";
- [_signArray addObject:s];
- s = [[StatusInfo alloc]init];
- s.tagName = @"sign";
- s.statusId = @"0";
- s.name = @"否";
- [_signArray addObject:s];
- }
- - (void)showSignAuthority{
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict= [NSMutableDictionary new];
-
- [dict setObject:@"GetSystemSettingValues" forKey:@"Action"];
- [dict setObject:kkAccountCode forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:@"SS_CTS_04" forKey:@"SettingType"];
- self.mDownManager= [[ASIDownManager alloc] init];;
- self.mDownManager.delegate = self;
- self.mDownManager.onRequestSuccess = @selector(onSignLoadFinish:);
- self.mDownManager.onRequestFail = @selector(onSignLoadFail:);
- [self.mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- - (void)showDeliveryAuthority{
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict= [NSMutableDictionary new];
-
- [dict setObject:@"GetSystemSettingValues" forKey:@"Action"];
- [dict setObject:kkAccountCode forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:@"SS_CTS_03" forKey:@"SettingType"];
- self.mDownManager= [[ASIDownManager alloc] init];;
- self.mDownManager.delegate = self;
- self.mDownManager.onRequestSuccess = @selector(onDeliveryLoadFinish:);
- self.mDownManager.onRequestFail = @selector(onDeliveryLoadFail:);
- [self.mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- - (void)showDeliveryAttributeData{
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict= [NSMutableDictionary new];
-
- [dict setObject:@"GetDataDictionary" forKey:@"Action"];
- [dict setObject:kkAccountCode forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:@"CTS008" forKey:@"DictionaryType"];
- self.mDownManager= [[ASIDownManager alloc] init];;
- self.mDownManager.delegate = self;
- self.mDownManager.onRequestSuccess = @selector(onDeliveryAttributeLoadFinish:);
- self.mDownManager.onRequestFail = @selector(onDeliveryAttributeLoadFail:);
- [self.mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- - (void)showGoodsAttributeData{
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict= [NSMutableDictionary new];
-
- [dict setObject:@"GetDataDictionary" forKey:@"Action"];
- [dict setObject:kkAccountCode forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:@"CTS009" forKey:@"DictionaryType"];
- self.mDownManager= [[ASIDownManager alloc] init];;
- self.mDownManager.delegate = self;
- self.mDownManager.onRequestSuccess = @selector(onGoodsAttributeLoadFinish:);
- self.mDownManager.onRequestFail = @selector(onGoodsAttributeLoadFail:);
- [self.mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- /**
- 初始化图片数组
- @return <#return value description#>
- */
- - (NSMutableArray *)imagePaths{
- if (!_imagePaths) {
- _imagePaths = [NSMutableArray array];
- }
- return _imagePaths;
- }
- /**
- 视图毁坏函数
- */
- - (void)dealloc{
- //[self cancel];
- // [[NSNotificationCenter defaultCenter]removeObserver:self name:@"UITextFieldTextDidChangeNotification" object:self.receiptAmount];
- }
- /**
- 初始化回执类型
- */
- - (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];
-
- }
- /**
- 获得拍照的照片总数
- @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;
- }
- /**
- 初始化collection view
- */
- - (void)setupCollectionView{
- 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(0, 0, Screen_Width,0) collectionViewLayout:flowLayout];
- self.collectionView.scrollEnabled = NO;
- self.collectionView.backgroundColor = [UIColor clearColor];
- self.collectionView.dataSource = self;
- self.collectionView.delegate = self;
- [self.collectionView registerNib:[UINib nibWithNibName:@"DKUICollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"DKUICollectionViewCell"];
- [_vCollectionView addSubview:self.collectionView];
- }
- /**
- 初始化相册数组
- @return <#return value description#>
- */
- - (NSMutableArray *)assets{
- if (!_assets) {
- _assets = [NSMutableArray array];
- }
- return _assets;
- }
- #pragma mark - 回调函数
- /**
- 文本值变化回调函数
- @param cell <#cell description#>
- @param txtfield <#txtfield description#>
- @param qualityTxt <#qualityTxt description#>
- @param remark <#remark description#>
- */
- - (void)textValueChange:(NewDeliveryListTableViewCell *)cell txtField:(UITextField *)txtfield qualityField:(UITextField *)qualityTxt remarkField:(UITextField *)remark{
- self.cellIndex=cell.cellIndex;
- NewDeliveryReceiptModel *model = [_dataList objectAtIndex:self.cellIndex];
- if(txtfield.tag == 1000){
- model.receiptQuantity = txtfield.text;
- }
- if(txtfield.tag == 1001){
- model.receiptRemarks = txtfield.text;
- }
-
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
- [self.view endEditing:NO];
- }
- /**
- 键盘隐藏回调函数
- @param cell <#cell description#>
- */
- - (void)keyboardWillHide:(NewDeliveryListTableViewCell *)cell{
- if (cell.cellIndex == _dataList.count - 1) {
- [self keyboardWillHide];
- }
- }
- /**
- 键盘弹出回调函数
- @param cell <#cell description#>
- */
- - (void)keyboardWillShow:(NewDeliveryListTableViewCell *)cell{
- if (cell.cellIndex == _dataList.count - 1) {
- [self myKeyboardWillShow];
- }
- }
- - (void)onSignLoadFinish:(ASIDownManager *)sender {
- // 取消进度条
- [self cancel];
- // 服务器返回数据转换model
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- // 服务器返回数据结果
- NSArray *approvArr = (NSArray *)resultModel.result;
- if(approvArr!=nil&&approvArr.count>0)
- {
- NSDictionary *dic = approvArr[0];
- _signFlag = [dic objectForKey:@"SettingValues"];
-
- }
- else{
- _signFlag = @"0";
- }
- }
- else {
- _signFlag = @"0";
-
- }
-
- [self showDeliveryAuthority];
-
-
- }
- /**
- 请求失败
- @param sender <#sender description#>
- */
- - (void)onSignLoadFail:(ASIDownManager *)sender {
- _signFlag = @"0";
- [self cancel];
- [self showAlertViewText:@"网络异常"];
- }
- - (void)onDeliveryLoadFinish:(ASIDownManager *)sender {
- // 取消进度条
- [self cancel];
- // 服务器返回数据转换model
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- // 服务器返回数据结果
- NSArray *approvArr = (NSArray *)resultModel.result;
- if(approvArr!=nil&&approvArr.count>0)
- {
- NSDictionary *dic = approvArr[0];
- _deliveryFlag = [dic objectForKey:@"SettingValues"];
-
- }
- else{
- _deliveryFlag = @"0";
- }
- }
- else {
- _deliveryFlag = @"0";
-
- }
-
- [self showDeliveryAttributeData];
-
- }
- /**
- 请求失败
- @param sender <#sender description#>
- */
- - (void)onDeliveryLoadFail:(ASIDownManager *)sender {
- _deliveryFlag = @"0";
- [self cancel];
- [self showAlertViewText:@"网络异常"];
- }
- - (void)onDeliveryAttributeLoadFinish:(ASIDownManager *)sender {
- // 取消进度条
- [self cancel];
- // 服务器返回数据转换model
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- // 服务器返回数据结果
- NSDictionary *approveDic = (NSDictionary *)resultModel.result;
- if(approveDic!=nil)
- {
- NSArray *approveArray=[approveDic objectForKey:@"Table"];
- if(approveArray!=nil&&approveArray.count>0)
- {
- _deliveryArray=[[NSMutableArray alloc]init];
- for(int i=0;i<approveArray.count;i++)
- {
- NSDictionary *approveDic=[approveArray objectAtIndex:i];
- NSInteger deliveryId= [[approveDic objectForKey:@"DictionaryID"]integerValue];
- NSString *deliveryValue=[approveDic objectForKey:@"DictionaryValue"];
- StatusInfo* s = [[StatusInfo alloc]init];
- s.tagName=@"delivery";
- s.statusId=[ NSString stringWithFormat:@"%ld" , deliveryId];
- s.name=deliveryValue;
- [_deliveryArray addObject:s];
-
- }
- }
-
- }
-
- }
-
- [self showGoodsAttributeData];
-
-
-
- }
- /**
- 请求失败
- @param sender <#sender description#>
- */
- - (void)onDeliveryAttributeLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"网络异常"];
- }
- - (void)onGoodsAttributeLoadFinish:(ASIDownManager *)sender {
- // 取消进度条
- [self cancel];
- // 服务器返回数据转换model
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- // 服务器返回数据结果
- NSDictionary *approveDic = (NSDictionary *)resultModel.result;
- if(approveDic!=nil)
- {
- NSArray *approveArray=[approveDic objectForKey:@"Table"];
- if(approveArray!=nil&&approveArray.count>0)
- {
- _goodsArray=[[NSMutableArray alloc]init];
- for(int i=0;i<approveArray.count;i++)
- {
- NSDictionary *approveDic=[approveArray objectAtIndex:i];
- NSInteger deliveryId= [[approveDic objectForKey:@"DictionaryID"]integerValue];
- NSString *deliveryValue=[approveDic objectForKey:@"DictionaryValue"];
- StatusInfo* s = [[StatusInfo alloc]init];
- s.tagName=@"goods";
- s.statusId=[ NSString stringWithFormat:@"%ld" , deliveryId];
- s.name=deliveryValue;
- [_goodsArray addObject:s];
-
- }
- }
-
- }
-
- }
-
-
-
- }
- /**
- 请求失败
- @param sender <#sender description#>
- */
- - (void)onGoodsAttributeLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"网络异常"];
- }
- /**
- 保存数据加载完成函数
- @param sender <#sender description#>
- */
- - (void)onSaveLoadFinish:(ASIDownManager *)sender {
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- [self cancel];
- int iStatus =resultModel.status;
- NSString *message = resultModel.message;
- self.navigationItem.rightBarButtonItem.enabled = YES;
- if (iStatus == 0) {
- //[self clearData];//新增后 清除画面的值
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"保存成功!" preferredStyle:UIAlertControllerStyleAlert ];
- [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
- [_parentVC ReloadList];
- [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 model <#model description#>
- */
- - (void)setPayTypeModel:(PayTypeModel *)model{
- [ _receivablesType setTitle:model.settlementTypeName forState:UIControlStateNormal];
- _settlementTypeName = model.settlementTypeName;
- _settlementType = model.settlementType;
- _existsHandlingFee = model.existsHandlingFee;
- _earnestFee = model.earnestFee;
- _remarks = model.remarks;
- }
- /**
- 单据数据加载完成函数
- @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) {
- NSArray * infoArr;
- NSArray * infoHead;
- NSDictionary *dicResult =(NSDictionary*) resultModel.result;
- if(dicResult != nil){
- infoArr = [dicResult objectForKey:@"Table1"];
- infoHead = [dicResult objectForKey:@"Table"];
- }
-
- if (infoHead == nil|| infoHead.count == 0) {
- self.receiptCode.text = @"";
- self.sReceiptCode = @"";
- [self showAlertViewText:@"该送货单未建安排单,请重新建安排单"];
- return;
- }
-
- //单据信息 一条数据
- BOOL receiptFlg=false;
- for (int i = 0; i < infoHead.count; i++) {
- NSDictionary *h = infoHead[i];
- receiptFlg = (BOOL)[h objectForKey:@"ReceiptFlag"] ;
- if (receiptFlg) {
- self.receiptFlag = @"1";
- }else{
- self.receiptFlag = @"0";
- }
-
- double receiptAmount = [[h objectForKey:@"ReceiptAmount"] doubleValue];
- _sReceiptAmount = [NSString stringWithFormat:@"%0.2f",receiptAmount];
- _sCustomerName = [h objectForKey:@"CustomerName"];
- _sReceivables = [NSString stringWithFormat:@"%0.2f",[[h objectForKey:@"Receivables"] doubleValue]];
- _sReceiptType = [h objectForKey:@"ReceiptType"];
- _sNextDeliveryDate = [h objectForKey:@"NextDeliveryDate"];
- [_receiptType setEnabled:YES];
- if ([_sReceiptType intValue] == 2) {
- self.sNextDeliveryDate = [h objectForKey:@"NextinstallDate"];
- [self.nextDeliveryDate setTitle:self.sNextDeliveryDate forState:UIControlStateNormal];
- [self.receiptType setTitle:@"推迟送货" forState:UIControlStateNormal];
- [self.nextDeliveryDate setTitle:_sNextDeliveryDate forState:UIControlStateNormal];//推迟日期
- [_nextDeliveryDate setEnabled:YES];
- self.receiptAmount.enabled=NO;
- [_receivablesType setEnabled:NO];
- }else if([_sReceiptType intValue] == 1){
- [self.receiptType setTitle:@"完成" forState:UIControlStateNormal];
- [self.nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
- self.sNextDeliveryDate = @"";
- [_nextDeliveryDate setEnabled:NO];
- self.receiptAmount.enabled=YES;
- [_receivablesType setEnabled:YES];
- }
- if (([_sReceivables doubleValue] > 0)) {
- self.receiptAmount.enabled = YES;
- [_receivablesType setEnabled:YES];
-
- }else{
- self.receiptAmount.enabled = NO;
- [_receivablesType setEnabled:NO];
- }
-
- _deliveryId = [NSString stringWithFormat:@"%d",[[h objectForKey:@"DeliveryID"] intValue]];
- _receiptAmount.text = _sReceiptAmount;//回执金额
- _customerName.text = _sCustomerName;//客户名称
- _receivables.text = _sReceivables;//应收金额
- _completeReceivables = [NSString stringWithFormat:@"%0.2f",[[h objectForKey:@"CompleteReceivables"] doubleValue]];
- if(_completeReceivables == nil){
- _completeReceivables = @"";
- }
-
- }
- [_dataList removeAllObjects];
- if(infoArr != nil){
- for (int i = 0; i < infoArr.count; i++) {
- NSDictionary *info = infoArr[i];
- NewDeliveryReceiptModel *mod = [NewDeliveryReceiptModel dk_modelWithDictionary:info];
- [_dataList addObject:mod];
- }
-
- _vImage.hidden=NO;
- [self reloadMyView];
- [self.myTableView reloadData];
-
- }
- }
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
- [self showReLoginDialog:message];
- return;
- }
-
- else {
-
- [self showAlertViewText:message];
- }
-
- [self showSignAuthority];
-
-
- }
- /**
- 数据加载失败函数
- @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self cancel];
- self.navigationItem.rightBarButtonItem.enabled = YES;
- [self showAlertViewText:@"网络异常"];
- }
- /**
- 回执类型回调函数
- @param s <#s description#>
- */
- - (void)showStatusValue:(StatusInfo *)s{
- _myCell = [_myTableView cellForRowAtIndexPath:_myRow];
- //回执类型回调
- if([s.tagName isEqualToString:@"status"]){
- _sReceiptType = s.statusId;
- [_receiptType setTitle:s.name forState:UIControlStateNormal];
- if([_sReceiptType isEqualToString:@"2"]){
- //推迟送货
- //收款方式
- [_receivablesType setEnabled:NO];
- _settlementType = @"";
- [_receivablesType setTitle:@"请选择收款方式" forState:UIControlStateNormal];
- //回执金额
- _receiptAmount.text = @"0.000000";
- _sReceiptAmount = @"0.000000";
- self.receiptAmount.enabled = NO;
- //推迟日期
- [_nextDeliveryDate setEnabled:YES];
- _sNextDeliveryDate = @"";
- [self.nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
- //列表
- for(NewDeliveryReceiptModel *model in _dataList){
- model.receiptType = @"1";
- model.receiptQuantity = @"0";
- }
- }
- else{
- //完成状态
- //推迟日期
- [_nextDeliveryDate setEnabled:NO];
- [self.nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
- _sNextDeliveryDate = @"";
-
- if (([_sReceivables doubleValue] > 0)) {
- self.receiptAmount.enabled = YES;
- [_receivablesType setEnabled:YES];
- }else{
- self.receiptAmount.enabled = NO;
- [_receivablesType setEnabled:NO];
- }
- }
- }
- //选择Cell回执状态回调
- if([s.tagName isEqualToString:@"cell"]){
-
- switch ([s.statusId intValue]) {
- case 1:
- [_myCell.btstate setTitle:@"完成" forState:UIControlStateNormal];
- _myCell.model.receiptType = @"1";
- break;
- case 2:
- [_myCell.btstate setTitle:@"再送" forState:UIControlStateNormal];
- _myCell.model.receiptType = @"2";
- [_myCell.receiptQuantity addTarget:self action:@selector(receiptQuantityValueChanged) forControlEvents:UIControlEventAllEditingEvents];
- break;
- case 3:
- [_myCell.btstate setTitle:@"换货" forState:UIControlStateNormal];
- _myCell.model.receiptType = @"3";
- break;
- case 4:
- [_myCell.btstate setTitle:@"退货" forState:UIControlStateNormal];
- _myCell.model.receiptType = @"4";
- break;
- default:
- break;
- }
- }
-
- if([s.tagName isEqualToString:@"sign"])
- {
- _signName=s.name;
- [_btnSign setTitle:s.name forState:UIControlStateNormal];
- }
-
- if([s.tagName isEqualToString:@"delivery"])
- {
- _deliveryAttributeId=s.statusId;
- [_btnDeliveryAttribute setTitle:s.name forState:UIControlStateNormal];
- }
-
- if([s.tagName isEqualToString:@"goods"])
- {
- _goodsAttributeId=s.statusId;
- [_btnGoodsAttribute setTitle:s.name forState:UIControlStateNormal];
- }
-
- [_myTableView reloadData];
- }
- /**
- 文本框的长度限制 实现监听方法
-
- @param sender <#sender description#>
- */
- - (void)onFocusPeopleEditingChanged:(NSNotification *)sender
- {
-
- UITextField *textField = (UITextField *)sender.object;
- NSString *toBeString = textField.text;
-
- NSString *lang = [[UIApplication sharedApplication]textInputMode].primaryLanguage;
- int kMaxLength = 0;
- if([textField isEqual:self.receiptAmount]){
- kMaxLength = 17;
-
- if (toBeString != nil && toBeString.length > 0 && [toBeString floatValue] -MAXIMUM_QUANTITY > 0.0000000001f) {
- textField.text = MAX_COUNT;
- toBeString = MAX_COUNT;
- }
-
- }
- if ([lang isEqualToString:@"zh-Hans"]) {
- UITextRange *selectedRange = [textField markedTextRange];
- UITextPosition *position = [textField positionFromPosition:selectedRange.start offset:0];
-
- if (!position) {
- if (toBeString.length > kMaxLength) {
- textField.text = [toBeString substringToIndex:kMaxLength];
- }
- }
- }else{
- if (toBeString.length > kMaxLength) {
- textField.text = [toBeString substringToIndex:kMaxLength];
- }
- }
- }
- /**
- 限制用户输入小数点后位数的方法
- @param textField <#textField description#>
- @param range <#range description#>
- @param string <#string description#>
- @return <#return value description#>
- */
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
-
- if ([textField isEqual:self.receiptCode]){
- return YES;
- }
-
- if ([textField.text rangeOfString:@"."].location == NSNotFound) {
- _isHaveDian = NO;
- }
- if ([string length] > 0) {
-
- unichar single = [string characterAtIndex:0];//当前输入的字符
- if ((single >= '0' && single <= '9') || single == '.') {//数据格式正确
-
- //首字母不能为0和小数点
- if([textField.text length] == 0){
- if(single == '.') {
- [self showAlertViewText:@"第一个数字不能为小数点"];
- [textField.text stringByReplacingCharactersInRange:range withString:@""];
- return NO;
- }
-
- }
- if([textField.text length] == 1 && [[textField.text substringToIndex:1] isEqualToString: @"0"]){
- if(!(single == '.')) {
- [textField.text stringByReplacingCharactersInRange:range withString:@""];
- return NO;
- }
-
- }
-
- //输入的字符是否是小数点
- if (single == '.') {
- if(!_isHaveDian)//text中还没有小数点
- {
- _isHaveDian = YES;
- return YES;
-
- }else{
- [self showAlertViewText:@"您已经输入过小数点了"];
- [textField.text stringByReplacingCharactersInRange:range withString:@""];
- return NO;
- }
- }else{
- if (_isHaveDian) {//存在小数点
-
- //判断小数点的位数
- NSRange ran = [textField.text rangeOfString:@"."];
- if (range.location - ran.location <= 6) {
- return YES;
- }else{
- //[self showAlertViewText:@"亲,您最多输入两位小数"];
- return NO;
- }
- }else{
- return YES;
- }
- }
- }else{//输入的数据格式不正确
- [self showAlertViewText:@"您输入的格式不正确"];
- [textField.text stringByReplacingCharactersInRange:range withString:@""];
- return NO;
- }
- }
- else
- {
- return YES;
- }
-
- }
- /**
- 相册回调事件
- @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];
- [self reloadMyView];
- }
- /**
- Cell回执类型回调函数
- */
- - (void)setReceiptType:path{
- _myRow= path;
- NewDeliveryReceiptModel *mode = _dataList[_myRow.row];
- if([mode.sourceFrom intValue] == 1){
- [self initStatus2:YES];
- }else{
- [self initStatus2:NO];
- }
- StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
- tc.sdelegate=self;
- [tc.arrFilter addObjectsFromArray: _arrayStatus];
- [self.navigationController pushViewController:tc animated:YES];
- self.hidesBottomBarWhenPushed = NO;
- }
- /**
- 选中位置回调事件
- @param name <#name description#>
- */
- - (void)relocationData:(NSString *)name{
- _lblPosition.text = name;
- _positionImage.hidden = NO;
- [self reloadMyView];
- }
- /**
- table view的分区数
-
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
-
- }
- /**
- table view的行数
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_dataList count];
- }
- /**
- table view的高度
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 197;
- }
- /**
- 获取tableview cell
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- NSString *CellIdentifier = @"DataListTableViewCell";
- NewDeliveryListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-
- cell = [[NewDeliveryListTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- cell.delegate = self;
- cell.nddelegate = self;
- cell.receiptQuantity.delegate = self;
- cell.receiptQuantity.tag = indexPath.row;
- NewDeliveryReceiptModel *datamodel = [_dataList objectAtIndex:indexPath.row];
- cell.myIndexPath = indexPath;
- cell.cellIndex = indexPath.row;
- [cell parseInfoModel:datamodel receiptType:_sReceiptType];
- return cell;
- }
- /**
- cellection view的分区数
- @param collectionView <#collectionView description#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
- return 1;
- }
- /**
- collection view的项数
- @param collectionView <#collectionView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
-
- return [self.assets count];
- }
- /**
- 获取collectionview 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.thumbImage;
- }
- 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 = [asset thumbImage];
- }
- return cell;
-
- }
- /**
- collectionview图片放大
- @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];
- }
- /**
- collectionview的分区数
- @param pickerBrowser <#pickerBrowser description#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionInPhotosInPickerBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser{
- return 1;
- }
- /**
- collection view的项数
- @param photoBrowser <#photoBrowser description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)photoBrowser:(DKPhotoPickerBrowserViewController *)photoBrowser numberOfItemsInSection:(NSUInteger)section{
- return [self.assets count];
- }
- /**
- collection view放大函数
- @param pickerBrowser <#pickerBrowser description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (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;
- }
- /**
- collection view删除图片函数
- @return <#return value description#>
- */
- #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];
- [self reloadMyView];
- }
- #pragma mark - 私有函数
- /**
- 加载单据信息
- @param code <#code description#>
- */
- - (void)reloadDataWithOnlyCode:(NSString *)code
- {
- self.receiptCode.text = code;
- self.sReceiptCode = code;
- double delayInSeconds = 0.5;
- dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
- dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
- [self loadDataSource];
- });
- }
- /**
- 键盘隐藏函数
- @param tap <#tap description#>
- */
- - (void)keyboardHide:(UITapGestureRecognizer*)tap{
- [self.view endEditing:YES];
- }
- /**
- 初始化布局函数
- */
- - (void)initUI{
- //返回
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,45,22);
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- scroll = [UIScrollView new];
- scroll.delegate = self;
- scroll.frame=self.view.bounds;
- scroll.tag=1000;
- [self.view addSubview:scroll];
- if(Screen_Height2 <= 480){
- scroll.contentSize=CGSizeMake(self.view.frame.size.width, self.view.frame.size.height + 80);
- }
- contentView = [[UIView alloc]init];
- contentView.frame=CGRectZero;
- contentView.backgroundColor = [UIColor whiteColor];
- UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
- //设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。
- tapGestureRecognizer.cancelsTouchesInView = NO;
- // //将触摸事件添加到当前view
- [scroll addGestureRecognizer:tapGestureRecognizer];
- [scroll addSubview:contentView];
-
- //送货单号--------------
- UIView *vReceiptCode = [UIView new];
- vReceiptCode.frame=CGRectMake(0, 5, Screen_Width,40);
- [contentView addSubview:vReceiptCode];
- UILabel *lblTxtReceiptCode = [UILabel new];
- lblTxtReceiptCode.frame=CGRectMake(20, 5, 90, 25);
- lblTxtReceiptCode.text = @"送货单号:";
- lblTxtReceiptCode.font=kTitleFont;
- [vReceiptCode addSubview:lblTxtReceiptCode];
- _receiptCode = [UITextField new];
- _receiptCode.frame = CGRectMake(95, 5, Screen_Width - 95 - 20, 25);
- _receiptCode.font = kTextFont;
- _receiptCode.placeholder = @"输入送货单号";
- _receiptCode.tag = 100;
- [vReceiptCode addSubview:_receiptCode];
- UIView *fReceiptCode = [[UIView alloc] initWithFrame:CGRectMake(0, 35,Screen_Width ,5)];
- fReceiptCode.backgroundColor = LineBackgroundColor;
- [vReceiptCode addSubview:fReceiptCode];
-
- //客户姓名--------------
- UIView *vCustomerName = [UIView new];
- vCustomerName.frame = CGRectMake(0,CGRectGetMaxY(vReceiptCode.frame) + 8, Screen_Width, 31);
- [contentView addSubview:vCustomerName];
- UILabel *lblTxtVCustomerName = [UILabel new];
- lblTxtVCustomerName.frame = CGRectMake(20, 3, 90, 25);
- lblTxtVCustomerName.text = @"客户名称:";
- lblTxtVCustomerName.font = kTextFont;
- [vCustomerName addSubview:lblTxtVCustomerName];
- _customerName = [UILabel new];
- _customerName.font = kTextFont;
- _customerName.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
- [vCustomerName addSubview:_customerName];
-
- //应收金额--------------
- UIView *vReceivables = [UIView new];
- vReceivables.frame=CGRectMake(0,CGRectGetMaxY(vCustomerName.frame) + 8, Screen_Width, 31);
- [contentView addSubview:vReceivables];
- UILabel *lblTxtVReceivables = [UILabel new];
- lblTxtVReceivables.frame = CGRectMake(20, 3, 90, 25);
- lblTxtVReceivables.text = @"应收金额:";
- lblTxtVReceivables.font = kTextFont;
- [vReceivables addSubview:lblTxtVReceivables];
- _receivables = [UILabel new];
- _receivables.font = kTextFont;
- _receivables.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
- [vReceivables addSubview:_receivables];
-
- //回执类型--------------
- UIView *vReceiptType = [UIView new];
- vReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vReceivables.frame)+8, Screen_Width, 31);
- [contentView addSubview:vReceiptType];
- UILabel *lblTxtVReceiptType = [UILabel new];
- lblTxtVReceiptType.frame = CGRectMake(20, 3, 90, 25);
- lblTxtVReceiptType.text = @"回执类型:";
- lblTxtVReceiptType.font = kTextFont;
- [vReceiptType addSubview:lblTxtVReceiptType];
- _receiptType = [UIButton buttonWithType:UIButtonTypeCustom];
- _receiptType.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- _receiptType.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
- _receiptType.frame=CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
- _receiptType.titleLabel.font= kTextFont;
- [_receiptType setTitle:@"请选择回执类型" forState:UIControlStateNormal];
- [_receiptType setTitleColor:[UIColor colorWithWhite:0 alpha:1] forState:UIControlStateNormal];
- [_receiptType addTarget:self action:@selector(showReceiptType) forControlEvents:UIControlEventTouchUpInside];
- [_receiptType setEnabled:NO];
- [vReceiptType addSubview:_receiptType];
- UIButton *jiantou1 = [UIButton buttonWithType:UIButtonTypeCustom];
- jiantou1.frame=CGRectMake(Screen_Width -17,8,7,12);
- [ jiantou1 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
- [vReceiptType addSubview:jiantou1];
-
- //=收款方式--------------
- UIView *vReceivablesType = [UIView new];
- vReceivablesType.frame = CGRectMake(0,CGRectGetMaxY(vReceiptType.frame)+8, Screen_Width, 31);
- [contentView addSubview:vReceivablesType];
- UILabel *lblTxtVReceivablesType = [UILabel new];
- lblTxtVReceivablesType.frame = CGRectMake(20, 3, 90, 25);
- lblTxtVReceivablesType.text = @"收款方式:";
- lblTxtVReceivablesType.font = kTextFont;
- [vReceivablesType addSubview:lblTxtVReceivablesType];
-
- _receivablesType = [UIButton buttonWithType:UIButtonTypeCustom];
- _receivablesType.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- _receivablesType.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
- _receivablesType.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
- _receivablesType.titleLabel.font = kTextFont;
- [_receivablesType setTitle:@"请选择收款方式" forState:UIControlStateNormal];
- [_receivablesType setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
- [_receivablesType addTarget:self action:@selector(showReceivablesType) forControlEvents:UIControlEventTouchUpInside];
- [_receivablesType setEnabled:NO];
- [vReceivablesType addSubview:_receivablesType];
-
- UIButton *jiantou2 = [UIButton buttonWithType:UIButtonTypeCustom];
- jiantou2.frame = CGRectMake(Screen_Width - 17,8,7,12);
- [ jiantou2 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
- [vReceivablesType addSubview:jiantou2];
-
-
- UIView *vSign = [UIView new];
- vSign.frame = CGRectMake(0,CGRectGetMaxY(vReceivablesType.frame)+8, Screen_Width, 31);
- [contentView addSubview:vSign];
- UILabel *lblTxtSign = [UILabel new];
- lblTxtSign.frame = CGRectMake(20, 3, 90, 25);
- lblTxtSign.text = @"是否签收:";
- lblTxtSign.font = kTextFont;
- [vSign addSubview:lblTxtSign];
-
- _btnSign = [UIButton buttonWithType:UIButtonTypeCustom];
- _btnSign.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- _btnSign.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
- _btnSign.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
- _btnSign.titleLabel.font = kTextFont;
- [_btnSign setTitle:@"请选择签收" forState:UIControlStateNormal];
- [_btnSign setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
- [_btnSign addTarget:self action:@selector(showSign) forControlEvents:UIControlEventTouchUpInside];
-
- [vSign addSubview:_btnSign];
-
- UIButton *jiantou3 = [UIButton buttonWithType:UIButtonTypeCustom];
- jiantou3.frame = CGRectMake(Screen_Width - 17,8,7,12);
- [ jiantou3 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
- [vSign addSubview:jiantou3];
-
-
- UIView *vDeliveryAttribute = [UIView new];
- vDeliveryAttribute.frame = CGRectMake(0,CGRectGetMaxY(vSign.frame)+8, Screen_Width, 31);
- [contentView addSubview:vDeliveryAttribute];
- UILabel *lblTxtDeliveryAttribute = [UILabel new];
- lblTxtDeliveryAttribute.frame = CGRectMake(20, 3, 90, 25);
- lblTxtDeliveryAttribute.text = @"配送属性:";
- lblTxtDeliveryAttribute.font = kTextFont;
- [vDeliveryAttribute addSubview:lblTxtDeliveryAttribute];
-
- _btnDeliveryAttribute = [UIButton buttonWithType:UIButtonTypeCustom];
- _btnDeliveryAttribute.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- _btnDeliveryAttribute.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
- _btnDeliveryAttribute.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
- _btnDeliveryAttribute.titleLabel.font = kTextFont;
- [_btnDeliveryAttribute setTitle:@"请选择配送属性" forState:UIControlStateNormal];
- [_btnDeliveryAttribute setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
- [_btnDeliveryAttribute addTarget:self action:@selector(showDeliveryAttribute) forControlEvents:UIControlEventTouchUpInside];
-
- [vDeliveryAttribute addSubview:_btnDeliveryAttribute];
-
-
-
- UIButton *jiantou4 = [UIButton buttonWithType:UIButtonTypeCustom];
- jiantou4.frame = CGRectMake(Screen_Width - 17,8,7,12);
- [ jiantou4 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
- [vDeliveryAttribute addSubview:jiantou4];
-
-
- UIView *vGoodsAttribute = [UIView new];
- vGoodsAttribute.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryAttribute.frame)+8, Screen_Width, 31);
- [contentView addSubview:vGoodsAttribute];
- UILabel *lblTxtGoodsAttribute = [UILabel new];
- lblTxtGoodsAttribute.frame = CGRectMake(20, 3, 90, 25);
- lblTxtGoodsAttribute.text = @"货物属性:";
- lblTxtGoodsAttribute.font = kTextFont;
- [vGoodsAttribute addSubview:lblTxtGoodsAttribute];
-
- _btnGoodsAttribute = [UIButton buttonWithType:UIButtonTypeCustom];
- _btnGoodsAttribute.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- _btnGoodsAttribute.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
- _btnGoodsAttribute.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
- _btnGoodsAttribute.titleLabel.font = kTextFont;
- [_btnGoodsAttribute setTitle:@"请选择货物属性" forState:UIControlStateNormal];
- [_btnGoodsAttribute setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
- [_btnGoodsAttribute addTarget:self action:@selector(showGoodsAttribute) forControlEvents:UIControlEventTouchUpInside];
-
- [vGoodsAttribute addSubview:_btnGoodsAttribute];
-
- UIButton *jiantou5 = [UIButton buttonWithType:UIButtonTypeCustom];
- jiantou5.frame = CGRectMake(Screen_Width - 17,8,7,12);
- [ jiantou5 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
- [vGoodsAttribute addSubview:jiantou5];
-
-
- //回执金额--------------
- UIView *vReceiptAmount = [UIView new];
- vReceiptAmount.frame = CGRectMake(0,CGRectGetMaxY(vGoodsAttribute.frame) + 8, Screen_Width, 31);
- [contentView addSubview:vReceiptAmount];
- UILabel *lblTxtReceiptAmount = [UILabel new];
- lblTxtReceiptAmount.frame = CGRectMake(20, 3, 90, 25);
- lblTxtReceiptAmount.text = @"回执金额:";
- lblTxtReceiptAmount.font = kTextFont;
- [vReceiptAmount addSubview:lblTxtReceiptAmount];
- _receiptAmount = [UITextField new];
- _receiptAmount.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
- _receiptAmount.font = kTextFont;
- _receiptAmount.placeholder = @"输入回执金额";
- _receiptAmount.delegate = self;
- [_receiptAmount setEnabled:NO];
- _receiptAmount.keyboardType = UIKeyboardTypeDecimalPad;
- [vReceiptAmount addSubview:_receiptAmount];
- UILabel *lblTxtunit = [UILabel new];
- lblTxtunit.frame = CGRectMake(Screen_Width - 40, 3, 30, 25);
- lblTxtunit.text = @"元";
- lblTxtunit.font = kTextFont;
- lblTxtunit.textAlignment = NSTextAlignmentRight;
- [vReceiptAmount addSubview:lblTxtunit];
-
- //推迟日期--------------
- _vNextDeliveryDate = [UIView new];
- _vNextDeliveryDate.frame = CGRectMake(0,CGRectGetMaxY(vReceiptAmount.frame) + 8, Screen_Width, 34);
- [contentView addSubview:_vNextDeliveryDate];
- UILabel *lblTxtVNextDeliveryDate = [UILabel new];
- lblTxtVNextDeliveryDate.frame = CGRectMake(20, 3, 90, 25);
- lblTxtVNextDeliveryDate.text = @"推迟日期:";
- lblTxtVNextDeliveryDate.font = kTextFont;
- [_vNextDeliveryDate addSubview:lblTxtVNextDeliveryDate];
- _nextDeliveryDate = [UIButton buttonWithType:UIButtonTypeCustom];
- _nextDeliveryDate.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- _nextDeliveryDate.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
- _nextDeliveryDate.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
- _nextDeliveryDate.titleLabel.font = kTextFont;
- [_nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
- [_nextDeliveryDate setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
- [_nextDeliveryDate addTarget:self action:@selector(showNextDeliveryDate) forControlEvents:UIControlEventTouchUpInside];
- [_nextDeliveryDate setEnabled:NO];
- [_vNextDeliveryDate addSubview:_nextDeliveryDate];
- UIButton *jiantou6 = [UIButton buttonWithType:UIButtonTypeCustom];
- jiantou6.frame = CGRectMake(Screen_Width-17,8,7,12);
- [ jiantou6 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
- [_vNextDeliveryDate addSubview:jiantou6];
- //分割线
- UIView *fNextDeliveryDate = [[UIView alloc]initWithFrame:CGRectMake(0, 30, Screen_Width, 3)];
- fNextDeliveryDate.backgroundColor = LineBackgroundColor;
- [_vNextDeliveryDate addSubview:fNextDeliveryDate];
- self.myTableView = [[UITableView alloc]init];
- self.myTableView.dataSource = self;
- self.myTableView.delegate = self;
- self.myTableView.scrollEnabled = NO;
- self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.myTableView.frame = CGRectMake(0,CGRectGetMaxY(_vNextDeliveryDate.frame), self.view.bounds.size.width, [self getDataViewHeight:_dataList]) ;
- [contentView addSubview:self.myTableView];
-
- _vCollectionView = [UIView new];
- _vCollectionView.frame = CGRectMake(0,CGRectGetMaxY(self.myTableView.frame) + 8, Screen_Width, 0);
- [contentView addSubview:_vCollectionView];
- [self setupCollectionView];
-
- _positionImage = [UIView new];
- _positionImage.frame=CGRectMake(0, CGRectGetMaxY(_vCollectionView.frame), Screen_Width, 0);
- [contentView addSubview:_positionImage];
- //星号
- _ivPosition = [UIImageView new];
- _ivPosition.frame=CGRectMake(12,20,9,12);
- [_positionImage addSubview:_ivPosition];
-
- _lblPosition = [UILabel new];
- _lblPosition.font=kTextFont;
- _lblPosition.frame=CGRectMake(32, 16, Screen_Width-32, 20);
- [_positionImage addSubview:_lblPosition];
-
- //照相和相册 —————————
- _vImage = [UIView new];
- _vImage.frame=CGRectMake(0,CGRectGetMaxY(_positionImage.frame), Screen_Width-32, 30);
- contentView.frame=CGRectMake(0, 0, Screen_Width,CGRectGetMaxY(_vImage.frame));
- [contentView addSubview:_vImage];
- CGFloat width = (SCREENWIDTH-70)/2;
- CustomButton *btnPhoto = [[CustomButton alloc]initWithFrame:CGRectMake(width-90, 0, 70, 20) andImage:[UIImage imageNamed:@"icon_takephoto"] addText:@"照相" addImageWidth:15 addImageHeight:12];
- [btnPhoto addTarget:self action:@selector(selectCamera) forControlEvents:(UIControlEventTouchUpInside)];
- [_vImage addSubview:btnPhoto];
-
- CustomButton *btn = [[CustomButton alloc]initWithFrame:CGRectMake(width, 0,70 , 20) andImage:[UIImage imageNamed:@"icon_photo"] addText:@"相册" addImageWidth:14 addImageHeight:15];
- [btn addTarget:self action:@selector(selectPhotos) forControlEvents:(UIControlEventTouchUpInside)];
-
- [_vImage addSubview:btn];
-
- CustomButton *btnLoaction = [[CustomButton alloc]initWithFrame:CGRectMake(width+85, 0,100 , 20) andImage:[UIImage imageNamed:@"icon_position"] addText:@"所在位置" addImageWidth:13 addImageHeight:16];
- [btnLoaction addTarget:self action:@selector(newMap) forControlEvents:(UIControlEventTouchUpInside)];
- [_vImage addSubview:btnLoaction];
- _vImage.hidden=YES;
- contentView.frame=CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(_vImage.frame));
- //保存按钮
- UIImage *pic = [UIImage imageNamed:@"bt_datasave"];
- CGFloat h = (Screen_Width - 40) * pic.size.height / pic.size.width;
- _saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _saveBtn.frame=CGRectMake(20, Screen_Height- h - 5 - rectStatusHeight-rectNavHeight-10, Screen_Width - 40,h) ;
- [_saveBtn setBackgroundImage:pic forState:UIControlStateNormal];
- [_saveBtn addTarget:self action:@selector(saveData) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:_saveBtn];
-
- }
- /**
- 键盘弹出函数
- */
- - (void)myKeyboardWillShow {
- if(!keyboardShow){
-
- [UIView animateWithDuration:0.3f animations:^ {
- self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y - 190, self.view.frame.size.width, self.view.frame.size.height);
-
- }];
- }
-
- keyboardShow=YES;
-
- }
- /**
- 键盘隐藏函数
- */
- - (void)keyboardWillHide {
- // Animate the current view back to its original position
- if(keyboardShow){
- [UIView animateWithDuration:0.0f animations:^ {
- self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y + 190, self.view.frame.size.width, self.view.frame.size.height);
-
- }];}
- keyboardShow=NO;
- }
- /**
- 总单回执类型
- */
- - (void)showReceiptType{
- 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;
- }
- -(void)showSign
- {
- self.hidesBottomBarWhenPushed=YES;
- [self initSignData];
- StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
- tc.sdelegate=self;
- [tc.arrFilter addObjectsFromArray: _signArray];
- [self.navigationController pushViewController:tc animated:YES];
- self.hidesBottomBarWhenPushed=NO;
-
- }
- -(void)showDeliveryAttribute
- {
- if(_deliveryArray!=nil&&_deliveryArray.count>0)
- {
- self.hidesBottomBarWhenPushed=YES;
- StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
- tc.sdelegate=self;
- [tc.arrFilter addObjectsFromArray: _deliveryArray];
- [self.navigationController pushViewController:tc animated:YES];
- self.hidesBottomBarWhenPushed=NO;
- }
- }
- -(void)showGoodsAttribute
- {
- if(_goodsArray!=nil&&_goodsArray.count>0)
- {
- self.hidesBottomBarWhenPushed=YES;
- StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
- tc.sdelegate=self;
- [tc.arrFilter addObjectsFromArray: _goodsArray];
- [self.navigationController pushViewController:tc animated:YES];
- self.hidesBottomBarWhenPushed=NO;
- }
- }
- /**
- 重新计算视图的位置
- */
- - (void)reloadMyView{
- self.myTableView.frame=CGRectMake(0,CGRectGetMaxY(_vNextDeliveryDate.frame), self.view.bounds.size.width, [self getDataViewHeight:_dataList]) ;
- _vCollectionView.frame=CGRectMake(0,CGRectGetMaxY(self.myTableView.frame), Screen_Width, [Util getPhotoCollectionViewHeightWithPhotos: _assets]);
- self.collectionView.frame=CGRectMake(0, 0,Screen_Width,[Util getPhotoCollectionViewHeightWithPhotos: _assets]);
- if (_lblPosition.text.length > 0){
- _ivPosition.image = [UIImage imageNamed:@"log_position"];
-
- _positionImage.frame=CGRectMake(0, CGRectGetMaxY(_vCollectionView.frame)-8, Screen_Width, 30);
- }
- else{
- _positionImage.frame=CGRectMake(0, CGRectGetMaxY(_vCollectionView.frame)-8, Screen_Width,0);
- }
-
- _vImage.frame=CGRectMake(0,CGRectGetMaxY(_positionImage.frame)+8, Screen_Width, 30);
- contentView.frame=CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(_vImage.frame));
- scroll.contentSize=CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + 150);
- }
- /**
- 回执数量变化函数
- */
- - (void)receiptQuantityValueChanged{
- if([_myCell.receiptQuantity.text doubleValue] > [_myCell.outQuantity.text doubleValue]){
- _myCell.receiptQuantity.text = _myCell.outQuantity.text;
- _myCell.model.receiptQuantity = _myCell.outQuantity.text;
- [self showAlertViewText:@"回执数量不能大于出库数量"];
- }
-
- }
- /**
- 收款方式
- */
- - (void)showReceivablesType{
- [self.view endEditing:YES];
- PayTypeVC *pay = [[PayTypeVC alloc] init];
- pay.payDelegate = self;
- [self.navigationController pushViewController:pay animated:YES];
- self.hidesBottomBarWhenPushed = NO;
-
- }
- /**
- 保存数据函数
- */
- - (void)saveData{
- [self.view endEditing:YES];
-
- if([kkRights rangeOfString:FUNCTION_DISTRIBUTION_RECEIP_OPERATION_IPHONE].location==NSNotFound){
-
- [self showAlertViewText:@"用户没有配送回执操作权限"];
- return;
- }
-
- if(_receiptCode.text == nil || [_receiptCode.text isEqualToString:@""]){
- [self showAlertViewText:@"请输入或扫描单号"];
- return;
- }
- if(_sReceiptCode == nil){
- [self showAlertViewText:@"请按回车加载数据!"];
- return;
- }
- if([_sReceiptType intValue] == 1){
- _sReceiptAmount = _receiptAmount.text;
- _sNextDeliveryDate = @"";
- }
- else{
- _sReceiptAmount = @"0.000000";
- [ _receivablesType setTitle:@"请输入收款方式" forState:UIControlStateNormal];
- _settlementTypeName = @"";
- _settlementType = @"";
- _existsHandlingFee = @"";
- _earnestFee = @"";
- _remarks = @"";
- }
-
- if([_signFlag isEqualToString:@"1"])
- {
- if(_signName==nil||[_signName isEqualToString:@""])
- {
- [self showAlertViewText:@"请选择是否签收!"];
- return;
- }
- }
-
- if([_deliveryFlag isEqualToString:@"1"])
- {
- if(_deliveryAttributeId==nil||[_deliveryAttributeId isEqualToString:@""])
- {
- [self showAlertViewText:@"请选择配送属性!"];
- return;
- }
-
- if(_goodsAttributeId==nil||[_goodsAttributeId isEqualToString:@""])
- {
- [self showAlertViewText:@"请选择货物属性!"];
- return;
- }
- }
-
-
- if([_sReceiptType intValue] != 1){
- NSString *nextDeliveryDate = _nextDeliveryDate.titleLabel.text;
- if([nextDeliveryDate isEqualToString:@"请选择推迟日期"]){
- [self showAlertViewText:@"请选择推迟日期!"];
- return;
- }
- NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];//实例化一个NSDateFormatter对象
-
- [dateFormat setDateFormat:@"yyyy-MM-dd"];
- NSDate *date = [dateFormat dateFromString:nextDeliveryDate];
- NSDate *lastDay = [NSDate dateWithTimeInterval:-24*60*60 sinceDate:[self getCurrentTime]];
- if([self compareOneDay:date withAnotherDay:lastDay] != 1){
- [self showAlertViewText:@"推迟日期不能小于当前日期"];
- return;
- }
- }
-
- if(self.receiptAmount.text != nil||![self.receiptAmount.text isEqualToString:@""]){
- RegularExpression *regularExpr = [[RegularExpression alloc]init];
- bool receiptAmountCheck = [regularExpr AmountRegular:self.receiptAmount.text];
- if(!receiptAmountCheck){
- [self showAlertViewText:@"回执金额格式不正确"];
- self.receiptAmount.text = @"";
- return ;
- }
- }
-
- if([_sReceiptAmount doubleValue] > [_sReceivables doubleValue] ){
- [self showAlertViewText:@"回执金额不能大于应收金额!"];
- return;
- }
- for (NewDeliveryReceiptModel* model in _dataList) {
- NSString *receiptQuantity = model.receiptQuantity;
- if(receiptQuantity != nil&&[receiptQuantity length] > 0){
- RegularExpression *re = [[RegularExpression alloc]init];
- bool isMatchDiscount = [re QuantityRegular:receiptQuantity];
- if(isMatchDiscount == NO){
- [self showAlertViewText:@"请输入正确的数"];
- return ;
- }
- }
- else{
- [self showAlertViewText:@"回执数量不能为空"];
- return ;
- }
- }
-
- if(_dataList != nil && _dataList.count > 0){
- for (NewDeliveryReceiptModel *model in _dataList) {
- if (model.receiptQuantity == nil
- || [@"" isEqualToString:model.receiptQuantity]) {
- [self showAlertViewText:@"请输入回执数量"];
- return;
- }
- //新增校验
- if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 1 && model.salesDetailType != 2){
- if ([model.receiptQuantity doubleValue] == 0) {
-
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能为0!",model.code]];
- return;
- }
- }
- if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 2 && model.salesDetailType != 2 && [model.outQuantity doubleValue]<[model.deliveryQuantity doubleValue] && [model.sourceFrom doubleValue] != 4 && [model.sourceFrom doubleValue] != 6){
- if ([model.outQuantity doubleValue] == 0) {
-
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品出库数量不能为0!",model.code]];
- }else{
- if([model.outQuantity doubleValue]<[model.deliveryQuantity doubleValue]){
-
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品出库数量小于送货数量不能保存,建议冲正对应送货单,按照出库数量重新开送货单!",model.code]];
- }
- }
- return;
- }
- if(model.salesDetailType != 2 && [model.sourceFrom doubleValue] != 4 && [model.sourceFrom doubleValue] != 6){
- if ([model.outQuantity doubleValue] == 0) {
-
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品出库数量不能为0!",model.code]];
- return;
- }
- }
- if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 2 ){
- if ([model.receiptQuantity doubleValue] < 0) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能小于0!",model.code]];
- return;
- }
- }
- if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 2 && [model.sourceFrom doubleValue] != 4 && [model.sourceFrom doubleValue] != 6){
- if ([model.receiptQuantity doubleValue] >= [model.deliveryQuantity doubleValue]) {
-
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能大于或等于送货数量!",model.code]];
- return;
- }
- }
-
- if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 2 &&model.salesDetailType != 2&& [model.sourceFrom doubleValue] != 4 && [model.sourceFrom doubleValue] != 6){
- if ([model.receiptQuantity doubleValue] >= [model.outQuantity doubleValue]) {
-
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能大于或等于出库数量!",model.code]];
- return;
- }
- }
-
- if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 2){
- if(model.maxReceiptQuantity <= [model.receiptQuantity doubleValue]){
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品配送明细类型为再送,送货量已超出最大允许配送回执量,请核对数据!",model.code]];
- return;
- }
- }
- if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 1 &&model.salesDetailType != 2&& [model.sourceFrom doubleValue] != 4 && [model.sourceFrom doubleValue] != 6 && [model.outQuantity doubleValue] != 0){
- if ([model.receiptQuantity doubleValue] > [model.outQuantity doubleValue]) {
-
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能大于出库数量!",model.code]];
- return;
- }
- }
- if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 1){
- if ([model.receiptQuantity doubleValue] > [model.deliveryQuantity doubleValue]) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能大于送货数量!",model.code]];
- return;
- }
- }
- //登记单退货
- // if ([model.outQuantity doubleValue] == 0.0 && !([@"4" isEqualToString:model.sourceFrom] || [@"6" isEqualToString:model.sourceFrom])) {
- // [self showAlertViewText:[NSString stringWithFormat:@"%@的商品没有出库!",model.code]];
- // return;
- // }
-
- // if ([model.receiptQuantity doubleValue] > [model.outQuantity doubleValue] && !([@"4" isEqualToString:model.sourceFrom] || [@"6" isEqualToString:model.sourceFrom])) {
- // [self showAlertViewText:[NSString stringWithFormat:@"%@的商品的回执数量不能大于出库数量!",model.code]];
- // return;
- // }
-
- // if ([model.receiptQuantity doubleValue] > [model
- // .deliveryQuantity doubleValue]) {
- // [self showAlertViewText:[NSString stringWithFormat:@"%@的商品的回执数量不能大于送货数量!",model.code]];
- // return;
- // }
- }
- }else{
- [self showAlertViewText:@"回执明细不能为空!"];
- return;
- }
-
-
- self.navigationItem.rightBarButtonItem.enabled=NO;
- [self saveInfo];
-
- }
- /**
- 保存图片函数
- @return <#return value description#>
- */
- - (BOOL)savePicsManager{
- self.mDownManager = [[ASIDownManager alloc] init];
- self.mDownManager.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.imagePaths removeAllObjects];
- for (int i = 0; i < self.assets.count; i++) {
- 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= [_mDownManager syncPostHttpRequestUrl:urlStr dic:dict path:c.imagePath filename:nil fileType:@"image/jpeg"];
- if (retValue == nil || retValue.length == 0){
- [self cancel];
- [self 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.imagePaths addObject:imgPath];
-
- }
- else{
- [self cancel];
- return NO;
- }
- }
-
- }
-
- return YES;
-
- }
- /**
- 保存图片到沙盒
- @param currentImage <#currentImage description#>
- @param imageName <#imageName description#>
- @return <#return value description#>
- */
- - (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];
- DKCamera *camera = [[DKCamera alloc] init];
- camera.imagePath = fullPath;
- camera.thumbImage = savedImage;// [UIImage imageWithData:data];
- return camera;
- }
- /**
- 保存数据函数
- */
- - (void)saveInfo{
- [self startLoading];
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
- if(![self savePicsManager]){
- return;
- }
- self.mDownManager = [[ASIDownManager alloc] init];
- self.mDownManager.delegate = self;
- self.mDownManager.onRequestSuccess = @selector(onSaveLoadFinish:);
- self.mDownManager.onRequestFail = @selector(onLoadFail:);
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"SaveIntelligentReceiptIphone" 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:self->_deliveryId forKey:@"DeliveryID"];
- [dict setObject:self->_signName forKeyedSubscript:@"IsSign"];
- [dict setObject:self->_deliveryAttributeId forKeyedSubscript:@"SendAttribute"];
- [dict setObject:self->_goodsAttributeId forKeyedSubscript:@"GoodsAttribute"];
- if (_lblPosition.text == nil) {
- [dict setObject:@"" forKey:@"Position"];
- }else{
- [dict setObject:_lblPosition.text forKey:@"Position"];
- }
- _remarks = @"";
- NSMutableDictionary *dicHead = [[NSMutableDictionary alloc] init];
- NSMutableArray *arrHead = [[NSMutableArray alloc]init];
- [dicHead setObject:_sReceiptType forKeyedSubscript:@"ReceiptType"];
- [dicHead setObject:_sNextDeliveryDate forKeyedSubscript:@"NextDeliveryDate"];
- [dicHead setObject:_remarks forKeyedSubscript:@"Remarks"];
- [dicHead setObject:_sReceivables forKeyedSubscript:@"Receivables"];
- // RecoverFlag 单据回收标识 0:未回收 1:已回收
- if([_sReceiptAmount doubleValue] > 0){
- [dicHead setObject:@"1" forKeyedSubscript:@"RecoverFlag"];
- }else{
- [dicHead setObject:@"0" forKeyedSubscript:@"RecoverFlag"];
- }
- [dicHead setObject:_sReceiptAmount forKeyedSubscript:@"ReceiptAmount"];
- [dicHead setObject:_completeReceivables forKeyedSubscript:@"CompleteReceivables"];
- [arrHead addObject:dicHead];
- [dict setObject:[Util objectToJson:arrHead] forKey:@"ReceiptData"];
- //详细列表
- NSMutableDictionary *dicDetails;
- NSMutableArray* arrDetails = [[NSMutableArray alloc]init];
- for (NewDeliveryReceiptModel* me in _dataList) {
- dicDetails = [[NSMutableDictionary alloc] init];
- [dicDetails setObject:me.detailId forKeyedSubscript:@"DetailID"];
- [dicDetails setObject:me.deliveryQuantity forKeyedSubscript:@"DeliveryQuantity"];
- [dicDetails setObject:me.receiptQuantity forKeyedSubscript:@"ReceiptQuantity"];
- [dicDetails setObject:me.receiptType forKeyedSubscript:@"ReceiptType"];
- [dicDetails setObject:me.sourceFrom forKeyedSubscript:@"SourceFrom"];
- [dicDetails setObject:me.invoiceId forKeyedSubscript:@"InvoiceID"];
- [dicDetails setObject:me.invoiceDetailId forKeyedSubscript:@"InvoiceDetailID"];
- [dicDetails setObject:me.receiptRemarks forKeyedSubscript:@"ReceiptRemarks"];
- [arrDetails addObject:dicDetails];
- }
- [dict setObject:[Util objectToJson:arrDetails] forKey:@"ReceiptDetailData"];
-
- //////付款方式
- NSMutableDictionary *dicSettle = [[NSMutableDictionary alloc] init];
- NSMutableArray* arrSettle = [[NSMutableArray alloc]init];
- if (_settlementType == nil || [_settlementType isEqual:@""]) {
- [dict setObject:@"" forKey:@"ReceiptEarnestData"];
- }else{
- [dicSettle setObject:self.settlementType forKeyedSubscript:@"SettlementType"];
- [dicSettle setObject:self.settlementTypeName forKeyedSubscript:@"SettlementTypeName"];
- [dicSettle setObject:_receiptAmount.text forKeyedSubscript:@"ReceivableSum"];
- [dicSettle setObject:self.earnestFee forKeyedSubscript:@"EarnestFee"];
- [dicSettle setObject:self.existsHandlingFee forKeyedSubscript:@"ExistsHandlingFee"];
- [dicSettle setObject:self.remarks forKeyedSubscript:@"Remarks"];
- [arrSettle addObject:dicSettle];
-
- [dict setObject:[Util objectToJson:arrSettle] forKey:@"ReceiptEarnestData"];
- }
- /////////图片上传返回的地址
- if (self.imagePaths && self.imagePaths.count > 0) {
- [dict setObject:[self.imagePaths componentsJoinedByString:@"," ] forKey:@"ImagePath"];
-
- }
-
- [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
-
- });
-
- }
- /**
- 清空画面函数
- */
- - (void)clearData{
- self.receiptCode.text = @"";
- self.sReceiptCode = @"";
- self.customerName.text = @"";
- self.sCustomerName = @"";
- self.receivables.text = @"";
- self.sReceivables = @"";
- [self.receiptType setTitle:@"请选择回执类型" forState:UIControlStateNormal];
- self.sReceiptType = @"";
- [self.receivablesType setTitle:@"请选择收款方式" forState:UIControlStateNormal];
- _settlementTypeName = @"";
- _settlementType = @"";
- _existsHandlingFee = @"";
- _earnestFee = @"";
- _remarks = @"";
- self.receiptAmount.text = @"";
- self.sReceiptAmount = @"";
- self.receiptCode.text = @"";
- self.sReceiptCode = @"";
- [self.nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
- self.sNextDeliveryDate = @"";
- _lblPosition.text = @"";
- _positionImage.hidden = YES;
- _vImage.hidden = YES;
- _positionHeight = 0;
- [_receiptType setEnabled:NO];
- [_receivablesType setEnabled:NO];
- [_receiptAmount setEnabled:NO];
- [_nextDeliveryDate setEnabled:NO];
-
- [self.imagePaths removeAllObjects];
- [self.dataList removeAllObjects];
- [self.assets removeAllObjects];
- [self.myTableView reloadData];
- [self.collectionView reloadData];
- [self reloadMyView];
- }
- /**
- 出示推迟日期函数
- @return <#return value description#>
- */
- - (void)showNextDeliveryDate{
- [self.view endEditing:YES];
- __weak typeof(self)weakself = self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- _sNextDeliveryDate = date;
- } andCompletionBlock:^(void){
- [weakself.nextDeliveryDate setTitle:_sNextDeliveryDate forState:UIControlStateNormal];
- } andCancelBlock:^(void){
- _sNextDeliveryDate = weakself.nextDeliveryDate.titleLabel.text;
- if([_sNextDeliveryDate isEqualToString:@"请选择推迟日期"]){
- _sNextDeliveryDate = @"";
- }
- }];
- [_dealDatePicker show];
-
-
- }
- /**
- 加载单据数据函数
- */
- - (void)loadDataSource{
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict = [NSMutableDictionary new];
- [dict setObject:@"GetIntelligentReceiptByDeliveryNoIphone" forKey:@"Action"];
- [dict setObject:kkAccountCode forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:self.receiptCode.text forKey:@"DeliveryNo"];
- self.mDownManager = [[ASIDownManager alloc] init];
- self.mDownManager.delegate=self;
- self.mDownManager.onRequestSuccess=@selector(onLoadFinish:);
- self.mDownManager.onRequestFail=@selector(onLoadFail:);
- [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];}
- /**
- 取消进度条
- */
- - (void)cancel {
- [self stopLoading];
- }
- /**
- 返回函数
- */
- - (void)goBack{
- [self.navigationController popViewControllerAnimated:YES];
- if([self.refreshDelegate respondsToSelector:@selector(refreshFollowUpData)]){
- [self.refreshDelegate refreshFollowUpData];
- }
- }
- /**
- 拍照函数
- */
- - (void)selectCamera{
- 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];
- [self reloadMyView];
-
- }];
-
- }
- /**
- 选择相册函数
- */
- - (void)selectPhotos {
- // 创建控制器
- 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];
- }
- /**
- 出示地图函数
- */
- - (void)newMap{
- self.hidesBottomBarWhenPushed=YES;
- MapViewController *mc = [MapViewController new];
- mc.pDelegate=self;
- [self.navigationController pushViewController:mc animated:YES];
- }
- /**
- 获取table view的高度
- @param soundArray <#soundArray description#>
- @return <#return value description#>
- */
- - (CGFloat)getDataViewHeight:(NSArray *)soundArray {
- // 上下间隔已经在frame上做了
- NSInteger row = soundArray.count;
- return (row *197);
- }
- #pragma mark -得到当前时间
- /**
- 获得当前日期
-
- @return <#return value description#>
- */
- - (NSDate *)getCurrentTime{
- NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSString *dateTime=[formatter stringFromDate:[NSDate date]];
- NSDate *date = [formatter dateFromString:dateTime];
- return date;
- }
- /**
- 比较时间
-
- @param oneDay <#oneDay description#>
- @param anotherDay <#anotherDay description#>
- @return <#return value description#>
- */
- - (int)compareOneDay:(NSDate *)oneDay withAnotherDay:(NSDate *)anotherDay
- {
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"dd-MM-yyyy-HHmmss"];
- NSString *oneDayStr = [dateFormatter stringFromDate:oneDay];
- NSString *anotherDayStr = [dateFormatter stringFromDate:anotherDay];
- NSDate *dateA = [dateFormatter dateFromString:oneDayStr];
- NSDate *dateB = [dateFormatter dateFromString:anotherDayStr];
- NSComparisonResult result = [dateA compare:dateB];
- NSLog(@"date1 : %@, date2 : %@", oneDay, anotherDay);
- if (result == NSOrderedDescending) {
- //NSLog(@"Date1 is in the future");
- return 1;
- }
- else if (result == NSOrderedAscending){
- //NSLog(@"Date1 is in the past");
- return -1;
- }
- //NSLog(@"Both dates are the same");
- return 0;
-
- }
- @end
|