NewDeliveryReceiptVC.m 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256
  1. //
  2. // NewDeliveryReceiptVC.m
  3. // IBOSS
  4. //
  5. // Created by Dongke on 16/1/7.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. // 功能描述:新增配送控制器
  8. #import "NewDeliveryReceiptVC.h"
  9. #import "NIDropDown.h"
  10. #import "StatusInfo.h"
  11. #import "StatusInfoTextVC.h"
  12. #import "PayTypeVC.h"
  13. #import "AlbumPhotoCollectionViewCell.h"
  14. #import "XHImageViewer.h"
  15. #import "DKPhotoPickerViewController.h"
  16. //#import "MapViewController.h"
  17. #import "DKCameraViewController.h"
  18. #import "DKUICollectionViewCell.h"
  19. #import "NewDeliveryKeyBoardDelegate.h"
  20. #import "RegularExpression.h"
  21. #import "Util.h"
  22. #import "NewDeliveryListTableViewCell.h"
  23. #import "CustomButton.h"
  24. #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
  25. #define kTitleFont [UIFont systemFontOfSize:14]
  26. @interface NewDeliveryReceiptVC ()<DataListTableViewCellDetegate,NewDeliveryKeyBoardDelegate,UITableViewDataSource,UIScrollViewDelegate, UITableViewDelegate>{
  27. NSInteger _positionHeight;
  28. UIView *_positionImage;
  29. UIView *_vImage;
  30. UILabel *_lblPosition;
  31. UIImageView *_ivPosition;
  32. BOOL _isHaveDian;
  33. UIView *_vCollectionView;
  34. NSIndexPath *_myRow;
  35. NewDeliveryListTableViewCell *_myCell;
  36. }
  37. @end
  38. @implementation NewDeliveryReceiptVC
  39. @synthesize scroll;
  40. @synthesize contentView;
  41. @synthesize refreshDelegate;
  42. @synthesize keyboardShow;
  43. #pragma mark - 公共函数
  44. /**
  45. 加载视图函数
  46. */
  47. - (void)viewDidLoad {
  48. [super viewDidLoad];
  49. _dataList = [[NSMutableArray alloc]init];
  50. [self initUI];
  51. _signName=@"";
  52. _deliveryAttributeId=@"";
  53. _goodsAttributeId=@"";
  54. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onFocusPeopleEditingChanged:) name:@"UITextFieldTextDidChangeNotification" object:self.receiptAmount ];
  55. self.navigationItem.title = @"新增配送回执";
  56. //返回
  57. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  58. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  59. [button addTarget:self action:@selector(goBack)
  60. forControlEvents:UIControlEventTouchUpInside];
  61. button.frame = CGRectMake(0, 0,45,22);
  62. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  63. self.navigationItem.leftBarButtonItem = menuButton;
  64. if(self.sReceiptCode != nil&&self.sReceiptCode.length > 0){
  65. self.receiptCode.enabled=NO;
  66. [self reloadDataWithOnlyCode:self.sReceiptCode];
  67. }
  68. }
  69. /**
  70. 安全区视图发生变化
  71. */
  72. -(void)viewSafeAreaInsetsDidChange{
  73. [self.view setBackgroundColor:[UIColor whiteColor]];
  74. UIImage *pic = [UIImage imageNamed:@"bt_datasave"];
  75. CGFloat h = (Screen_Width - 40) * pic.size.height / pic.size.width;
  76. scroll.frame =CGRectMake(0, 0, Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height -h);
  77. _saveBtn.frame = CGRectMake(20,
  78. self.view.safeAreaLayoutGuide.layoutFrame.size.height -h-15,
  79. Screen_Width-40,
  80. h);
  81. [super viewSafeAreaInsetsDidChange];
  82. }
  83. /**
  84. 初始化回执类型
  85. */
  86. - (void)initStatus2:(BOOL) flag{
  87. _arrayStatus = [[NSMutableArray alloc]init];
  88. StatusInfo *s = [[StatusInfo alloc]init];
  89. s.tagName = @"cell";
  90. s.statusId = @"1";
  91. s.name = @"完成";
  92. [_arrayStatus addObject:s];
  93. if(flag){
  94. s = [[StatusInfo alloc]init];
  95. s.tagName = @"cell";
  96. s.statusId = @"2";
  97. s.name = @"再送";
  98. [_arrayStatus addObject:s];
  99. s = [[StatusInfo alloc]init];
  100. s.tagName = @"cell";
  101. s.statusId = @"3";
  102. s.name = @"换货";
  103. [_arrayStatus addObject:s];
  104. s = [[StatusInfo alloc]init];
  105. s.tagName = @"cell";
  106. s.statusId = @"4";
  107. s.name = @"退货";
  108. [_arrayStatus addObject:s];
  109. }
  110. }
  111. -(void)initSignData
  112. {
  113. _signArray=[[NSMutableArray alloc]init];
  114. StatusInfo *s = [[StatusInfo alloc]init];
  115. s.tagName = @"sign";
  116. s.statusId = @"1";
  117. s.name = @"是";
  118. [_signArray addObject:s];
  119. s = [[StatusInfo alloc]init];
  120. s.tagName = @"sign";
  121. s.statusId = @"0";
  122. s.name = @"否";
  123. [_signArray addObject:s];
  124. }
  125. - (void)showSignAuthority{
  126. [self startLoading];
  127. NSString *urlStr = ServerURL;
  128. NSMutableDictionary *dict= [NSMutableDictionary new];
  129. [dict setObject:@"GetSystemSettingValues" forKey:@"Action"];
  130. [dict setObject:kkAccountCode forKey:@"AccountCode"];
  131. [dict setObject:kkUserCode forKey:@"UserCode"];
  132. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  133. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  134. [dict setObject:@"SS_CTS_04" forKey:@"SettingType"];
  135. self.mDownManager= [[ASIDownManager alloc] init];;
  136. self.mDownManager.delegate = self;
  137. self.mDownManager.onRequestSuccess = @selector(onSignLoadFinish:);
  138. self.mDownManager.onRequestFail = @selector(onSignLoadFail:);
  139. [self.mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  140. }
  141. - (void)showDeliveryAuthority{
  142. [self startLoading];
  143. NSString *urlStr = ServerURL;
  144. NSMutableDictionary *dict= [NSMutableDictionary new];
  145. [dict setObject:@"GetSystemSettingValues" forKey:@"Action"];
  146. [dict setObject:kkAccountCode forKey:@"AccountCode"];
  147. [dict setObject:kkUserCode forKey:@"UserCode"];
  148. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  149. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  150. [dict setObject:@"SS_CTS_03" forKey:@"SettingType"];
  151. self.mDownManager= [[ASIDownManager alloc] init];;
  152. self.mDownManager.delegate = self;
  153. self.mDownManager.onRequestSuccess = @selector(onDeliveryLoadFinish:);
  154. self.mDownManager.onRequestFail = @selector(onDeliveryLoadFail:);
  155. [self.mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  156. }
  157. - (void)showDeliveryAttributeData{
  158. [self startLoading];
  159. NSString *urlStr = ServerURL;
  160. NSMutableDictionary *dict= [NSMutableDictionary new];
  161. [dict setObject:@"GetDataDictionary" forKey:@"Action"];
  162. [dict setObject:kkAccountCode forKey:@"AccountCode"];
  163. [dict setObject:kkUserCode forKey:@"UserCode"];
  164. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  165. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  166. [dict setObject:@"CTS008" forKey:@"DictionaryType"];
  167. self.mDownManager= [[ASIDownManager alloc] init];;
  168. self.mDownManager.delegate = self;
  169. self.mDownManager.onRequestSuccess = @selector(onDeliveryAttributeLoadFinish:);
  170. self.mDownManager.onRequestFail = @selector(onDeliveryAttributeLoadFail:);
  171. [self.mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  172. }
  173. - (void)showGoodsAttributeData{
  174. [self startLoading];
  175. NSString *urlStr = ServerURL;
  176. NSMutableDictionary *dict= [NSMutableDictionary new];
  177. [dict setObject:@"GetDataDictionary" forKey:@"Action"];
  178. [dict setObject:kkAccountCode forKey:@"AccountCode"];
  179. [dict setObject:kkUserCode forKey:@"UserCode"];
  180. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  181. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  182. [dict setObject:@"CTS009" forKey:@"DictionaryType"];
  183. self.mDownManager= [[ASIDownManager alloc] init];;
  184. self.mDownManager.delegate = self;
  185. self.mDownManager.onRequestSuccess = @selector(onGoodsAttributeLoadFinish:);
  186. self.mDownManager.onRequestFail = @selector(onGoodsAttributeLoadFail:);
  187. [self.mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  188. }
  189. /**
  190. 初始化图片数组
  191. @return <#return value description#>
  192. */
  193. - (NSMutableArray *)imagePaths{
  194. if (!_imagePaths) {
  195. _imagePaths = [NSMutableArray array];
  196. }
  197. return _imagePaths;
  198. }
  199. /**
  200. 视图毁坏函数
  201. */
  202. - (void)dealloc{
  203. //[self cancel];
  204. // [[NSNotificationCenter defaultCenter]removeObserver:self name:@"UITextFieldTextDidChangeNotification" object:self.receiptAmount];
  205. }
  206. /**
  207. 初始化回执类型
  208. */
  209. - (void)initStatus{
  210. _arrayDStatus = [[NSMutableArray alloc]init];
  211. StatusInfo* s = [[StatusInfo alloc]init];
  212. s.tagName = @"status";
  213. s.statusId = @"1";
  214. s.name = @"完成";
  215. [_arrayDStatus addObject:s];
  216. s = [[StatusInfo alloc]init];
  217. s.tagName = @"status";
  218. s.statusId = @"2";
  219. s.name = @"推迟送货";
  220. [_arrayDStatus addObject:s];
  221. }
  222. /**
  223. 获得拍照的照片总数
  224. @return <#return value description#>
  225. */
  226. - (NSInteger)cameraCount{
  227. NSInteger count = 0;
  228. for (int i = 0; i < self.assets.count; i++) {
  229. id asset = self.assets[i];
  230. if ([asset isKindOfClass:[DKCamera class]]) {
  231. count++;
  232. }
  233. }
  234. return count;
  235. }
  236. /**
  237. 初始化collection view
  238. */
  239. - (void)setupCollectionView{
  240. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  241. flowLayout.itemSize = CGSizeMake(85, 85);
  242. flowLayout.minimumInteritemSpacing = 5;
  243. flowLayout.minimumLineSpacing = 10;
  244. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  245. flowLayout.sectionInset = UIEdgeInsetsMake(7, 20, 0, 20);
  246. self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width,0) collectionViewLayout:flowLayout];
  247. self.collectionView.scrollEnabled = NO;
  248. self.collectionView.backgroundColor = [UIColor clearColor];
  249. self.collectionView.dataSource = self;
  250. self.collectionView.delegate = self;
  251. [self.collectionView registerNib:[UINib nibWithNibName:@"DKUICollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"DKUICollectionViewCell"];
  252. [_vCollectionView addSubview:self.collectionView];
  253. }
  254. /**
  255. 初始化相册数组
  256. @return <#return value description#>
  257. */
  258. - (NSMutableArray *)assets{
  259. if (!_assets) {
  260. _assets = [NSMutableArray array];
  261. }
  262. return _assets;
  263. }
  264. #pragma mark - 回调函数
  265. /**
  266. 文本值变化回调函数
  267. @param cell <#cell description#>
  268. @param txtfield <#txtfield description#>
  269. @param qualityTxt <#qualityTxt description#>
  270. @param remark <#remark description#>
  271. */
  272. - (void)textValueChange:(NewDeliveryListTableViewCell *)cell txtField:(UITextField *)txtfield qualityField:(UITextField *)qualityTxt remarkField:(UITextField *)remark{
  273. self.cellIndex=cell.cellIndex;
  274. NewDeliveryReceiptModel *model = [_dataList objectAtIndex:self.cellIndex];
  275. if(txtfield.tag == 1000){
  276. model.receiptQuantity = txtfield.text;
  277. }
  278. if(txtfield.tag == 1001){
  279. model.receiptRemarks = txtfield.text;
  280. }
  281. }
  282. -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
  283. [self.view endEditing:NO];
  284. }
  285. /**
  286. 键盘隐藏回调函数
  287. @param cell <#cell description#>
  288. */
  289. - (void)keyboardWillHide:(NewDeliveryListTableViewCell *)cell{
  290. if (cell.cellIndex == _dataList.count - 1) {
  291. [self keyboardWillHide];
  292. }
  293. }
  294. /**
  295. 键盘弹出回调函数
  296. @param cell <#cell description#>
  297. */
  298. - (void)keyboardWillShow:(NewDeliveryListTableViewCell *)cell{
  299. if (cell.cellIndex == _dataList.count - 1) {
  300. [self myKeyboardWillShow];
  301. }
  302. }
  303. - (void)onSignLoadFinish:(ASIDownManager *)sender {
  304. // 取消进度条
  305. [self cancel];
  306. // 服务器返回数据转换model
  307. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  308. // 服务器返回数据状态值
  309. int iStatus = resultModel.status;
  310. // 服务器返回数据消息
  311. // 服务器返回数据状态值正确
  312. if (iStatus == 0) {
  313. // 服务器返回数据结果
  314. NSArray *approvArr = (NSArray *)resultModel.result;
  315. if(approvArr!=nil&&approvArr.count>0)
  316. {
  317. NSDictionary *dic = approvArr[0];
  318. _signFlag = [dic objectForKey:@"SettingValues"];
  319. }
  320. else{
  321. _signFlag = @"0";
  322. }
  323. }
  324. else {
  325. _signFlag = @"0";
  326. }
  327. [self showDeliveryAuthority];
  328. }
  329. /**
  330. 请求失败
  331. @param sender <#sender description#>
  332. */
  333. - (void)onSignLoadFail:(ASIDownManager *)sender {
  334. _signFlag = @"0";
  335. [self cancel];
  336. [self showAlertViewText:@"网络异常"];
  337. }
  338. - (void)onDeliveryLoadFinish:(ASIDownManager *)sender {
  339. // 取消进度条
  340. [self cancel];
  341. // 服务器返回数据转换model
  342. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  343. // 服务器返回数据状态值
  344. int iStatus = resultModel.status;
  345. // 服务器返回数据消息
  346. // 服务器返回数据状态值正确
  347. if (iStatus == 0) {
  348. // 服务器返回数据结果
  349. NSArray *approvArr = (NSArray *)resultModel.result;
  350. if(approvArr!=nil&&approvArr.count>0)
  351. {
  352. NSDictionary *dic = approvArr[0];
  353. _deliveryFlag = [dic objectForKey:@"SettingValues"];
  354. }
  355. else{
  356. _deliveryFlag = @"0";
  357. }
  358. }
  359. else {
  360. _deliveryFlag = @"0";
  361. }
  362. [self showDeliveryAttributeData];
  363. }
  364. /**
  365. 请求失败
  366. @param sender <#sender description#>
  367. */
  368. - (void)onDeliveryLoadFail:(ASIDownManager *)sender {
  369. _deliveryFlag = @"0";
  370. [self cancel];
  371. [self showAlertViewText:@"网络异常"];
  372. }
  373. - (void)onDeliveryAttributeLoadFinish:(ASIDownManager *)sender {
  374. // 取消进度条
  375. [self cancel];
  376. // 服务器返回数据转换model
  377. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  378. // 服务器返回数据状态值
  379. int iStatus = resultModel.status;
  380. // 服务器返回数据消息
  381. // 服务器返回数据状态值正确
  382. if (iStatus == 0) {
  383. // 服务器返回数据结果
  384. NSDictionary *approveDic = (NSDictionary *)resultModel.result;
  385. if(approveDic!=nil)
  386. {
  387. NSArray *approveArray=[approveDic objectForKey:@"Table"];
  388. if(approveArray!=nil&&approveArray.count>0)
  389. {
  390. _deliveryArray=[[NSMutableArray alloc]init];
  391. for(int i=0;i<approveArray.count;i++)
  392. {
  393. NSDictionary *approveDic=[approveArray objectAtIndex:i];
  394. NSInteger deliveryId= [[approveDic objectForKey:@"DictionaryID"]integerValue];
  395. NSString *deliveryValue=[approveDic objectForKey:@"DictionaryValue"];
  396. StatusInfo* s = [[StatusInfo alloc]init];
  397. s.tagName=@"delivery";
  398. s.statusId=[ NSString stringWithFormat:@"%ld" , deliveryId];
  399. s.name=deliveryValue;
  400. [_deliveryArray addObject:s];
  401. }
  402. }
  403. }
  404. }
  405. [self showGoodsAttributeData];
  406. }
  407. /**
  408. 请求失败
  409. @param sender <#sender description#>
  410. */
  411. - (void)onDeliveryAttributeLoadFail:(ASIDownManager *)sender {
  412. [self cancel];
  413. [self showAlertViewText:@"网络异常"];
  414. }
  415. - (void)onGoodsAttributeLoadFinish:(ASIDownManager *)sender {
  416. // 取消进度条
  417. [self cancel];
  418. // 服务器返回数据转换model
  419. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  420. // 服务器返回数据状态值
  421. int iStatus = resultModel.status;
  422. // 服务器返回数据消息
  423. // 服务器返回数据状态值正确
  424. if (iStatus == 0) {
  425. // 服务器返回数据结果
  426. NSDictionary *approveDic = (NSDictionary *)resultModel.result;
  427. if(approveDic!=nil)
  428. {
  429. NSArray *approveArray=[approveDic objectForKey:@"Table"];
  430. if(approveArray!=nil&&approveArray.count>0)
  431. {
  432. _goodsArray=[[NSMutableArray alloc]init];
  433. for(int i=0;i<approveArray.count;i++)
  434. {
  435. NSDictionary *approveDic=[approveArray objectAtIndex:i];
  436. NSInteger deliveryId= [[approveDic objectForKey:@"DictionaryID"]integerValue];
  437. NSString *deliveryValue=[approveDic objectForKey:@"DictionaryValue"];
  438. StatusInfo* s = [[StatusInfo alloc]init];
  439. s.tagName=@"goods";
  440. s.statusId=[ NSString stringWithFormat:@"%ld" , deliveryId];
  441. s.name=deliveryValue;
  442. [_goodsArray addObject:s];
  443. }
  444. }
  445. }
  446. }
  447. }
  448. /**
  449. 请求失败
  450. @param sender <#sender description#>
  451. */
  452. - (void)onGoodsAttributeLoadFail:(ASIDownManager *)sender {
  453. [self cancel];
  454. [self showAlertViewText:@"网络异常"];
  455. }
  456. /**
  457. 保存数据加载完成函数
  458. @param sender <#sender description#>
  459. */
  460. - (void)onSaveLoadFinish:(ASIDownManager *)sender {
  461. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  462. [self cancel];
  463. int iStatus =resultModel.status;
  464. NSString *message = resultModel.message;
  465. self.navigationItem.rightBarButtonItem.enabled = YES;
  466. if (iStatus == 0) {
  467. //[self clearData];//新增后 清除画面的值
  468. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"保存成功!" preferredStyle:UIAlertControllerStyleAlert ];
  469. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
  470. [_parentVC ReloadList];
  471. [self.navigationController popViewControllerAnimated:YES];
  472. }]];
  473. // 3.显示alertController:presentViewController
  474. [self presentViewController:alert animated:YES completion:nil];
  475. }
  476. else if(iStatus == ActionResultStatusAuthError
  477. ||iStatus == ActionResultStatusNoLogin
  478. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  479. [self showReLoginDialog:message];
  480. return;
  481. }
  482. else {
  483. [self showAlertViewText:message];
  484. return;
  485. }
  486. }
  487. /**
  488. 收款方式回调函数
  489. @param model <#model description#>
  490. */
  491. - (void)setPayTypeModel:(PayTypeModel *)model{
  492. [ _receivablesType setTitle:model.settlementTypeName forState:UIControlStateNormal];
  493. _settlementTypeName = model.settlementTypeName;
  494. _settlementType = model.settlementType;
  495. _existsHandlingFee = model.existsHandlingFee;
  496. _earnestFee = model.earnestFee;
  497. _remarks = model.remarks;
  498. }
  499. /**
  500. 单据数据加载完成函数
  501. @param sender <#sender description#>
  502. */
  503. - (void)onLoadFinish:(ASIDownManager *)sender {
  504. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  505. [self cancel];
  506. int iStatus =resultModel.status;
  507. NSString *message = resultModel.message;
  508. if (iStatus == 0) {
  509. NSArray * infoArr;
  510. NSArray * infoHead;
  511. NSDictionary *dicResult =(NSDictionary*) resultModel.result;
  512. if(dicResult != nil){
  513. infoArr = [dicResult objectForKey:@"Table1"];
  514. infoHead = [dicResult objectForKey:@"Table"];
  515. }
  516. if (infoHead == nil|| infoHead.count == 0) {
  517. self.receiptCode.text = @"";
  518. self.sReceiptCode = @"";
  519. [self showAlertViewText:@"该送货单未建安排单,请重新建安排单"];
  520. return;
  521. }
  522. //单据信息 一条数据
  523. BOOL receiptFlg=false;
  524. for (int i = 0; i < infoHead.count; i++) {
  525. NSDictionary *h = infoHead[i];
  526. receiptFlg = (BOOL)[h objectForKey:@"ReceiptFlag"] ;
  527. if (receiptFlg) {
  528. self.receiptFlag = @"1";
  529. }else{
  530. self.receiptFlag = @"0";
  531. }
  532. double receiptAmount = [[h objectForKey:@"ReceiptAmount"] doubleValue];
  533. _sReceiptAmount = [NSString stringWithFormat:@"%0.2f",receiptAmount];
  534. _sCustomerName = [h objectForKey:@"CustomerName"];
  535. _sReceivables = [NSString stringWithFormat:@"%0.2f",[[h objectForKey:@"Receivables"] doubleValue]];
  536. _sReceiptType = [h objectForKey:@"ReceiptType"];
  537. _sNextDeliveryDate = [h objectForKey:@"NextDeliveryDate"];
  538. [_receiptType setEnabled:YES];
  539. if ([_sReceiptType intValue] == 2) {
  540. self.sNextDeliveryDate = [h objectForKey:@"NextinstallDate"];
  541. [self.nextDeliveryDate setTitle:self.sNextDeliveryDate forState:UIControlStateNormal];
  542. [self.receiptType setTitle:@"推迟送货" forState:UIControlStateNormal];
  543. [self.nextDeliveryDate setTitle:_sNextDeliveryDate forState:UIControlStateNormal];//推迟日期
  544. [_nextDeliveryDate setEnabled:YES];
  545. self.receiptAmount.enabled=NO;
  546. [_receivablesType setEnabled:NO];
  547. }else if([_sReceiptType intValue] == 1){
  548. [self.receiptType setTitle:@"完成" forState:UIControlStateNormal];
  549. [self.nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
  550. self.sNextDeliveryDate = @"";
  551. [_nextDeliveryDate setEnabled:NO];
  552. self.receiptAmount.enabled=YES;
  553. [_receivablesType setEnabled:YES];
  554. }
  555. if (([_sReceivables doubleValue] > 0)) {
  556. self.receiptAmount.enabled = YES;
  557. [_receivablesType setEnabled:YES];
  558. }else{
  559. self.receiptAmount.enabled = NO;
  560. [_receivablesType setEnabled:NO];
  561. }
  562. _deliveryId = [NSString stringWithFormat:@"%d",[[h objectForKey:@"DeliveryID"] intValue]];
  563. _receiptAmount.text = _sReceiptAmount;//回执金额
  564. _customerName.text = _sCustomerName;//客户名称
  565. _receivables.text = _sReceivables;//应收金额
  566. _completeReceivables = [NSString stringWithFormat:@"%0.2f",[[h objectForKey:@"CompleteReceivables"] doubleValue]];
  567. if(_completeReceivables == nil){
  568. _completeReceivables = @"";
  569. }
  570. }
  571. [_dataList removeAllObjects];
  572. if(infoArr != nil){
  573. for (int i = 0; i < infoArr.count; i++) {
  574. NSDictionary *info = infoArr[i];
  575. NewDeliveryReceiptModel *mod = [NewDeliveryReceiptModel dk_modelWithDictionary:info];
  576. [_dataList addObject:mod];
  577. }
  578. _vImage.hidden=NO;
  579. [self reloadMyView];
  580. [self.myTableView reloadData];
  581. }
  582. }
  583. else if(iStatus == ActionResultStatusAuthError
  584. ||iStatus == ActionResultStatusNoLogin
  585. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  586. [self showReLoginDialog:message];
  587. return;
  588. }
  589. else {
  590. [self showAlertViewText:message];
  591. }
  592. [self showSignAuthority];
  593. }
  594. /**
  595. 数据加载失败函数
  596. @param sender <#sender description#>
  597. */
  598. - (void)onLoadFail:(ASIDownManager *)sender {
  599. [self cancel];
  600. self.navigationItem.rightBarButtonItem.enabled = YES;
  601. [self showAlertViewText:@"网络异常"];
  602. }
  603. /**
  604. 回执类型回调函数
  605. @param s <#s description#>
  606. */
  607. - (void)showStatusValue:(StatusInfo *)s{
  608. _myCell = [_myTableView cellForRowAtIndexPath:_myRow];
  609. //回执类型回调
  610. if([s.tagName isEqualToString:@"status"]){
  611. _sReceiptType = s.statusId;
  612. [_receiptType setTitle:s.name forState:UIControlStateNormal];
  613. if([_sReceiptType isEqualToString:@"2"]){
  614. //推迟送货
  615. //收款方式
  616. [_receivablesType setEnabled:NO];
  617. _settlementType = @"";
  618. [_receivablesType setTitle:@"请选择收款方式" forState:UIControlStateNormal];
  619. //回执金额
  620. _receiptAmount.text = @"0.000000";
  621. _sReceiptAmount = @"0.000000";
  622. self.receiptAmount.enabled = NO;
  623. //推迟日期
  624. [_nextDeliveryDate setEnabled:YES];
  625. _sNextDeliveryDate = @"";
  626. [self.nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
  627. //列表
  628. for(NewDeliveryReceiptModel *model in _dataList){
  629. model.receiptType = @"1";
  630. model.receiptQuantity = @"0";
  631. }
  632. }
  633. else{
  634. //完成状态
  635. //推迟日期
  636. [_nextDeliveryDate setEnabled:NO];
  637. [self.nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
  638. _sNextDeliveryDate = @"";
  639. if (([_sReceivables doubleValue] > 0)) {
  640. self.receiptAmount.enabled = YES;
  641. [_receivablesType setEnabled:YES];
  642. }else{
  643. self.receiptAmount.enabled = NO;
  644. [_receivablesType setEnabled:NO];
  645. }
  646. }
  647. }
  648. //选择Cell回执状态回调
  649. if([s.tagName isEqualToString:@"cell"]){
  650. switch ([s.statusId intValue]) {
  651. case 1:
  652. [_myCell.btstate setTitle:@"完成" forState:UIControlStateNormal];
  653. _myCell.model.receiptType = @"1";
  654. break;
  655. case 2:
  656. [_myCell.btstate setTitle:@"再送" forState:UIControlStateNormal];
  657. _myCell.model.receiptType = @"2";
  658. [_myCell.receiptQuantity addTarget:self action:@selector(receiptQuantityValueChanged) forControlEvents:UIControlEventAllEditingEvents];
  659. break;
  660. case 3:
  661. [_myCell.btstate setTitle:@"换货" forState:UIControlStateNormal];
  662. _myCell.model.receiptType = @"3";
  663. break;
  664. case 4:
  665. [_myCell.btstate setTitle:@"退货" forState:UIControlStateNormal];
  666. _myCell.model.receiptType = @"4";
  667. break;
  668. default:
  669. break;
  670. }
  671. }
  672. if([s.tagName isEqualToString:@"sign"])
  673. {
  674. _signName=s.name;
  675. [_btnSign setTitle:s.name forState:UIControlStateNormal];
  676. }
  677. if([s.tagName isEqualToString:@"delivery"])
  678. {
  679. _deliveryAttributeId=s.statusId;
  680. [_btnDeliveryAttribute setTitle:s.name forState:UIControlStateNormal];
  681. }
  682. if([s.tagName isEqualToString:@"goods"])
  683. {
  684. _goodsAttributeId=s.statusId;
  685. [_btnGoodsAttribute setTitle:s.name forState:UIControlStateNormal];
  686. }
  687. [_myTableView reloadData];
  688. }
  689. /**
  690. 文本框的长度限制 实现监听方法
  691. @param sender <#sender description#>
  692. */
  693. - (void)onFocusPeopleEditingChanged:(NSNotification *)sender
  694. {
  695. UITextField *textField = (UITextField *)sender.object;
  696. NSString *toBeString = textField.text;
  697. NSString *lang = [[UIApplication sharedApplication]textInputMode].primaryLanguage;
  698. int kMaxLength = 0;
  699. if([textField isEqual:self.receiptAmount]){
  700. kMaxLength = 17;
  701. if (toBeString != nil && toBeString.length > 0 && [toBeString floatValue] -MAXIMUM_QUANTITY > 0.0000000001f) {
  702. textField.text = MAX_COUNT;
  703. toBeString = MAX_COUNT;
  704. }
  705. }
  706. if ([lang isEqualToString:@"zh-Hans"]) {
  707. UITextRange *selectedRange = [textField markedTextRange];
  708. UITextPosition *position = [textField positionFromPosition:selectedRange.start offset:0];
  709. if (!position) {
  710. if (toBeString.length > kMaxLength) {
  711. textField.text = [toBeString substringToIndex:kMaxLength];
  712. }
  713. }
  714. }else{
  715. if (toBeString.length > kMaxLength) {
  716. textField.text = [toBeString substringToIndex:kMaxLength];
  717. }
  718. }
  719. }
  720. /**
  721. 限制用户输入小数点后位数的方法
  722. @param textField <#textField description#>
  723. @param range <#range description#>
  724. @param string <#string description#>
  725. @return <#return value description#>
  726. */
  727. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  728. if ([textField isEqual:self.receiptCode]){
  729. return YES;
  730. }
  731. if ([textField.text rangeOfString:@"."].location == NSNotFound) {
  732. _isHaveDian = NO;
  733. }
  734. if ([string length] > 0) {
  735. unichar single = [string characterAtIndex:0];//当前输入的字符
  736. if ((single >= '0' && single <= '9') || single == '.') {//数据格式正确
  737. //首字母不能为0和小数点
  738. if([textField.text length] == 0){
  739. if(single == '.') {
  740. [self showAlertViewText:@"第一个数字不能为小数点"];
  741. [textField.text stringByReplacingCharactersInRange:range withString:@""];
  742. return NO;
  743. }
  744. }
  745. if([textField.text length] == 1 && [[textField.text substringToIndex:1] isEqualToString: @"0"]){
  746. if(!(single == '.')) {
  747. [textField.text stringByReplacingCharactersInRange:range withString:@""];
  748. return NO;
  749. }
  750. }
  751. //输入的字符是否是小数点
  752. if (single == '.') {
  753. if(!_isHaveDian)//text中还没有小数点
  754. {
  755. _isHaveDian = YES;
  756. return YES;
  757. }else{
  758. [self showAlertViewText:@"您已经输入过小数点了"];
  759. [textField.text stringByReplacingCharactersInRange:range withString:@""];
  760. return NO;
  761. }
  762. }else{
  763. if (_isHaveDian) {//存在小数点
  764. //判断小数点的位数
  765. NSRange ran = [textField.text rangeOfString:@"."];
  766. if (range.location - ran.location <= 6) {
  767. return YES;
  768. }else{
  769. //[self showAlertViewText:@"亲,您最多输入两位小数"];
  770. return NO;
  771. }
  772. }else{
  773. return YES;
  774. }
  775. }
  776. }else{//输入的数据格式不正确
  777. [self showAlertViewText:@"您输入的格式不正确"];
  778. [textField.text stringByReplacingCharactersInRange:range withString:@""];
  779. return NO;
  780. }
  781. }
  782. else
  783. {
  784. return YES;
  785. }
  786. }
  787. /**
  788. 相册回调事件
  789. @param assets <#assets description#>
  790. */
  791. - (void)pickerViewControllerDoneAsstes:(NSArray *)assets{
  792. for (int i = (int)self.assets.count - 1;i >= 0;i-- ) {
  793. if ([self.assets[i] isKindOfClass:[DKPhotoAssets class]]) {
  794. [self.assets removeObject:self.assets[i]];
  795. }
  796. }
  797. for (DKPhotoAssets* asset in assets ) {
  798. if ([asset isKindOfClass:[DKPhotoAssets class]]) {
  799. [self.assets addObject:asset];
  800. }
  801. }
  802. [self.collectionView reloadData];
  803. [self reloadMyView];
  804. }
  805. /**
  806. Cell回执类型回调函数
  807. */
  808. - (void)setReceiptType:path{
  809. _myRow= path;
  810. NewDeliveryReceiptModel *mode = _dataList[_myRow.row];
  811. if([mode.sourceFrom intValue] == 1){
  812. [self initStatus2:YES];
  813. }else{
  814. [self initStatus2:NO];
  815. }
  816. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  817. tc.sdelegate=self;
  818. [tc.arrFilter addObjectsFromArray: _arrayStatus];
  819. [self.navigationController pushViewController:tc animated:YES];
  820. self.hidesBottomBarWhenPushed = NO;
  821. }
  822. /**
  823. 选中位置回调事件
  824. @param name <#name description#>
  825. */
  826. - (void)relocationData:(NSString *)name{
  827. _lblPosition.text = name;
  828. _positionImage.hidden = NO;
  829. [self reloadMyView];
  830. }
  831. /**
  832. table view的分区数
  833. @param tableView <#tableView description#>
  834. @return <#return value description#>
  835. */
  836. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  837. {
  838. return 1;
  839. }
  840. /**
  841. table view的行数
  842. @param tableView <#tableView description#>
  843. @param section <#section description#>
  844. @return <#return value description#>
  845. */
  846. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  847. {
  848. return [_dataList count];
  849. }
  850. /**
  851. table view的高度
  852. @param tableView <#tableView description#>
  853. @param indexPath <#indexPath description#>
  854. @return <#return value description#>
  855. */
  856. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  857. return 197;
  858. }
  859. /**
  860. 获取tableview cell
  861. @param tableView <#tableView description#>
  862. @param indexPath <#indexPath description#>
  863. @return <#return value description#>
  864. */
  865. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  866. NSString *CellIdentifier = @"DataListTableViewCell";
  867. NewDeliveryListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  868. cell = [[NewDeliveryListTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  869. cell.delegate = self;
  870. cell.nddelegate = self;
  871. cell.receiptQuantity.delegate = self;
  872. cell.receiptQuantity.tag = indexPath.row;
  873. NewDeliveryReceiptModel *datamodel = [_dataList objectAtIndex:indexPath.row];
  874. cell.myIndexPath = indexPath;
  875. cell.cellIndex = indexPath.row;
  876. [cell parseInfoModel:datamodel receiptType:_sReceiptType];
  877. return cell;
  878. }
  879. /**
  880. cellection view的分区数
  881. @param collectionView <#collectionView description#>
  882. @return <#return value description#>
  883. */
  884. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  885. return 1;
  886. }
  887. /**
  888. collection view的项数
  889. @param collectionView <#collectionView description#>
  890. @param section <#section description#>
  891. @return <#return value description#>
  892. */
  893. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  894. return [self.assets count];
  895. }
  896. /**
  897. 获取collectionview cell
  898. @param collectionView <#collectionView description#>
  899. @param indexPath <#indexPath description#>
  900. @return <#return value description#>
  901. */
  902. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  903. DKUICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DKUICollectionViewCell" forIndexPath:indexPath];
  904. // 判断类型来获取Image
  905. DKPhotoAssets *asset = self.assets[indexPath.item];
  906. if ([asset isKindOfClass:[DKPhotoAssets class]]) {
  907. cell.imageView.image = asset.thumbImage;
  908. }
  909. else if ([asset isKindOfClass:[NSString class]]){
  910. [cell.imageView sd_setImageWithURL:[NSURL URLWithString:(NSString *)asset] placeholderImage:[UIImage imageNamed:@"wallpaper_placeholder"]];
  911. }
  912. else if([asset isKindOfClass:[UIImage class]]){
  913. cell.imageView.image = (UIImage *)asset;
  914. }
  915. else if ([asset isKindOfClass:[DKCamera class]]){
  916. cell.imageView.image = [asset thumbImage];
  917. }
  918. return cell;
  919. }
  920. /**
  921. collectionview图片放大
  922. @param collectionView <#collectionView description#>
  923. @param indexPath <#indexPath description#>
  924. */
  925. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  926. DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
  927. // 图片游览器
  928. DKPhotoPickerBrowserViewController *pickerBrowser = [[DKPhotoPickerBrowserViewController alloc] init];
  929. // 传入点击图片View的话,会有微信朋友圈照片的风格
  930. pickerBrowser.toView = cell.imageView;
  931. // 数据源/delegate
  932. pickerBrowser.delegate = self;
  933. pickerBrowser.dataSource = self;
  934. // 是否可以删除照片
  935. pickerBrowser.editing = YES;
  936. // 当前选中的值
  937. pickerBrowser.currentIndexPath = [NSIndexPath indexPathForItem:indexPath.row inSection:0];
  938. // 展示控制器
  939. [pickerBrowser show];
  940. }
  941. /**
  942. collectionview的分区数
  943. @param pickerBrowser <#pickerBrowser description#>
  944. @return <#return value description#>
  945. */
  946. - (NSInteger)numberOfSectionInPhotosInPickerBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser{
  947. return 1;
  948. }
  949. /**
  950. collection view的项数
  951. @param photoBrowser <#photoBrowser description#>
  952. @param section <#section description#>
  953. @return <#return value description#>
  954. */
  955. - (NSInteger)photoBrowser:(DKPhotoPickerBrowserViewController *)photoBrowser numberOfItemsInSection:(NSUInteger)section{
  956. return [self.assets count];
  957. }
  958. /**
  959. collection view放大函数
  960. @param pickerBrowser <#pickerBrowser description#>
  961. @param indexPath <#indexPath description#>
  962. @return <#return value description#>
  963. */
  964. - (DKPhotoPickerBrowserPhoto *)photoBrowser:(DKPhotoPickerBrowserViewController *)pickerBrowser photoAtIndexPath:(NSIndexPath *)indexPath{
  965. id imageObj = [self.assets objectAtIndex:indexPath.item];
  966. DKPhotoPickerBrowserPhoto *photo = [DKPhotoPickerBrowserPhoto photoAnyImageObjWith:imageObj];
  967. // 包装下imageObj 成 DKPhotoPickerBrowserPhoto 传给数据源
  968. DKUICollectionViewCell *cell = (DKUICollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
  969. // 缩略图
  970. photo.thumbImage = cell.imageView.image;
  971. return photo;
  972. }
  973. /**
  974. collection view删除图片函数
  975. @return <#return value description#>
  976. */
  977. #pragma mark - <DKPhotoPickerBrowserViewControllerDelegate>
  978. - (void)photoBrowser:(DKPhotoPickerBrowserViewController *)photoBrowser removePhotoAtIndexPath:(NSIndexPath *)indexPath{
  979. if (indexPath.row > [self.assets count]) return;
  980. [self.assets removeObjectAtIndex:indexPath.row];
  981. [self.collectionView reloadData];
  982. [self reloadMyView];
  983. }
  984. #pragma mark - 私有函数
  985. /**
  986. 加载单据信息
  987. @param code <#code description#>
  988. */
  989. - (void)reloadDataWithOnlyCode:(NSString *)code
  990. {
  991. self.receiptCode.text = code;
  992. self.sReceiptCode = code;
  993. double delayInSeconds = 0.5;
  994. dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
  995. dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
  996. [self loadDataSource];
  997. });
  998. }
  999. /**
  1000. 键盘隐藏函数
  1001. @param tap <#tap description#>
  1002. */
  1003. - (void)keyboardHide:(UITapGestureRecognizer*)tap{
  1004. [self.view endEditing:YES];
  1005. }
  1006. /**
  1007. 初始化布局函数
  1008. */
  1009. - (void)initUI{
  1010. //返回
  1011. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  1012. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  1013. [button addTarget:self action:@selector(goBack)
  1014. forControlEvents:UIControlEventTouchUpInside];
  1015. button.frame = CGRectMake(0, 0,45,22);
  1016. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  1017. self.navigationItem.leftBarButtonItem = menuButton;
  1018. scroll = [UIScrollView new];
  1019. scroll.delegate = self;
  1020. scroll.frame=self.view.bounds;
  1021. scroll.tag=1000;
  1022. [self.view addSubview:scroll];
  1023. if(Screen_Height2 <= 480){
  1024. scroll.contentSize=CGSizeMake(self.view.frame.size.width, self.view.frame.size.height + 80);
  1025. }
  1026. contentView = [[UIView alloc]init];
  1027. contentView.frame=CGRectZero;
  1028. contentView.backgroundColor = [UIColor whiteColor];
  1029. UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
  1030. //设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。
  1031. tapGestureRecognizer.cancelsTouchesInView = NO;
  1032. // //将触摸事件添加到当前view
  1033. [scroll addGestureRecognizer:tapGestureRecognizer];
  1034. [scroll addSubview:contentView];
  1035. //送货单号--------------
  1036. UIView *vReceiptCode = [UIView new];
  1037. vReceiptCode.frame=CGRectMake(0, 5, Screen_Width,40);
  1038. [contentView addSubview:vReceiptCode];
  1039. UILabel *lblTxtReceiptCode = [UILabel new];
  1040. lblTxtReceiptCode.frame=CGRectMake(20, 5, 90, 25);
  1041. lblTxtReceiptCode.text = @"送货单号:";
  1042. lblTxtReceiptCode.font=kTitleFont;
  1043. [vReceiptCode addSubview:lblTxtReceiptCode];
  1044. _receiptCode = [UITextField new];
  1045. _receiptCode.frame = CGRectMake(95, 5, Screen_Width - 95 - 20, 25);
  1046. _receiptCode.font = kTextFont;
  1047. _receiptCode.placeholder = @"输入送货单号";
  1048. _receiptCode.tag = 100;
  1049. [vReceiptCode addSubview:_receiptCode];
  1050. UIView *fReceiptCode = [[UIView alloc] initWithFrame:CGRectMake(0, 35,Screen_Width ,5)];
  1051. fReceiptCode.backgroundColor = LineBackgroundColor;
  1052. [vReceiptCode addSubview:fReceiptCode];
  1053. //客户姓名--------------
  1054. UIView *vCustomerName = [UIView new];
  1055. vCustomerName.frame = CGRectMake(0,CGRectGetMaxY(vReceiptCode.frame) + 8, Screen_Width, 31);
  1056. [contentView addSubview:vCustomerName];
  1057. UILabel *lblTxtVCustomerName = [UILabel new];
  1058. lblTxtVCustomerName.frame = CGRectMake(20, 3, 90, 25);
  1059. lblTxtVCustomerName.text = @"客户名称:";
  1060. lblTxtVCustomerName.font = kTextFont;
  1061. [vCustomerName addSubview:lblTxtVCustomerName];
  1062. _customerName = [UILabel new];
  1063. _customerName.font = kTextFont;
  1064. _customerName.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
  1065. [vCustomerName addSubview:_customerName];
  1066. //应收金额--------------
  1067. UIView *vReceivables = [UIView new];
  1068. vReceivables.frame=CGRectMake(0,CGRectGetMaxY(vCustomerName.frame) + 8, Screen_Width, 31);
  1069. [contentView addSubview:vReceivables];
  1070. UILabel *lblTxtVReceivables = [UILabel new];
  1071. lblTxtVReceivables.frame = CGRectMake(20, 3, 90, 25);
  1072. lblTxtVReceivables.text = @"应收金额:";
  1073. lblTxtVReceivables.font = kTextFont;
  1074. [vReceivables addSubview:lblTxtVReceivables];
  1075. _receivables = [UILabel new];
  1076. _receivables.font = kTextFont;
  1077. _receivables.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
  1078. [vReceivables addSubview:_receivables];
  1079. //回执类型--------------
  1080. UIView *vReceiptType = [UIView new];
  1081. vReceiptType.frame = CGRectMake(0,CGRectGetMaxY(vReceivables.frame)+8, Screen_Width, 31);
  1082. [contentView addSubview:vReceiptType];
  1083. UILabel *lblTxtVReceiptType = [UILabel new];
  1084. lblTxtVReceiptType.frame = CGRectMake(20, 3, 90, 25);
  1085. lblTxtVReceiptType.text = @"回执类型:";
  1086. lblTxtVReceiptType.font = kTextFont;
  1087. [vReceiptType addSubview:lblTxtVReceiptType];
  1088. _receiptType = [UIButton buttonWithType:UIButtonTypeCustom];
  1089. _receiptType.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1090. _receiptType.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
  1091. _receiptType.frame=CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
  1092. _receiptType.titleLabel.font= kTextFont;
  1093. [_receiptType setTitle:@"请选择回执类型" forState:UIControlStateNormal];
  1094. [_receiptType setTitleColor:[UIColor colorWithWhite:0 alpha:1] forState:UIControlStateNormal];
  1095. [_receiptType addTarget:self action:@selector(showReceiptType) forControlEvents:UIControlEventTouchUpInside];
  1096. [_receiptType setEnabled:NO];
  1097. [vReceiptType addSubview:_receiptType];
  1098. UIButton *jiantou1 = [UIButton buttonWithType:UIButtonTypeCustom];
  1099. jiantou1.frame=CGRectMake(Screen_Width -17,8,7,12);
  1100. [ jiantou1 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
  1101. [vReceiptType addSubview:jiantou1];
  1102. //=收款方式--------------
  1103. UIView *vReceivablesType = [UIView new];
  1104. vReceivablesType.frame = CGRectMake(0,CGRectGetMaxY(vReceiptType.frame)+8, Screen_Width, 31);
  1105. [contentView addSubview:vReceivablesType];
  1106. UILabel *lblTxtVReceivablesType = [UILabel new];
  1107. lblTxtVReceivablesType.frame = CGRectMake(20, 3, 90, 25);
  1108. lblTxtVReceivablesType.text = @"收款方式:";
  1109. lblTxtVReceivablesType.font = kTextFont;
  1110. [vReceivablesType addSubview:lblTxtVReceivablesType];
  1111. _receivablesType = [UIButton buttonWithType:UIButtonTypeCustom];
  1112. _receivablesType.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1113. _receivablesType.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
  1114. _receivablesType.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
  1115. _receivablesType.titleLabel.font = kTextFont;
  1116. [_receivablesType setTitle:@"请选择收款方式" forState:UIControlStateNormal];
  1117. [_receivablesType setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
  1118. [_receivablesType addTarget:self action:@selector(showReceivablesType) forControlEvents:UIControlEventTouchUpInside];
  1119. [_receivablesType setEnabled:NO];
  1120. [vReceivablesType addSubview:_receivablesType];
  1121. UIButton *jiantou2 = [UIButton buttonWithType:UIButtonTypeCustom];
  1122. jiantou2.frame = CGRectMake(Screen_Width - 17,8,7,12);
  1123. [ jiantou2 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
  1124. [vReceivablesType addSubview:jiantou2];
  1125. UIView *vSign = [UIView new];
  1126. vSign.frame = CGRectMake(0,CGRectGetMaxY(vReceivablesType.frame)+8, Screen_Width, 31);
  1127. [contentView addSubview:vSign];
  1128. UILabel *lblTxtSign = [UILabel new];
  1129. lblTxtSign.frame = CGRectMake(20, 3, 90, 25);
  1130. lblTxtSign.text = @"是否签收:";
  1131. lblTxtSign.font = kTextFont;
  1132. [vSign addSubview:lblTxtSign];
  1133. _btnSign = [UIButton buttonWithType:UIButtonTypeCustom];
  1134. _btnSign.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1135. _btnSign.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
  1136. _btnSign.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
  1137. _btnSign.titleLabel.font = kTextFont;
  1138. [_btnSign setTitle:@"请选择签收" forState:UIControlStateNormal];
  1139. [_btnSign setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
  1140. [_btnSign addTarget:self action:@selector(showSign) forControlEvents:UIControlEventTouchUpInside];
  1141. [vSign addSubview:_btnSign];
  1142. UIButton *jiantou3 = [UIButton buttonWithType:UIButtonTypeCustom];
  1143. jiantou3.frame = CGRectMake(Screen_Width - 17,8,7,12);
  1144. [ jiantou3 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
  1145. [vSign addSubview:jiantou3];
  1146. UIView *vDeliveryAttribute = [UIView new];
  1147. vDeliveryAttribute.frame = CGRectMake(0,CGRectGetMaxY(vSign.frame)+8, Screen_Width, 31);
  1148. [contentView addSubview:vDeliveryAttribute];
  1149. UILabel *lblTxtDeliveryAttribute = [UILabel new];
  1150. lblTxtDeliveryAttribute.frame = CGRectMake(20, 3, 90, 25);
  1151. lblTxtDeliveryAttribute.text = @"配送属性:";
  1152. lblTxtDeliveryAttribute.font = kTextFont;
  1153. [vDeliveryAttribute addSubview:lblTxtDeliveryAttribute];
  1154. _btnDeliveryAttribute = [UIButton buttonWithType:UIButtonTypeCustom];
  1155. _btnDeliveryAttribute.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1156. _btnDeliveryAttribute.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
  1157. _btnDeliveryAttribute.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
  1158. _btnDeliveryAttribute.titleLabel.font = kTextFont;
  1159. [_btnDeliveryAttribute setTitle:@"请选择配送属性" forState:UIControlStateNormal];
  1160. [_btnDeliveryAttribute setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
  1161. [_btnDeliveryAttribute addTarget:self action:@selector(showDeliveryAttribute) forControlEvents:UIControlEventTouchUpInside];
  1162. [vDeliveryAttribute addSubview:_btnDeliveryAttribute];
  1163. UIButton *jiantou4 = [UIButton buttonWithType:UIButtonTypeCustom];
  1164. jiantou4.frame = CGRectMake(Screen_Width - 17,8,7,12);
  1165. [ jiantou4 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
  1166. [vDeliveryAttribute addSubview:jiantou4];
  1167. UIView *vGoodsAttribute = [UIView new];
  1168. vGoodsAttribute.frame = CGRectMake(0,CGRectGetMaxY(vDeliveryAttribute.frame)+8, Screen_Width, 31);
  1169. [contentView addSubview:vGoodsAttribute];
  1170. UILabel *lblTxtGoodsAttribute = [UILabel new];
  1171. lblTxtGoodsAttribute.frame = CGRectMake(20, 3, 90, 25);
  1172. lblTxtGoodsAttribute.text = @"货物属性:";
  1173. lblTxtGoodsAttribute.font = kTextFont;
  1174. [vGoodsAttribute addSubview:lblTxtGoodsAttribute];
  1175. _btnGoodsAttribute = [UIButton buttonWithType:UIButtonTypeCustom];
  1176. _btnGoodsAttribute.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1177. _btnGoodsAttribute.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
  1178. _btnGoodsAttribute.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
  1179. _btnGoodsAttribute.titleLabel.font = kTextFont;
  1180. [_btnGoodsAttribute setTitle:@"请选择货物属性" forState:UIControlStateNormal];
  1181. [_btnGoodsAttribute setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
  1182. [_btnGoodsAttribute addTarget:self action:@selector(showGoodsAttribute) forControlEvents:UIControlEventTouchUpInside];
  1183. [vGoodsAttribute addSubview:_btnGoodsAttribute];
  1184. UIButton *jiantou5 = [UIButton buttonWithType:UIButtonTypeCustom];
  1185. jiantou5.frame = CGRectMake(Screen_Width - 17,8,7,12);
  1186. [ jiantou5 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
  1187. [vGoodsAttribute addSubview:jiantou5];
  1188. //回执金额--------------
  1189. UIView *vReceiptAmount = [UIView new];
  1190. vReceiptAmount.frame = CGRectMake(0,CGRectGetMaxY(vGoodsAttribute.frame) + 8, Screen_Width, 31);
  1191. [contentView addSubview:vReceiptAmount];
  1192. UILabel *lblTxtReceiptAmount = [UILabel new];
  1193. lblTxtReceiptAmount.frame = CGRectMake(20, 3, 90, 25);
  1194. lblTxtReceiptAmount.text = @"回执金额:";
  1195. lblTxtReceiptAmount.font = kTextFont;
  1196. [vReceiptAmount addSubview:lblTxtReceiptAmount];
  1197. _receiptAmount = [UITextField new];
  1198. _receiptAmount.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
  1199. _receiptAmount.font = kTextFont;
  1200. _receiptAmount.placeholder = @"输入回执金额";
  1201. _receiptAmount.delegate = self;
  1202. [_receiptAmount setEnabled:NO];
  1203. _receiptAmount.keyboardType = UIKeyboardTypeDecimalPad;
  1204. [vReceiptAmount addSubview:_receiptAmount];
  1205. UILabel *lblTxtunit = [UILabel new];
  1206. lblTxtunit.frame = CGRectMake(Screen_Width - 40, 3, 30, 25);
  1207. lblTxtunit.text = @"元";
  1208. lblTxtunit.font = kTextFont;
  1209. lblTxtunit.textAlignment = NSTextAlignmentRight;
  1210. [vReceiptAmount addSubview:lblTxtunit];
  1211. //推迟日期--------------
  1212. _vNextDeliveryDate = [UIView new];
  1213. _vNextDeliveryDate.frame = CGRectMake(0,CGRectGetMaxY(vReceiptAmount.frame) + 8, Screen_Width, 34);
  1214. [contentView addSubview:_vNextDeliveryDate];
  1215. UILabel *lblTxtVNextDeliveryDate = [UILabel new];
  1216. lblTxtVNextDeliveryDate.frame = CGRectMake(20, 3, 90, 25);
  1217. lblTxtVNextDeliveryDate.text = @"推迟日期:";
  1218. lblTxtVNextDeliveryDate.font = kTextFont;
  1219. [_vNextDeliveryDate addSubview:lblTxtVNextDeliveryDate];
  1220. _nextDeliveryDate = [UIButton buttonWithType:UIButtonTypeCustom];
  1221. _nextDeliveryDate.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1222. _nextDeliveryDate.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
  1223. _nextDeliveryDate.frame = CGRectMake(95, 3, Screen_Width - 95 - 30, 25);
  1224. _nextDeliveryDate.titleLabel.font = kTextFont;
  1225. [_nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
  1226. [_nextDeliveryDate setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:UIControlStateNormal];
  1227. [_nextDeliveryDate addTarget:self action:@selector(showNextDeliveryDate) forControlEvents:UIControlEventTouchUpInside];
  1228. [_nextDeliveryDate setEnabled:NO];
  1229. [_vNextDeliveryDate addSubview:_nextDeliveryDate];
  1230. UIButton *jiantou6 = [UIButton buttonWithType:UIButtonTypeCustom];
  1231. jiantou6.frame = CGRectMake(Screen_Width-17,8,7,12);
  1232. [ jiantou6 setImage:[UIImage imageNamed:@"rightarrow"] forState:UIControlStateNormal];
  1233. [_vNextDeliveryDate addSubview:jiantou6];
  1234. //分割线
  1235. UIView *fNextDeliveryDate = [[UIView alloc]initWithFrame:CGRectMake(0, 30, Screen_Width, 3)];
  1236. fNextDeliveryDate.backgroundColor = LineBackgroundColor;
  1237. [_vNextDeliveryDate addSubview:fNextDeliveryDate];
  1238. self.myTableView = [[UITableView alloc]init];
  1239. self.myTableView.dataSource = self;
  1240. self.myTableView.delegate = self;
  1241. self.myTableView.scrollEnabled = NO;
  1242. self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  1243. self.myTableView.frame = CGRectMake(0,CGRectGetMaxY(_vNextDeliveryDate.frame), self.view.bounds.size.width, [self getDataViewHeight:_dataList]) ;
  1244. [contentView addSubview:self.myTableView];
  1245. _vCollectionView = [UIView new];
  1246. _vCollectionView.frame = CGRectMake(0,CGRectGetMaxY(self.myTableView.frame) + 8, Screen_Width, 0);
  1247. [contentView addSubview:_vCollectionView];
  1248. [self setupCollectionView];
  1249. _positionImage = [UIView new];
  1250. _positionImage.frame=CGRectMake(0, CGRectGetMaxY(_vCollectionView.frame), Screen_Width, 0);
  1251. [contentView addSubview:_positionImage];
  1252. //星号
  1253. _ivPosition = [UIImageView new];
  1254. _ivPosition.frame=CGRectMake(12,20,9,12);
  1255. [_positionImage addSubview:_ivPosition];
  1256. _lblPosition = [UILabel new];
  1257. _lblPosition.font=kTextFont;
  1258. _lblPosition.frame=CGRectMake(32, 16, Screen_Width-32, 20);
  1259. [_positionImage addSubview:_lblPosition];
  1260. //照相和相册 —————————
  1261. _vImage = [UIView new];
  1262. _vImage.frame=CGRectMake(0,CGRectGetMaxY(_positionImage.frame), Screen_Width-32, 30);
  1263. contentView.frame=CGRectMake(0, 0, Screen_Width,CGRectGetMaxY(_vImage.frame));
  1264. [contentView addSubview:_vImage];
  1265. CGFloat width = (SCREENWIDTH-70)/2;
  1266. CustomButton *btnPhoto = [[CustomButton alloc]initWithFrame:CGRectMake(width-90, 0, 70, 20) andImage:[UIImage imageNamed:@"icon_takephoto"] addText:@"照相" addImageWidth:15 addImageHeight:12];
  1267. [btnPhoto addTarget:self action:@selector(selectCamera) forControlEvents:(UIControlEventTouchUpInside)];
  1268. [_vImage addSubview:btnPhoto];
  1269. CustomButton *btn = [[CustomButton alloc]initWithFrame:CGRectMake(width, 0,70 , 20) andImage:[UIImage imageNamed:@"icon_photo"] addText:@"相册" addImageWidth:14 addImageHeight:15];
  1270. [btn addTarget:self action:@selector(selectPhotos) forControlEvents:(UIControlEventTouchUpInside)];
  1271. [_vImage addSubview:btn];
  1272. CustomButton *btnLoaction = [[CustomButton alloc]initWithFrame:CGRectMake(width+85, 0,100 , 20) andImage:[UIImage imageNamed:@"icon_position"] addText:@"所在位置" addImageWidth:13 addImageHeight:16];
  1273. [btnLoaction addTarget:self action:@selector(newMap) forControlEvents:(UIControlEventTouchUpInside)];
  1274. [_vImage addSubview:btnLoaction];
  1275. _vImage.hidden=YES;
  1276. contentView.frame=CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(_vImage.frame));
  1277. //保存按钮
  1278. UIImage *pic = [UIImage imageNamed:@"bt_datasave"];
  1279. CGFloat h = (Screen_Width - 40) * pic.size.height / pic.size.width;
  1280. _saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1281. _saveBtn.frame=CGRectMake(20, Screen_Height- h - 5 - rectStatusHeight-rectNavHeight-10, Screen_Width - 40,h) ;
  1282. [_saveBtn setBackgroundImage:pic forState:UIControlStateNormal];
  1283. [_saveBtn addTarget:self action:@selector(saveData) forControlEvents:UIControlEventTouchUpInside];
  1284. [self.view addSubview:_saveBtn];
  1285. }
  1286. /**
  1287. 键盘弹出函数
  1288. */
  1289. - (void)myKeyboardWillShow {
  1290. if(!keyboardShow){
  1291. [UIView animateWithDuration:0.3f animations:^ {
  1292. 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);
  1293. }];
  1294. }
  1295. keyboardShow=YES;
  1296. }
  1297. /**
  1298. 键盘隐藏函数
  1299. */
  1300. - (void)keyboardWillHide {
  1301. // Animate the current view back to its original position
  1302. if(keyboardShow){
  1303. [UIView animateWithDuration:0.0f animations:^ {
  1304. 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);
  1305. }];}
  1306. keyboardShow=NO;
  1307. }
  1308. /**
  1309. 总单回执类型
  1310. */
  1311. - (void)showReceiptType{
  1312. self.hidesBottomBarWhenPushed=YES;
  1313. [self initStatus];
  1314. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  1315. tc.sdelegate=self;
  1316. [tc.arrFilter addObjectsFromArray: _arrayDStatus];
  1317. [self.navigationController pushViewController:tc animated:YES];
  1318. self.hidesBottomBarWhenPushed=NO;
  1319. }
  1320. -(void)showSign
  1321. {
  1322. self.hidesBottomBarWhenPushed=YES;
  1323. [self initSignData];
  1324. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  1325. tc.sdelegate=self;
  1326. [tc.arrFilter addObjectsFromArray: _signArray];
  1327. [self.navigationController pushViewController:tc animated:YES];
  1328. self.hidesBottomBarWhenPushed=NO;
  1329. }
  1330. -(void)showDeliveryAttribute
  1331. {
  1332. if(_deliveryArray!=nil&&_deliveryArray.count>0)
  1333. {
  1334. self.hidesBottomBarWhenPushed=YES;
  1335. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  1336. tc.sdelegate=self;
  1337. [tc.arrFilter addObjectsFromArray: _deliveryArray];
  1338. [self.navigationController pushViewController:tc animated:YES];
  1339. self.hidesBottomBarWhenPushed=NO;
  1340. }
  1341. }
  1342. -(void)showGoodsAttribute
  1343. {
  1344. if(_goodsArray!=nil&&_goodsArray.count>0)
  1345. {
  1346. self.hidesBottomBarWhenPushed=YES;
  1347. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  1348. tc.sdelegate=self;
  1349. [tc.arrFilter addObjectsFromArray: _goodsArray];
  1350. [self.navigationController pushViewController:tc animated:YES];
  1351. self.hidesBottomBarWhenPushed=NO;
  1352. }
  1353. }
  1354. /**
  1355. 重新计算视图的位置
  1356. */
  1357. - (void)reloadMyView{
  1358. self.myTableView.frame=CGRectMake(0,CGRectGetMaxY(_vNextDeliveryDate.frame), self.view.bounds.size.width, [self getDataViewHeight:_dataList]) ;
  1359. _vCollectionView.frame=CGRectMake(0,CGRectGetMaxY(self.myTableView.frame), Screen_Width, [Util getPhotoCollectionViewHeightWithPhotos: _assets]);
  1360. self.collectionView.frame=CGRectMake(0, 0,Screen_Width,[Util getPhotoCollectionViewHeightWithPhotos: _assets]);
  1361. if (_lblPosition.text.length > 0){
  1362. _ivPosition.image = [UIImage imageNamed:@"log_position"];
  1363. _positionImage.frame=CGRectMake(0, CGRectGetMaxY(_vCollectionView.frame)-8, Screen_Width, 30);
  1364. }
  1365. else{
  1366. _positionImage.frame=CGRectMake(0, CGRectGetMaxY(_vCollectionView.frame)-8, Screen_Width,0);
  1367. }
  1368. _vImage.frame=CGRectMake(0,CGRectGetMaxY(_positionImage.frame)+8, Screen_Width, 30);
  1369. contentView.frame=CGRectMake(0,0,self.view.bounds.size.width,CGRectGetMaxY(_vImage.frame));
  1370. scroll.contentSize=CGSizeMake(self.view.frame.size.width, contentView.frame.size.height + 150);
  1371. }
  1372. /**
  1373. 回执数量变化函数
  1374. */
  1375. - (void)receiptQuantityValueChanged{
  1376. if([_myCell.receiptQuantity.text doubleValue] > [_myCell.outQuantity.text doubleValue]){
  1377. _myCell.receiptQuantity.text = _myCell.outQuantity.text;
  1378. _myCell.model.receiptQuantity = _myCell.outQuantity.text;
  1379. [self showAlertViewText:@"回执数量不能大于出库数量"];
  1380. }
  1381. }
  1382. /**
  1383. 收款方式
  1384. */
  1385. - (void)showReceivablesType{
  1386. [self.view endEditing:YES];
  1387. PayTypeVC *pay = [[PayTypeVC alloc] init];
  1388. pay.payDelegate = self;
  1389. [self.navigationController pushViewController:pay animated:YES];
  1390. self.hidesBottomBarWhenPushed = NO;
  1391. }
  1392. /**
  1393. 保存数据函数
  1394. */
  1395. - (void)saveData{
  1396. [self.view endEditing:YES];
  1397. if([kkRights rangeOfString:FUNCTION_DISTRIBUTION_RECEIP_OPERATION_IPHONE].location==NSNotFound){
  1398. [self showAlertViewText:@"用户没有配送回执操作权限"];
  1399. return;
  1400. }
  1401. if(_receiptCode.text == nil || [_receiptCode.text isEqualToString:@""]){
  1402. [self showAlertViewText:@"请输入或扫描单号"];
  1403. return;
  1404. }
  1405. if(_sReceiptCode == nil){
  1406. [self showAlertViewText:@"请按回车加载数据!"];
  1407. return;
  1408. }
  1409. if([_sReceiptType intValue] == 1){
  1410. _sReceiptAmount = _receiptAmount.text;
  1411. _sNextDeliveryDate = @"";
  1412. }
  1413. else{
  1414. _sReceiptAmount = @"0.000000";
  1415. [ _receivablesType setTitle:@"请输入收款方式" forState:UIControlStateNormal];
  1416. _settlementTypeName = @"";
  1417. _settlementType = @"";
  1418. _existsHandlingFee = @"";
  1419. _earnestFee = @"";
  1420. _remarks = @"";
  1421. }
  1422. if([_signFlag isEqualToString:@"1"])
  1423. {
  1424. if(_signName==nil||[_signName isEqualToString:@""])
  1425. {
  1426. [self showAlertViewText:@"请选择是否签收!"];
  1427. return;
  1428. }
  1429. }
  1430. if([_deliveryFlag isEqualToString:@"1"])
  1431. {
  1432. if(_deliveryAttributeId==nil||[_deliveryAttributeId isEqualToString:@""])
  1433. {
  1434. [self showAlertViewText:@"请选择配送属性!"];
  1435. return;
  1436. }
  1437. if(_goodsAttributeId==nil||[_goodsAttributeId isEqualToString:@""])
  1438. {
  1439. [self showAlertViewText:@"请选择货物属性!"];
  1440. return;
  1441. }
  1442. }
  1443. if([_sReceiptType intValue] != 1){
  1444. NSString *nextDeliveryDate = _nextDeliveryDate.titleLabel.text;
  1445. if([nextDeliveryDate isEqualToString:@"请选择推迟日期"]){
  1446. [self showAlertViewText:@"请选择推迟日期!"];
  1447. return;
  1448. }
  1449. NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];//实例化一个NSDateFormatter对象
  1450. [dateFormat setDateFormat:@"yyyy-MM-dd"];
  1451. NSDate *date = [dateFormat dateFromString:nextDeliveryDate];
  1452. NSDate *lastDay = [NSDate dateWithTimeInterval:-24*60*60 sinceDate:[self getCurrentTime]];
  1453. if([self compareOneDay:date withAnotherDay:lastDay] != 1){
  1454. [self showAlertViewText:@"推迟日期不能小于当前日期"];
  1455. return;
  1456. }
  1457. }
  1458. if(self.receiptAmount.text != nil||![self.receiptAmount.text isEqualToString:@""]){
  1459. RegularExpression *regularExpr = [[RegularExpression alloc]init];
  1460. bool receiptAmountCheck = [regularExpr AmountRegular:self.receiptAmount.text];
  1461. if(!receiptAmountCheck){
  1462. [self showAlertViewText:@"回执金额格式不正确"];
  1463. self.receiptAmount.text = @"";
  1464. return ;
  1465. }
  1466. }
  1467. if([_sReceiptAmount doubleValue] > [_sReceivables doubleValue] ){
  1468. [self showAlertViewText:@"回执金额不能大于应收金额!"];
  1469. return;
  1470. }
  1471. for (NewDeliveryReceiptModel* model in _dataList) {
  1472. NSString *receiptQuantity = model.receiptQuantity;
  1473. if(receiptQuantity != nil&&[receiptQuantity length] > 0){
  1474. RegularExpression *re = [[RegularExpression alloc]init];
  1475. bool isMatchDiscount = [re QuantityRegular:receiptQuantity];
  1476. if(isMatchDiscount == NO){
  1477. [self showAlertViewText:@"请输入正确的数"];
  1478. return ;
  1479. }
  1480. }
  1481. else{
  1482. [self showAlertViewText:@"回执数量不能为空"];
  1483. return ;
  1484. }
  1485. }
  1486. if(_dataList != nil && _dataList.count > 0){
  1487. for (NewDeliveryReceiptModel *model in _dataList) {
  1488. if (model.receiptQuantity == nil
  1489. || [@"" isEqualToString:model.receiptQuantity]) {
  1490. [self showAlertViewText:@"请输入回执数量"];
  1491. return;
  1492. }
  1493. //新增校验
  1494. if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 1 && model.salesDetailType != 2){
  1495. if ([model.receiptQuantity doubleValue] == 0) {
  1496. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能为0!",model.code]];
  1497. return;
  1498. }
  1499. }
  1500. 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){
  1501. if ([model.outQuantity doubleValue] == 0) {
  1502. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品出库数量不能为0!",model.code]];
  1503. }else{
  1504. if([model.outQuantity doubleValue]<[model.deliveryQuantity doubleValue]){
  1505. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品出库数量小于送货数量不能保存,建议冲正对应送货单,按照出库数量重新开送货单!",model.code]];
  1506. }
  1507. }
  1508. return;
  1509. }
  1510. if(model.salesDetailType != 2 && [model.sourceFrom doubleValue] != 4 && [model.sourceFrom doubleValue] != 6){
  1511. if ([model.outQuantity doubleValue] == 0) {
  1512. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品出库数量不能为0!",model.code]];
  1513. return;
  1514. }
  1515. }
  1516. if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 2 ){
  1517. if ([model.receiptQuantity doubleValue] < 0) {
  1518. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能小于0!",model.code]];
  1519. return;
  1520. }
  1521. }
  1522. if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 2 && [model.sourceFrom doubleValue] != 4 && [model.sourceFrom doubleValue] != 6){
  1523. if ([model.receiptQuantity doubleValue] >= [model.deliveryQuantity doubleValue]) {
  1524. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能大于或等于送货数量!",model.code]];
  1525. return;
  1526. }
  1527. }
  1528. if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 2 &&model.salesDetailType != 2&& [model.sourceFrom doubleValue] != 4 && [model.sourceFrom doubleValue] != 6){
  1529. if ([model.receiptQuantity doubleValue] >= [model.outQuantity doubleValue]) {
  1530. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能大于或等于出库数量!",model.code]];
  1531. return;
  1532. }
  1533. }
  1534. if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 2){
  1535. if(model.maxReceiptQuantity <= [model.receiptQuantity doubleValue]){
  1536. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品配送明细类型为再送,送货量已超出最大允许配送回执量,请核对数据!",model.code]];
  1537. return;
  1538. }
  1539. }
  1540. if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 1 &&model.salesDetailType != 2&& [model.sourceFrom doubleValue] != 4 && [model.sourceFrom doubleValue] != 6 && [model.outQuantity doubleValue] != 0){
  1541. if ([model.receiptQuantity doubleValue] > [model.outQuantity doubleValue]) {
  1542. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能大于出库数量!",model.code]];
  1543. return;
  1544. }
  1545. }
  1546. if([_sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 1){
  1547. if ([model.receiptQuantity doubleValue] > [model.deliveryQuantity doubleValue]) {
  1548. [self showAlertViewText:[NSString stringWithFormat:@"%@的商品回执数量不能大于送货数量!",model.code]];
  1549. return;
  1550. }
  1551. }
  1552. //登记单退货
  1553. // if ([model.outQuantity doubleValue] == 0.0 && !([@"4" isEqualToString:model.sourceFrom] || [@"6" isEqualToString:model.sourceFrom])) {
  1554. // [self showAlertViewText:[NSString stringWithFormat:@"%@的商品没有出库!",model.code]];
  1555. // return;
  1556. // }
  1557. // if ([model.receiptQuantity doubleValue] > [model.outQuantity doubleValue] && !([@"4" isEqualToString:model.sourceFrom] || [@"6" isEqualToString:model.sourceFrom])) {
  1558. // [self showAlertViewText:[NSString stringWithFormat:@"%@的商品的回执数量不能大于出库数量!",model.code]];
  1559. // return;
  1560. // }
  1561. // if ([model.receiptQuantity doubleValue] > [model
  1562. // .deliveryQuantity doubleValue]) {
  1563. // [self showAlertViewText:[NSString stringWithFormat:@"%@的商品的回执数量不能大于送货数量!",model.code]];
  1564. // return;
  1565. // }
  1566. }
  1567. }else{
  1568. [self showAlertViewText:@"回执明细不能为空!"];
  1569. return;
  1570. }
  1571. self.navigationItem.rightBarButtonItem.enabled=NO;
  1572. [self saveInfo];
  1573. }
  1574. /**
  1575. 保存图片函数
  1576. @return <#return value description#>
  1577. */
  1578. - (BOOL)savePicsManager{
  1579. self.mDownManager = [[ASIDownManager alloc] init];
  1580. self.mDownManager.delegate=self;
  1581. //////////////上传图片
  1582. NSString *urlStr = ServerURL;
  1583. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  1584. [dict setObject:@"SaveImg" forKey:@"Action"];
  1585. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  1586. [dict setObject:kkUserCode forKey:@"UserCode"];
  1587. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  1588. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  1589. [self.imagePaths removeAllObjects];
  1590. for (int i = 0; i < self.assets.count; i++) {
  1591. DKPhotoAssets *asset = self.assets[i];
  1592. DKCamera * c;
  1593. if ([asset isKindOfClass:[DKPhotoAssets class]]) {
  1594. c = [self saveImage:asset.originImage withName:nil];
  1595. }else if ([asset isKindOfClass:[NSString class]]){
  1596. }else if([asset isKindOfClass:[UIImage class]]){
  1597. }else if ([asset isKindOfClass:[DKCamera class]]){
  1598. c = (DKCamera *)asset;
  1599. c = [self saveImage:c.thumbImage withName:nil];
  1600. }
  1601. //延时
  1602. [NSThread sleepForTimeInterval:0.5];
  1603. NSString* retValue= [_mDownManager syncPostHttpRequestUrl:urlStr dic:dict path:c.imagePath filename:nil fileType:@"image/jpeg"];
  1604. if (retValue == nil || retValue.length == 0){
  1605. [self cancel];
  1606. [self showAlertViewText:@"上传图片失败"];
  1607. self.navigationItem.rightBarButtonItem.enabled = YES;
  1608. return NO;
  1609. }
  1610. NSDictionary *dicRetValue = [retValue JSONValue];
  1611. if (dicRetValue && [dicRetValue isKindOfClass:[NSDictionary class]]) {
  1612. int iStatus = [[dicRetValue objectForKey:@"Status"] intValue];
  1613. if (iStatus == 0) {
  1614. NSString * imgPath = [dicRetValue objectForKey:@"Result"];
  1615. [self.imagePaths addObject:imgPath];
  1616. }
  1617. else{
  1618. [self cancel];
  1619. return NO;
  1620. }
  1621. }
  1622. }
  1623. return YES;
  1624. }
  1625. /**
  1626. 保存图片到沙盒
  1627. @param currentImage <#currentImage description#>
  1628. @param imageName <#imageName description#>
  1629. @return <#return value description#>
  1630. */
  1631. - (DKCamera *) saveImage:(UIImage *)currentImage withName:(NSString *)imageName
  1632. {
  1633. if (!currentImage) {
  1634. return nil;
  1635. }
  1636. NSDateFormatter *formater = [[NSDateFormatter alloc] init];
  1637. formater.dateFormat = @"yyyyMMddHHmmss";
  1638. NSString *currentTimeStr = [[formater stringFromDate:[NSDate date]] stringByAppendingFormat:@"_%d_.jpg" ,arc4random_uniform(10000)];
  1639. NSData *imageData= [LeslieAsyncImageDownloader resetSizeOfImageData:currentImage maxSize:500];
  1640. // 获取沙盒目录
  1641. NSString *fullPath ;
  1642. if([imageName isEqualToString:@""] || imageName == nil){
  1643. fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:currentTimeStr];
  1644. }
  1645. else{
  1646. fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
  1647. }
  1648. // 将图片写入文件
  1649. [imageData writeToFile:fullPath atomically:NO];
  1650. UIImage *savedImage = [[UIImage alloc] initWithContentsOfFile:fullPath];
  1651. DKCamera *camera = [[DKCamera alloc] init];
  1652. camera.imagePath = fullPath;
  1653. camera.thumbImage = savedImage;// [UIImage imageWithData:data];
  1654. return camera;
  1655. }
  1656. /**
  1657. 保存数据函数
  1658. */
  1659. - (void)saveInfo{
  1660. [self startLoading];
  1661. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  1662. if(![self savePicsManager]){
  1663. return;
  1664. }
  1665. self.mDownManager = [[ASIDownManager alloc] init];
  1666. self.mDownManager.delegate = self;
  1667. self.mDownManager.onRequestSuccess = @selector(onSaveLoadFinish:);
  1668. self.mDownManager.onRequestFail = @selector(onLoadFail:);
  1669. NSString *urlStr = ServerURL;
  1670. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  1671. [dict setObject:@"SaveIntelligentReceiptIphone" forKey:@"Action"];
  1672. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  1673. [dict setObject:kkUserCode forKey:@"UserCode"];
  1674. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  1675. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  1676. [dict setObject:kkLicenseCode forKey:@"LicenseCode"];
  1677. [dict setObject:self->_deliveryId forKey:@"DeliveryID"];
  1678. [dict setObject:self->_signName forKeyedSubscript:@"IsSign"];
  1679. [dict setObject:self->_deliveryAttributeId forKeyedSubscript:@"SendAttribute"];
  1680. [dict setObject:self->_goodsAttributeId forKeyedSubscript:@"GoodsAttribute"];
  1681. if (_lblPosition.text == nil) {
  1682. [dict setObject:@"" forKey:@"Position"];
  1683. }else{
  1684. [dict setObject:_lblPosition.text forKey:@"Position"];
  1685. }
  1686. _remarks = @"";
  1687. NSMutableDictionary *dicHead = [[NSMutableDictionary alloc] init];
  1688. NSMutableArray *arrHead = [[NSMutableArray alloc]init];
  1689. [dicHead setObject:_sReceiptType forKeyedSubscript:@"ReceiptType"];
  1690. [dicHead setObject:_sNextDeliveryDate forKeyedSubscript:@"NextDeliveryDate"];
  1691. [dicHead setObject:_remarks forKeyedSubscript:@"Remarks"];
  1692. [dicHead setObject:_sReceivables forKeyedSubscript:@"Receivables"];
  1693. // RecoverFlag 单据回收标识 0:未回收 1:已回收
  1694. if([_sReceiptAmount doubleValue] > 0){
  1695. [dicHead setObject:@"1" forKeyedSubscript:@"RecoverFlag"];
  1696. }else{
  1697. [dicHead setObject:@"0" forKeyedSubscript:@"RecoverFlag"];
  1698. }
  1699. [dicHead setObject:_sReceiptAmount forKeyedSubscript:@"ReceiptAmount"];
  1700. [dicHead setObject:_completeReceivables forKeyedSubscript:@"CompleteReceivables"];
  1701. [arrHead addObject:dicHead];
  1702. [dict setObject:[Util objectToJson:arrHead] forKey:@"ReceiptData"];
  1703. //详细列表
  1704. NSMutableDictionary *dicDetails;
  1705. NSMutableArray* arrDetails = [[NSMutableArray alloc]init];
  1706. for (NewDeliveryReceiptModel* me in _dataList) {
  1707. dicDetails = [[NSMutableDictionary alloc] init];
  1708. [dicDetails setObject:me.detailId forKeyedSubscript:@"DetailID"];
  1709. [dicDetails setObject:me.deliveryQuantity forKeyedSubscript:@"DeliveryQuantity"];
  1710. [dicDetails setObject:me.receiptQuantity forKeyedSubscript:@"ReceiptQuantity"];
  1711. [dicDetails setObject:me.receiptType forKeyedSubscript:@"ReceiptType"];
  1712. [dicDetails setObject:me.sourceFrom forKeyedSubscript:@"SourceFrom"];
  1713. [dicDetails setObject:me.invoiceId forKeyedSubscript:@"InvoiceID"];
  1714. [dicDetails setObject:me.invoiceDetailId forKeyedSubscript:@"InvoiceDetailID"];
  1715. [dicDetails setObject:me.receiptRemarks forKeyedSubscript:@"ReceiptRemarks"];
  1716. [arrDetails addObject:dicDetails];
  1717. }
  1718. [dict setObject:[Util objectToJson:arrDetails] forKey:@"ReceiptDetailData"];
  1719. //////付款方式
  1720. NSMutableDictionary *dicSettle = [[NSMutableDictionary alloc] init];
  1721. NSMutableArray* arrSettle = [[NSMutableArray alloc]init];
  1722. if (_settlementType == nil || [_settlementType isEqual:@""]) {
  1723. [dict setObject:@"" forKey:@"ReceiptEarnestData"];
  1724. }else{
  1725. [dicSettle setObject:self.settlementType forKeyedSubscript:@"SettlementType"];
  1726. [dicSettle setObject:self.settlementTypeName forKeyedSubscript:@"SettlementTypeName"];
  1727. [dicSettle setObject:_receiptAmount.text forKeyedSubscript:@"ReceivableSum"];
  1728. [dicSettle setObject:self.earnestFee forKeyedSubscript:@"EarnestFee"];
  1729. [dicSettle setObject:self.existsHandlingFee forKeyedSubscript:@"ExistsHandlingFee"];
  1730. [dicSettle setObject:self.remarks forKeyedSubscript:@"Remarks"];
  1731. [arrSettle addObject:dicSettle];
  1732. [dict setObject:[Util objectToJson:arrSettle] forKey:@"ReceiptEarnestData"];
  1733. }
  1734. /////////图片上传返回的地址
  1735. if (self.imagePaths && self.imagePaths.count > 0) {
  1736. [dict setObject:[self.imagePaths componentsJoinedByString:@"," ] forKey:@"ImagePath"];
  1737. }
  1738. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  1739. });
  1740. }
  1741. /**
  1742. 清空画面函数
  1743. */
  1744. - (void)clearData{
  1745. self.receiptCode.text = @"";
  1746. self.sReceiptCode = @"";
  1747. self.customerName.text = @"";
  1748. self.sCustomerName = @"";
  1749. self.receivables.text = @"";
  1750. self.sReceivables = @"";
  1751. [self.receiptType setTitle:@"请选择回执类型" forState:UIControlStateNormal];
  1752. self.sReceiptType = @"";
  1753. [self.receivablesType setTitle:@"请选择收款方式" forState:UIControlStateNormal];
  1754. _settlementTypeName = @"";
  1755. _settlementType = @"";
  1756. _existsHandlingFee = @"";
  1757. _earnestFee = @"";
  1758. _remarks = @"";
  1759. self.receiptAmount.text = @"";
  1760. self.sReceiptAmount = @"";
  1761. self.receiptCode.text = @"";
  1762. self.sReceiptCode = @"";
  1763. [self.nextDeliveryDate setTitle:@"请选择推迟日期" forState:UIControlStateNormal];
  1764. self.sNextDeliveryDate = @"";
  1765. _lblPosition.text = @"";
  1766. _positionImage.hidden = YES;
  1767. _vImage.hidden = YES;
  1768. _positionHeight = 0;
  1769. [_receiptType setEnabled:NO];
  1770. [_receivablesType setEnabled:NO];
  1771. [_receiptAmount setEnabled:NO];
  1772. [_nextDeliveryDate setEnabled:NO];
  1773. [self.imagePaths removeAllObjects];
  1774. [self.dataList removeAllObjects];
  1775. [self.assets removeAllObjects];
  1776. [self.myTableView reloadData];
  1777. [self.collectionView reloadData];
  1778. [self reloadMyView];
  1779. }
  1780. /**
  1781. 出示推迟日期函数
  1782. @return <#return value description#>
  1783. */
  1784. - (void)showNextDeliveryDate{
  1785. [self.view endEditing:YES];
  1786. __weak typeof(self)weakself = self;
  1787. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  1788. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  1789. _sNextDeliveryDate = date;
  1790. } andCompletionBlock:^(void){
  1791. [weakself.nextDeliveryDate setTitle:_sNextDeliveryDate forState:UIControlStateNormal];
  1792. } andCancelBlock:^(void){
  1793. _sNextDeliveryDate = weakself.nextDeliveryDate.titleLabel.text;
  1794. if([_sNextDeliveryDate isEqualToString:@"请选择推迟日期"]){
  1795. _sNextDeliveryDate = @"";
  1796. }
  1797. }];
  1798. [_dealDatePicker show];
  1799. }
  1800. /**
  1801. 加载单据数据函数
  1802. */
  1803. - (void)loadDataSource{
  1804. [self startLoading];
  1805. NSString *urlStr = ServerURL;
  1806. NSMutableDictionary *dict = [NSMutableDictionary new];
  1807. [dict setObject:@"GetIntelligentReceiptByDeliveryNoIphone" forKey:@"Action"];
  1808. [dict setObject:kkAccountCode forKey:@"AccountCode"];
  1809. [dict setObject:kkUserCode forKey:@"UserCode"];
  1810. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  1811. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  1812. [dict setObject:self.receiptCode.text forKey:@"DeliveryNo"];
  1813. self.mDownManager = [[ASIDownManager alloc] init];
  1814. self.mDownManager.delegate=self;
  1815. self.mDownManager.onRequestSuccess=@selector(onLoadFinish:);
  1816. self.mDownManager.onRequestFail=@selector(onLoadFail:);
  1817. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];}
  1818. /**
  1819. 取消进度条
  1820. */
  1821. - (void)cancel {
  1822. [self stopLoading];
  1823. }
  1824. /**
  1825. 返回函数
  1826. */
  1827. - (void)goBack{
  1828. [self.navigationController popViewControllerAnimated:YES];
  1829. if([self.refreshDelegate respondsToSelector:@selector(refreshFollowUpData)]){
  1830. [self.refreshDelegate refreshFollowUpData];
  1831. }
  1832. }
  1833. /**
  1834. 拍照函数
  1835. */
  1836. - (void)selectCamera{
  1837. DKCameraViewController *cameraVc = [[DKCameraViewController alloc] init];
  1838. __weak typeof(self) weakSelf = self;
  1839. // 多选相册+相机多拍 回调
  1840. [cameraVc startCameraOrPhotoFileWithViewController:self complate:^(NSArray *object) {
  1841. // 选择完照片、拍照完回调
  1842. [object enumerateObjectsUsingBlock:^(id asset, NSUInteger idx, BOOL *stop) {
  1843. if(weakSelf.assets.count<9){
  1844. if ([asset isKindOfClass:[DKCamera class]]) {
  1845. [weakSelf.assets addObject:asset];
  1846. }else{
  1847. [weakSelf.assets addObject:asset];
  1848. }
  1849. }else{
  1850. [self showAlertViewText:@"最多只能选择9张图片"];
  1851. }
  1852. }];
  1853. [weakSelf.collectionView reloadData];
  1854. [self reloadMyView];
  1855. }];
  1856. }
  1857. /**
  1858. 选择相册函数
  1859. */
  1860. - (void)selectPhotos {
  1861. // 创建控制器
  1862. DKPhotoPickerViewController *pickerVc = [[DKPhotoPickerViewController alloc] init];
  1863. // 默认显示相册里面的内容SavePhotos
  1864. pickerVc.status = PickerViewShowStatusCameraRoll;
  1865. pickerVc.selectPickers = self.assets;
  1866. // 最多能选9张图片
  1867. pickerVc.minCount = 9;
  1868. pickerVc.cameraCount = [self cameraCount];
  1869. pickerVc.delegate = self;
  1870. [pickerVc show];
  1871. }
  1872. /**
  1873. 出示地图函数
  1874. */
  1875. - (void)newMap{
  1876. self.hidesBottomBarWhenPushed=YES;
  1877. MapViewController *mc = [MapViewController new];
  1878. mc.pDelegate=self;
  1879. [self.navigationController pushViewController:mc animated:YES];
  1880. }
  1881. /**
  1882. 获取table view的高度
  1883. @param soundArray <#soundArray description#>
  1884. @return <#return value description#>
  1885. */
  1886. - (CGFloat)getDataViewHeight:(NSArray *)soundArray {
  1887. // 上下间隔已经在frame上做了
  1888. NSInteger row = soundArray.count;
  1889. return (row *197);
  1890. }
  1891. #pragma mark -得到当前时间
  1892. /**
  1893. 获得当前日期
  1894. @return <#return value description#>
  1895. */
  1896. - (NSDate *)getCurrentTime{
  1897. NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
  1898. [formatter setDateFormat:@"yyyy-MM-dd"];
  1899. NSString *dateTime=[formatter stringFromDate:[NSDate date]];
  1900. NSDate *date = [formatter dateFromString:dateTime];
  1901. return date;
  1902. }
  1903. /**
  1904. 比较时间
  1905. @param oneDay <#oneDay description#>
  1906. @param anotherDay <#anotherDay description#>
  1907. @return <#return value description#>
  1908. */
  1909. - (int)compareOneDay:(NSDate *)oneDay withAnotherDay:(NSDate *)anotherDay
  1910. {
  1911. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  1912. [dateFormatter setDateFormat:@"dd-MM-yyyy-HHmmss"];
  1913. NSString *oneDayStr = [dateFormatter stringFromDate:oneDay];
  1914. NSString *anotherDayStr = [dateFormatter stringFromDate:anotherDay];
  1915. NSDate *dateA = [dateFormatter dateFromString:oneDayStr];
  1916. NSDate *dateB = [dateFormatter dateFromString:anotherDayStr];
  1917. NSComparisonResult result = [dateA compare:dateB];
  1918. NSLog(@"date1 : %@, date2 : %@", oneDay, anotherDay);
  1919. if (result == NSOrderedDescending) {
  1920. //NSLog(@"Date1 is in the future");
  1921. return 1;
  1922. }
  1923. else if (result == NSOrderedAscending){
  1924. //NSLog(@"Date1 is in the past");
  1925. return -1;
  1926. }
  1927. //NSLog(@"Both dates are the same");
  1928. return 0;
  1929. }
  1930. @end