WorkFlowController.m 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. //
  2. // WorkFlowController.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/10/21.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "WorkFlowController.h"
  9. #import "WorkFLowModel.h"
  10. #import "MyChanelCollectionReusableViewTop.h"
  11. #import "FootCollectionReusableView.h"
  12. #import "WorkFLowCell.h"
  13. #import "MyApprovalPageVC.h"
  14. #import "MyWorkWordVC.h"
  15. #import "WorkFlowTabbarController.h"
  16. #import "FecordJoinWorkFlowListController.h"
  17. #import "MyWorkCarVC.h"
  18. #import "CountDataVC.h"
  19. @interface WorkFlowController ()<UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
  20. @property (nonatomic, strong) UILabel *titleLabel;
  21. @property (strong, nonatomic) UICollectionView *collectionView;
  22. /// 协同工作
  23. @property (nonatomic, strong) NSMutableArray<WorkFLowModel*> *cooperativeWorkArray;
  24. /// 数据报表
  25. @property (nonatomic, strong) NSMutableArray <WorkFLowModel*>*dataReportArray;
  26. @property (nonatomic, strong) WorkNumberModel *numberDic;
  27. @property (nonatomic,assign) NSInteger loadFlag;
  28. @end
  29. @implementation WorkFlowController
  30. - (void)viewWillAppear:(BOOL)animated{
  31. [super viewWillAppear:animated];
  32. [self getData];
  33. }
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. // Do any additional setup after loading the view.
  37. self.fd_prefersNavigationBarHidden = YES;
  38. [self loadStatusBarColor:[UIColor whiteColor]];
  39. self.view.backgroundColor = UIColorHex(F7F7F7);
  40. [self.view addSubview:self.titleLabel];
  41. [self createCollectionView];
  42. [self layoutSubviews];
  43. SHOWLOADING
  44. self.loadFlag = 1;
  45. }
  46. - (BOOL)hidesBottomBarWhenPushed
  47. {
  48. return NO;
  49. }
  50. #pragma mark - 数据加载
  51. - (void)getData{
  52. [self.cooperativeWorkArray removeAllObjects];
  53. [self.dataReportArray removeAllObjects];
  54. // [self testData];
  55. self.loadFlag = 1;
  56. [[HttpManager sharedHttpManager] GETUrl: [NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowHomeData_Post]parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  57. NSArray *array = responseObject;
  58. NSMutableArray *arr = [NSMutableArray array];
  59. for (NSDictionary *dic in array) {
  60. WorkFLowModel *mode = [[WorkFLowModel alloc] initWithDictionary:dic error:nil];
  61. [self.cooperativeWorkArray addObject:mode];
  62. }
  63. [self.cooperativeWorkArray addObjectsFromArray:arr];
  64. self.loadFlag += 1;
  65. if (self.loadFlag == 2) {
  66. REMOVESHOW
  67. [self.collectionView reloadData];
  68. }
  69. } failure:^(NSError * _Nonnull error) {
  70. }];
  71. // //获取我审批和我发起以及抄送我的未读数
  72. // [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,@"/api/app/user/user-uread-count"] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  73. // NSDictionary *dic = responseObject;
  74. // self.numberDic = [[WorkNumberModel alloc] initWithDictionary:dic error:nil];
  75. // self.navigationController.tabBarItem.badgeValue = [self.numberDic allNumber];
  76. // /// 我的审批未读数
  77. // self.cooperativeWorkArray.firstObject.workNumber = [dic[@"FlowAuditUReadCount"] integerValue];
  78. // for (WorkFLowModel *model in self.cooperativeWorkArray) {
  79. // if ([model.Name isEqualToString:@"我发起的"]) {
  80. // model.workNumber = [dic[@"FlowSendUReadCount"] integerValue];
  81. // }
  82. // if ([model.Name isEqualToString:@"抄送我的"]) {
  83. // model.workNumber = [dic[@"FlowCcUReadCount"] integerValue];
  84. // }
  85. // }
  86. // self.loadFlag += 1;
  87. // if (self.loadFlag == 4) {
  88. // REMOVESHOW
  89. // [self.collectionView reloadData];
  90. // }
  91. // } failure:^(NSError * _Nonnull error) {
  92. // }];
  93. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowHomeData2_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  94. NSArray *array = responseObject;
  95. NSLog(@"%@",responseObject);
  96. for (NSDictionary *dic in array) {
  97. WorkFLowModel *mode = [[WorkFLowModel alloc]initWithDictionary:dic error:nil];
  98. [self.dataReportArray addObject:mode];
  99. }
  100. self.loadFlag += 1;
  101. if (self.loadFlag == 2) {
  102. REMOVESHOW
  103. [self.collectionView reloadData];
  104. }
  105. } failure:^(NSError * _Nonnull error) {
  106. }];
  107. }
  108. - (void)testData{
  109. WorkFLowModel *mode1 = [[WorkFLowModel alloc] init];
  110. mode1.Name = @"我的审批";
  111. mode1.iconImage = IMG(@"work_flow_approvalme");
  112. mode1.workNumber = 0;
  113. [self.cooperativeWorkArray addObject:mode1];
  114. WorkFLowModel *mode2 = [[WorkFLowModel alloc] init];
  115. mode2.Name = @"我发起的";
  116. mode2.iconImage = IMG(@"work_flow_fromme");
  117. mode2.workNumber = 0;
  118. [self.cooperativeWorkArray addObject:mode2];
  119. WorkFLowModel *mode3 = [[WorkFLowModel alloc] init];
  120. mode3.Name = @"抄送我的";
  121. mode3.iconImage = IMG(@"work_flow_forme");
  122. mode3.workNumber = 0;
  123. [self.cooperativeWorkArray addObject:mode3];
  124. //
  125. // WorkFLowModel *mode13 = [[WorkFLowModel alloc] init];
  126. // mode13.Name = @"财务数据";
  127. // mode13.iconImage = IMG(@"work_flow_money_data");
  128. // mode13.workNumber = 0;
  129. // [self.dataReportArray addObject:mode13];
  130. //
  131. // WorkFLowModel *mode14 = [[WorkFLowModel alloc] init];
  132. // mode14.Name = @"出版数据";
  133. // mode14.iconImage = IMG(@"work_flow_version_data");
  134. // mode14.workNumber = 0;
  135. // [self.dataReportArray addObject:mode14];
  136. //
  137. // WorkFLowModel *mode15 = [[WorkFLowModel alloc] init];
  138. // mode15.Name = @"人事数据";
  139. // mode15.iconImage = IMG(@"work_flow_hr_data");
  140. // mode15.workNumber = 0;
  141. // [self.dataReportArray addObject:mode15];
  142. }
  143. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  144. return 2;
  145. }
  146. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  147. if (section == 0) {
  148. return self.cooperativeWorkArray.count;
  149. }else{
  150. return self.dataReportArray.count;
  151. }
  152. }
  153. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
  154. if (kind == UICollectionElementKindSectionFooter){
  155. FootCollectionReusableView *footerView = [self.collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FootCollectionReusableView" forIndexPath:indexPath];
  156. return footerView;
  157. }else{
  158. MyChanelCollectionReusableViewTop *headerView = [self.collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MyChanelCollectionReusableViewTop" forIndexPath:indexPath];
  159. headerView.bottomLineView.hidden = NO;
  160. if (indexPath.section == 0) {
  161. headerView.labelTitle.text = @"协同办公";
  162. headerView.left.constant = 15.f;
  163. headerView.labelTitle.font = [UIFont systemFontOfSize:15.f];
  164. headerView.labelDetail.text = @"";
  165. }else{
  166. headerView.labelTitle.text = @"数据报表";
  167. headerView.left.constant = 15.f;
  168. headerView.labelTitle.font = [UIFont systemFontOfSize:15.f];
  169. headerView.labelDetail.text = @"";
  170. }
  171. return headerView;
  172. }
  173. }
  174. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
  175. return CGSizeMake(kGXScreenWidth-14, 39);
  176. }
  177. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{
  178. return CGSizeMake(kGXScreenWidth-14, 20);
  179. }
  180. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
  181. return CGSizeMake((kGXScreenWidth -14)/3 ,(kGXScreenWidth -14)/3);
  182. }
  183. -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  184. return UIEdgeInsetsMake(0, 0, 0, 0);
  185. }
  186. //func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
  187. // return UIEdgeInsetsZero
  188. //}
  189. //
  190. // func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
  191. // return 1
  192. //}
  193. //
  194. //func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat {
  195. // return 5
  196. //}
  197. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  198. WorkFLowCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WorkFLowCellID" forIndexPath:indexPath];
  199. WorkFLowModel *model = (indexPath.section == 0) ? self.cooperativeWorkArray[indexPath.item]:self.dataReportArray[indexPath.item];
  200. if (model.workNumber > 0) {
  201. NSString * count = [NSString stringWithFormat:@"%ld",(long)model.workNumber];
  202. UILabel * label = [UILabel new];
  203. label.font = [UIFont systemFontOfSize:12];
  204. label.text = count;
  205. CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
  206. cell.workNumberLab.layer.cornerRadius = 8;
  207. cell.workNumberLab.layer.masksToBounds = YES;
  208. if ((width + 5) < 16) {
  209. cell.width.constant = 16;
  210. }else{
  211. cell.width.constant = width + 8;
  212. }
  213. cell.workNumberLab.text = count;
  214. }
  215. if (model.workNumber == 0 ) {
  216. cell.workNumberLab.hidden = YES;
  217. cell.workNumberLab.layer.cornerRadius = 10;
  218. cell.workNumberLab.layer.masksToBounds = YES;
  219. }else{
  220. cell.workNumberLab.hidden = NO;
  221. }
  222. cell.titleLabel.text = model.Name;
  223. if (indexPath.item == 0 || indexPath.item == 1 || indexPath.item == 2) {
  224. cell.iconImageView.image = model.iconImage;
  225. }else{
  226. [cell.iconImageView setImageWithURL:[NSURL URLWithString:model.IconUrl] placeholder:IMG(@"work_flow_approvalme")];
  227. }
  228. cell.leftLine.hidden = NO;
  229. cell.rightLine.hidden = NO;
  230. cell.bottomLine.hidden= NO;
  231. cell.topLine.hidden = NO;
  232. if (indexPath.section == 1) {
  233. cell.titleLabel.text = model.Title;
  234. [cell.iconImageView setImageWithURL:[NSURL URLWithString:model.IocUrl] placeholder:IMG(@"work_flow_approvalme")];
  235. }
  236. return cell;
  237. }
  238. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  239. WorkFLowModel *model = (indexPath.section == 0) ? self.cooperativeWorkArray[indexPath.item]:self.dataReportArray[indexPath.item];
  240. if (indexPath.section == 0) {
  241. if (indexPath.item == 0 || indexPath.item == 1 || indexPath.item == 2) {
  242. MyApprovalPageVC *myApprovalPageVC = [[MyApprovalPageVC alloc]init];
  243. myApprovalPageVC.title = model.Name;
  244. if (indexPath.item == 0) {
  245. myApprovalPageVC.pageType = Type_ONEA;
  246. }
  247. if (indexPath.item == 1) {
  248. myApprovalPageVC.pageType = Type_ONEB;
  249. }
  250. if (indexPath.item == 2) {
  251. myApprovalPageVC.pageType = Type_ONEC;
  252. }
  253. myApprovalPageVC.numberDic = self.numberDic;
  254. [self.navigationController pushViewController:myApprovalPageVC animated:YES];
  255. }else{
  256. if ([model.Name isEqualToString:@"会议"]) {
  257. [self.navigationController pushViewController:[[WorkFlowTabbarController alloc] init] animated:YES];
  258. // }else if ([model.Name isEqualToString:@"车辆"]){
  259. // MyWorkCarVC *vc = [[MyWorkCarVC alloc]init];
  260. // vc.title = model.Name;
  261. // vc.indexID = model.Id;
  262. // [self.navigationController pushViewController:vc animated:YES];
  263. } else {
  264. MyWorkWordVC *workWordVC = [[MyWorkWordVC alloc]init];
  265. workWordVC.title = model.Name;
  266. workWordVC.pageType = Type_GongWen;
  267. workWordVC.indexID = model.Id;
  268. [self.navigationController pushViewController:workWordVC animated:YES];
  269. }
  270. }
  271. }
  272. if (indexPath.section == 1) {
  273. WorkFLowCell *cell = (WorkFLowCell *)[collectionView cellForItemAtIndexPath:indexPath];
  274. if ([cell.titleLabel.text isEqualToString:@"财务统计"]) {
  275. CountDataVC *vc = [CountDataVC initCountDataVC];
  276. vc.index = 0;
  277. vc.titleStr = @"财务统计";
  278. [self.navigationController pushViewController:vc animated:YES];
  279. }
  280. if ([cell.titleLabel.text isEqualToString:@"人事统计"]) {
  281. CountDataVC *vc = [CountDataVC initCountDataVC];
  282. vc.index = 1;
  283. vc.titleStr = @"人事统计";
  284. [self.navigationController pushViewController:vc animated:YES];
  285. }
  286. if ([cell.titleLabel.text isEqualToString:@"出版统计"]) {
  287. CountDataVC *vc = [CountDataVC initCountDataVC];
  288. vc.index = 2;
  289. vc.titleStr = @"出版统计";
  290. [self.navigationController pushViewController:vc animated:YES];
  291. }
  292. // WorkFLowCell *cell = (WorkFLowCell *)[collectionView cellForItemAtIndexPath:indexPath];
  293. // if ([cell.titleLabel.text isEqualToString:@"财务统计"]) {
  294. // VersionDataVC *vc = [VersionDataVC initVersionDataVC];
  295. // vc.pageType = 1;
  296. // [self.navigationController pushViewController:vc animated:YES];
  297. // }
  298. // if ([cell.titleLabel.text isEqualToString:@"人事统计"]) {
  299. // VersionDataVC *vc = [VersionDataVC initVersionData3VC];
  300. // vc.pageType = 3;
  301. // [self.navigationController pushViewController:vc animated:YES];
  302. // }
  303. // if ([cell.titleLabel.text isEqualToString:@"出版统计"]) {
  304. // VersionDataVC *vc = [VersionDataVC initVersionData2VC];
  305. // vc.pageType = 2;
  306. // [self.navigationController pushViewController:vc animated:YES];
  307. // }
  308. }
  309. }
  310. #pragma mark - Setter
  311. - (UILabel *)titleLabel {
  312. if (!_titleLabel) {
  313. _titleLabel = [UILabel new];
  314. _titleLabel.backgroundColor = [UIColor whiteColor];
  315. _titleLabel.text = @"工作应用";
  316. _titleLabel.font = [UIFont systemFontOfSize:16.f];
  317. _titleLabel.textColor = UIColorHex(1A1A1A);
  318. _titleLabel.textAlignment = NSTextAlignmentCenter;
  319. }
  320. return _titleLabel;
  321. }
  322. - (NSMutableArray<WorkFLowModel*> *)cooperativeWorkArray{
  323. if (!_cooperativeWorkArray) {
  324. _cooperativeWorkArray = [NSMutableArray new];
  325. }
  326. return _cooperativeWorkArray;
  327. }
  328. - (NSMutableArray<WorkFLowModel *> *)dataReportArray{
  329. if (!_dataReportArray) {
  330. _dataReportArray = [NSMutableArray new];
  331. }
  332. return _dataReportArray;
  333. }
  334. - (void)createCollectionView {
  335. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  336. layout.minimumLineSpacing = 0;
  337. layout.minimumInteritemSpacing = 0;
  338. self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  339. self.collectionView.dataSource = self;
  340. self.collectionView.delegate = self;
  341. self.collectionView.layer.cornerRadius = 2;
  342. self.collectionView.layer.masksToBounds = YES;
  343. self.collectionView.backgroundColor = UIColorHex(F7F7F7);
  344. [self.collectionView registerNib:[UINib nibWithNibName:@"WorkFLowCell" bundle:nil] forCellWithReuseIdentifier:@"WorkFLowCellID"];
  345. [self.collectionView registerNib:[UINib nibWithNibName:@"MyChanelCollectionReusableViewTop" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MyChanelCollectionReusableViewTop"];
  346. [self.collectionView registerNib:[UINib nibWithNibName:@"FootCollectionReusableView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FootCollectionReusableView"];
  347. self.collectionView.backgroundColor = [UIColor whiteColor];
  348. // UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)];
  349. // [self.collectionView addGestureRecognizer:longPressGesture];
  350. [self.collectionView setShowsVerticalScrollIndicator:NO];
  351. [self.collectionView setShowsHorizontalScrollIndicator:NO];
  352. [self.view addSubview:self.collectionView];
  353. self.collectionView.backgroundColor = UIColorHex(F7F7F7);
  354. }
  355. #pragma mark - 布局
  356. -(void)layoutSubviews{
  357. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  358. make.top.equalTo(self.statusBar.mas_bottom);
  359. make.left.right.equalTo(self.view);
  360. make.height.equalTo(@44);
  361. }];
  362. [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  363. make.left.mas_offset(7);
  364. make.right.mas_offset(-7);
  365. make.top.mas_equalTo(self.titleLabel.mas_bottom);
  366. if (@available(iOS 11.0, *)) {
  367. make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
  368. } else {
  369. make.bottom.equalTo(self.view.mas_bottom);
  370. }
  371. }];
  372. }
  373. @end