CommonToolVC.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. //
  2. // CommonToolVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/4/28.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "CommonToolVC.h"
  9. #import "WorkFLowModel.h"
  10. #import "WorkFLowCell.h"
  11. #import "myApprovalPageVC.h"
  12. #import "WorkFlowTabbarController.h"
  13. #import "MyWorkWordVC.h"
  14. #import "CountDataVC.h"
  15. #import "CommonToolMoveVC.h"
  16. @interface CommonToolVC ()<UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
  17. @property (weak, nonatomic) IBOutlet UIButton *setBtn;
  18. @property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
  19. /// 协同工作
  20. @property (nonatomic, strong) NSMutableArray<WorkFLowModel*> *cooperativeWorkArray;
  21. /// 数据报表
  22. @property (nonatomic, strong) NSMutableArray <WorkFLowModel*>*dataReportArray;
  23. @property (nonatomic, strong) WorkNumberModel *numberDic;
  24. @property (nonatomic,assign) NSInteger loadFlag;
  25. @end
  26. @implementation CommonToolVC
  27. +(CommonToolVC *)initCommonToolVC{
  28. CommonToolVC *controller = [StoryboardManager.shared.Common instantiateViewControllerWithIdentifier:@"CommonToolVC"];
  29. return controller;
  30. }
  31. - (void)viewWillAppear:(BOOL)animated{
  32. [super viewWillAppear:animated];
  33. }
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. self.fd_prefersNavigationBarHidden = YES;
  37. [self.view setBackgroundColor:UIColorHex(0xf7f7f7)];
  38. [self createCollectionView];
  39. WS(weakSelf);
  40. [self.setBtn setAction:^{
  41. CommonToolMoveVC * vc = [CommonToolMoveVC initCommonToolMoveVC];
  42. [weakSelf.navigationController pushViewController:vc animated:YES];
  43. }];
  44. [self.collectionView reloadData];
  45. }
  46. #pragma mark - 数据加载
  47. - (void)getData{
  48. [self.cooperativeWorkArray removeAllObjects];
  49. [self.dataReportArray removeAllObjects];
  50. // [self testData];
  51. self.loadFlag = 1;
  52. [[HttpManager sharedHttpManager] GETUrl: [NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowHomeData_Post]parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  53. NSArray *array = responseObject;
  54. NSMutableArray *arr = [NSMutableArray array];
  55. for (NSDictionary *dic in array) {
  56. WorkFLowModel *mode = [[WorkFLowModel alloc] initWithDictionary:dic error:nil];
  57. [self.cooperativeWorkArray addObject:mode];
  58. }
  59. [self.cooperativeWorkArray addObjectsFromArray:arr];
  60. self.loadFlag += 1;
  61. if (self.loadFlag == 3) {
  62. REMOVESHOW
  63. [self.collectionView reloadData];
  64. }
  65. } failure:^(NSError * _Nonnull error) {
  66. }];
  67. //获取我审批和我发起以及抄送我的未读数
  68. // [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,@"/api/app/user/user-uread-count"] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  69. // NSDictionary *dic = responseObject;
  70. // self.numberDic = [[WorkNumberModel alloc] initWithDictionary:dic error:nil];
  71. // self.navigationController.tabBarItem.badgeValue = [self.numberDic allNumber];
  72. // /// 我的审批未读数
  73. // self.cooperativeWorkArray.firstObject.workNumber = [dic[@"FlowAuditUReadCount"] integerValue];
  74. // for (WorkFLowModel *model in self.cooperativeWorkArray) {
  75. // if ([model.Name isEqualToString:@"我发起的"]) {
  76. // model.workNumber = [dic[@"FlowSendUReadCount"] integerValue];
  77. // }
  78. // if ([model.Name isEqualToString:@"抄送我的"]) {
  79. // model.workNumber = [dic[@"FlowCcUReadCount"] integerValue];
  80. // }
  81. // }
  82. // self.loadFlag += 1;
  83. // if (self.loadFlag == 4) {
  84. // REMOVESHOW
  85. // [self.collectionView reloadData];
  86. // }
  87. // } failure:^(NSError * _Nonnull error) {
  88. // }];
  89. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowHomeData2_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  90. NSArray *array = responseObject;
  91. NSLog(@"%@",responseObject);
  92. for (NSDictionary *dic in array) {
  93. WorkFLowModel *mode = [[WorkFLowModel alloc]initWithDictionary:dic error:nil];
  94. [self.dataReportArray addObject:mode];
  95. }
  96. self.loadFlag += 1;
  97. if (self.loadFlag == 3) {
  98. REMOVESHOW
  99. [self.collectionView reloadData];
  100. }
  101. } failure:^(NSError * _Nonnull error) {
  102. }];
  103. }
  104. - (void)testData{
  105. WorkFLowModel *mode1 = [[WorkFLowModel alloc] init];
  106. mode1.Name = @"我的审批";
  107. mode1.iconImage = IMG(@"work_flow_approvalme");
  108. mode1.workNumber = 0;
  109. [self.cooperativeWorkArray addObject:mode1];
  110. WorkFLowModel *mode2 = [[WorkFLowModel alloc] init];
  111. mode2.Name = @"我发起的";
  112. mode2.iconImage = IMG(@"work_flow_fromme");
  113. mode2.workNumber = 0;
  114. [self.cooperativeWorkArray addObject:mode2];
  115. WorkFLowModel *mode3 = [[WorkFLowModel alloc] init];
  116. mode3.Name = @"抄送我的";
  117. mode3.iconImage = IMG(@"work_flow_forme");
  118. mode3.workNumber = 0;
  119. [self.cooperativeWorkArray addObject:mode3];
  120. //
  121. // WorkFLowModel *mode13 = [[WorkFLowModel alloc] init];
  122. // mode13.Name = @"财务数据";
  123. // mode13.iconImage = IMG(@"work_flow_money_data");
  124. // mode13.workNumber = 0;
  125. // [self.dataReportArray addObject:mode13];
  126. //
  127. // WorkFLowModel *mode14 = [[WorkFLowModel alloc] init];
  128. // mode14.Name = @"出版数据";
  129. // mode14.iconImage = IMG(@"work_flow_version_data");
  130. // mode14.workNumber = 0;
  131. // [self.dataReportArray addObject:mode14];
  132. //
  133. // WorkFLowModel *mode15 = [[WorkFLowModel alloc] init];
  134. // mode15.Name = @"人事数据";
  135. // mode15.iconImage = IMG(@"work_flow_hr_data");
  136. // mode15.workNumber = 0;
  137. // [self.dataReportArray addObject:mode15];
  138. }
  139. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  140. return 1;
  141. }
  142. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  143. return 15;
  144. }
  145. //- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
  146. // return CGSizeMake(kGXScreenWidth-14, 39);
  147. //}
  148. //- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{
  149. // return CGSizeMake(kGXScreenWidth-14, 20);
  150. //}
  151. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
  152. return CGSizeMake((kGXScreenWidth -14)/3 ,(kGXScreenWidth -14)/3);
  153. }
  154. -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  155. return UIEdgeInsetsMake(0, 0, 0, 0);
  156. }
  157. //func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
  158. // return UIEdgeInsetsZero
  159. //}
  160. //
  161. // func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
  162. // return 1
  163. //}
  164. //
  165. //func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat {
  166. // return 5
  167. //}
  168. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  169. WorkFLowCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WorkFLowCellID" forIndexPath:indexPath];
  170. // WorkFLowModel *model = (indexPath.section == 0) ? self.cooperativeWorkArray[indexPath.item]:self.dataReportArray[indexPath.item];
  171. // if (model.workNumber > 0) {
  172. // NSString * count = [NSString stringWithFormat:@"%ld",(long)model.workNumber];
  173. // UILabel * label = [UILabel new];
  174. // label.font = [UIFont systemFontOfSize:12];
  175. // label.text = count;
  176. // CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
  177. // cell.workNumberLab.layer.cornerRadius = 8;
  178. // cell.workNumberLab.layer.masksToBounds = YES;
  179. // if ((width + 5) < 16) {
  180. // cell.width.constant = 16;
  181. // }else{
  182. // cell.width.constant = width + 8;
  183. // }
  184. // cell.workNumberLab.text = count;
  185. // }
  186. // if (model.workNumber == 0 ) {
  187. // cell.workNumberLab.hidden = YES;
  188. // cell.workNumberLab.layer.cornerRadius = 10;
  189. // cell.workNumberLab.layer.masksToBounds = YES;
  190. // }else{
  191. // cell.workNumberLab.hidden = NO;
  192. // }
  193. cell.workNumberLab.hidden = YES;
  194. cell.titleLabel.text = [NSString stringWithFormat:@"工具%ld",indexPath.row + 1];
  195. cell.iconImageView.image = IMG(@"img_placeHolder");
  196. cell.leftLine.hidden = NO;
  197. cell.rightLine.hidden = NO;
  198. cell.bottomLine.hidden= NO;
  199. cell.topLine.hidden = NO;
  200. return cell;
  201. }
  202. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  203. [collectionView deselectItemAtIndexPath:indexPath animated:YES];
  204. // WorkFLowModel *model = (indexPath.section == 0) ? self.cooperativeWorkArray[indexPath.item]:self.dataReportArray[indexPath.item];
  205. // if (indexPath.section == 0) {
  206. // // if (indexPath.item == 0 || indexPath.item == 1 || indexPath.item == 2) {
  207. // // MyApprovalPageVC *myApprovalPageVC = [[MyApprovalPageVC alloc]init];
  208. // // myApprovalPageVC.title = model.Name;
  209. // // if (indexPath.item == 0) {
  210. // // myApprovalPageVC.pageType = Type_ONEA;
  211. // // }
  212. // // if (indexPath.item == 1) {
  213. // // myApprovalPageVC.pageType = Type_ONEB;
  214. // // }
  215. // // if (indexPath.item == 2) {
  216. // // myApprovalPageVC.pageType = Type_ONEC;
  217. // // }
  218. // // myApprovalPageVC.numberDic = self.numberDic;
  219. // // [self.navigationController pushViewController:myApprovalPageVC animated:YES];
  220. // // }else{
  221. // // if ([model.Name isEqualToString:@"会议"]) {
  222. // // [self.navigationController pushViewController:[[WorkFlowTabbarController alloc] init] animated:YES];
  223. // // } else {
  224. // // MyWorkWordVC *workWordVC = [[MyWorkWordVC alloc]init];
  225. // // workWordVC.title = model.Name;
  226. // // workWordVC.pageType = Type_GongWen;
  227. // // workWordVC.indexID = model.Id;
  228. // // [self.navigationController pushViewController:workWordVC animated:YES];
  229. // // }
  230. // // }
  231. // if ([model.Name isEqualToString:@"会议"]) {
  232. // [self.navigationController pushViewController:[[WorkFlowTabbarController alloc] init] animated:YES];
  233. // } else {
  234. // MyWorkWordVC *workWordVC = [[MyWorkWordVC alloc]init];
  235. // workWordVC.title = model.Name;
  236. // workWordVC.pageType = Type_GongWen;
  237. // workWordVC.indexID = model.Id;
  238. // [self.navigationController pushViewController:workWordVC animated:YES];
  239. // }
  240. // }
  241. // if (indexPath.section == 1) {
  242. // WorkFLowCell *cell = (WorkFLowCell *)[collectionView cellForItemAtIndexPath:indexPath];
  243. // if ([cell.titleLabel.text isEqualToString:@"财务统计"]) {
  244. // CountDataVC *vc = [CountDataVC initCountDataVC];
  245. // vc.index = 0;
  246. // vc.titleStr = @"财务统计";
  247. // [self.navigationController pushViewController:vc animated:YES];
  248. // }
  249. // if ([cell.titleLabel.text isEqualToString:@"人事统计"]) {
  250. // CountDataVC *vc = [CountDataVC initCountDataVC];
  251. // vc.index = 1;
  252. // vc.titleStr = @"人事统计";
  253. // [self.navigationController pushViewController:vc animated:YES];
  254. // }
  255. // if ([cell.titleLabel.text isEqualToString:@"出版统计"]) {
  256. // CountDataVC *vc = [CountDataVC initCountDataVC];
  257. // vc.index = 2;
  258. // vc.titleStr = @"出版统计";
  259. // [self.navigationController pushViewController:vc animated:YES];
  260. // }
  261. //// WorkFLowCell *cell = (WorkFLowCell *)[collectionView cellForItemAtIndexPath:indexPath];
  262. //// if ([cell.titleLabel.text isEqualToString:@"财务统计"]) {
  263. //// VersionDataVC *vc = [VersionDataVC initVersionDataVC];
  264. //// vc.pageType = 1;
  265. //// [self.navigationController pushViewController:vc animated:YES];
  266. //// }
  267. //// if ([cell.titleLabel.text isEqualToString:@"人事统计"]) {
  268. //// VersionDataVC *vc = [VersionDataVC initVersionData3VC];
  269. //// vc.pageType = 3;
  270. //// [self.navigationController pushViewController:vc animated:YES];
  271. //// }
  272. //// if ([cell.titleLabel.text isEqualToString:@"出版统计"]) {
  273. //// VersionDataVC *vc = [VersionDataVC initVersionData2VC];
  274. //// vc.pageType = 2;
  275. //// [self.navigationController pushViewController:vc animated:YES];
  276. //// }
  277. // }
  278. }
  279. #pragma mark - Setter
  280. - (NSMutableArray<WorkFLowModel*> *)cooperativeWorkArray{
  281. if (!_cooperativeWorkArray) {
  282. _cooperativeWorkArray = [NSMutableArray new];
  283. }
  284. return _cooperativeWorkArray;
  285. }
  286. - (NSMutableArray<WorkFLowModel *> *)dataReportArray{
  287. if (!_dataReportArray) {
  288. _dataReportArray = [NSMutableArray new];
  289. }
  290. return _dataReportArray;
  291. }
  292. - (void)createCollectionView {
  293. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  294. layout.minimumLineSpacing = 0;
  295. layout.minimumInteritemSpacing = 0;
  296. [self.collectionView setCollectionViewLayout:layout];
  297. self.collectionView.dataSource = self;
  298. self.collectionView.delegate = self;
  299. self.collectionView.layer.cornerRadius = 2;
  300. self.collectionView.layer.masksToBounds = YES;
  301. self.collectionView.backgroundColor = UIColorHex(F7F7F7);
  302. [self.collectionView registerNib:[UINib nibWithNibName:@"WorkFLowCell" bundle:nil] forCellWithReuseIdentifier:@"WorkFLowCellID"];
  303. [self.collectionView registerNib:[UINib nibWithNibName:@"MyChanelCollectionReusableViewTop" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MyChanelCollectionReusableViewTop"];
  304. [self.collectionView registerNib:[UINib nibWithNibName:@"FootCollectionReusableView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FootCollectionReusableView"];
  305. self.collectionView.backgroundColor = [UIColor whiteColor];
  306. [self.collectionView setShowsVerticalScrollIndicator:NO];
  307. [self.collectionView setShowsHorizontalScrollIndicator:NO];
  308. [self.view addSubview:self.collectionView];
  309. self.collectionView.backgroundColor = UIColorHex(F7F7F7);
  310. }
  311. @end