WorkFlowController.m 18 KB

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