// // ReportInfoViewController.m // IBOSSmini // // Created by apple on 2017/5/4. // Copyright © 2017年 elongtian. All rights reserved. // #import "ReportInfoViewController.h" #import "BusinessCollectionViewCell.h" #import "DailyReconciliationViewController.h" #import "StockingViewController.h" #import "SingleProfitViewController.h" #import "ExpenseDetailViewController.h" #import "CusomerFillingReportViewController.h" #import "CustomerBalanceViewController.h" #import "SupplierBalanceViewController.h" #import "OrderSaleViewController.h" #import "InventoryViewController.h" #import "SalesAnalysisListViewController.h" #import "SalesPaymentRankHomeViewController.h" #import "SalesAchievementRankHomeViewController.h" #import "InventoryCostListVC.h" #define PhotoCollectionViewCellIdentifier @"PhotoCollectionViewCellIdentifier" @interface ReportInfoViewController (){ UICollectionView *_businessCollectionView; UILabel *_lblAllBusiness; } @end @implementation ReportInfoViewController #pragma mark - 公共函数 /** viewDidLoad函数 */ - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title=@"iBOSSMini"; [self initUI]; } /** 适配安全区 */ -(void)viewDidAppear:(BOOL)animated{ self.tabBarController.tabBar.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = [UIColor whiteColor]; if (@available(iOS 11.0, *)) { //将CollectionView的frame设置到全部列表的下边 _businessCollectionView.frame = CGRectMake(10,CGRectGetMaxY(_lblAllBusiness.frame)+10, SCREENWIDTH-20, self.view.safeAreaLayoutGuide.layoutFrame.size.height-(CGRectGetMaxY(_lblAllBusiness.frame)+10)); } } /** didReceiveMemoryWarning */ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } /** 数据源 @return <#return value description#> */ - (NSMutableArray *)businessArray { if (_businessArray == nil) { _businessArray = [[NSMutableArray alloc]init]; BusinessModel *model = [[BusinessModel alloc]init]; if([kkRights isEqualToString:@""]){ [model setImageName:@"report_day_account"]; [model setImageTitle:@"日结对账表"]; [_businessArray addObject:model]; model = [[BusinessModel alloc]init]; [model setImageName:@"report_inventory"]; [model setImageTitle:@"库存明细表"]; [_businessArray addObject:model]; model = [[BusinessModel alloc]init]; [model setImageName:@"report_sale_order"]; [model setImageTitle:@"订单销售单"]; [_businessArray addObject:model]; model = [[BusinessModel alloc]init]; [model setImageName:@"report_stocking"]; [model setImageTitle:@"库存盘点"]; [_businessArray addObject:model]; model = [[BusinessModel alloc]init]; [model setImageName:@"report_customer_balance"]; [model setImageTitle:@"客户往来余额"]; [_businessArray addObject:model]; model = [[BusinessModel alloc]init]; [model setImageName:@"report_single_profit"]; [model setImageTitle:@"每单利润表"]; [_businessArray addObject:model]; } else{ if([kkRights rangeOfString:FUNCTION_INTELLIGENT_IPHONE_DAILYREPORT].location!=NSNotFound){ [model setImageName:@"report_day_account"]; [model setImageTitle:@"日结对账表"]; [_businessArray addObject:model]; } if([kkRights rangeOfString:FUNCTION_INTELLIGENT_IPHONE_IVTSEARCH].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"report_inventory"]; [model setImageTitle:@"库存明细表"]; [_businessArray addObject:model]; } if([kkRights rangeOfString:FUNCTION_ORDER_SALE_REPORT_IPHONE].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"report_sale_order"]; [model setImageTitle:@"订单销售单"]; [_businessArray addObject:model]; } if([kkRights rangeOfString: FUNCTION_STOCKING_IPHONE].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"report_stocking"]; [model setImageTitle:@"库存盘点"]; [_businessArray addObject:model]; } if([kkRights rangeOfString: FUNCTION_CUSTOMER_BALANCE_REPORT_IPHONE].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"report_customer_balance"]; [model setImageTitle:@"客户往来余额"]; [_businessArray addObject:model]; } if([kkRights rangeOfString: FUNCTION_SUPPLIER_TRANSACTION_BALANCE_IPHONE].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"supply"]; [model setImageTitle:@"供应商往来余额"]; [_businessArray addObject:model]; } if([kkRights rangeOfString: FUNCTION_SINGLE_PROFIT_REPORT_IPHONE].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"report_single_profit"]; [model setImageTitle:@"每单利润表"]; [_businessArray addObject:model]; } if([kkRights rangeOfString: FUNCTION_BEST_SELLERS_ANALYSIS_REPORT_IPHONE].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"goods_sales_well"]; [model setImageTitle:@"商品畅滞销"]; [_businessArray addObject:model]; } if([kkRights rangeOfString: FUNCTION_SALES_BACKAMOUNT_RANKING_REPORT_IPHONE].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"sales_payment"]; [model setImageTitle:@"销售回款排行"]; [_businessArray addObject:model]; } if([kkRights rangeOfString: FUNCTION_SALES_PERFORMANCE_RANKING_REPORT_IPHONE].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"sales_achievement"]; [model setImageTitle:@"销售业绩排行"]; [_businessArray addObject:model]; } if([kkRights rangeOfString: FUNCTION_INVENTORY_COST_REPORT_IPHONE].location!=NSNotFound){ model = [[BusinessModel alloc]init]; [model setImageName:@"inventory_summary"]; [model setImageTitle:@"库存即时成本"]; [_businessArray addObject:model]; } } } return _businessArray; } #pragma mark - 委托回调函数 /** 个数 @param collectionView <#collectionView description#> @param section <#section description#> @return <#return value description#> */ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return _businessArray.count; } /** 单元格 @param collectionView <#collectionView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { BusinessCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier forIndexPath:indexPath]; BusinessModel *model = _businessArray[indexPath.row]; [cell setBusinessInfoModel:model]; return cell; } /** 点击当个单元格 @param collectionView <#collectionView description#> @param indexPath <#indexPath description#> */ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { BaseViewController *vc; BusinessModel *model = self.businessArray[indexPath.row]; if ([model.imageTitle isEqualToString:@"日结对账表"]) { // 日结对账表 vc = [[DailyReconciliationViewController alloc]init]; } if ([model.imageTitle isEqualToString:@"库存明细表"]) { // 库存明细表 vc = [[InventoryViewController alloc]init]; } if ([model.imageTitle isEqualToString:@"订单销售单"]) { // 销售单订单 vc = [[OrderSaleViewController alloc]init]; } if ([model.imageTitle isEqualToString:@"库存盘点"]) { // 库存盘点 vc = [[StockingViewController alloc]init]; } if ([model.imageTitle isEqualToString:@"客户往来余额"]) { // 客户往来余额表 vc = [[CustomerBalanceViewController alloc]init]; } if ([model.imageTitle isEqualToString:@"供应商往来余额"]) { // 客户往来余额表 vc = [[SupplierBalanceViewController alloc]init]; } if ([model.imageTitle isEqualToString:@"每单利润表"]) { // 每单利润表 vc = [[SingleProfitViewController alloc]init]; } if ([model.imageTitle isEqualToString:@"商品畅滞销"]) { // 商品畅滞销分析 vc = [[SalesAnalysisListViewController alloc]init]; } else if([model.imageTitle isEqualToString:@"销售回款排行"]){ vc=[[SalesPaymentRankHomeViewController alloc]init]; } else if([model.imageTitle isEqualToString:@"销售业绩排行"]){ vc=[[SalesAchievementRankHomeViewController alloc]init]; } else if([model.imageTitle isEqualToString:@"库存即时成本"]){ vc=[[InventoryCostListVC alloc]init]; } vc.hidesBottomBarWhenPushed = YES; [self.navigationController setNavigationBarHidden:NO animated:YES]; [self.navigationController pushViewController:vc animated:YES]; } /** Sections @param tableView <#tableView description#> @return <#return value description#> */ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } #pragma mark - 私有函数 /** 初始化ui */ - (void)initUI{ UIImage *pic = [UIImage imageNamed:@"banner_report"]; UIImageView *bannerView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.width*pic.size.height/pic.size.width)]; [bannerView setImage:pic]; [self.view addSubview:bannerView]; UIView *separatorView = [[UIView alloc]init]; [separatorView setBackgroundColor: LineBackgroundColor]; separatorView.frame=CGRectMake(0, CGRectGetMaxY(bannerView.frame), self.view.frame.size.width, 10); [self.view addSubview: separatorView]; UIImageView *allBusinessImagView = [[UIImageView alloc] initWithFrame:CGRectMake(10,CGRectGetMaxY(separatorView.frame)+5,20,20)]; [allBusinessImagView setImage:[UIImage imageNamed:@"icon_allbusiness"]]; [self.view addSubview:allBusinessImagView]; _lblAllBusiness = [UILabel new]; _lblAllBusiness.text = @"全部报表"; _lblAllBusiness.font = [UIFont systemFontOfSize:15]; _lblAllBusiness.frame=CGRectMake(CGRectGetMaxX(allBusinessImagView.frame)+10,CGRectGetMaxY(separatorView.frame)+5,80, 20); _lblAllBusiness.textColor = [UIColor blackColor]; [self.view addSubview:_lblAllBusiness]; UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init]; _businessCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(_lblAllBusiness.frame)+10,Screen_Width-20,Screen_Height-CGRectGetMaxY(_lblAllBusiness.frame)-rectStatusHeight-rectNavHeight-59) collectionViewLayout:flowLayout]; [ _businessCollectionView registerClass:[BusinessCollectionViewCell class] forCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier]; flowLayout.itemSize=CGSizeMake(Screen_Width/4,90); flowLayout.minimumLineSpacing = 20; flowLayout.minimumInteritemSpacing = 20; _businessCollectionView.dataSource=self; _businessCollectionView.delegate=self; _businessCollectionView.backgroundColor = [UIColor whiteColor]; _businessCollectionView.showsVerticalScrollIndicator=NO; _businessCollectionView.scrollEnabled=YES; [self.view addSubview:_businessCollectionView]; [_businessCollectionView reloadData]; if(self.businessArray.count == 0){ UILabel *noReport = [[UILabel alloc] init]; noReport.frame = CGRectMake(0, 0, CGRectGetWidth(_businessCollectionView.frame), CGRectGetHeight(_businessCollectionView.frame)); noReport.font = [UIFont systemFontOfSize:15]; noReport.textColor = [UIColor grayColor]; noReport.textAlignment = NSTextAlignmentCenter; noReport.text = @"该用户没有相应报表权限"; [_businessCollectionView addSubview:noReport]; } } ///** // 高度 // // @param photos <#photos description#> // @return <#return value description#> // */ //- (CGFloat)getPhotoCollectionViewHeightWithPhotos:(NSMutableArray *)photos { // // 上下间隔已经在frame上做了 // NSInteger row = (photos.count / 3 + (photos.count % 3 ? 1 : 0)); // //return (row *100 + (row *15)); // if(self.view.frame.size.width<=320){ // return (row * 80 + (row * 20)); // }else{ // return (row * 100 + (row * 20)); // } //} @end