| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- //
- // NewDispatchRequirementHomeController.m
- // IBOSS-HJ
- //
- // Created by 关宏厚 on 2021/1/28.
- // Copyright © 2021 elongtian. All rights reserved.
- //
- #import "NewDispatchRequirementHomeController.h"
- #import "NewDispatchRequirementInvoiceInfoController.h"
- #import "NewDispatchRequirementGoodsDetailController.h"
- #import "DispatchImageInfoVC.h"
- @interface NewDispatchRequirementHomeController ()
- {
- NewDispatchRequirementInvoiceInfoController *invoiceInfoVc;
- NewDispatchRequirementGoodsDetailController *goodsVc;
- UIButton *_invoiceInfoBtn;
- // 业绩信息按钮
- UIButton *_goodsDetailBtn;
- UILabel *lblCustomer;
-
- // 滑动线
- UILabel *_sliderLabel;
- // 滚动条
- UIScrollView *_mainScrollView;
- UIButton *btnSave;
- UIView *navView;
- UIView *viewBackgroud;
-
- }
- @end
- static int navcount = 2;
- @implementation NewDispatchRequirementHomeController
- - (void)viewDidLoad {
- [super viewDidLoad];
- _currentIndex=0;
- [self initUI];
- [self setMainSrollView];
- //设置默认
- [self sliderWithTag:self.currentIndex+1];
- self.goodsVc.noReceiptModel=_noReceiptModel;
- lblCustomer.text=_noReceiptModel.customerName;
- self.goodsVc.lblTelephone.text=_noReceiptModel.telephone;
- self.goodsVc.lbDeliveryAddress.text=_noReceiptModel.deliveryAddress;
- self.goodsVc.txtPlateNumber.text=_noReceiptModel.truckName;
- self.invoiceInfoVc.lblDeliveryDate.text=_noReceiptModel.deliveryDate;
- self.invoiceInfoVc.lblReceivables.text=_noReceiptModel.receivables;
- self.invoiceInfoVc.lblRemainingReceivables.text=_noReceiptModel.remainingReceivables;
- self.invoiceInfoVc.txtReceiptAmount.text=_noReceiptModel.receiptAmount;
- if([_noReceiptModel.remainingReceivables doubleValue]>0)
- {
- self.invoiceInfoVc.txtReceiptAmount.enabled=YES;
- self.invoiceInfoVc.btnReceivablesType.enabled=YES;
- }
- else
- {
- self.invoiceInfoVc.txtReceiptAmount.enabled=NO;
- self.invoiceInfoVc.btnReceivablesType.enabled=NO;
- }
-
- [self.goodsVc loadData];
-
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- self.view.backgroundColor = [UIColor whiteColor];
- navView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, 40)];
- _mainScrollView.frame = CGRectMake(0,CGRectGetMaxY(navView.frame), 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.invoiceInfoVc viewSafeAreaInsetsDidChange];
- [self.goodsVc viewSafeAreaInsetsDidChange];
- btnSave.frame=CGRectMake(0,self.view.safeAreaLayoutGuide.layoutFrame.size.height-40, Screen_Width,40) ;
- [super viewSafeAreaInsetsDidChange];
- }
- -(void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)initUI
- {
- self.navigationItem.title = @"新增派工回执";
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setBackgroundImage:[UIImage imageNamed:@"icon_back.png"]
- forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,15,18);
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
-
- UIView *vCustomerName = [UIView new];
- vCustomerName.frame = CGRectMake(0,0, Screen_Width, 40);
- [self.view addSubview:vCustomerName];
- UILabel *lblTxtVCustomerName = [UILabel new];
- lblTxtVCustomerName.frame = CGRectMake(20, 7, 90, 25);
- lblTxtVCustomerName.text = @"客户名称:";
- lblTxtVCustomerName.font = [UIFont systemFontOfSize:16];;
- [vCustomerName addSubview:lblTxtVCustomerName];
- lblCustomer = [UILabel new];
- lblCustomer.font = [UIFont systemFontOfSize:16];
- lblCustomer.frame = CGRectMake(CGRectGetMaxX(lblTxtVCustomerName.frame), 7, Screen_Width -CGRectGetMaxX(lblTxtVCustomerName.frame) - 30, 25);
- [vCustomerName addSubview:lblCustomer];
-
-
- //分割线
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vCustomerName.frame), Screen_Width, 1);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [self.view addSubview:viewBackgroud];
-
- navView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, 40)];
- [self.view setBackgroundColor:[UIColor whiteColor]];
- _goodsDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_goodsDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
- [_goodsDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-
- _goodsDetailBtn.frame = CGRectMake(2, 0, Screen_Width/navcount, navView.frame.size.height);
- _goodsDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
- [_goodsDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
- [_goodsDetailBtn setTitle:@"明细" forState:UIControlStateNormal];
- _goodsDetailBtn.tag = 1;
- _goodsDetailBtn.selected = YES;
- [navView addSubview:_goodsDetailBtn];
-
- // 业绩
- _invoiceInfoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _invoiceInfoBtn.frame = CGRectMake(_goodsDetailBtn.frame.origin.x+_goodsDetailBtn.frame.size.width, 0, Screen_Width/navcount, navView.frame.size.height);
- [_invoiceInfoBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
- [_invoiceInfoBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-
- _invoiceInfoBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
- [_invoiceInfoBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
- [_invoiceInfoBtn setTitle:@"总单" forState:UIControlStateNormal];
- _invoiceInfoBtn.tag = 2;
- [navView addSubview:_invoiceInfoBtn];
- // 选中后的红线
- _sliderLabel = [[UILabel alloc]initWithFrame:CGRectMake(_goodsDetailBtn.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];
-
- }
- /**
- 获得当前日期
-
- @return <#return value description#>
- */
- - (NSDate *)getCurrentTime{
- NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSString *dateTime=[formatter stringFromDate:[NSDate date]];
- NSDate *date = [formatter dateFromString:dateTime];
- return date;
- }
- /**
- 初始化srollView
- */
- - (void)setMainSrollView{
-
- // 滚动view
- _mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(navView.frame), Screen_Width, Screen_Height-CGRectGetMaxY(navView.frame) - 10 - 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.goodsVc.view,self.invoiceInfoVc.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];
-
-
- //保存按钮
- btnSave = [UIButton buttonWithType:UIButtonTypeCustom];
- btnSave.frame=CGRectMake(0, Screen_Height- 40- rectStatusHeight-rectNavHeight, Screen_Width,40) ;
- btnSave.backgroundColor=NavigationBarColor;
- [btnSave setTitle:@"确定" forState:UIControlStateNormal];
- [btnSave setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [btnSave addTarget:self action:@selector(dataSave) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:btnSave];
- }
- /**
- 比较时间
-
- @param oneDay <#oneDay description#>
- @param anotherDay <#anotherDay description#>
- @return <#return value description#>
- */
- - (int)compareOneDay:(NSDate *)oneDay withAnotherDay:(NSDate *)anotherDay
- {
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"dd-MM-yyyy-HHmmss"];
- NSString *oneDayStr = [dateFormatter stringFromDate:oneDay];
- NSString *anotherDayStr = [dateFormatter stringFromDate:anotherDay];
- NSDate *dateA = [dateFormatter dateFromString:oneDayStr];
- NSDate *dateB = [dateFormatter dateFromString:anotherDayStr];
- NSComparisonResult result = [dateA compare:dateB];
- if (result == NSOrderedDescending) {
- //NSLog(@"Date1 is in the future");
- return 1;
- }
- else if (result == NSOrderedAscending){
- //NSLog(@"Date1 is in the past");
- return -1;
- }
- //NSLog(@"Both dates are the same");
- return 0;
-
- }
- /**
- 保存数据函数
- */
- - (void)dataSave{
- [self.view endEditing:YES];
- _sReceiptAmount = invoiceInfoVc.txtReceiptAmount.text;
-
- if(goodsVc.txtPlateNumber.text==nil||[goodsVc.txtPlateNumber.text isEqualToString:@""])
- {
- [self showAlertViewText:@"车牌号为空,请维护车牌号"];
- return;
- }
- if(goodsVc.sNextDeliveryDate!=nil&&goodsVc.sNextDeliveryDate.length>0)
- {
- NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];//实例化一个NSDateFormatter对象
- [dateFormat setDateFormat:@"yyyy-MM-dd"];
- NSDate *date = [dateFormat dateFromString:goodsVc.sNextDeliveryDate];
- NSDate *lastDay = [NSDate dateWithTimeInterval:-24*60*60 sinceDate:[self getCurrentTime]];
- if([self compareOneDay:date withAnotherDay:lastDay] != 1){
- [self showAlertViewText:@"推迟日期不能小于当前日期"];
- return;
- }
- }
- if(_sReceiptAmount != nil||![_sReceiptAmount isEqualToString:@""]){
- RegularExpression *regularExpr = [[RegularExpression alloc]init];
- bool receiptAmountCheck = [regularExpr AmountRegular:_sReceiptAmount];
- if(!receiptAmountCheck){
- [self showAlertViewText:@"回执金额格式不正确"];
- invoiceInfoVc.txtReceiptAmount.text = @"";
- return ;
- }
- }
- if([_sReceiptAmount doubleValue] > [invoiceInfoVc.lblRemainingReceivables.text doubleValue] ){
- [self showAlertViewText:@"回执金额不能大于剩余应收"];
- return;
- }
-
- // for (NewDispatchRequirementModel* model in goodsVc.dataList) {
- // NSString *receiptQuantity = model.receiptQuantity;
- // if(receiptQuantity != nil&&[receiptQuantity length] > 0){
- // RegularExpression *re = [[RegularExpression alloc]init];
- // bool isMatchDiscount = [re QuantityRegular:receiptQuantity];
- // if(isMatchDiscount == NO){
- // [self showAlertViewText:@"请输入正确的数"];
- // return ;
- // }
- // }
- // else{
- // [self showAlertViewText:@"请输入回执数量"];
- // return ;
- // }
- // }
- if(goodsVc.dataList != nil && goodsVc.dataList.count > 0){
- for (NewDispatchRequirementModel *model in goodsVc.dataList) {
- if (model.receiptQuantity == nil
- || [@"" isEqualToString:model.receiptQuantity]) {
- [self showAlertViewText:@"请输入配送回执数量"];
- return;
- }
-
- RegularExpression *re = [[RegularExpression alloc]init];
- bool isMatchDiscount = [re QuantityRegular:model.receiptQuantity];
- if(isMatchDiscount == NO){
- [self showAlertViewText:@"配送回执数量格式不正确"];
- return ;
- }
-
-
- if (model.installReceiptQuantity == nil
- || [@"" isEqualToString:model.installReceiptQuantity]) {
- [self showAlertViewText:@"请输入安装回执数量"];
- return;
- }
- //新增校验
- //
- // if ([goodsVc.sReceiptType doubleValue] == 1 && [model.receiptType doubleValue] == 1
- // && [model.installReceiptType doubleValue] == 1 && model. salesDetailType != 2) {
- // NSString *receiptQuantity = model.receiptQuantity;
- // NSString *installationQuantity = model.installReceiptQuantity;
- // if ([receiptQuantity doubleValue]
- // + [installationQuantity doubleValue] == 0) {
- // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"配送回执明细类型为完成,最大允许回执数量为零,请核对数据"]];
- // return;
- // }
- // }
-
- if([goodsVc.sReceiptType doubleValue]==1&&( [goodsVc.receiptFlag intValue]==1|| [goodsVc.receiptFlag intValue]==3))
- {
- if([model.receiptType doubleValue] == 0)
- {
- [self showAlertViewText:@"配送回执类型不能为空"];
- return;
- }
- }
-
- if([goodsVc.sReceiptType doubleValue]==1&&( [goodsVc.receiptFlag intValue]==2|| [goodsVc.receiptFlag intValue]==3))
- {
- if([model.installReceiptType doubleValue] == 0)
- {
- [self showAlertViewText:@"安装回执类型不能为空"];
- return;
- }
- }
-
- if([goodsVc.sReceiptType doubleValue]==1&& [goodsVc.receiptFlag intValue]==3)
- {
- if([model.receiptType doubleValue] == 2&&[model.installReceiptType intValue]==1)
- {
- [self showAlertViewText:@"送货回执类型为再送,安装回执类型不能为完成"];
- return;
- }
-
- }
-
- if([_noReceiptModel.requirementType doubleValue]==1)
- {
- if([model.outQuantity doubleValue]<=[model.finalDeliveryReceiptQuantity doubleValue])
- {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
- return;
- }
- }
-
- if([_noReceiptModel.requirementType doubleValue]==2)
- {
- if ([model.outQuantity doubleValue] <= [model.finalInstallReceiptQuantity doubleValue]) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
- return;
- }
- }
-
-
- if([_noReceiptModel.requirementType doubleValue]==3)
- {
- if( [goodsVc.receiptFlag intValue]==1|| [goodsVc.receiptFlag intValue]==3)
- {
-
- if([model.outQuantity doubleValue]<=[model.finalDeliveryReceiptQuantity doubleValue])
- {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
- return;
- }
- }
-
- if( [goodsVc.receiptFlag intValue]==2)
- {
- if ([model.outQuantity doubleValue] <= [model.finalInstallReceiptQuantity doubleValue]) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
- return;
- }
- }
-
-
- }
-
- if (
- [goodsVc.sReceiptType doubleValue] == 1
- &&( [goodsVc.receiptFlag intValue]==1|| [goodsVc.receiptFlag intValue]==3)&&
- ( [model.receiptType doubleValue] == 1 || [model.receiptType doubleValue] == 2)
- )
-
- {
- double outQuantityValue = [model.outQuantity
- doubleValue] ;
- double deliveryQuantityValue=[model.deliveryQuantity
- doubleValue] ;
- if (deliveryQuantityValue>0&&outQuantityValue == 0) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不能为0"]];
- return;
- }
-
-
- }
-
-
- //
- // if (model.maxReceiptQuantity< [model.receiptQuantity doubleValue]) {
- // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"配送明细类型为再送,送货量已超出最大允许配送回执量,请核对数据"]];
- //
- // return;
- // }
-
- // if ([model.sourceFrom intValue] != 4 && [model.receiptQuantity doubleValue] > [model.outQuantity doubleValue]) {
- // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"回执数量不能大于出库量"]];
- //
- // return;
- // }
- // if ([_sReceiptType doubleValue] == 1 && [model.installReceiptType intValue] == 5) {
- // if ([model.maxInstallReceiptQuantity doubleValue] <= [model.installReceiptQuantity doubleValue]) {
- // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"再安装时回执数量不能大于或等于(安装数量或出库量的最小值)"]];
- // return;
- // }
- //
- // }
- // if (model.salesDetailType != 2 && [model.sourceFrom intValue]!= 4) {
- // if ([model.receiptQuantity doubleValue] > [model.outQuantity doubleValue]) {
- // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"回执数量不能大于出库量"]];
- // return;
- // }
- if ([model.deliveryQuantity doubleValue] > [model.outQuantity doubleValue]) {
- if ([model.receiptQuantity doubleValue] > [model.outQuantity doubleValue]) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"配送回执数量不能大于出库量"]];
- return;
- }
- }
-
- // if([model.outQuantity doubleValue]<=[model.finalDeliveryReceiptQuantity doubleValue])
- // {
- // [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库量不能小于等于已送货数量"]];
- // return;
- // }
-
- if ([goodsVc.sReceiptType doubleValue] == 1
- &&( [goodsVc.receiptFlag intValue]==1|| [goodsVc.receiptFlag intValue]==3)&&
- [model.receiptType doubleValue] == 2
- )
-
- {
- if ([model.receiptQuantity doubleValue] >= [model.deliveryQuantity doubleValue]) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"配送明细类型为再送,配送回执数量不能大于等于送货数量"]];
- return;
- }
-
- if([model.outQuantity doubleValue]<=[model.finalDeliveryReceiptQuantity doubleValue])
- {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
- return;
- }
- }
-
-
-
- if ([goodsVc.sReceiptType doubleValue] == 1 && [model.installReceiptType intValue] == 5) {
- if ([model.installReceiptQuantity doubleValue] < 0) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"安装回执数量不能小于0"]];
- return;
- }
- if ([model.installReceiptQuantity doubleValue] >= [model.installQuantity doubleValue]) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"安装回执数量不能大于或等于最大允许回执数量"]];
- return;
- }
-
- if ([model.outQuantity doubleValue] <= [model.finalInstallReceiptQuantity doubleValue]) {
- [self showAlertViewText:[NSString stringWithFormat:@"%@%@",model.code,@"出库数量不足"]];
- return;
- }
- }
- }
- }
-
- else{
- [self showAlertViewText:@"回执明细不能为空!"];
- return;
- }
- self.navigationItem.rightBarButtonItem.enabled=NO;
- DispatchImageInfoVC *imgVc=[[DispatchImageInfoVC alloc]init];
- imgVc.collectDetailId=_noReceiptModel.collectDetailId;
- imgVc.arrangementId=_noReceiptModel.arrangementId;
- imgVc.customerId=_noReceiptModel.customerId;
- imgVc.receiptAmount=invoiceInfoVc.txtReceiptAmount.text;
- imgVc.receivable=invoiceInfoVc.lblReceivables.text;
- imgVc.organizationId=_noReceiptModel.organizationId;
- imgVc.organizationCode=_noReceiptModel.organizationCode;
- imgVc.remarks=invoiceInfoVc.txtRemarks.text;
- imgVc.truckNumber=goodsVc.txtPlateNumber.text;
- imgVc.nextDeliveryDate=goodsVc.sNextDeliveryDate;
- imgVc.paymentMethodArray=invoiceInfoVc.paymentMethodFilterArray;
- imgVc.deliveryAddress=_noReceiptModel.deliveryAddress;
- imgVc.receiptFlag=_noReceiptModel.requirementType;
- imgVc.dataList=goodsVc.dataList;
- imgVc.refreshDelegate=self;
-
- [self.navigationController pushViewController:imgVc animated:YES];
- self.hidesBottomBarWhenPushed=YES;
-
- }
- /**
- 滑动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];
- }
- /**
- 基本信息vc
-
- @return <#return value description#>
- */
- - (NewDispatchRequirementGoodsDetailController *)goodsVc{
- if (goodsVc == nil) {
- goodsVc = [[NewDispatchRequirementGoodsDetailController alloc] init];
-
- goodsVc.cNav = self.navigationController;
- // goodsVc.uDelegate = self;
- }
- return goodsVc;
- }
- /**
- 业绩信息vc
-
- @return <#return value description#>
- */
- - (NewDispatchRequirementInvoiceInfoController *)invoiceInfoVc{
- if (invoiceInfoVc == nil) {
- invoiceInfoVc = [[NewDispatchRequirementInvoiceInfoController alloc] init];
- invoiceInfoVc.cNav = self.navigationController;
- }
- return invoiceInfoVc;
- }
- /**
- 返回相应的button
-
- @param tag <#tag description#>
- @return <#return value description#>
- */
- - (UIButton *)buttonWithTag:(NSInteger )tag{
- if (tag == 1) {
- return _goodsDetailBtn;
- }else if (tag == 2){
- return _invoiceInfoBtn;
- }
- else{
- return nil;
- }
- }
- /**
- 按钮点击事件
-
- @param sender <#sender description#>
- */
- - (void)sliderAction:(UIButton *)sender{
- if (_currentIndex == sender.tag) {
- return;
- }
- // 切换controller
- [self sliderAnimationWithTag:sender.tag];
-
- [UIView animateWithDuration:0.3 animations:^{
- _mainScrollView.contentOffset = CGPointMake(Screen_Width*(sender.tag-1), 0);
- } completion:^(BOOL finished) {
- }];
- }
- /**
- 滑动tag
-
- @param tag <#tag description#>
- */
- - (void)sliderAnimationWithTag:(NSInteger)tag{
- self.currentIndex = tag;
- _goodsDetailBtn.selected = NO;
- _invoiceInfoBtn.selected = NO;
- UIButton *sender = [self buttonWithTag:tag];
- sender.selected = YES;
- //动画
- [UIView animateWithDuration:0.3 animations:^{
- _sliderLabel.frame = CGRectMake(sender.frame.origin.x, _sliderLabel.frame.origin.y, _sliderLabel.frame.size.width, _sliderLabel.frame.size.height);
-
- } completion:^(BOOL finished) {
- }];
- }
- /**
- 滑动tag
-
- @param tag <#tag description#>
- */
- - (void)sliderWithTag:(NSInteger)tag{
- self.currentIndex = tag;
- _goodsDetailBtn.selected = NO;
- _invoiceInfoBtn.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);
- }
- -(void)refreshData
- {
- if([self.refreshDelegate respondsToSelector:@selector(refreshData)])
- {
- [self.refreshDelegate refreshData];
- }
- [self.navigationController popViewControllerAnimated:YES];
-
- }
- @end
|