| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- //
- // OrderAuditDetailHomeViewController.m
- // IBOSS
- //
- // Created by 关宏厚 on 2018/11/15.
- // Copyright © 2018 elongtian. All rights reserved.
- //
- #import "OrderAuditDetailHomeViewController.h"
- #import "OrderDetailListViewController.h"
- #import "ManufactureDetailListViewController.h"
- #import "OrderFeesDetailListViewController.h"
- #import "AttachmentViewController.h"
- #import "OrderDetailHeadViewController.h"
- #import "OrderFeesDetailModel.h"
- @interface OrderAuditDetailHomeViewController (){
-
- OrderDetailListViewController *_orderDetailListVc;
- ManufactureDetailListViewController *_manufactureDetailListVc;
- OrderFeesDetailListViewController *_orderFeesDetailListVc;
- AttachmentViewController *_attachmentVc;
- OrderDetailHeadViewController *_headVc;
- // 滑动线
- UILabel *_sliderLabel;
- // 滚动条
- UIScrollView *_mainScrollView;
- // 基本信息按钮
- UIButton *_orderHeadBtn;
- UIButton *_orderDetailBtn;
- UIButton *_manufactureDetailBtn;
- UIButton *_orderFeesDetailBtn;
- UIButton *_attachmentBtn;
- }
- @end
- static int navcount = 5;
- @implementation OrderAuditDetailHomeViewController
- #pragma mark - 公共函数
- /**
- 视图加载完成函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initUI];
- [self setMainSrollView];
- _orderDetailArray=[[NSMutableArray alloc]init];
- _orderFeesDetailArray=[[NSMutableArray alloc]init];
- _manuDetailArray=[[NSMutableArray alloc]init];
- _attachArray=[[NSMutableArray alloc]init];
- [self sliderWithTag:self.currentIndex+1];
- [self startLoading];
- [self loadData];
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- self.view.backgroundColor = [UIColor whiteColor];
- _mainScrollView.frame = CGRectMake(0, 40, Screen_Width,self.view.safeAreaLayoutGuide.layoutFrame.size.height-40);
- for (NSInteger i = 0; i < _mainScrollView.subviews.count; i++) {
- _mainScrollView.subviews[i].frame = CGRectMake(Screen_Width * i, 0, Screen_Width,CGRectGetHeight(_mainScrollView.frame));
- }
- [self.headVc viewSafeAreaInsetsDidChange];
- [self.orderDetailListVc viewSafeAreaInsetsDidChange];
- [self.manufactureDetailListVc viewSafeAreaInsetsDidChange];
- [self.orderFeesDetailListVc viewSafeAreaInsetsDidChange];
- [self.attachmentVc viewSafeAreaInsetsDidChange];
-
- [super viewSafeAreaInsetsDidChange];
- }
- - (OrderDetailHeadViewController *)headVc{
- if (_headVc == nil) {
- _headVc = [[OrderDetailHeadViewController alloc] init];
- _headVc.auditListModel=_auditModel;
- }
- return _headVc;
- }
- /**
- 订单明细vc
- @return <#return value description#>
- */
- - (OrderDetailListViewController *)orderDetailListVc{
- if (_orderDetailListVc == nil) {
- _orderDetailListVc = [[OrderDetailListViewController alloc] init];
- }
- return _orderDetailListVc;
- }
- /**
- h加工明细vc
- @return <#return value description#>
- */
- - (ManufactureDetailListViewController *)manufactureDetailListVc{
- if (_manufactureDetailListVc == nil) {
- _manufactureDetailListVc = [[ManufactureDetailListViewController alloc] init];
- }
- return _manufactureDetailListVc;
- }
- - (OrderFeesDetailListViewController *)orderFeesDetailListVc{
- if (_orderFeesDetailListVc == nil) {
- _orderFeesDetailListVc = [[OrderFeesDetailListViewController alloc] init];
- }
- return _orderFeesDetailListVc;
- }
- - (AttachmentViewController *)attachmentVc{
- if (_attachmentVc == nil) {
- _attachmentVc = [[AttachmentViewController alloc] init];
- }
-
- return _attachmentVc;
- }
- #pragma mark - 委托函数
- /**
- 加载列表数据成功回调
- @param sender
- */
- - (void)onLoadFinish:(ASIDownManager *)sender {
- // 取消进度条
- [self stopLoading];
- // 服务器返回数据
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- NSString *message = resultModel.message;
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- // 服务器返回数据结果
- NSDictionary *infoDic= (NSDictionary *)resultModel.result;
- if(infoDic!=nil){
- NSArray *tableArray=[infoDic objectForKey:@"Table"];
- NSArray *table1Array=[infoDic objectForKey:@"Table1"];
- NSArray *table2Array=[infoDic objectForKey:@"Table2"];
- NSArray *table3Array=[infoDic objectForKey:@"Table3"];
- if(tableArray!=nil&&tableArray.count>0){
- for(int i=0;i<tableArray.count;i++){
- NSDictionary *tableDic=[tableArray objectAtIndex:i];
- OrderDetailModel *detailModel=[OrderDetailModel new];
- [detailModel parseDic:tableDic];
- [_orderDetailArray addObject:detailModel];
- }
- [ _orderDetailListVc loadData:_orderDetailArray];
- }
-
- if(table1Array!=nil&&table1Array.count>0){
- for(int i=0;i<table1Array.count;i++){
- NSDictionary *feesDic=[table1Array objectAtIndex:i];
- OrderFeesDetailModel *orderFeesDetailModel=[OrderFeesDetailModel new];
- [orderFeesDetailModel parseDic:feesDic];
- [_orderFeesDetailArray addObject:orderFeesDetailModel];
- }
- [_orderFeesDetailListVc loadData:_orderFeesDetailArray];
- }
-
- if(table2Array!=nil&&table2Array.count>0){
- for(int i=0;i<table2Array.count;i++){
- NSDictionary *manuFeesDic=[table2Array objectAtIndex:i];
- ManufactureDetailModel *manuDetailModel=[ManufactureDetailModel new];
- [manuDetailModel parseDic:manuFeesDic];
- [_manuDetailArray addObject:manuDetailModel];
- }
-
- [_manufactureDetailListVc loadData:_manuDetailArray];
- }
-
- if(table3Array!=nil&&table3Array.count>0){
- for(int i=0;i<table3Array.count;i++){
- NSDictionary *attachDic=[table3Array objectAtIndex:i];
- NSString *filePath= [attachDic objectForKey:@"FilePath"];
- NSString *fileName= [attachDic objectForKey:@"FileName"];
- NSString *lowercaseFileName= [fileName lowercaseString];
- if([lowercaseFileName rangeOfString:@"jpg"].location!=NSNotFound||[lowercaseFileName rangeOfString:@"png"].location!=NSNotFound||[lowercaseFileName rangeOfString:@"gif"].location!=NSNotFound||[lowercaseFileName rangeOfString:@"jpeg"].location!=NSNotFound){
- ImageModel *img=[ImageModel new];
- img.imageName=filePath;
- [_attachArray addObject:img];
- }
- }
-
- if(_attachArray!=nil&&_attachArray.count>0){
- [_attachmentVc loadData:_attachArray];
- }
- }
-
-
- }
- }
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
-
-
- [self showReLoginDialog:message];
- }
- else{
-
- [self showAlertViewText:message];
- return;
- }
- }
- /**
- 列表加载数据失败回调
- @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self showAlertViewText:@"网络异常"];
- }
- /**
- 滑动label位置
-
- @param scrollView <#scrollView description#>
- */
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- //实时计算当前位置,实现和titleView上的按钮的联动
- CGFloat contentOffSetX = scrollView.contentOffset.x;
- CGFloat X = contentOffSetX/ navcount;
- CGRect frame = _sliderLabel.frame;
- frame.origin.x = X;
- _sliderLabel.frame = frame;
- if(X > _sliderLabel.frame.size.width/2){
- UIView *line = _sliderLabel.subviews[0];
- line.frame = CGRectMake(((Screen_Width/navcount)-40)/2, 0, 40, 2);
- }else{
- UIView *line = _sliderLabel.subviews[0];
- line.frame = CGRectMake(((Screen_Width/navcount)-70)/2, 0, 70, 2);
- }
- }
- /**
- 滑动完成
-
- @param scrollView <#scrollView description#>
- */
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
- CGFloat contentOffSetX = scrollView.contentOffset.x;
- int index_ = contentOffSetX/Screen_Width;
- [self sliderWithTag:index_+1];
- }
- #pragma mark - 私有函数
- -(void)loadData
- {
- [self startLoading];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetExamineDetailIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:[NSString stringWithFormat:@"%d", _orderId] forKey:@"OrderID"];
-
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onLoadFinish:);
- _downManager.onRequestFail = @selector(onLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- /**
- 初始化ui
- */
- - (void)initUI{
- self.navigationItem.title =@"订单审核明细";
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,45,22);
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
-
- // 5个controller按钮
- UIView *navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 40)];
- [self.view setBackgroundColor:[UIColor whiteColor]];
-
- _orderHeadBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_orderHeadBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
- [_orderHeadBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-
- _orderHeadBtn.frame = CGRectMake(2, 0, Screen_Width/navcount, navView.frame.size.height);
- _orderHeadBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
- [_orderHeadBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
- [_orderHeadBtn setTitle:@"订单总表" forState:UIControlStateNormal];
- _orderHeadBtn.tag = 1;
- _orderHeadBtn.selected = YES;
- [navView addSubview:_orderHeadBtn];
-
-
- _orderDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_orderDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
- [_orderDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-
- _orderDetailBtn.frame = CGRectMake(_orderHeadBtn.frame.origin.x+_orderHeadBtn.frame.size.width, _orderHeadBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
- _orderDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
- [_orderDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
- [_orderDetailBtn setTitle:@"订单明细" forState:UIControlStateNormal];
- _orderDetailBtn.tag = 2;
- _orderDetailBtn.selected = YES;
- [navView addSubview:_orderDetailBtn];
-
- _manufactureDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _manufactureDetailBtn.frame = CGRectMake(_orderDetailBtn.frame.origin.x+_orderDetailBtn.frame.size.width, _orderDetailBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
- [_manufactureDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
- [_manufactureDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-
- _manufactureDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
- [_manufactureDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
- [_manufactureDetailBtn setTitle:@"加工明细" forState:UIControlStateNormal];
- _manufactureDetailBtn.tag = 3;
- [navView addSubview:_manufactureDetailBtn];
-
- _orderFeesDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _orderFeesDetailBtn.frame = CGRectMake(_manufactureDetailBtn.frame.origin.x+_manufactureDetailBtn.frame.size.width, _manufactureDetailBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
- [_orderFeesDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
- [_orderFeesDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-
- _orderFeesDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
- [_orderFeesDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
- [_orderFeesDetailBtn setTitle:@"订单费用" forState:UIControlStateNormal];
- _orderFeesDetailBtn.tag = 4;
- [navView addSubview:_orderFeesDetailBtn];
- // 私密
- _attachmentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _attachmentBtn.frame = CGRectMake(_orderFeesDetailBtn.frame.origin.x+_orderFeesDetailBtn.frame.size.width, _orderFeesDetailBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
- [_attachmentBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
- [_attachmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-
- _attachmentBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
- [_attachmentBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
- [_attachmentBtn setTitle:@"附件" forState:UIControlStateNormal];
- _attachmentBtn.tag = 5;
- [navView addSubview:_attachmentBtn];
-
-
- // 选中后的红线
- _sliderLabel = [[UILabel alloc]initWithFrame:CGRectMake(_orderHeadBtn.frame.origin.x, 40-2, Screen_Width/navcount, 2)];
- UIView *line = [[UIView alloc] initWithFrame:CGRectMake(((Screen_Width/navcount)-75)/2, 0, 75, 2)];
- line.backgroundColor = [UIColor redColor];
- [_sliderLabel addSubview:line];
- [navView addSubview:_sliderLabel];
- [self.view addSubview:navView];
-
- }
- /**
- 初始化srollView
- */
- - (void)setMainSrollView{
-
- // 滚动view
- _mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 40, Screen_Width, Screen_Height- rectStatusHeight-rectNavHeight - 40)];
- _mainScrollView.delegate = self;
- _mainScrollView.backgroundColor = [UIColor whiteColor];
- _mainScrollView.pagingEnabled = YES;
- _mainScrollView.showsHorizontalScrollIndicator = NO;
- _mainScrollView.showsVerticalScrollIndicator = NO;
- [self.view addSubview:_mainScrollView];
-
- NSArray *views = @[self.headVc.view,self.orderDetailListVc.view,self.manufactureDetailListVc.view ,
- self.orderFeesDetailListVc.view,self.attachmentVc.view];
- for (NSInteger i = 0; i< views.count; i++) {
- //把三个vc的view依次贴到mainScrollView上面
- UIView *pageView = [[UIView alloc]initWithFrame:CGRectMake(Screen_Width * i, 0, _mainScrollView.frame.size.width, _mainScrollView.frame.size.height)];
- [pageView addSubview:views[i]];
- [_mainScrollView addSubview:pageView];
- }
- _mainScrollView.contentSize = CGSizeMake(Screen_Width*(views.count), 0);
- //滚动到_currentIndex对应的tab
- [_mainScrollView setContentOffset:CGPointMake((_mainScrollView.frame.size.width)*_currentIndex, 0) animated:YES];
-
-
- }
- /**
- 返回相应的button
-
- @param tag <#tag description#>
- @return <#return value description#>
- */
- - (UIButton *)buttonWithTag:(NSInteger )tag{
- if(tag==1){
- return _orderHeadBtn;
- }
- else if (tag == 2) {
- return _orderDetailBtn;
- }else if (tag == 3){
- return _manufactureDetailBtn;
- }
- else if (tag == 4){
- return _orderFeesDetailBtn;
- }
- else if (tag == 5){
- return _attachmentBtn;
- }
- else{
- return nil;
- }
- }
- /**
- 按钮点击事件
-
- @param sender <#sender description#>
- */
- - (void)sliderAction:(UIButton *)sender{
- if (self.currentIndex == sender.tag) {
- return;
- }
- // 切换controller
- [self.view endEditing:YES];
- [self sliderAnimationWithTag:sender.tag];
- [UIView animateWithDuration:0.3 animations:^{
- self->_mainScrollView.contentOffset = CGPointMake(Screen_Width*(sender.tag-1), 0);
- } completion:^(BOOL finished) {
-
- }];
- }
- /**
- 滑动tag
-
- @param tag <#tag description#>
- */
- - (void)sliderAnimationWithTag:(NSInteger)tag{
- self.currentIndex = tag;
- _orderHeadBtn.selected = NO;
- _orderDetailBtn.selected = NO;
- _manufactureDetailBtn.selected = NO;
- _orderFeesDetailBtn.selected = NO;
- _attachmentBtn.selected = NO;
- UIButton *sender = [self buttonWithTag:tag];
- sender.selected = YES;
- //动画
- [UIView animateWithDuration:0.3 animations:^{
- self->_sliderLabel.frame = CGRectMake(sender.frame.origin.x, self->_sliderLabel.frame.origin.y, self->_sliderLabel.frame.size.width, self->_sliderLabel.frame.size.height);
-
- } completion:^(BOOL finished) {
- }];
- }
- /**
- 滑动tag
-
- @param tag <#tag description#>
- */
- - (void)sliderWithTag:(NSInteger)tag{
- self.currentIndex = tag;
- _orderHeadBtn.selected = NO;
- _orderDetailBtn.selected = NO;
- _manufactureDetailBtn.selected = NO;
- _orderFeesDetailBtn.selected = NO;
- _attachmentBtn.selected = NO;
- UIButton *sender = [self buttonWithTag:tag];
- sender.selected = YES;
- //动画
- _sliderLabel.frame = CGRectMake(sender.frame.origin.x, _sliderLabel.frame.origin.y, _sliderLabel.frame.size.width, _sliderLabel.frame.size.height);
- }
- @end
|