OrderAuditDetailHomeViewController.m 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. //
  2. // OrderAuditDetailHomeViewController.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2018/11/15.
  6. // Copyright © 2018 elongtian. All rights reserved.
  7. //
  8. #import "OrderAuditDetailHomeViewController.h"
  9. #import "OrderDetailListViewController.h"
  10. #import "ManufactureDetailListViewController.h"
  11. #import "OrderFeesDetailListViewController.h"
  12. #import "AttachmentViewController.h"
  13. #import "OrderDetailHeadViewController.h"
  14. #import "OrderFeesDetailModel.h"
  15. @interface OrderAuditDetailHomeViewController (){
  16. OrderDetailListViewController *_orderDetailListVc;
  17. ManufactureDetailListViewController *_manufactureDetailListVc;
  18. OrderFeesDetailListViewController *_orderFeesDetailListVc;
  19. AttachmentViewController *_attachmentVc;
  20. OrderDetailHeadViewController *_headVc;
  21. // 滑动线
  22. UILabel *_sliderLabel;
  23. // 滚动条
  24. UIScrollView *_mainScrollView;
  25. // 基本信息按钮
  26. UIButton *_orderHeadBtn;
  27. UIButton *_orderDetailBtn;
  28. UIButton *_manufactureDetailBtn;
  29. UIButton *_orderFeesDetailBtn;
  30. UIButton *_attachmentBtn;
  31. }
  32. @end
  33. static int navcount = 5;
  34. @implementation OrderAuditDetailHomeViewController
  35. #pragma mark - 公共函数
  36. /**
  37. 视图加载完成函数
  38. */
  39. - (void)viewDidLoad {
  40. [super viewDidLoad];
  41. [self initUI];
  42. [self setMainSrollView];
  43. _orderDetailArray=[[NSMutableArray alloc]init];
  44. _orderFeesDetailArray=[[NSMutableArray alloc]init];
  45. _manuDetailArray=[[NSMutableArray alloc]init];
  46. _attachArray=[[NSMutableArray alloc]init];
  47. [self sliderWithTag:self.currentIndex+1];
  48. [self startLoading];
  49. [self loadData];
  50. }
  51. /**
  52. 安全区视图发生变化
  53. */
  54. -(void)viewSafeAreaInsetsDidChange{
  55. self.view.backgroundColor = [UIColor whiteColor];
  56. _mainScrollView.frame = CGRectMake(0, 40, Screen_Width,self.view.safeAreaLayoutGuide.layoutFrame.size.height-40);
  57. for (NSInteger i = 0; i < _mainScrollView.subviews.count; i++) {
  58. _mainScrollView.subviews[i].frame = CGRectMake(Screen_Width * i, 0, Screen_Width,CGRectGetHeight(_mainScrollView.frame));
  59. }
  60. [self.headVc viewSafeAreaInsetsDidChange];
  61. [self.orderDetailListVc viewSafeAreaInsetsDidChange];
  62. [self.manufactureDetailListVc viewSafeAreaInsetsDidChange];
  63. [self.orderFeesDetailListVc viewSafeAreaInsetsDidChange];
  64. [self.attachmentVc viewSafeAreaInsetsDidChange];
  65. [super viewSafeAreaInsetsDidChange];
  66. }
  67. - (OrderDetailHeadViewController *)headVc{
  68. if (_headVc == nil) {
  69. _headVc = [[OrderDetailHeadViewController alloc] init];
  70. _headVc.auditListModel=_auditModel;
  71. }
  72. return _headVc;
  73. }
  74. /**
  75. 订单明细vc
  76. @return <#return value description#>
  77. */
  78. - (OrderDetailListViewController *)orderDetailListVc{
  79. if (_orderDetailListVc == nil) {
  80. _orderDetailListVc = [[OrderDetailListViewController alloc] init];
  81. }
  82. return _orderDetailListVc;
  83. }
  84. /**
  85. h加工明细vc
  86. @return <#return value description#>
  87. */
  88. - (ManufactureDetailListViewController *)manufactureDetailListVc{
  89. if (_manufactureDetailListVc == nil) {
  90. _manufactureDetailListVc = [[ManufactureDetailListViewController alloc] init];
  91. }
  92. return _manufactureDetailListVc;
  93. }
  94. - (OrderFeesDetailListViewController *)orderFeesDetailListVc{
  95. if (_orderFeesDetailListVc == nil) {
  96. _orderFeesDetailListVc = [[OrderFeesDetailListViewController alloc] init];
  97. }
  98. return _orderFeesDetailListVc;
  99. }
  100. - (AttachmentViewController *)attachmentVc{
  101. if (_attachmentVc == nil) {
  102. _attachmentVc = [[AttachmentViewController alloc] init];
  103. }
  104. return _attachmentVc;
  105. }
  106. #pragma mark - 委托函数
  107. /**
  108. 加载列表数据成功回调
  109. @param sender
  110. */
  111. - (void)onLoadFinish:(ASIDownManager *)sender {
  112. // 取消进度条
  113. [self stopLoading];
  114. // 服务器返回数据
  115. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  116. // 服务器返回数据状态值
  117. int iStatus = resultModel.status;
  118. // 服务器返回数据消息
  119. NSString *message = resultModel.message;
  120. // 服务器返回数据状态值正确
  121. if (iStatus == 0) {
  122. // 服务器返回数据结果
  123. NSDictionary *infoDic= (NSDictionary *)resultModel.result;
  124. if(infoDic!=nil){
  125. NSArray *tableArray=[infoDic objectForKey:@"Table"];
  126. NSArray *table1Array=[infoDic objectForKey:@"Table1"];
  127. NSArray *table2Array=[infoDic objectForKey:@"Table2"];
  128. NSArray *table3Array=[infoDic objectForKey:@"Table3"];
  129. if(tableArray!=nil&&tableArray.count>0){
  130. for(int i=0;i<tableArray.count;i++){
  131. NSDictionary *tableDic=[tableArray objectAtIndex:i];
  132. OrderDetailModel *detailModel=[OrderDetailModel new];
  133. [detailModel parseDic:tableDic];
  134. [_orderDetailArray addObject:detailModel];
  135. }
  136. [ _orderDetailListVc loadData:_orderDetailArray];
  137. }
  138. if(table1Array!=nil&&table1Array.count>0){
  139. for(int i=0;i<table1Array.count;i++){
  140. NSDictionary *feesDic=[table1Array objectAtIndex:i];
  141. OrderFeesDetailModel *orderFeesDetailModel=[OrderFeesDetailModel new];
  142. [orderFeesDetailModel parseDic:feesDic];
  143. [_orderFeesDetailArray addObject:orderFeesDetailModel];
  144. }
  145. [_orderFeesDetailListVc loadData:_orderFeesDetailArray];
  146. }
  147. if(table2Array!=nil&&table2Array.count>0){
  148. for(int i=0;i<table2Array.count;i++){
  149. NSDictionary *manuFeesDic=[table2Array objectAtIndex:i];
  150. ManufactureDetailModel *manuDetailModel=[ManufactureDetailModel new];
  151. [manuDetailModel parseDic:manuFeesDic];
  152. [_manuDetailArray addObject:manuDetailModel];
  153. }
  154. [_manufactureDetailListVc loadData:_manuDetailArray];
  155. }
  156. if(table3Array!=nil&&table3Array.count>0){
  157. for(int i=0;i<table3Array.count;i++){
  158. NSDictionary *attachDic=[table3Array objectAtIndex:i];
  159. NSString *filePath= [attachDic objectForKey:@"FilePath"];
  160. NSString *fileName= [attachDic objectForKey:@"FileName"];
  161. NSString *lowercaseFileName= [fileName lowercaseString];
  162. if([lowercaseFileName rangeOfString:@"jpg"].location!=NSNotFound||[lowercaseFileName rangeOfString:@"png"].location!=NSNotFound||[lowercaseFileName rangeOfString:@"gif"].location!=NSNotFound||[lowercaseFileName rangeOfString:@"jpeg"].location!=NSNotFound){
  163. ImageModel *img=[ImageModel new];
  164. img.imageName=filePath;
  165. [_attachArray addObject:img];
  166. }
  167. }
  168. if(_attachArray!=nil&&_attachArray.count>0){
  169. [_attachmentVc loadData:_attachArray];
  170. }
  171. }
  172. }
  173. }
  174. // 服务器返回数据状态值异常
  175. else if(iStatus == ActionResultStatusAuthError
  176. ||iStatus == ActionResultStatusNoLogin
  177. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  178. [self showReLoginDialog:message];
  179. }
  180. else{
  181. [self showAlertViewText:message];
  182. return;
  183. }
  184. }
  185. /**
  186. 列表加载数据失败回调
  187. @param sender <#sender description#>
  188. */
  189. - (void)onLoadFail:(ASIDownManager *)sender {
  190. [self showAlertViewText:@"网络异常"];
  191. }
  192. /**
  193. 滑动label位置
  194. @param scrollView <#scrollView description#>
  195. */
  196. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  197. //实时计算当前位置,实现和titleView上的按钮的联动
  198. CGFloat contentOffSetX = scrollView.contentOffset.x;
  199. CGFloat X = contentOffSetX/ navcount;
  200. CGRect frame = _sliderLabel.frame;
  201. frame.origin.x = X;
  202. _sliderLabel.frame = frame;
  203. if(X > _sliderLabel.frame.size.width/2){
  204. UIView *line = _sliderLabel.subviews[0];
  205. line.frame = CGRectMake(((Screen_Width/navcount)-40)/2, 0, 40, 2);
  206. }else{
  207. UIView *line = _sliderLabel.subviews[0];
  208. line.frame = CGRectMake(((Screen_Width/navcount)-70)/2, 0, 70, 2);
  209. }
  210. }
  211. /**
  212. 滑动完成
  213. @param scrollView <#scrollView description#>
  214. */
  215. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  216. CGFloat contentOffSetX = scrollView.contentOffset.x;
  217. int index_ = contentOffSetX/Screen_Width;
  218. [self sliderWithTag:index_+1];
  219. }
  220. #pragma mark - 私有函数
  221. -(void)loadData
  222. {
  223. [self startLoading];
  224. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  225. [dict setObject:@"GetExamineDetailIphone" forKey:@"Action"];
  226. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  227. [dict setObject:kkUserCode forKey:@"UserCode"];
  228. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  229. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  230. [dict setObject:[NSString stringWithFormat:@"%d", _orderId] forKey:@"OrderID"];
  231. _downManager = [[ASIDownManager alloc] init];
  232. _downManager.delegate = self;
  233. _downManager.onRequestSuccess = @selector(onLoadFinish:);
  234. _downManager.onRequestFail = @selector(onLoadFail:);
  235. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  236. }
  237. /**
  238. 初始化ui
  239. */
  240. - (void)initUI{
  241. self.navigationItem.title =@"订单审核明细";
  242. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  243. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  244. [button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
  245. button.frame = CGRectMake(0, 0,45,22);
  246. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
  247. // 5个controller按钮
  248. UIView *navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 40)];
  249. [self.view setBackgroundColor:[UIColor whiteColor]];
  250. _orderHeadBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  251. [_orderHeadBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  252. [_orderHeadBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  253. _orderHeadBtn.frame = CGRectMake(2, 0, Screen_Width/navcount, navView.frame.size.height);
  254. _orderHeadBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
  255. [_orderHeadBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
  256. [_orderHeadBtn setTitle:@"订单总表" forState:UIControlStateNormal];
  257. _orderHeadBtn.tag = 1;
  258. _orderHeadBtn.selected = YES;
  259. [navView addSubview:_orderHeadBtn];
  260. _orderDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  261. [_orderDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  262. [_orderDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  263. _orderDetailBtn.frame = CGRectMake(_orderHeadBtn.frame.origin.x+_orderHeadBtn.frame.size.width, _orderHeadBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
  264. _orderDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
  265. [_orderDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
  266. [_orderDetailBtn setTitle:@"订单明细" forState:UIControlStateNormal];
  267. _orderDetailBtn.tag = 2;
  268. _orderDetailBtn.selected = YES;
  269. [navView addSubview:_orderDetailBtn];
  270. _manufactureDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  271. _manufactureDetailBtn.frame = CGRectMake(_orderDetailBtn.frame.origin.x+_orderDetailBtn.frame.size.width, _orderDetailBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
  272. [_manufactureDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  273. [_manufactureDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  274. _manufactureDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
  275. [_manufactureDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
  276. [_manufactureDetailBtn setTitle:@"加工明细" forState:UIControlStateNormal];
  277. _manufactureDetailBtn.tag = 3;
  278. [navView addSubview:_manufactureDetailBtn];
  279. _orderFeesDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  280. _orderFeesDetailBtn.frame = CGRectMake(_manufactureDetailBtn.frame.origin.x+_manufactureDetailBtn.frame.size.width, _manufactureDetailBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
  281. [_orderFeesDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  282. [_orderFeesDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  283. _orderFeesDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
  284. [_orderFeesDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
  285. [_orderFeesDetailBtn setTitle:@"订单费用" forState:UIControlStateNormal];
  286. _orderFeesDetailBtn.tag = 4;
  287. [navView addSubview:_orderFeesDetailBtn];
  288. // 私密
  289. _attachmentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  290. _attachmentBtn.frame = CGRectMake(_orderFeesDetailBtn.frame.origin.x+_orderFeesDetailBtn.frame.size.width, _orderFeesDetailBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
  291. [_attachmentBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  292. [_attachmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  293. _attachmentBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
  294. [_attachmentBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
  295. [_attachmentBtn setTitle:@"附件" forState:UIControlStateNormal];
  296. _attachmentBtn.tag = 5;
  297. [navView addSubview:_attachmentBtn];
  298. // 选中后的红线
  299. _sliderLabel = [[UILabel alloc]initWithFrame:CGRectMake(_orderHeadBtn.frame.origin.x, 40-2, Screen_Width/navcount, 2)];
  300. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(((Screen_Width/navcount)-75)/2, 0, 75, 2)];
  301. line.backgroundColor = [UIColor redColor];
  302. [_sliderLabel addSubview:line];
  303. [navView addSubview:_sliderLabel];
  304. [self.view addSubview:navView];
  305. }
  306. /**
  307. 初始化srollView
  308. */
  309. - (void)setMainSrollView{
  310. // 滚动view
  311. _mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 40, Screen_Width, Screen_Height- rectStatusHeight-rectNavHeight - 40)];
  312. _mainScrollView.delegate = self;
  313. _mainScrollView.backgroundColor = [UIColor whiteColor];
  314. _mainScrollView.pagingEnabled = YES;
  315. _mainScrollView.showsHorizontalScrollIndicator = NO;
  316. _mainScrollView.showsVerticalScrollIndicator = NO;
  317. [self.view addSubview:_mainScrollView];
  318. NSArray *views = @[self.headVc.view,self.orderDetailListVc.view,self.manufactureDetailListVc.view ,
  319. self.orderFeesDetailListVc.view,self.attachmentVc.view];
  320. for (NSInteger i = 0; i< views.count; i++) {
  321. //把三个vc的view依次贴到mainScrollView上面
  322. UIView *pageView = [[UIView alloc]initWithFrame:CGRectMake(Screen_Width * i, 0, _mainScrollView.frame.size.width, _mainScrollView.frame.size.height)];
  323. [pageView addSubview:views[i]];
  324. [_mainScrollView addSubview:pageView];
  325. }
  326. _mainScrollView.contentSize = CGSizeMake(Screen_Width*(views.count), 0);
  327. //滚动到_currentIndex对应的tab
  328. [_mainScrollView setContentOffset:CGPointMake((_mainScrollView.frame.size.width)*_currentIndex, 0) animated:YES];
  329. }
  330. /**
  331. 返回相应的button
  332. @param tag <#tag description#>
  333. @return <#return value description#>
  334. */
  335. - (UIButton *)buttonWithTag:(NSInteger )tag{
  336. if(tag==1){
  337. return _orderHeadBtn;
  338. }
  339. else if (tag == 2) {
  340. return _orderDetailBtn;
  341. }else if (tag == 3){
  342. return _manufactureDetailBtn;
  343. }
  344. else if (tag == 4){
  345. return _orderFeesDetailBtn;
  346. }
  347. else if (tag == 5){
  348. return _attachmentBtn;
  349. }
  350. else{
  351. return nil;
  352. }
  353. }
  354. /**
  355. 按钮点击事件
  356. @param sender <#sender description#>
  357. */
  358. - (void)sliderAction:(UIButton *)sender{
  359. if (self.currentIndex == sender.tag) {
  360. return;
  361. }
  362. // 切换controller
  363. [self.view endEditing:YES];
  364. [self sliderAnimationWithTag:sender.tag];
  365. [UIView animateWithDuration:0.3 animations:^{
  366. self->_mainScrollView.contentOffset = CGPointMake(Screen_Width*(sender.tag-1), 0);
  367. } completion:^(BOOL finished) {
  368. }];
  369. }
  370. /**
  371. 滑动tag
  372. @param tag <#tag description#>
  373. */
  374. - (void)sliderAnimationWithTag:(NSInteger)tag{
  375. self.currentIndex = tag;
  376. _orderHeadBtn.selected = NO;
  377. _orderDetailBtn.selected = NO;
  378. _manufactureDetailBtn.selected = NO;
  379. _orderFeesDetailBtn.selected = NO;
  380. _attachmentBtn.selected = NO;
  381. UIButton *sender = [self buttonWithTag:tag];
  382. sender.selected = YES;
  383. //动画
  384. [UIView animateWithDuration:0.3 animations:^{
  385. self->_sliderLabel.frame = CGRectMake(sender.frame.origin.x, self->_sliderLabel.frame.origin.y, self->_sliderLabel.frame.size.width, self->_sliderLabel.frame.size.height);
  386. } completion:^(BOOL finished) {
  387. }];
  388. }
  389. /**
  390. 滑动tag
  391. @param tag <#tag description#>
  392. */
  393. - (void)sliderWithTag:(NSInteger)tag{
  394. self.currentIndex = tag;
  395. _orderHeadBtn.selected = NO;
  396. _orderDetailBtn.selected = NO;
  397. _manufactureDetailBtn.selected = NO;
  398. _orderFeesDetailBtn.selected = NO;
  399. _attachmentBtn.selected = NO;
  400. UIButton *sender = [self buttonWithTag:tag];
  401. sender.selected = YES;
  402. //动画
  403. _sliderLabel.frame = CGRectMake(sender.frame.origin.x, _sliderLabel.frame.origin.y, _sliderLabel.frame.size.width, _sliderLabel.frame.size.height);
  404. }
  405. @end