NewDispatchRequirementHomeController.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. //
  2. // NewDispatchRequirementHomeController.m
  3. // IBOSS-HJ
  4. //
  5. // Created by 关宏厚 on 2021/1/28.
  6. // Copyright © 2021 elongtian. All rights reserved.
  7. //
  8. #import "NewDispatchRequirementHomeController.h"
  9. #import "NewDispatchRequirementInvoiceInfoController.h"
  10. #import "NewDispatchRequirementGoodsDetailController.h"
  11. #import "DispatchImageInfoVC.h"
  12. @interface NewDispatchRequirementHomeController ()
  13. {
  14. NewDispatchRequirementInvoiceInfoController *invoiceInfoVc;
  15. NewDispatchRequirementGoodsDetailController *goodsVc;
  16. UIButton *_invoiceInfoBtn;
  17. // 业绩信息按钮
  18. UIButton *_goodsDetailBtn;
  19. UILabel *lblCustomer;
  20. // 滑动线
  21. UILabel *_sliderLabel;
  22. // 滚动条
  23. UIScrollView *_mainScrollView;
  24. UIButton *btnSave;
  25. UIView *navView;
  26. UIView *viewBackgroud;
  27. }
  28. @end
  29. static int navcount = 2;
  30. @implementation NewDispatchRequirementHomeController
  31. - (void)viewDidLoad {
  32. [super viewDidLoad];
  33. _currentIndex=0;
  34. [self initUI];
  35. [self setMainSrollView];
  36. //设置默认
  37. [self sliderWithTag:self.currentIndex+1];
  38. self.goodsVc.noReceiptModel=_noReceiptModel;
  39. lblCustomer.text=_noReceiptModel.customerName;
  40. self.goodsVc.lblTelephone.text=_noReceiptModel.telephone;
  41. self.goodsVc.lbDeliveryAddress.text=_noReceiptModel.deliveryAddress;
  42. self.goodsVc.txtPlateNumber.text=_noReceiptModel.truckName;
  43. self.invoiceInfoVc.lblDeliveryDate.text=_noReceiptModel.deliveryDate;
  44. self.invoiceInfoVc.lblReceivables.text=_noReceiptModel.receivables;
  45. self.invoiceInfoVc.lblRemainingReceivables.text=_noReceiptModel.remainingReceivables;
  46. self.invoiceInfoVc.txtReceiptAmount.text=_noReceiptModel.receiptAmount;
  47. if([_noReceiptModel.remainingReceivables doubleValue]>0)
  48. {
  49. self.invoiceInfoVc.txtReceiptAmount.enabled=YES;
  50. self.invoiceInfoVc.btnReceivablesType.enabled=YES;
  51. }
  52. else
  53. {
  54. self.invoiceInfoVc.txtReceiptAmount.enabled=NO;
  55. self.invoiceInfoVc.btnReceivablesType.enabled=NO;
  56. }
  57. [self.goodsVc loadData];
  58. }
  59. /**
  60. 安全区视图发生变化
  61. */
  62. -(void)viewSafeAreaInsetsDidChange{
  63. self.view.backgroundColor = [UIColor whiteColor];
  64. navView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, 40)];
  65. _mainScrollView.frame = CGRectMake(0,CGRectGetMaxY(navView.frame), Screen_Width,self.view.safeAreaLayoutGuide.layoutFrame.size.height-40);
  66. for (NSInteger i = 0; i < _mainScrollView.subviews.count; i++) {
  67. _mainScrollView.subviews[i].frame = CGRectMake(Screen_Width * i, 0, Screen_Width,CGRectGetHeight(_mainScrollView.frame));
  68. }
  69. [self.invoiceInfoVc viewSafeAreaInsetsDidChange];
  70. [self.goodsVc viewSafeAreaInsetsDidChange];
  71. btnSave.frame=CGRectMake(0,self.view.safeAreaLayoutGuide.layoutFrame.size.height-40, Screen_Width,40) ;
  72. [super viewSafeAreaInsetsDidChange];
  73. }
  74. -(void)goBack
  75. {
  76. [self.navigationController popViewControllerAnimated:YES];
  77. }
  78. -(void)initUI
  79. {
  80. self.navigationItem.title = @"新增派工回执";
  81. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  82. [button setBackgroundImage:[UIImage imageNamed:@"icon_back.png"]
  83. forState:UIControlStateNormal];
  84. [button addTarget:self action:@selector(goBack)
  85. forControlEvents:UIControlEventTouchUpInside];
  86. button.frame = CGRectMake(0, 0,15,18);
  87. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  88. self.navigationItem.leftBarButtonItem = menuButton;
  89. UIView *vCustomerName = [UIView new];
  90. vCustomerName.frame = CGRectMake(0,0, Screen_Width, 40);
  91. [self.view addSubview:vCustomerName];
  92. UILabel *lblTxtVCustomerName = [UILabel new];
  93. lblTxtVCustomerName.frame = CGRectMake(20, 7, 90, 25);
  94. lblTxtVCustomerName.text = @"客户名称:";
  95. lblTxtVCustomerName.font = [UIFont systemFontOfSize:16];;
  96. [vCustomerName addSubview:lblTxtVCustomerName];
  97. lblCustomer = [UILabel new];
  98. lblCustomer.font = [UIFont systemFontOfSize:16];
  99. lblCustomer.frame = CGRectMake(CGRectGetMaxX(lblTxtVCustomerName.frame), 7, Screen_Width -CGRectGetMaxX(lblTxtVCustomerName.frame) - 30, 25);
  100. [vCustomerName addSubview:lblCustomer];
  101. //分割线
  102. viewBackgroud = [UIView new];
  103. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vCustomerName.frame), Screen_Width, 1);
  104. viewBackgroud.backgroundColor = LineBackgroundColor;
  105. [self.view addSubview:viewBackgroud];
  106. navView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, 40)];
  107. [self.view setBackgroundColor:[UIColor whiteColor]];
  108. _goodsDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  109. [_goodsDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  110. [_goodsDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  111. _goodsDetailBtn.frame = CGRectMake(2, 0, Screen_Width/navcount, navView.frame.size.height);
  112. _goodsDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
  113. [_goodsDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
  114. [_goodsDetailBtn setTitle:@"明细" forState:UIControlStateNormal];
  115. _goodsDetailBtn.tag = 1;
  116. _goodsDetailBtn.selected = YES;
  117. [navView addSubview:_goodsDetailBtn];
  118. // 业绩
  119. _invoiceInfoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  120. _invoiceInfoBtn.frame = CGRectMake(_goodsDetailBtn.frame.origin.x+_goodsDetailBtn.frame.size.width, 0, Screen_Width/navcount, navView.frame.size.height);
  121. [_invoiceInfoBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  122. [_invoiceInfoBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  123. _invoiceInfoBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
  124. [_invoiceInfoBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
  125. [_invoiceInfoBtn setTitle:@"总单" forState:UIControlStateNormal];
  126. _invoiceInfoBtn.tag = 2;
  127. [navView addSubview:_invoiceInfoBtn];
  128. // 选中后的红线
  129. _sliderLabel = [[UILabel alloc]initWithFrame:CGRectMake(_goodsDetailBtn.frame.origin.x, 40-2, Screen_Width/navcount, 2)];
  130. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(((Screen_Width/navcount)-75)/2, 0, 75, 2)];
  131. line.backgroundColor = [UIColor redColor];
  132. [_sliderLabel addSubview:line];
  133. [navView addSubview:_sliderLabel];
  134. [self.view addSubview:navView];
  135. }
  136. /**
  137. 获得当前日期
  138. @return <#return value description#>
  139. */
  140. - (NSDate *)getCurrentTime{
  141. NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
  142. [formatter setDateFormat:@"yyyy-MM-dd"];
  143. NSString *dateTime=[formatter stringFromDate:[NSDate date]];
  144. NSDate *date = [formatter dateFromString:dateTime];
  145. return date;
  146. }
  147. /**
  148. 初始化srollView
  149. */
  150. - (void)setMainSrollView{
  151. // 滚动view
  152. _mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(navView.frame), Screen_Width, Screen_Height-CGRectGetMaxY(navView.frame) - 10 - rectStatusHeight-rectNavHeight - 40)];
  153. _mainScrollView.delegate = self;
  154. _mainScrollView.backgroundColor = [UIColor whiteColor];
  155. _mainScrollView.pagingEnabled = YES;
  156. _mainScrollView.showsHorizontalScrollIndicator = NO;
  157. _mainScrollView.showsVerticalScrollIndicator = NO;
  158. [self.view addSubview:_mainScrollView];
  159. NSArray *views = @[self.goodsVc.view,self.invoiceInfoVc.view];
  160. for (NSInteger i = 0; i< views.count; i++) {
  161. //把三个vc的view依次贴到mainScrollView上面
  162. UIView *pageView = [[UIView alloc]initWithFrame:CGRectMake(Screen_Width * i, 0, _mainScrollView.frame.size.width, _mainScrollView.frame.size.height)];
  163. [pageView addSubview:views[i]];
  164. [_mainScrollView addSubview:pageView];
  165. }
  166. _mainScrollView.contentSize = CGSizeMake(Screen_Width*(views.count), 0);
  167. //滚动到_currentIndex对应的tab
  168. [_mainScrollView setContentOffset:CGPointMake((_mainScrollView.frame.size.width)*_currentIndex, 0) animated:YES];
  169. //保存按钮
  170. btnSave = [UIButton buttonWithType:UIButtonTypeCustom];
  171. btnSave.frame=CGRectMake(0, Screen_Height- 40- rectStatusHeight-rectNavHeight, Screen_Width,40) ;
  172. btnSave.backgroundColor=NavigationBarColor;
  173. [btnSave setTitle:@"确定" forState:UIControlStateNormal];
  174. [btnSave setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  175. [btnSave addTarget:self action:@selector(dataSave) forControlEvents:UIControlEventTouchUpInside];
  176. [self.view addSubview:btnSave];
  177. }
  178. /**
  179. 比较时间
  180. @param oneDay <#oneDay description#>
  181. @param anotherDay <#anotherDay description#>
  182. @return <#return value description#>
  183. */
  184. - (int)compareOneDay:(NSDate *)oneDay withAnotherDay:(NSDate *)anotherDay
  185. {
  186. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  187. [dateFormatter setDateFormat:@"dd-MM-yyyy-HHmmss"];
  188. NSString *oneDayStr = [dateFormatter stringFromDate:oneDay];
  189. NSString *anotherDayStr = [dateFormatter stringFromDate:anotherDay];
  190. NSDate *dateA = [dateFormatter dateFromString:oneDayStr];
  191. NSDate *dateB = [dateFormatter dateFromString:anotherDayStr];
  192. NSComparisonResult result = [dateA compare:dateB];
  193. if (result == NSOrderedDescending) {
  194. //NSLog(@"Date1 is in the future");
  195. return 1;
  196. }
  197. else if (result == NSOrderedAscending){
  198. //NSLog(@"Date1 is in the past");
  199. return -1;
  200. }
  201. //NSLog(@"Both dates are the same");
  202. return 0;
  203. }
  204. /**
  205. 保存数据函数
  206. */
  207. - (void)dataSave{
  208. [self.view endEditing:YES];
  209. _sReceiptAmount = invoiceInfoVc.txtReceiptAmount.text;
  210. if(goodsVc.txtPlateNumber.text==nil||[goodsVc.txtPlateNumber.text isEqualToString:@""])
  211. {
  212. [self showAlertViewText:@"车牌号为空,请维护车牌号"];
  213. return;
  214. }
  215. if(goodsVc.sNextDeliveryDate!=nil&&goodsVc.sNextDeliveryDate.length>0)
  216. {
  217. NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];//实例化一个NSDateFormatter对象
  218. [dateFormat setDateFormat:@"yyyy-MM-dd"];
  219. NSDate *date = [dateFormat dateFromString:goodsVc.sNextDeliveryDate];
  220. NSDate *lastDay = [NSDate dateWithTimeInterval:-24*60*60 sinceDate:[self getCurrentTime]];
  221. if([self compareOneDay:date withAnotherDay:lastDay] != 1){
  222. [self showAlertViewText:@"推迟日期不能小于当前日期"];
  223. return;
  224. }
  225. }
  226. if(_sReceiptAmount != nil||![_sReceiptAmount isEqualToString:@""]){
  227. RegularExpression *regularExpr = [[RegularExpression alloc]init];
  228. bool receiptAmountCheck = [regularExpr AmountRegular:_sReceiptAmount];
  229. if(!receiptAmountCheck){
  230. [self showAlertViewText:@"回执金额格式不正确"];
  231. invoiceInfoVc.txtReceiptAmount.text = @"";
  232. return ;
  233. }
  234. }
  235. if([_sReceiptAmount doubleValue] > [invoiceInfoVc.lblRemainingReceivables.text doubleValue] ){
  236. [self showAlertViewText:@"回执金额不能大于剩余应收"];
  237. return;
  238. }
  239. // for (NewDispatchRequirementModel* model in goodsVc.dataList) {
  240. // NSString *receiptQuantity = model.receiptQuantity;
  241. // if(receiptQuantity != nil&&[receiptQuantity length] > 0){
  242. // RegularExpression *re = [[RegularExpression alloc]init];
  243. // bool isMatchDiscount = [re QuantityRegular:receiptQuantity];
  244. // if(isMatchDiscount == NO){
  245. // [self showAlertViewText:@"请输入正确的数"];
  246. // return ;
  247. // }
  248. // }
  249. // else{
  250. // [self showAlertViewText:@"请输入回执数量"];
  251. // return ;
  252. // }
  253. // }
  254. if(goodsVc.dataList != nil && goodsVc.dataList.count > 0){
  255. for (NewDispatchRequirementModel *model in goodsVc.dataList) {
  256. if (model.receiptQuantity == nil
  257. || [@"" isEqualToString:model.receiptQuantity]) {
  258. [self showAlertViewText:@"请输入配送回执数量"];
  259. return;
  260. }
  261. RegularExpression *re = [[RegularExpression alloc]init];
  262. bool isMatchDiscount = [re QuantityRegular:model.receiptQuantity];
  263. if(isMatchDiscount == NO){
  264. [self showAlertViewText:@"配送回执数量格式不正确"];
  265. return ;
  266. }
  267. if (model.installReceiptQuantity == nil
  268. || [@"" isEqualToString:model.installReceiptQuantity]) {
  269. [self showAlertViewText:@"请输入安装回执数量"];
  270. return;
  271. }
  272. //新增校验
  273. //
  274. // if ([goodsVc.sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 1
  275. // && [model.installReceiptType doubleValue] == 1 && model. salesDetailType != 2) {
  276. // NSString *receiptQuantity = model.receiptQuantity;
  277. // NSString *installationQuantity = model.installReceiptQuantity;
  278. // if ([receiptQuantity doubleValue]
  279. // + [installationQuantity doubleValue] == 0) {
  280. // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"配送回执明细类型为完成,最大允许回执数量为零,请核对数据"]];
  281. // return;
  282. // }
  283. // }
  284. if([goodsVc.sReceiptType doubleValue]==1&&( [goodsVc.receiptFlag intValue]==1|| [goodsVc.receiptFlag intValue]==3))
  285. {
  286. if([model.receiptType doubleValue] == 0)
  287. {
  288. [self showAlertViewText:@"配送回执类型不能为空"];
  289. return;
  290. }
  291. }
  292. if([goodsVc.sReceiptType doubleValue]==1&&( [goodsVc.receiptFlag intValue]==2|| [goodsVc.receiptFlag intValue]==3))
  293. {
  294. if([model.installReceiptType doubleValue] == 0)
  295. {
  296. [self showAlertViewText:@"安装回执类型不能为空"];
  297. return;
  298. }
  299. }
  300. if([goodsVc.sReceiptType doubleValue]==1&& [goodsVc.receiptFlag intValue]==3)
  301. {
  302. if([model.receiptType doubleValue] == 2&&[model.installReceiptType intValue]==1)
  303. {
  304. [self showAlertViewText:@"送货回执类型为再送,安装回执类型不能为完成"];
  305. return;
  306. }
  307. }
  308. if([_noReceiptModel.requirementType doubleValue]==1)
  309. {
  310. if([model.outQuantity doubleValue]<=[model.finalDeliveryReceiptQuantity doubleValue])
  311. {
  312. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
  313. return;
  314. }
  315. }
  316. if([_noReceiptModel.requirementType doubleValue]==2)
  317. {
  318. if ([model.outQuantity doubleValue] <= [model.finalInstallReceiptQuantity doubleValue]) {
  319. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
  320. return;
  321. }
  322. }
  323. if([_noReceiptModel.requirementType doubleValue]==3)
  324. {
  325. if( [goodsVc.receiptFlag intValue]==1|| [goodsVc.receiptFlag intValue]==3)
  326. {
  327. if([model.outQuantity doubleValue]<=[model.finalDeliveryReceiptQuantity doubleValue])
  328. {
  329. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
  330. return;
  331. }
  332. }
  333. if( [goodsVc.receiptFlag intValue]==2)
  334. {
  335. if ([model.outQuantity doubleValue] <= [model.finalInstallReceiptQuantity doubleValue]) {
  336. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
  337. return;
  338. }
  339. }
  340. }
  341. if (
  342. [goodsVc.sReceiptType doubleValue] == 1
  343. &&( [goodsVc.receiptFlag intValue]==1|| [goodsVc.receiptFlag intValue]==3)&&
  344. ( [model.receiptType doubleValue] == 1 || [model.receiptType doubleValue] == 2)
  345. )
  346. {
  347. double outQuantityValue = [model.outQuantity
  348. doubleValue] ;
  349. double deliveryQuantityValue=[model.deliveryQuantity
  350. doubleValue] ;
  351. if (deliveryQuantityValue>0&&outQuantityValue == 0) {
  352. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不能为0"]];
  353. return;
  354. }
  355. }
  356. //
  357. // if (model.maxReceiptQuantity< [model.receiptQuantity doubleValue]) {
  358. // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"配送明细类型为再送,送货量已超出最大允许配送回执量,请核对数据"]];
  359. //
  360. // return;
  361. // }
  362. // if ([model.sourceFrom intValue] != 4 && [model.receiptQuantity doubleValue] > [model.outQuantity doubleValue]) {
  363. // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"回执数量不能大于出库量"]];
  364. //
  365. // return;
  366. // }
  367. // if ([_sReceiptType doubleValue] == 1 && [model.installReceiptType intValue] == 5) {
  368. // if ([model.maxInstallReceiptQuantity doubleValue] <= [model.installReceiptQuantity doubleValue]) {
  369. // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"再安装时回执数量不能大于或等于(安装数量或出库量的最小值)"]];
  370. // return;
  371. // }
  372. //
  373. // }
  374. // if (model.salesDetailType != 2 && [model.sourceFrom intValue]!= 4) {
  375. // if ([model.receiptQuantity doubleValue] > [model.outQuantity doubleValue]) {
  376. // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"回执数量不能大于出库量"]];
  377. // return;
  378. // }
  379. if ([model.deliveryQuantity doubleValue] > [model.outQuantity doubleValue]) {
  380. if ([model.receiptQuantity doubleValue] > [model.outQuantity doubleValue]) {
  381. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"配送回执数量不能大于出库量"]];
  382. return;
  383. }
  384. }
  385. // if([model.outQuantity doubleValue]<=[model.finalDeliveryReceiptQuantity doubleValue])
  386. // {
  387. // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库量不能小于等于已送货数量"]];
  388. // return;
  389. // }
  390. if ([goodsVc.sReceiptType doubleValue] == 1
  391. &&( [goodsVc.receiptFlag intValue]==1|| [goodsVc.receiptFlag intValue]==3)&&
  392. [model.receiptType doubleValue] == 2
  393. )
  394. {
  395. if ([model.receiptQuantity doubleValue] >= [model.deliveryQuantity doubleValue]) {
  396. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"配送明细类型为再送,配送回执数量不能大于等于送货数量"]];
  397. return;
  398. }
  399. if([model.outQuantity doubleValue]<=[model.finalDeliveryReceiptQuantity doubleValue])
  400. {
  401. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
  402. return;
  403. }
  404. }
  405. if ([goodsVc.sReceiptType doubleValue] == 1 && [model.installReceiptType intValue] == 5) {
  406. if ([model.installReceiptQuantity doubleValue] < 0) {
  407. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"安装回执数量不能小于0"]];
  408. return;
  409. }
  410. if ([model.installReceiptQuantity doubleValue] >= [model.installQuantity doubleValue]) {
  411. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"安装回执数量不能大于或等于最大允许回执数量"]];
  412. return;
  413. }
  414. if ([model.outQuantity doubleValue] <= [model.finalInstallReceiptQuantity doubleValue]) {
  415. [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
  416. return;
  417. }
  418. }
  419. }
  420. }
  421. else{
  422. [self showAlertViewText:@"回执明细不能为空!"];
  423. return;
  424. }
  425. self.navigationItem.rightBarButtonItem.enabled=NO;
  426. DispatchImageInfoVC *imgVc=[[DispatchImageInfoVC alloc]init];
  427. imgVc.collectDetailId=_noReceiptModel.collectDetailId;
  428. imgVc.arrangementId=_noReceiptModel.arrangementId;
  429. imgVc.customerId=_noReceiptModel.customerId;
  430. imgVc.receiptAmount=invoiceInfoVc.txtReceiptAmount.text;
  431. imgVc.receivable=invoiceInfoVc.lblReceivables.text;
  432. imgVc.organizationId=_noReceiptModel.organizationId;
  433. imgVc.organizationCode=_noReceiptModel.organizationCode;
  434. imgVc.remarks=invoiceInfoVc.txtRemarks.text;
  435. imgVc.truckNumber=goodsVc.txtPlateNumber.text;
  436. imgVc.nextDeliveryDate=goodsVc.sNextDeliveryDate;
  437. imgVc.paymentMethodArray=invoiceInfoVc.paymentMethodFilterArray;
  438. imgVc.deliveryAddress=_noReceiptModel.deliveryAddress;
  439. imgVc.receiptFlag=_noReceiptModel.requirementType;
  440. imgVc.dataList=goodsVc.dataList;
  441. imgVc.refreshDelegate=self;
  442. [self.navigationController pushViewController:imgVc animated:YES];
  443. self.hidesBottomBarWhenPushed=YES;
  444. }
  445. /**
  446. 滑动label位置
  447. @param scrollView <#scrollView description#>
  448. */
  449. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  450. //实时计算当前位置,实现和titleView上的按钮的联动
  451. CGFloat contentOffSetX = scrollView.contentOffset.x;
  452. CGFloat X = contentOffSetX/ navcount;
  453. CGRect frame = _sliderLabel.frame;
  454. frame.origin.x = X;
  455. _sliderLabel.frame = frame;
  456. if(X > _sliderLabel.frame.size.width/2){
  457. UIView *line = _sliderLabel.subviews[0];
  458. line.frame = CGRectMake(((Screen_Width/navcount)-40)/2, 0, 40, 2);
  459. }else{
  460. UIView *line = _sliderLabel.subviews[0];
  461. line.frame = CGRectMake(((Screen_Width/navcount)-70)/2, 0, 70, 2);
  462. }
  463. }
  464. /**
  465. 滑动完成
  466. @param scrollView <#scrollView description#>
  467. */
  468. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  469. CGFloat contentOffSetX = scrollView.contentOffset.x;
  470. int index_ = contentOffSetX/Screen_Width;
  471. [self sliderWithTag:index_+1];
  472. }
  473. /**
  474. 基本信息vc
  475. @return <#return value description#>
  476. */
  477. - (NewDispatchRequirementGoodsDetailController *)goodsVc{
  478. if (goodsVc == nil) {
  479. goodsVc = [[NewDispatchRequirementGoodsDetailController alloc] init];
  480. goodsVc.cNav = self.navigationController;
  481. // goodsVc.uDelegate = self;
  482. }
  483. return goodsVc;
  484. }
  485. /**
  486. 业绩信息vc
  487. @return <#return value description#>
  488. */
  489. - (NewDispatchRequirementInvoiceInfoController *)invoiceInfoVc{
  490. if (invoiceInfoVc == nil) {
  491. invoiceInfoVc = [[NewDispatchRequirementInvoiceInfoController alloc] init];
  492. invoiceInfoVc.cNav = self.navigationController;
  493. }
  494. return invoiceInfoVc;
  495. }
  496. /**
  497. 返回相应的button
  498. @param tag <#tag description#>
  499. @return <#return value description#>
  500. */
  501. - (UIButton *)buttonWithTag:(NSInteger )tag{
  502. if (tag == 1) {
  503. return _goodsDetailBtn;
  504. }else if (tag == 2){
  505. return _invoiceInfoBtn;
  506. }
  507. else{
  508. return nil;
  509. }
  510. }
  511. /**
  512. 按钮点击事件
  513. @param sender <#sender description#>
  514. */
  515. - (void)sliderAction:(UIButton *)sender{
  516. if (_currentIndex == sender.tag) {
  517. return;
  518. }
  519. // 切换controller
  520. [self sliderAnimationWithTag:sender.tag];
  521. [UIView animateWithDuration:0.3 animations:^{
  522. _mainScrollView.contentOffset = CGPointMake(Screen_Width*(sender.tag-1), 0);
  523. } completion:^(BOOL finished) {
  524. }];
  525. }
  526. /**
  527. 滑动tag
  528. @param tag <#tag description#>
  529. */
  530. - (void)sliderAnimationWithTag:(NSInteger)tag{
  531. self.currentIndex = tag;
  532. _goodsDetailBtn.selected = NO;
  533. _invoiceInfoBtn.selected = NO;
  534. UIButton *sender = [self buttonWithTag:tag];
  535. sender.selected = YES;
  536. //动画
  537. [UIView animateWithDuration:0.3 animations:^{
  538. _sliderLabel.frame = CGRectMake(sender.frame.origin.x, _sliderLabel.frame.origin.y, _sliderLabel.frame.size.width, _sliderLabel.frame.size.height);
  539. } completion:^(BOOL finished) {
  540. }];
  541. }
  542. /**
  543. 滑动tag
  544. @param tag <#tag description#>
  545. */
  546. - (void)sliderWithTag:(NSInteger)tag{
  547. self.currentIndex = tag;
  548. _goodsDetailBtn.selected = NO;
  549. _invoiceInfoBtn.selected = NO;
  550. UIButton *sender = [self buttonWithTag:tag];
  551. sender.selected = YES;
  552. //动画
  553. _sliderLabel.frame = CGRectMake(sender.frame.origin.x,
  554. _sliderLabel.frame.origin.y, _sliderLabel.frame.size.width, _sliderLabel.frame.size.height);
  555. }
  556. -(void)refreshData
  557. {
  558. if([self.refreshDelegate respondsToSelector:@selector(refreshData)])
  559. {
  560. [self.refreshDelegate refreshData];
  561. }
  562. [self.navigationController popViewControllerAnimated:YES];
  563. }
  564. @end