BusinessInfoViewController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. //
  2. // BusinessInfoViewController.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2017/5/3.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "BusinessInfoViewController.h"
  9. #import "BusinessCollectionViewCell.h"
  10. #import "NewCustomerViewController.h"
  11. #import "LogListViewController.h"
  12. #import "CustomerListViewController.h"
  13. #import "CustomerNewListViewController.h"
  14. #import "SalesOrderListVC.h"
  15. #import "SalesSlipListVC.h"
  16. #define PhotoCollectionViewCellIdentifier @"PhotoCollectionViewCellIdentifier"
  17. @interface BusinessInfoViewController ()
  18. @end
  19. @implementation BusinessInfoViewController
  20. #pragma mark - 公共函数
  21. /**
  22. viewDidLoad函数
  23. */
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. self.navigationItem.title=@"iBOSSMini";
  27. [self initUI];
  28. }
  29. /**
  30. 适配安全区
  31. */
  32. -(void)viewDidAppear:(BOOL)animated{
  33. self.tabBarController.tabBar.backgroundColor = [UIColor whiteColor];
  34. self.view.backgroundColor = [UIColor whiteColor];
  35. if (@available(iOS 11.0, *)) {
  36. //将CollectionView的frame设置到全部列表的下边
  37. _businessCollectionView.frame = CGRectMake(10,CGRectGetMaxY(_lblAllBusiness.frame)+10, SCREENWIDTH-20, self.view.safeAreaLayoutGuide.layoutFrame.size.height-(CGRectGetMaxY(_lblAllBusiness.frame)+10));
  38. }
  39. }
  40. #pragma mark - 属性
  41. - (NSMutableArray *)businessArray{
  42. if (_businessArray == nil) {
  43. _businessArray=[NSMutableArray new];
  44. if([kkRights isEqualToString:@""]){
  45. BusinessModel *businessModel=[[BusinessModel alloc]init];
  46. [businessModel setImageName:@"icon_log"];
  47. [businessModel setImageTitle:@"工作日志"];
  48. [_businessArray addObject:businessModel];
  49. businessModel=[[BusinessModel alloc]init];
  50. [businessModel setImageName:@"icon_filing"];
  51. [businessModel setImageTitle:@"客户报备"];
  52. [_businessArray addObject:businessModel];
  53. // businessModel=[[BusinessModel alloc]init];
  54. // [businessModel setImageName:@"icon_follow"];
  55. // [businessModel setImageTitle:@"报备跟进"];
  56. // [_businessArray addObject:businessModel];
  57. businessModel=[[BusinessModel alloc]init];
  58. [businessModel setImageName:@"icon_order"];
  59. [businessModel setImageTitle:@"手机开单"];
  60. [_businessArray addObject:businessModel];
  61. }
  62. else{
  63. BusinessModel *businessModel=[[BusinessModel alloc]init];
  64. [businessModel setImageName:@"icon_log"];
  65. [businessModel setImageTitle:@"工作日志"];
  66. [_businessArray addObject:businessModel];
  67. if( [kkRights rangeOfString:FUNCTION_CUSTOMER_CUSTOMERSFILING_IPHONE].location!=NSNotFound){
  68. businessModel=[[BusinessModel alloc]init];
  69. [businessModel setImageName:@"icon_filing"];
  70. [businessModel setImageTitle:@"客户报备"];
  71. [_businessArray addObject:businessModel];
  72. businessModel=[[BusinessModel alloc]init];
  73. [businessModel setImageName:@"icon_follow"];
  74. [businessModel setImageTitle:@"新增报备"];
  75. [_businessArray addObject:businessModel];
  76. }
  77. // if( [kkRights rangeOfString:FUNCTION_CUSTOMER_FILINGFOLLOW_IPHONE].location!=NSNotFound){
  78. // businessModel=[[BusinessModel alloc]init];
  79. // [businessModel setImageName:@"icon_follow"];
  80. // [businessModel setImageTitle:@"报备跟进"];
  81. // [_businessArray addObject:businessModel];
  82. // }
  83. if( [kkRights rangeOfString:FUNCTION_ORDER_IPHONE].location!=NSNotFound){
  84. businessModel=[[BusinessModel alloc]init];
  85. [businessModel setImageName:@"icon_order"];
  86. [businessModel setImageTitle:@"手机开单"];
  87. [_businessArray addObject:businessModel];
  88. }
  89. if([kkRights rangeOfString:FUNCTION_ADD_SALE_ORDER_FORM_IPHONE].location!=NSNotFound){
  90. businessModel=[[BusinessModel alloc]init];
  91. [businessModel setImageName:@"order"];
  92. [businessModel setImageTitle:@"销售订单"];
  93. [_businessArray addObject:businessModel];
  94. }
  95. if( [kkRights rangeOfString:FUNCTION_ADD_SALE_FORM_IPHONE].location!=NSNotFound){
  96. businessModel=[[BusinessModel alloc]init];
  97. [businessModel setImageName:@"salesslip"];
  98. [businessModel setImageTitle:@"销售单"];
  99. [_businessArray addObject:businessModel];
  100. }
  101. if( [kkRights rangeOfString:FUNCTION_SALES_INVENTORY_FORM_IPHONE].location!=NSNotFound){
  102. businessModel=[[BusinessModel alloc]init];
  103. [businessModel setImageName:@"salesoutstorage"];
  104. [businessModel setImageTitle:@"销售出库"];
  105. [_businessArray addObject:businessModel];
  106. }
  107. if( [kkRights rangeOfString:FUNCTION_OTHER_INVENTORY_FORM_IPHONE].location!=NSNotFound){
  108. businessModel=[[BusinessModel alloc]init];
  109. [businessModel setImageName:@"otheroutstorage@2x.png"];
  110. [businessModel setImageTitle:@"其他出库"];
  111. [_businessArray addObject:businessModel];
  112. }
  113. if( [kkRights rangeOfString:FUNCTION_OTHER_ENTER_FORM_IPHONE].location!=NSNotFound){
  114. businessModel=[[BusinessModel alloc]init];
  115. [businessModel setImageName:@"otherinstorage"];
  116. [businessModel setImageTitle:@"其他入库"];
  117. [_businessArray addObject:businessModel];
  118. }
  119. }
  120. }
  121. return _businessArray;
  122. }
  123. #pragma mark - 委托回调函数
  124. /**
  125. 个数
  126. @param collectionView <#collectionView description#>
  127. @param section <#section description#>
  128. @return <#return value description#>
  129. */
  130. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  131. return self.businessArray.count;
  132. }
  133. /**
  134. 单元格
  135. @param collectionView <#collectionView description#>
  136. @param indexPath <#indexPath description#>
  137. @return <#return value description#>
  138. */
  139. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  140. BusinessCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier forIndexPath:indexPath];
  141. BusinessModel *model = self.businessArray[indexPath.row];
  142. [cell setBusinessInfoModel:model];
  143. return cell;
  144. }
  145. /**
  146. 点击当个单元格
  147. @param collectionView <#collectionView description#>
  148. @param indexPath <#indexPath description#>
  149. */
  150. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  151. self.hidesBottomBarWhenPushed=YES;
  152. BusinessModel *businessModel= self.businessArray[indexPath.row];
  153. NSString *title= businessModel.imageTitle;
  154. if ([title isEqualToString:@"工作日志"]) {
  155. LogListViewController *vc=[[LogListViewController alloc]init];
  156. [self.navigationController setNavigationBarHidden:NO animated:YES];
  157. [self.navigationController pushViewController:vc animated:YES];
  158. }
  159. else if([title isEqualToString:@"客户报备"]){
  160. // 客户报备
  161. CustomerNewListViewController *vc=[[CustomerNewListViewController alloc]init];
  162. [self.navigationController setNavigationBarHidden:NO animated:YES];
  163. vc.flagCustomerAndFollow = YES;
  164. vc.checkFlagList = YES;
  165. [self.navigationController pushViewController:vc animated:YES];
  166. }
  167. else if([title isEqualToString:@"新增报备"]){
  168. // 客户报备
  169. NewCustomerViewController *vc=[[NewCustomerViewController alloc]init];
  170. [self.navigationController setNavigationBarHidden:NO animated:YES];
  171. [self.navigationController pushViewController:vc animated:YES];
  172. }
  173. else if([title isEqualToString:@"报备跟进"]){
  174. // 客户报备跟进
  175. CustomerListViewController *vc=[[CustomerListViewController alloc]init];
  176. [self.navigationController setNavigationBarHidden:NO animated:YES];
  177. vc.flagCustomerAndFollow = NO;
  178. vc.checkFlagList = YES;
  179. [self.navigationController pushViewController:vc animated:YES];
  180. }
  181. else if([title isEqualToString:@"手机开单"]){
  182. OrderHomeViewController *homeVC=[[OrderHomeViewController alloc]init];
  183. homeVC.parentVC=self;
  184. [self.navigationController setNavigationBarHidden:NO animated:YES];
  185. [self.navigationController pushViewController:homeVC animated:YES];
  186. }
  187. else if([title isEqualToString:@"销售订单"]){
  188. SalesOrderListVC *salesOrderVC=[[SalesOrderListVC alloc]init];
  189. [self.navigationController setNavigationBarHidden:NO animated:YES];
  190. [self.navigationController pushViewController:salesOrderVC animated:YES];
  191. }else if([title isEqualToString:@"销售单"]){
  192. SalesSlipListVC *salesOrderVC=[[SalesSlipListVC alloc]init];
  193. [self.navigationController setNavigationBarHidden:NO animated:YES];
  194. [self.navigationController pushViewController:salesOrderVC animated:YES];
  195. }
  196. else if([title isEqualToString:@"销售出库"]){
  197. SalesOutStorageListVC *salesOutStorageListVC=[[SalesOutStorageListVC alloc]init];
  198. [self.navigationController setNavigationBarHidden:NO animated:YES];
  199. [self.navigationController pushViewController:salesOutStorageListVC animated:YES];
  200. }
  201. else if([title isEqualToString:@"其他出库"]){
  202. OtherOutStorageListVC *otherOutStorageListVC=[[OtherOutStorageListVC alloc]init];
  203. [self.navigationController setNavigationBarHidden:NO animated:YES];
  204. [self.navigationController pushViewController:otherOutStorageListVC animated:YES];
  205. }
  206. else if([title isEqualToString:@"其他入库"]){
  207. OtherInStorageListVC *otherInStorageListVC=[[OtherInStorageListVC alloc]init];
  208. [self.navigationController setNavigationBarHidden:NO animated:YES];
  209. [self.navigationController pushViewController:otherInStorageListVC animated:YES];
  210. }
  211. self.hidesBottomBarWhenPushed=NO;
  212. }
  213. /**
  214. Sections
  215. @param tableView <#tableView description#>
  216. @return <#return value description#>
  217. */
  218. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  219. {
  220. return 1;
  221. }
  222. #pragma mark - 私有函数
  223. /**
  224. 初始化ui
  225. */
  226. -(void)initUI{
  227. // 背景头图片
  228. UIImage *pic = [UIImage imageNamed:@"banner"];
  229. UIImageView *bannerView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.width*pic.size.height/pic.size.width)];
  230. [bannerView setImage:pic];
  231. [self.view addSubview:bannerView];
  232. // 分割线
  233. _separatorView = [[UIView alloc]init];
  234. [_separatorView setBackgroundColor:LineBackgroundColor];
  235. _separatorView.frame=CGRectMake(0, CGRectGetMaxY(bannerView.frame), self.view.frame.size.width, 10);
  236. [self.view addSubview: _separatorView];
  237. UIImageView *allBusinessImagView = [[UIImageView alloc] initWithFrame:CGRectMake(10,CGRectGetMaxY(_separatorView.frame)+5,20,20)];
  238. [allBusinessImagView setImage:[UIImage imageNamed:@"icon_allbusiness"]];
  239. [self.view addSubview:allBusinessImagView];
  240. _lblAllBusiness = [UILabel new];
  241. _lblAllBusiness.text = @"全部业务";
  242. _lblAllBusiness.font = [UIFont systemFontOfSize:15];
  243. _lblAllBusiness.frame=CGRectMake(CGRectGetMaxX(allBusinessImagView.frame)+10,CGRectGetMaxY(_separatorView.frame)+5,80, 20);
  244. _lblAllBusiness.textColor = [UIColor blackColor];
  245. [self.view addSubview:_lblAllBusiness];
  246. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
  247. [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
  248. _businessCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(_lblAllBusiness.frame)+10,Screen_Width-20,Screen_Height-CGRectGetMaxY(_lblAllBusiness.frame)-rectStatusHeight-rectNavHeight-59) collectionViewLayout:flowLayout];
  249. [ _businessCollectionView registerClass:[BusinessCollectionViewCell class] forCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier];
  250. flowLayout.itemSize=CGSizeMake(Screen_Width/4,90);
  251. flowLayout.minimumLineSpacing=20;
  252. flowLayout.minimumInteritemSpacing=20;
  253. _businessCollectionView.dataSource=self;
  254. _businessCollectionView.delegate=self;
  255. _businessCollectionView.backgroundColor = [UIColor whiteColor];
  256. _businessCollectionView.showsVerticalScrollIndicator=NO;
  257. _businessCollectionView.scrollEnabled=YES;
  258. [self.view addSubview:_businessCollectionView];
  259. [_businessCollectionView reloadData];
  260. }
  261. ///**
  262. // 高度
  263. //
  264. // @param photos <#photos description#>
  265. // @return <#return value description#>
  266. // */
  267. //- (CGFloat)getPhotoCollectionViewHeightWithPhotos:(NSMutableArray *)photos {
  268. // // 上下间隔已经在frame上做了
  269. // NSInteger row = (photos.count / 3 + (photos.count % 3 ? 1 : 0));
  270. // if(self.view.frame.size.width<=320){
  271. // return (row * 80 + (row * 20));
  272. // }else{
  273. // return (row * 100 + (row * 20));
  274. // }
  275. //
  276. //}
  277. @end