CommonToolVC.m 15 KB

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