// // InventoryAnalysisViewController.m // IBOSS // // Created by ssl on 2018/1/4. // Copyright © 2018年 elongtian. All rights reserved. // #import "SideSlipModel.h" #import "DateFormat.h" #import "InventoryAnalysisSearchModel.h" #import "SalesPaymentRankFrame.h" #import "InventoryAnalysisViewController.h" #import "InventoryAnalysisDataListController.h" #import "InventoryAnalysisViewChartViewController.h" @interface InventoryAnalysisViewController (){ InventoryAnalysisDataListController *_dataListVC; InventoryAnalysisViewChartViewController *_chartViewVC; UILabel *_lbInventoryQuantity; UILabel *_lbCanSaleQuantity; NSString *_strOperateType; } @end @implementation InventoryAnalysisViewController /** 导航数 */ static int navcount = 2; #pragma mark - 公共函数 /** 视图加载完成函数 */ - (void)viewDidLoad { [super viewDidLoad]; //self.navigationController.navigationBar.translucent=NO; [self.navigationController.navigationBar setTintColor:NavigationBarTintColor ]; self.navigationItem.title = @"库存分析表"; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:[UIImage imageNamed:@"icon_back.png"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(0, 0,45,22); UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button]; self.navigationItem.leftBarButtonItem = menuButton; UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 40, 16)]; UIButton *btnfilter = [UIButton buttonWithType:UIButtonTypeCustom]; [btnfilter addTarget:self action:@selector(search) forControlEvents:UIControlEventTouchUpInside]; btnfilter.frame = CGRectMake(0, 0, 16, 16); [btnfilter setTitleColor:NavBarItemColor forState:UIControlStateNormal]; [btnfilter setBackgroundImage:[UIImage imageNamed:@"icon_filter_white"] forState:UIControlStateNormal]; [v addSubview:btnfilter]; UIButton *filterLbl = [[UIButton alloc]init]; filterLbl.frame=CGRectMake(CGRectGetMaxX(btnfilter.frame)+3,0,28, 16); [filterLbl setTitle:@"筛选" forState:UIControlStateNormal]; [filterLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; filterLbl.titleLabel.font = [UIFont systemFontOfSize:ButtonFontOfSize]; [filterLbl addTarget:self action:@selector(search) forControlEvents:UIControlEventTouchUpInside]; [v addSubview:filterLbl]; UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:v]; self.navigationItem.rightBarButtonItem = menubtnAdd; [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; [self initUI]; _strOperateType = @"1"; [self loadData]; } #pragma mark - 委托函数 /** 加载数据成功回调 @param sender <#sender description#> */ - (void)onSalesPaymentFinish:(ASIDownManager *)sender { for(UIView *view in [_chartViewVC.view subviews]) { if(view.tag==1001){ [view removeFromSuperview]; } } // 服务器返回数据 RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; // 服务器返回数据状态值 int iStatus = resultModel.status; [self cancel]; // 服务器返回数据消息 NSString *message = resultModel.message; // 服务器返回数据状态值正确 if (iStatus == 0) { // 服务器返回数据结果 NSArray * infoArr = (NSArray *)resultModel.result; _rankList = [[NSMutableArray alloc]init]; if(infoArr!=nil && infoArr.count > 0){ double totalInventoryQuantity = 0; for(int i = 0;i < infoArr.count;i++){ NSDictionary * dic = infoArr[i]; double inventoryQuantity = [[dic objectForKey:@"SUMInventoryQuantity"] doubleValue]; totalInventoryQuantity += inventoryQuantity; } double totalCanSaleQuantity = 0; for(int i = 0;i < infoArr.count;i++){ NSDictionary * dic = infoArr[i]; double canSaleQuantity = [[dic objectForKey:@"SUMCanSaleQuantity"] doubleValue]; totalCanSaleQuantity += canSaleQuantity; } for(int i = 0;i */ - (void)onSalesPaymentFail:(ASIDownManager *)sender { [self showAlertViewText:@"网络异常"]; } #pragma mark - 私有函数 /* 初始化UI */ - (void)initUI{ UIView *titleView = [[UIView alloc]init]; titleView.backgroundColor = NavigationBarTintColor; titleView.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:titleView]; UILabel *lbTitleInventoryQuantity = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH/2, 35)]; lbTitleInventoryQuantity.text = @"总结存量"; lbTitleInventoryQuantity.font = [UIFont systemFontOfSize:15]; lbTitleInventoryQuantity.textColor =[UIColor whiteColor]; lbTitleInventoryQuantity.textAlignment = NSTextAlignmentCenter; [titleView addSubview:lbTitleInventoryQuantity]; _lbInventoryQuantity = [[UILabel alloc] initWithFrame:CGRectMake(0, 25, SCREENWIDTH/2, 35)]; _lbInventoryQuantity.textColor =[UIColor whiteColor]; _lbInventoryQuantity.font = [UIFont systemFontOfSize:15]; _lbInventoryQuantity.textAlignment = NSTextAlignmentCenter; [titleView addSubview:_lbInventoryQuantity]; UILabel *lbTitleCanSaleQuantity = [[UILabel alloc] initWithFrame:CGRectMake(SCREENWIDTH/2, 0, SCREENWIDTH/2, 35)]; lbTitleCanSaleQuantity.text = @"总可售量"; lbTitleCanSaleQuantity.font = [UIFont systemFontOfSize:15]; lbTitleCanSaleQuantity.textColor =[UIColor whiteColor]; lbTitleCanSaleQuantity.textAlignment = NSTextAlignmentCenter; [titleView addSubview:lbTitleCanSaleQuantity]; _lbCanSaleQuantity = [[UILabel alloc] initWithFrame:CGRectMake(SCREENWIDTH/2 , 25, SCREENWIDTH/2, 35)]; _lbCanSaleQuantity.textColor =[UIColor whiteColor]; _lbCanSaleQuantity.font = [UIFont systemFontOfSize:15]; _lbCanSaleQuantity.textAlignment = NSTextAlignmentCenter; [titleView addSubview:_lbCanSaleQuantity]; UIView *line = [[UIView alloc] initWithFrame:CGRectMake(SCREENWIDTH/2, 10, 1, 40)]; line.backgroundColor = [UIColor whiteColor]; [titleView addSubview:line]; self.page = [[PageSwitchView alloc] init]; [self.view addSubview:self.page]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[titleView]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(titleView)]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_page]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_page)]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[titleView(60)]-0-[_page]-marg-|" options:0 metrics:@{@"marg":@(SCREENHEIGHT >= 812 ? 34 : 0)} views:NSDictionaryOfVariableBindings(titleView,_page)]]; NSMutableArray *arr = [NSMutableArray array]; _dataListVC = [[InventoryAnalysisDataListController alloc] init]; _chartViewVC = [[InventoryAnalysisViewChartViewController alloc] init]; //_dataListVC.nav = self.navigationController; //_dataListVC.parentController = self; PageSwitchModel *model = [[PageSwitchModel alloc] init]; model.title = @"图形(前10条)"; model.controller = _chartViewVC; [arr addObject:model]; model = [[PageSwitchModel alloc] init]; model.title = @"全部列表数据"; model.controller = _dataListVC; [arr addObject:model]; self.page.datas = arr; __weak typeof(self) weakself=self; // 抽屉对象 self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) { for (SideSlipModel *model in dataList) { model.selectedItemList = nil; model.customDict = nil; } } commitBlock:^(NSArray *dataList) { // 查询条件 SideSlipModel *serviceRegionModel = dataList[0]; InventoryAnalysisSearchModel *m = [serviceRegionModel.customDict objectForKey:INVENTORY_ANALYSIS_SEARCH]; _strOperateType = m.OperateType; [self loadData]; [weakself.filterController dismiss]; }]; _filterController.animationDuration = AnimationDuration; _filterController.hasHeadView = YES; _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width; _filterController.dataList = [self packageDataList]; } /** 加载数据 */ -(void)loadData{ [self startLoading]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetInventoryStatisticsIphone" 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:_strOperateType forKey:@"OperateType"]; _downManager = [[ASIDownManager alloc] init]; _downManager.delegate = self; _downManager.onRequestSuccess = @selector(onSalesPaymentFinish:); _downManager.onRequestFail = @selector(onSalesPaymentFail:); [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil]; } /** 隐藏进度条 */ - (void)cancel { [self stopLoading]; } /** 数据源 @return <#return value description#> */ - (NSArray *)packageDataList { NSMutableArray *dataArray = [NSMutableArray array]; SideSlipModel *model = [[SideSlipModel alloc] init]; model.containerCellClass = @"InventoryAnalysisSearchCel"; model.regionTitle = @"查询条件"; [dataArray addObject:model]; return [dataArray mutableCopy]; } /** 抽屉弹出 */ -(void)search{ [_filterController show]; } @end