ReportInfoViewController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. //
  2. // ReportInfoViewController.m
  3. // IBOSSmini
  4. //
  5. // Created by apple on 2017/5/4.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "ReportInfoViewController.h"
  9. #import "BusinessCollectionViewCell.h"
  10. #import "DailyReconciliationViewController.h"
  11. #import "StockingViewController.h"
  12. #import "SingleProfitViewController.h"
  13. #import "ExpenseDetailViewController.h"
  14. #import "CusomerFillingReportViewController.h"
  15. #import "CustomerBalanceViewController.h"
  16. #import "SupplierBalanceViewController.h"
  17. #import "OrderSaleViewController.h"
  18. #import "InventoryViewController.h"
  19. #import "SalesAnalysisListViewController.h"
  20. #import "SalesPaymentRankHomeViewController.h"
  21. #import "SalesAchievementRankHomeViewController.h"
  22. #import "InventoryCostListVC.h"
  23. #define PhotoCollectionViewCellIdentifier @"PhotoCollectionViewCellIdentifier"
  24. @interface ReportInfoViewController (){
  25. UICollectionView *_businessCollectionView;
  26. UILabel *_lblAllBusiness;
  27. }
  28. @end
  29. @implementation ReportInfoViewController
  30. #pragma mark - 公共函数
  31. /**
  32. viewDidLoad函数
  33. */
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. self.navigationItem.title=@"iBOSSMini";
  37. [self initUI];
  38. }
  39. /**
  40. 适配安全区
  41. */
  42. -(void)viewDidAppear:(BOOL)animated{
  43. self.tabBarController.tabBar.backgroundColor = [UIColor whiteColor];
  44. self.view.backgroundColor = [UIColor whiteColor];
  45. if (@available(iOS 11.0, *)) {
  46. //将CollectionView的frame设置到全部列表的下边
  47. _businessCollectionView.frame = CGRectMake(10,CGRectGetMaxY(_lblAllBusiness.frame)+10, SCREENWIDTH-20, self.view.safeAreaLayoutGuide.layoutFrame.size.height-(CGRectGetMaxY(_lblAllBusiness.frame)+10));
  48. }
  49. }
  50. /**
  51. didReceiveMemoryWarning
  52. */
  53. - (void)didReceiveMemoryWarning {
  54. [super didReceiveMemoryWarning];
  55. }
  56. /**
  57. 数据源
  58. @return <#return value description#>
  59. */
  60. - (NSMutableArray *)businessArray {
  61. if (_businessArray == nil) {
  62. _businessArray = [[NSMutableArray alloc]init];
  63. BusinessModel *model = [[BusinessModel alloc]init];
  64. if([kkRights isEqualToString:@""]){
  65. [model setImageName:@"report_day_account"];
  66. [model setImageTitle:@"日结对账表"];
  67. [_businessArray addObject:model];
  68. model = [[BusinessModel alloc]init];
  69. [model setImageName:@"report_inventory"];
  70. [model setImageTitle:@"库存明细表"];
  71. [_businessArray addObject:model];
  72. model = [[BusinessModel alloc]init];
  73. [model setImageName:@"report_sale_order"];
  74. [model setImageTitle:@"订单销售单"];
  75. [_businessArray addObject:model];
  76. model = [[BusinessModel alloc]init];
  77. [model setImageName:@"report_stocking"];
  78. [model setImageTitle:@"库存盘点"];
  79. [_businessArray addObject:model];
  80. model = [[BusinessModel alloc]init];
  81. [model setImageName:@"report_customer_balance"];
  82. [model setImageTitle:@"客户往来余额"];
  83. [_businessArray addObject:model];
  84. model = [[BusinessModel alloc]init];
  85. [model setImageName:@"report_single_profit"];
  86. [model setImageTitle:@"每单利润表"];
  87. [_businessArray addObject:model];
  88. }
  89. else{
  90. if([kkRights rangeOfString:FUNCTION_INTELLIGENT_IPHONE_DAILYREPORT].location!=NSNotFound){
  91. [model setImageName:@"report_day_account"];
  92. [model setImageTitle:@"日结对账表"];
  93. [_businessArray addObject:model];
  94. }
  95. if([kkRights rangeOfString:FUNCTION_INTELLIGENT_IPHONE_IVTSEARCH].location!=NSNotFound){
  96. model = [[BusinessModel alloc]init];
  97. [model setImageName:@"report_inventory"];
  98. [model setImageTitle:@"库存明细表"];
  99. [_businessArray addObject:model];
  100. }
  101. if([kkRights rangeOfString:FUNCTION_ORDER_SALE_REPORT_IPHONE].location!=NSNotFound){
  102. model = [[BusinessModel alloc]init];
  103. [model setImageName:@"report_sale_order"];
  104. [model setImageTitle:@"订单销售单"];
  105. [_businessArray addObject:model];
  106. }
  107. if([kkRights rangeOfString: FUNCTION_STOCKING_IPHONE].location!=NSNotFound){
  108. model = [[BusinessModel alloc]init];
  109. [model setImageName:@"report_stocking"];
  110. [model setImageTitle:@"库存盘点"];
  111. [_businessArray addObject:model];
  112. }
  113. if([kkRights rangeOfString: FUNCTION_CUSTOMER_BALANCE_REPORT_IPHONE].location!=NSNotFound){
  114. model = [[BusinessModel alloc]init];
  115. [model setImageName:@"report_customer_balance"];
  116. [model setImageTitle:@"客户往来余额"];
  117. [_businessArray addObject:model];
  118. }
  119. if([kkRights rangeOfString: FUNCTION_SUPPLIER_TRANSACTION_BALANCE_IPHONE].location!=NSNotFound){
  120. model = [[BusinessModel alloc]init];
  121. [model setImageName:@"supply"];
  122. [model setImageTitle:@"供应商往来余额"];
  123. [_businessArray addObject:model];
  124. }
  125. if([kkRights rangeOfString: FUNCTION_SINGLE_PROFIT_REPORT_IPHONE].location!=NSNotFound){
  126. model = [[BusinessModel alloc]init];
  127. [model setImageName:@"report_single_profit"];
  128. [model setImageTitle:@"每单利润表"];
  129. [_businessArray addObject:model];
  130. }
  131. if([kkRights rangeOfString: FUNCTION_BEST_SELLERS_ANALYSIS_REPORT_IPHONE].location!=NSNotFound){
  132. model = [[BusinessModel alloc]init];
  133. [model setImageName:@"goods_sales_well"];
  134. [model setImageTitle:@"商品畅滞销"];
  135. [_businessArray addObject:model];
  136. }
  137. if([kkRights rangeOfString: FUNCTION_SALES_BACKAMOUNT_RANKING_REPORT_IPHONE].location!=NSNotFound){
  138. model = [[BusinessModel alloc]init];
  139. [model setImageName:@"sales_payment"];
  140. [model setImageTitle:@"销售回款排行"];
  141. [_businessArray addObject:model];
  142. }
  143. if([kkRights rangeOfString: FUNCTION_SALES_PERFORMANCE_RANKING_REPORT_IPHONE].location!=NSNotFound){
  144. model = [[BusinessModel alloc]init];
  145. [model setImageName:@"sales_achievement"];
  146. [model setImageTitle:@"销售业绩排行"];
  147. [_businessArray addObject:model];
  148. }
  149. if([kkRights rangeOfString: FUNCTION_INVENTORY_COST_REPORT_IPHONE].location!=NSNotFound){
  150. model = [[BusinessModel alloc]init];
  151. [model setImageName:@"inventory_summary"];
  152. [model setImageTitle:@"库存即时成本"];
  153. [_businessArray addObject:model];
  154. }
  155. }
  156. }
  157. return _businessArray;
  158. }
  159. #pragma mark - 委托回调函数
  160. /**
  161. 个数
  162. @param collectionView <#collectionView description#>
  163. @param section <#section description#>
  164. @return <#return value description#>
  165. */
  166. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  167. return _businessArray.count;
  168. }
  169. /**
  170. 单元格
  171. @param collectionView <#collectionView description#>
  172. @param indexPath <#indexPath description#>
  173. @return <#return value description#>
  174. */
  175. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  176. BusinessCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier forIndexPath:indexPath];
  177. BusinessModel *model = _businessArray[indexPath.row];
  178. [cell setBusinessInfoModel:model];
  179. return cell;
  180. }
  181. /**
  182. 点击当个单元格
  183. @param collectionView <#collectionView description#>
  184. @param indexPath <#indexPath description#>
  185. */
  186. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  187. BaseViewController *vc;
  188. BusinessModel *model = self.businessArray[indexPath.row];
  189. if ([model.imageTitle isEqualToString:@"日结对账表"]) {
  190. // 日结对账表
  191. vc = [[DailyReconciliationViewController alloc]init];
  192. }
  193. if ([model.imageTitle isEqualToString:@"库存明细表"]) {
  194. // 库存明细表
  195. vc = [[InventoryViewController alloc]init];
  196. }
  197. if ([model.imageTitle isEqualToString:@"订单销售单"]) {
  198. // 销售单订单
  199. vc = [[OrderSaleViewController alloc]init];
  200. }
  201. if ([model.imageTitle isEqualToString:@"库存盘点"]) {
  202. // 库存盘点
  203. vc = [[StockingViewController alloc]init];
  204. }
  205. if ([model.imageTitle isEqualToString:@"客户往来余额"]) {
  206. // 客户往来余额表
  207. vc = [[CustomerBalanceViewController alloc]init];
  208. }
  209. if ([model.imageTitle isEqualToString:@"供应商往来余额"]) {
  210. // 客户往来余额表
  211. vc = [[SupplierBalanceViewController alloc]init];
  212. }
  213. if ([model.imageTitle isEqualToString:@"每单利润表"])
  214. {
  215. // 每单利润表
  216. vc = [[SingleProfitViewController alloc]init];
  217. }
  218. if ([model.imageTitle isEqualToString:@"商品畅滞销"]) {
  219. // 商品畅滞销分析
  220. vc = [[SalesAnalysisListViewController alloc]init];
  221. }
  222. else if([model.imageTitle isEqualToString:@"销售回款排行"]){
  223. vc=[[SalesPaymentRankHomeViewController alloc]init];
  224. }
  225. else if([model.imageTitle isEqualToString:@"销售业绩排行"]){
  226. vc=[[SalesAchievementRankHomeViewController alloc]init];
  227. }
  228. else if([model.imageTitle isEqualToString:@"库存即时成本"]){
  229. vc=[[InventoryCostListVC alloc]init];
  230. }
  231. vc.hidesBottomBarWhenPushed = YES;
  232. [self.navigationController setNavigationBarHidden:NO animated:YES];
  233. [self.navigationController pushViewController:vc animated:YES];
  234. }
  235. /**
  236. Sections
  237. @param tableView <#tableView description#>
  238. @return <#return value description#>
  239. */
  240. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  241. {
  242. return 1;
  243. }
  244. #pragma mark - 私有函数
  245. /**
  246. 初始化ui
  247. */
  248. - (void)initUI{
  249. UIImage *pic = [UIImage imageNamed:@"banner_report"];
  250. UIImageView *bannerView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.width*pic.size.height/pic.size.width)];
  251. [bannerView setImage:pic];
  252. [self.view addSubview:bannerView];
  253. UIView *separatorView = [[UIView alloc]init];
  254. [separatorView setBackgroundColor: LineBackgroundColor];
  255. separatorView.frame=CGRectMake(0, CGRectGetMaxY(bannerView.frame), self.view.frame.size.width, 10);
  256. [self.view addSubview: separatorView];
  257. UIImageView *allBusinessImagView = [[UIImageView alloc] initWithFrame:CGRectMake(10,CGRectGetMaxY(separatorView.frame)+5,20,20)];
  258. [allBusinessImagView setImage:[UIImage imageNamed:@"icon_allbusiness"]];
  259. [self.view addSubview:allBusinessImagView];
  260. _lblAllBusiness = [UILabel new];
  261. _lblAllBusiness.text = @"全部报表";
  262. _lblAllBusiness.font = [UIFont systemFontOfSize:15];
  263. _lblAllBusiness.frame=CGRectMake(CGRectGetMaxX(allBusinessImagView.frame)+10,CGRectGetMaxY(separatorView.frame)+5,80, 20);
  264. _lblAllBusiness.textColor = [UIColor blackColor];
  265. [self.view addSubview:_lblAllBusiness];
  266. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
  267. _businessCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(_lblAllBusiness.frame)+10,Screen_Width-20,Screen_Height-CGRectGetMaxY(_lblAllBusiness.frame)-rectStatusHeight-rectNavHeight-59) collectionViewLayout:flowLayout];
  268. [ _businessCollectionView registerClass:[BusinessCollectionViewCell class] forCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier];
  269. flowLayout.itemSize=CGSizeMake(Screen_Width/4,90);
  270. flowLayout.minimumLineSpacing = 20;
  271. flowLayout.minimumInteritemSpacing = 20;
  272. _businessCollectionView.dataSource=self;
  273. _businessCollectionView.delegate=self;
  274. _businessCollectionView.backgroundColor = [UIColor whiteColor];
  275. _businessCollectionView.showsVerticalScrollIndicator=NO;
  276. _businessCollectionView.scrollEnabled=YES;
  277. [self.view addSubview:_businessCollectionView];
  278. [_businessCollectionView reloadData];
  279. if(self.businessArray.count == 0){
  280. UILabel *noReport = [[UILabel alloc] init];
  281. noReport.frame = CGRectMake(0, 0, CGRectGetWidth(_businessCollectionView.frame), CGRectGetHeight(_businessCollectionView.frame));
  282. noReport.font = [UIFont systemFontOfSize:15];
  283. noReport.textColor = [UIColor grayColor];
  284. noReport.textAlignment = NSTextAlignmentCenter;
  285. noReport.text = @"该用户没有相应报表权限";
  286. [_businessCollectionView addSubview:noReport];
  287. }
  288. }
  289. ///**
  290. // 高度
  291. //
  292. // @param photos <#photos description#>
  293. // @return <#return value description#>
  294. // */
  295. //- (CGFloat)getPhotoCollectionViewHeightWithPhotos:(NSMutableArray *)photos {
  296. // // 上下间隔已经在frame上做了
  297. // NSInteger row = (photos.count / 3 + (photos.count % 3 ? 1 : 0));
  298. // //return (row *100 + (row *15));
  299. // if(self.view.frame.size.width<=320){
  300. // return (row * 80 + (row * 20));
  301. // }else{
  302. // return (row * 100 + (row * 20));
  303. // }
  304. //}
  305. @end