MyApprovalPageVC.m 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. //
  2. // MyApprovalPageVC.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/11/1.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyApprovalPageVC.h"
  9. #import "DrawerView.h"
  10. #import "WorkListCell.h"
  11. #import "MyApprovalModel.h"
  12. #import "MyApprovalBCell.h"
  13. #import "MyApprovalPageDetail.h"
  14. #import "WorkFlowSearchVC.h"
  15. #import "TDNavigationBar.h"
  16. #import "WorkFLowCollectionSelectView.h"
  17. #import "TabBarController.h"
  18. @interface MyApprovalPageVC ()<UITableViewDelegate,UITableViewDataSource,TDNavigationBarDelegate,WorkFLowCollectionSelectViewDelegate>
  19. @property (nonatomic, strong) TDNavigationBar *myNavigationBar;
  20. @property (nonatomic, strong) TDTableView *mytableView;
  21. @property (nonatomic, assign) ApprovalPageSelectType apprvovalType;
  22. @property (nonatomic, strong) UIView *header1;
  23. @property (nonatomic, strong) UIView *header2;
  24. @property (nonatomic, strong) TDButton *waitApprovalButton;
  25. @property (nonatomic, strong) UIView *waitApprovalButtonBottomLine;
  26. @property (nonatomic, strong) TDButton *approvalButton;
  27. @property (nonatomic, strong) UIView *approvalButtonBottomLine;
  28. @property (nonatomic, strong) TDButton *searchButton;
  29. @property (nonatomic, strong) TDButton *selectButton;
  30. @property (nonatomic, strong) NSMutableArray <MyApprovalModel*>*waitApprovalDataArray;
  31. @property (nonatomic, strong) NSMutableArray <MyApprovalModel*>*approvalDataArray;
  32. @property (nonatomic, strong) UIView *myBackImageView;
  33. @property (nonatomic, strong) WorkFLowCollectionSelectView *workFLowCollectionSelectView;
  34. @property (nonatomic, assign) NSInteger haveRedFlag;
  35. @property (nonatomic, strong) NSString *approvalTypeStr;
  36. @property (nonatomic, assign) NSInteger page;
  37. @property (nonatomic, assign) NSInteger dataCount;
  38. @property (nonatomic, strong) NSArray<WorkFilterModel *> *selectedMyApprovalModel;
  39. @property (nonatomic, strong) NSMutableArray<WorkFilterModel *> *selectModelArray;
  40. @property (nonatomic, strong) DrawerView *drawerView;
  41. @property (nonatomic, strong) NSMutableArray * selectArray;
  42. @end
  43. @implementation MyApprovalPageVC
  44. - (void)viewWillAppear:(BOOL)animated
  45. {
  46. [super viewWillAppear:animated];
  47. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
  48. [self getCount];
  49. [self headerRefresh];
  50. }
  51. - (void)viewDidLoad {
  52. [super viewDidLoad];
  53. [self.myNavigationBar setTitle:self.title];
  54. [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithBgColor:[UIColor colorWithRed:92/255.0 green:118.0/255.0 blue:167.0/255.f alpha:1.0] alpha:1.0] forBarMetrics:UIBarMetricsDefault];
  55. [self.view addSubview:self.myBackImageView];
  56. [self.view addSubview:self.myNavigationBar];
  57. self.view.backgroundColor = UIColorHex(EEEEEE);
  58. self.fd_prefersNavigationBarHidden = YES;
  59. CGFloat listTopSpace = 96 + kNavigationHeight;
  60. self.apprvovalType = WaitApprovalType;
  61. // 头部处理
  62. switch (self.pageType) {
  63. case Type_ONEA:
  64. [self myapprovall];
  65. self.waitApprovalButtonBottomLine.hidden = NO;
  66. self.approvalButtonBottomLine.hidden = YES;
  67. self.waitApprovalButton.selected = YES;
  68. self.approvalButton.selected = NO;
  69. self.approvalTypeStr = @"MyChecking";
  70. break;
  71. case Type_ONEB:
  72. [self myapprovallB];
  73. self.haveRedFlag = 1;
  74. self.approvalTypeStr = @"SubmittedChecked";
  75. self.waitApprovalButtonBottomLine.hidden = NO;
  76. self.approvalButtonBottomLine.hidden = YES;
  77. self.waitApprovalButton.selected = YES;
  78. self.approvalButton.selected = NO;
  79. break;
  80. case Type_ONEC:
  81. [self myapprovallC];
  82. self.waitApprovalButtonBottomLine.hidden = NO;
  83. self.approvalButtonBottomLine.hidden = YES;
  84. self.waitApprovalButton.selected = YES;
  85. self.approvalButton.selected = NO;
  86. self.approvalTypeStr = @"CcUnread";
  87. break;
  88. default:
  89. break;
  90. }
  91. // [self getData];
  92. [self getFilterModelData];
  93. [self.view addSubview:self.mytableView];
  94. [self.mytableView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.left.equalTo(self.view);
  96. make.right.equalTo(self.view);
  97. make.top.equalTo(self.view).offset(listTopSpace);
  98. make.bottom.equalTo(self.view);
  99. }];
  100. [self setTableViewRefresh];
  101. [self addNoDataMessageToViewCenter:self.mytableView message:@"暂无审核内容"];
  102. self.selectArray = [NSMutableArray array];
  103. for (NSInteger i = 0; i < 3; i ++) {
  104. NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithDictionary:@{@"waitTitle":@"筛选",@"Title":@"筛选",@"waitIds":@[],@"ids":@[]}];
  105. [self.selectArray addObject:dict];
  106. }
  107. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(headerRefresh) name:WORKREUPDATA object:nil];
  108. }
  109. - (void)dealloc
  110. {
  111. [[NSNotificationCenter defaultCenter] removeObserver:self];
  112. }
  113. - (void)setTableViewRefresh{
  114. WeakSelf(self)
  115. self.mytableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  116. [weakself headerRefresh];
  117. }];
  118. self.mytableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
  119. [weakself footerRefresh];
  120. }];
  121. }
  122. - (void)headerRefresh
  123. {
  124. [self.waitApprovalDataArray removeAllObjects];
  125. [self.approvalDataArray removeAllObjects];
  126. self.page = 1;
  127. [self getFromePage:self.page WithType:self.approvalTypeStr];
  128. }
  129. - (void)footerRefresh{
  130. switch (self.apprvovalType) {
  131. case WaitApprovalType:{
  132. if (self.waitApprovalDataArray.count == self.dataCount) {
  133. [self.mytableView.mj_footer endRefreshingWithNoMoreData];
  134. }else{
  135. self.page ++;
  136. [self getFromePage:self.page WithType:self.approvalTypeStr];
  137. }
  138. }break;
  139. case ApprovalType:{
  140. if (self.approvalDataArray.count == self.dataCount) {
  141. [self.mytableView.mj_footer endRefreshingWithNoMoreData];
  142. }else{
  143. self.page ++;
  144. [self getFromePage:self.page WithType:self.approvalTypeStr];
  145. }
  146. }break;
  147. }
  148. }
  149. #pragma mark - 界面头部异化处理
  150. - (void)myapprovall{
  151. self.view.backgroundColor = UIColorHex(EEEEEE);
  152. [self.view addSubview:self.header1];
  153. [self.header1 mas_makeConstraints:^(MASConstraintMaker *make) {
  154. make.left.equalTo(self.view);
  155. make.top.equalTo(self.view).offset(kNavigationHeight);
  156. make.right.equalTo(self.view);
  157. make.height.mas_equalTo(44);
  158. }];
  159. [self.view addSubview:self.header2];
  160. [self.header2 mas_makeConstraints:^(MASConstraintMaker *make) {
  161. make.left.equalTo(self.view);
  162. make.top.equalTo(self.header1.mas_bottom).offset(9);
  163. make.right.equalTo(self.view);
  164. make.height.mas_equalTo(32);
  165. }];
  166. }
  167. - (void)myapprovallB{
  168. self.view.backgroundColor = UIColorHex(EEEEEE);
  169. [self.view addSubview:self.header1];
  170. [self.header1 mas_makeConstraints:^(MASConstraintMaker *make) {
  171. make.left.equalTo(self.view);
  172. make.top.equalTo(self.view).offset(kNavigationHeight);
  173. make.right.equalTo(self.view);
  174. make.height.mas_equalTo(44);
  175. }];
  176. [self.view addSubview:self.header2];
  177. [self.header2 mas_makeConstraints:^(MASConstraintMaker *make) {
  178. make.left.equalTo(self.view);
  179. make.top.equalTo(self.header1.mas_bottom).offset(9);
  180. make.right.equalTo(self.view);
  181. make.height.mas_equalTo(32);
  182. }];
  183. }
  184. - (void)myapprovallC{
  185. self.view.backgroundColor = UIColorHex(EEEEEE);
  186. [self.view addSubview:self.header1];
  187. [self.header1 mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.left.equalTo(self.view);
  189. make.top.equalTo(self.view).offset(kNavigationHeight);
  190. make.right.equalTo(self.view);
  191. make.height.mas_equalTo(44);
  192. }];
  193. [self.waitApprovalButton setTitle:@"未读" forState:UIControlStateNormal];
  194. [self.approvalButton setTitle:@"己读" forState:UIControlStateNormal];
  195. [self.view addSubview:self.header2];
  196. [self.header2 mas_makeConstraints:^(MASConstraintMaker *make) {
  197. make.left.equalTo(self.view);
  198. make.top.equalTo(self.header1.mas_bottom).offset(9);
  199. make.right.equalTo(self.view);
  200. make.height.mas_equalTo(32);
  201. }];
  202. }
  203. #pragma mark - 导航栏事件处理
  204. - (void)backButtonAction{
  205. [self back];
  206. }
  207. - (void)rightButtonAction:(TDButton *)sender{
  208. }
  209. -(void)back{
  210. if (self.navigationController.viewControllers.count > 1) {
  211. [self.navigationController popViewControllerAnimated:YES];
  212. }else{
  213. [self dismissViewControllerAnimated:YES completion:nil];
  214. }
  215. }
  216. - (void)backButtonAction2:(UIButton *)sender {
  217. [self secondBarButtonItems];
  218. }
  219. - (void)secondBarButtonItems{
  220. [self.view endEditing:YES];
  221. [[UtilsTools getWindow] addSubview:self.drawerView];
  222. WS(weakSelf);
  223. self.drawerView.SelectDrawerBlock = ^(NSIndexPath * _Nonnull indexPath) {
  224. if ([weakSelf.navigationController.viewControllers count] > 1) {
  225. [weakSelf.navigationController popToRootViewControllerAnimated:NO];
  226. }
  227. if (indexPath.section == 0) {
  228. [[TabBarController sharedTabBarController] setSelectedIndex:indexPath.row];
  229. }else{
  230. ///@"站内信", @"通知", @"收藏",@"笔记", @"设置"
  231. switch (indexPath.row) {
  232. case 0:
  233. {
  234. [[TabBarController sharedTabBarController] setSelectedIndex:2];
  235. }
  236. break;
  237. case 1:
  238. {
  239. [[TabBarController sharedTabBarController] setSelectedIndex:2];
  240. }
  241. break;
  242. default:
  243. {
  244. [[TabBarController sharedTabBarController] setSelectedIndex:3];
  245. }
  246. break;
  247. }
  248. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  249. [[NSNotificationCenter defaultCenter] postNotificationName:DRAWERPUSHVC object:nil userInfo:@{VCINDEX:@(indexPath.row)}];
  250. });
  251. }
  252. };
  253. self.drawerView.frame = CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT);
  254. }
  255. - (void)viewWillDisappear:(BOOL)animated{
  256. [super viewWillDisappear:animated];
  257. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
  258. }
  259. - (UIStatusBarStyle)preferredStatusBarStyle{
  260. return UIStatusBarStyleLightContent;
  261. }
  262. #pragma mark - 数据加载
  263. - (void)setCountNumWithDict:(NSDictionary *)dict
  264. {
  265. switch (self.pageType) {
  266. case Type_ONEA:
  267. if ([dict[@"MyCheckingCount"] integerValue] == 0) {
  268. [self.waitApprovalButton setTitle:@"待审批" forState:UIControlStateNormal];
  269. }else{
  270. [self.waitApprovalButton setTitle:[NSString stringWithFormat:@"待审批(%ld)",(long)[dict[@"MyCheckingCount"] integerValue]] forState:UIControlStateNormal];
  271. }
  272. if ([dict[@"MyCheckedCount"] integerValue] == 0) {
  273. [self.approvalButton setTitle:@"已审批" forState:UIControlStateNormal];
  274. }else{
  275. [self.approvalButton setTitle:[NSString stringWithFormat:@"已审批(%ld)",(long)[dict[@"MyCheckedCount"] integerValue]] forState:UIControlStateNormal];
  276. }
  277. break;
  278. case Type_ONEB:
  279. if ([dict[@"SubmittedCheckingCount"] integerValue] > 0) {
  280. [self.approvalButton setTitle:[NSString stringWithFormat:@"待批复(%ld)",(long)[dict[@"SubmittedCheckingCount"] integerValue]] forState:UIControlStateNormal];
  281. }else {
  282. [self.approvalButton setTitle:@"待批复" forState:UIControlStateNormal];
  283. }
  284. if ([dict[@"SubmittedCheckedCount"] integerValue] > 0) {
  285. [self.waitApprovalButton setTitle:[NSString stringWithFormat:@"已批复(%ld)",(long)[dict[@"SubmittedCheckedCount"] integerValue]] forState:UIControlStateNormal];
  286. }else {
  287. [self.waitApprovalButton setTitle:@"已批复" forState:UIControlStateNormal];
  288. }
  289. break;
  290. case Type_ONEC:
  291. if ([dict[@"CcUnreadCount"] integerValue] > 0) {
  292. [self.waitApprovalButton setTitle:[NSString stringWithFormat:@"未读(%ld)",(long)[dict[@"CcUnreadCount"] integerValue]] forState:UIControlStateNormal];
  293. }else {
  294. [self.waitApprovalButton setTitle:@"未读" forState:UIControlStateNormal];
  295. }
  296. if ([dict[@"CcAllCount"] integerValue] > 0) {
  297. [self.approvalButton setTitle:[NSString stringWithFormat:@"已读(%ld)",(long)[dict[@"CcAllCount"] integerValue]] forState:UIControlStateNormal];
  298. }else {
  299. [self.approvalButton setTitle:@"已读" forState:UIControlStateNormal];
  300. }
  301. break;
  302. default:
  303. break;
  304. }
  305. }
  306. - (void)getCount
  307. {
  308. WS(weakSelf);
  309. [[HttpManager sharedHttpManager] GETUrl:Host(WorkFlowNumberCount_Get) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  310. dispatch_async(dispatch_get_main_queue(), ^{
  311. [weakSelf setCountNumWithDict:responseObject];
  312. });
  313. } failure:^(NSError * _Nonnull error) {
  314. }];
  315. }
  316. //- (void)getData{
  317. // [self getFromMe];
  318. // [self getFilterModelData];
  319. //}
  320. //- (void)getFromMe{
  321. // if ([self.approvalTypeStr isEqualToString:@"MyChecking"]) {
  322. // [self getFromePage:1 WithType:self.approvalTypeStr];
  323. // }
  324. // if ([self.approvalTypeStr isEqualToString:@"SubmittedChecked"]) {
  325. // [self getFromePage:1 WithType:self.approvalTypeStr];
  326. // }
  327. // if ([self.approvalTypeStr isEqualToString:@"CcUnread"]) {
  328. // [self getFromePage:1 WithType:self.approvalTypeStr];
  329. // }
  330. //}
  331. - (void)getFromePage:(NSInteger)page WithType:(NSString *)type{
  332. NSArray * ids = @[];
  333. switch (self.pageType) {
  334. case Type_ONEA:{
  335. NSMutableDictionary * dict = self.selectArray[0];
  336. if (self.apprvovalType == WaitApprovalType) {
  337. ids = dict[@"waitIds"];
  338. }else{
  339. ids = dict[@"ids"];
  340. }
  341. }break;
  342. case Type_ONEB: {
  343. NSMutableDictionary * dict = self.selectArray[1];
  344. if (self.apprvovalType == WaitApprovalType) {
  345. ids = dict[@"waitIds"];
  346. }else{
  347. ids = dict[@"ids"];
  348. }
  349. }break;
  350. case Type_ONEC:{
  351. NSMutableDictionary * dict = self.selectArray[2];
  352. if (self.apprvovalType == WaitApprovalType) {
  353. ids = dict[@"waitIds"];
  354. }else{
  355. ids = dict[@"ids"];
  356. }
  357. }break;
  358. default:
  359. break;
  360. }
  361. NSLog(@"=======%@",type);
  362. NSLog(@"%@",ids);
  363. WS(weakSelf);
  364. //原来的接口WorkFlowAddApproval_Post
  365. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,@"/api/app/flow/list"] parameters:@{@"PerPage":@(10),
  366. @"Page":@(page),
  367. @"Type":type,
  368. @"ProcessIds":ids} responseStyle:JOSN
  369. success:^(id _Nonnull responseObject) {
  370. NSLog(@"%@",responseObject);
  371. if (weakSelf.page == 1) {
  372. [weakSelf.waitApprovalDataArray removeAllObjects];
  373. [weakSelf.approvalDataArray removeAllObjects];
  374. }
  375. NSDictionary *dic = responseObject;
  376. weakSelf.dataCount = [dic[@"Count"] integerValue];
  377. id arr = dic[@"Items"];
  378. NSMutableArray *array = [NSMutableArray array];
  379. if (arr != [NSNull null]) {
  380. for (NSDictionary *dic2 in arr) {
  381. MyApprovalModel *model = [[MyApprovalModel alloc]initWithDictionary:dic2 error:nil];
  382. [array addObject:model];
  383. }
  384. }
  385. switch (weakSelf.apprvovalType) {
  386. case WaitApprovalType:{
  387. [weakSelf.waitApprovalDataArray addObjectsFromArray:array];
  388. }break;
  389. case ApprovalType:{
  390. [weakSelf.approvalDataArray addObjectsFromArray:array];
  391. }break;
  392. }
  393. [weakSelf.mytableView.mj_header endRefreshing];
  394. [weakSelf.mytableView.mj_footer endRefreshing];
  395. [weakSelf changeMessageStatusWithNumber:array.count];
  396. [weakSelf.mytableView reloadData];
  397. } failure:^(NSError * _Nonnull error) {
  398. SHOWERROR([ZYCTool handerResultData:error])
  399. }];
  400. }
  401. - (NSMutableArray<WorkFilterModel *>*)selectModelArray
  402. {
  403. if (!_selectModelArray) {
  404. _selectModelArray = [NSMutableArray array];
  405. }
  406. return _selectModelArray;
  407. }
  408. - (void)getFilterModelData{
  409. WS(weakSelf);
  410. [self.selectModelArray removeAllObjects];
  411. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowFilter_Get] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  412. NSArray *arr = responseObject;
  413. for (NSDictionary *dic in arr) {
  414. WorkFilterModel *model = [[WorkFilterModel alloc]initWithDictionary:dic error:nil];
  415. [weakSelf.selectModelArray addObject:model];
  416. }
  417. weakSelf.workFLowCollectionSelectView.approvalNameArray = weakSelf.selectModelArray;
  418. dispatch_async(dispatch_get_main_queue(), ^{
  419. [weakSelf.workFLowCollectionSelectView.collectionView reloadData] ;
  420. });
  421. } failure:^(NSError * _Nonnull error) {
  422. SHOWERROR([ZYCTool handerResultData:error]);
  423. }];
  424. }
  425. #pragma mark -
  426. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  427. return 1;
  428. }
  429. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  430. switch (self.apprvovalType) {
  431. case WaitApprovalType:
  432. return self.waitApprovalDataArray.count;
  433. case ApprovalType:
  434. return self.approvalDataArray.count;
  435. }
  436. return 5;
  437. }
  438. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  439. MyApprovalModel *model;
  440. switch (self.apprvovalType) {
  441. case WaitApprovalType:
  442. model = self.waitApprovalDataArray[indexPath.row];
  443. break;
  444. case ApprovalType:
  445. model = self.approvalDataArray[indexPath.row];
  446. break;
  447. }
  448. NSString *cellIdentifier = @"MyApprovalBCell";
  449. MyApprovalBCell *cell = (MyApprovalBCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  450. [cell loadApprovalData:model];
  451. // if ([self.approvalTypeStr isEqualToString:@"MyChecking"] ||
  452. // [self.approvalTypeStr isEqualToString:@"SubmittedChecked"] ||
  453. // [self.approvalTypeStr isEqualToString:@"CcUnread"] ||
  454. // [self.approvalTypeStr isEqualToString:@"SubmittedChecking"] ) {
  455. // cell.falgLab.hidden = model.IsRead;
  456. // }else {
  457. // cell.falgLab.hidden = YES;
  458. // }
  459. return cell;
  460. }
  461. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  462. return 159.f;
  463. }
  464. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  465. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  466. MyApprovalModel *model;
  467. switch (self.apprvovalType) {
  468. case WaitApprovalType:
  469. model = self.waitApprovalDataArray[indexPath.row];
  470. break;
  471. case ApprovalType:
  472. model = self.approvalDataArray[indexPath.row];
  473. break;
  474. }
  475. if (model.Id > 0) {
  476. MyApprovalPageDetail * myApprovalPageDetail = [[MyApprovalPageDetail alloc]init];
  477. myApprovalPageDetail.pageType = self.pageType;
  478. myApprovalPageDetail.indexId = model.Id;
  479. myApprovalPageDetail.title = model.Title;
  480. myApprovalPageDetail.TodoId = model.TodoId;
  481. myApprovalPageDetail.userId = model.UserId;
  482. WS(weakSelf);
  483. [myApprovalPageDetail setActionSussBlock:^{
  484. //重新获取数据
  485. [weakSelf headerRefresh];
  486. }];
  487. [self.navigationController pushViewController:myApprovalPageDetail animated:YES];
  488. }
  489. }
  490. #pragma mark - setter
  491. - (TDTableView *)mytableView{
  492. if (!_mytableView) {
  493. _mytableView = [[TDTableView alloc]init];
  494. _mytableView.backgroundColor = [UIColor clearColor];
  495. _mytableView.delegate = self;
  496. _mytableView.dataSource = self;
  497. [_mytableView registerNib:[UINib nibWithNibName:@"MyApprovalBCell" bundle:nil] forCellReuseIdentifier:@"MyApprovalBCell"];
  498. }
  499. return _mytableView;
  500. }
  501. - (UIView *)header1{
  502. if (!_header1) {
  503. _header1 = [[UIView alloc]init];
  504. _header1.backgroundColor = [UIColor whiteColor];
  505. [_header1 addSubview:self.waitApprovalButton];
  506. [self.waitApprovalButton mas_makeConstraints:^(MASConstraintMaker *make) {
  507. make.centerX.equalTo(self.header1.mas_centerX).multipliedBy(0.5);
  508. make.centerY.equalTo(self.header1.mas_centerY);
  509. }];
  510. [_header1 addSubview:self.waitApprovalButtonBottomLine];
  511. [self.waitApprovalButtonBottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  512. make.centerX.equalTo(self.waitApprovalButton.mas_centerX);
  513. make.bottom.equalTo(self.header1.mas_bottom).offset(-1);
  514. make.width.equalTo(self.waitApprovalButton);
  515. make.height.mas_equalTo(2);
  516. }];
  517. self.waitApprovalButtonBottomLine.backgroundColor = UIColorHex(3795FD);
  518. [_header1 addSubview:self.approvalButton];
  519. [self.approvalButton mas_makeConstraints:^(MASConstraintMaker *make) {
  520. make.centerX.equalTo(self.header1.mas_centerX).multipliedBy(1.5);
  521. make.centerY.equalTo(self.header1.mas_centerY);
  522. }];
  523. [_header1 addSubview:self.approvalButtonBottomLine];
  524. [self.approvalButtonBottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  525. make.centerX.equalTo(self.approvalButton.mas_centerX);
  526. make.bottom.equalTo(self.header1.mas_bottom).offset(-1);
  527. make.bottom.equalTo(@10);
  528. make.width.equalTo(self.approvalButton);
  529. make.height.mas_equalTo(2);
  530. }];
  531. self.approvalButtonBottomLine.backgroundColor = UIColorHex(3795FD);
  532. }
  533. return _header1;
  534. }
  535. - (UIView *)approvalButtonBottomLine{
  536. if (!_approvalButtonBottomLine) {
  537. _approvalButtonBottomLine = [[UIView alloc]init];
  538. }
  539. return _approvalButtonBottomLine;
  540. }
  541. - (UIView *)waitApprovalButtonBottomLine{
  542. if (!_waitApprovalButtonBottomLine) {
  543. _waitApprovalButtonBottomLine = [UIView new];
  544. }
  545. return _waitApprovalButtonBottomLine;
  546. }
  547. - (TDButton *)waitApprovalButton{
  548. if (!_waitApprovalButton) {
  549. _waitApprovalButton = [[TDButton alloc]init];
  550. [_waitApprovalButton setTitle:@"待审批" forState:UIControlStateNormal];
  551. [_waitApprovalButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  552. [[_waitApprovalButton titleLabel] setFont:[UIFont systemFontOfSize:15.f]];
  553. [_waitApprovalButton setTitleColor:UIColorHex(3795FD) forState:UIControlStateSelected];
  554. [_waitApprovalButton addTarget:self action:@selector(waitApprovalButtonHander:) forControlEvents:UIControlEventTouchDown];
  555. }
  556. return _waitApprovalButton;
  557. }
  558. - (TDButton *)approvalButton{
  559. if (!_approvalButton) {
  560. _approvalButton =[[TDButton alloc] init];
  561. [_approvalButton setTitle:@"已审批" forState:UIControlStateNormal];
  562. [_approvalButton setTitleColor:UIColorHex(333333) forState:UIControlStateNormal];
  563. [[_approvalButton titleLabel] setFont:[UIFont systemFontOfSize:15.f]];
  564. [_approvalButton setTitleColor:UIColorHex(3795FD) forState:UIControlStateSelected];
  565. [_approvalButton addTarget:self action:@selector(approvalButtonHander:) forControlEvents:UIControlEventTouchDown];
  566. }
  567. return _approvalButton;
  568. }
  569. - (UIView *)header2{
  570. if (!_header2) {
  571. _header2 = [[UIView alloc] init];
  572. _header2.backgroundColor = [UIColor whiteColor];
  573. [_header2 addSubview:self.searchButton];
  574. [self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
  575. make.centerX.equalTo(self.header2.mas_centerX).multipliedBy(0.5);
  576. make.centerY.equalTo(self.header2.mas_centerY);
  577. make.width.mas_equalTo(self.header2.mas_width).multipliedBy(0.25);
  578. make.height.mas_equalTo(self.header2.mas_height);
  579. }];
  580. UIView *verticalView = [[UIView alloc]init];
  581. verticalView.backgroundColor = UIColorHex(E6E6E6);
  582. [_header2 addSubview:verticalView];
  583. [verticalView mas_makeConstraints:^(MASConstraintMaker *make) {
  584. make.centerX.equalTo(self.header2);
  585. make.centerY.equalTo(self.header2);
  586. make.width.mas_equalTo(0.5);
  587. make.height.equalTo(self.header2.mas_height).multipliedBy(0.7);
  588. }];
  589. [_header2 addSubview:self.selectButton];
  590. [self.selectButton mas_makeConstraints:^(MASConstraintMaker *make) {
  591. make.centerX.equalTo(self.header2.mas_centerX).multipliedBy(1.5);
  592. make.centerY.equalTo(self.header2.mas_centerY);
  593. make.width.mas_equalTo(self.header2.mas_width).multipliedBy(0.25);
  594. make.height.mas_equalTo(self.header2.mas_height);
  595. }];
  596. }
  597. return _header2;
  598. }
  599. - (TDButton *)searchButton{
  600. if (!_searchButton) {
  601. _searchButton = [[TDButton alloc] init];
  602. [_searchButton setTitle:@"搜索" forState:UIControlStateNormal];
  603. [_searchButton addTarget:self action:@selector(searchApprovalButtonHander) forControlEvents:UIControlEventTouchDown];
  604. [_searchButton setImage:IMG(@"approval_sousuo") forState:UIControlStateNormal];
  605. // [[_searchButton imageView] setSize:CGSizeMake(14.f, 14.f)];
  606. [_searchButton setTitleColor:UIColorHex(666666) forState:UIControlStateNormal];
  607. [[_searchButton titleLabel] setFont:[UIFont systemFontOfSize:14.f weight:UIFontWeightRegular]];
  608. [_searchButton layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:6.5];
  609. }
  610. return _searchButton;
  611. }
  612. - (TDButton *)selectButton{
  613. if (!_selectButton) {
  614. _selectButton = [[TDButton alloc] init];
  615. [_selectButton setTitle:@"筛选" forState:UIControlStateNormal];
  616. [_selectButton setImage:IMG(@"筛选") forState:UIControlStateNormal];
  617. [_selectButton setTitleColor:UIColorHex(666666) forState:UIControlStateNormal];
  618. [[_selectButton titleLabel] setFont:[UIFont systemFontOfSize:14.f weight:UIFontWeightRegular]];
  619. // [[_selectButton imageView] setSize:CGSizeMake(14.f, 14.f)];
  620. [_selectButton addTarget:self action:@selector(selectButtonHander) forControlEvents:UIControlEventTouchDown];
  621. [_selectButton layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:6.5];
  622. }
  623. return _selectButton;
  624. }
  625. - (NSMutableArray <MyApprovalModel *>*)approvalDataArray{
  626. if (!_approvalDataArray) {
  627. _approvalDataArray = [NSMutableArray array];
  628. }
  629. return _approvalDataArray;
  630. }
  631. - (NSMutableArray <MyApprovalModel *>*)waitApprovalDataArray{
  632. if (!_waitApprovalDataArray) {
  633. _waitApprovalDataArray = [NSMutableArray array];
  634. }
  635. return _waitApprovalDataArray;
  636. }
  637. #pragma mark - 已审批事件处理
  638. - (void)approvalButtonHander:(TDButton *)approvalButton{
  639. self.approvalButton.selected = YES;
  640. self.waitApprovalButton.selected = NO;
  641. self.approvalButtonBottomLine.hidden = NO;
  642. self.waitApprovalButtonBottomLine.hidden = YES;
  643. self.apprvovalType = ApprovalType;
  644. switch (self.pageType) {
  645. case Type_ONEA:{
  646. self.approvalTypeStr = @"MyChecked";
  647. NSMutableDictionary * dict = self.selectArray[0];
  648. [self.selectButton setTitle:dict[@"Title"] forState:UIControlStateNormal];
  649. }break;
  650. case Type_ONEB: {
  651. self.approvalTypeStr = @"SubmittedChecking";
  652. NSMutableDictionary * dict = self.selectArray[1];
  653. [self.selectButton setTitle:dict[@"Title"] forState:UIControlStateNormal];
  654. }break;
  655. case Type_ONEC:{
  656. self.approvalTypeStr = @"CcAll";
  657. NSMutableDictionary * dict = self.selectArray[2];
  658. [self.selectButton setTitle:dict[@"Title"] forState:UIControlStateNormal];
  659. }break;
  660. default:
  661. break;
  662. }
  663. [self headerRefresh];
  664. [self.mytableView reloadData];
  665. }
  666. #pragma mark - 待审批事件处理
  667. - (void)waitApprovalButtonHander:(TDButton *)waitApprovalButton{
  668. self.approvalButton.selected = NO;
  669. self.waitApprovalButton.selected = YES;
  670. self.approvalButtonBottomLine.hidden = YES;
  671. self.waitApprovalButtonBottomLine.hidden = NO;
  672. self.apprvovalType = WaitApprovalType;
  673. switch (self.pageType) {
  674. case Type_ONEA:{
  675. self.approvalTypeStr = @"MyChecking";
  676. NSMutableDictionary * dict = self.selectArray[0];
  677. [self.selectButton setTitle:dict[@"waitTitle"] forState:UIControlStateNormal];
  678. }break;
  679. case Type_ONEB:{
  680. self.approvalTypeStr = @"SubmittedChecked";
  681. NSMutableDictionary * dict = self.selectArray[1];
  682. [self.selectButton setTitle:dict[@"waitTitle"] forState:UIControlStateNormal];
  683. }break;
  684. case Type_ONEC:{
  685. self.approvalTypeStr = @"CcUnread";
  686. NSMutableDictionary * dict = self.selectArray[2];
  687. [self.selectButton setTitle:dict[@"waitTitle"] forState:UIControlStateNormal];
  688. }break;
  689. default:
  690. break;
  691. }
  692. [self headerRefresh];
  693. [self.mytableView reloadData];
  694. }
  695. #pragma mark - 搜索事件处理
  696. - (void)searchApprovalButtonHander{
  697. WorkFlowSearchVC *workFlowSearchVC = [[WorkFlowSearchVC alloc]init];
  698. workFlowSearchVC.typeString = self.approvalTypeStr;
  699. workFlowSearchVC.apprvovalType = self.apprvovalType;
  700. workFlowSearchVC.pageType = self.pageType;
  701. [self.navigationController pushViewController:workFlowSearchVC animated:YES];
  702. }
  703. #pragma mark - 筛选事件处理
  704. - (void)selectButtonHander{
  705. if(self.workFLowCollectionSelectView != nil){
  706. NSMutableDictionary * dict = nil;
  707. switch (self.pageType) {
  708. case Type_ONEA:{
  709. dict = self.selectArray[0];
  710. }break;
  711. case Type_ONEB:{
  712. dict = self.selectArray[1];
  713. }break;
  714. case Type_ONEC:{
  715. dict = self.selectArray[2];
  716. }break;
  717. default:
  718. break;
  719. }
  720. for (WorkFilterModel * model in self.selectModelArray) {
  721. model.isSelected = NO;
  722. }
  723. if (self.apprvovalType == WaitApprovalType) {
  724. for (id obj in dict[@"waitIds"]) {
  725. NSInteger ids = [obj integerValue];
  726. for (WorkFilterModel * model in self.selectModelArray) {
  727. if (model.Value == ids) {
  728. model.isSelected = YES;
  729. }
  730. }
  731. self.workFLowCollectionSelectView.approvalNameArray = self.selectModelArray.mutableCopy;
  732. }
  733. }else{
  734. for (id obj in dict[@"ids"]) {
  735. NSInteger ids = [obj integerValue];
  736. for (WorkFilterModel * model in self.selectModelArray) {
  737. if (model.Value == ids) {
  738. model.isSelected = YES;
  739. }
  740. }
  741. self.workFLowCollectionSelectView.approvalNameArray = self.selectModelArray.mutableCopy;
  742. }
  743. }
  744. [self.workFLowCollectionSelectView collectionViewReloadData];
  745. }
  746. }
  747. - (void)selecetWorkFLow:(NSIndexPath *)path withModel:(NSArray<WorkFilterModel *> *)modle {
  748. NSLog(@"%@",self.workFLowCollectionSelectView.approvalNameArray[path.item]);
  749. self.selectedMyApprovalModel = modle;
  750. NSMutableString *labelStr = [[NSMutableString alloc] initWithString:@""];
  751. NSMutableArray *ids = [NSMutableArray array];
  752. [modle enumerateObjectsUsingBlock:^(WorkFilterModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  753. WorkFilterModel *filterModel = obj;
  754. if ((idx + 1) < modle.count) {
  755. [labelStr appendFormat:@"%@,",filterModel.Label];
  756. }else {
  757. [labelStr appendFormat:@"%@",filterModel.Label];
  758. }
  759. [ids addObject:@(filterModel.Value)];
  760. }];
  761. [self.selectButton setTitle:labelStr forState:UIControlStateNormal];
  762. switch (self.pageType) {
  763. case Type_ONEA:
  764. {
  765. NSMutableDictionary * dict = self.selectArray[0];
  766. if (self.apprvovalType == WaitApprovalType) {
  767. [dict setObject:labelStr forKey:@"waitTitle"];
  768. [dict setObject:ids forKey:@"waitIds"];
  769. }else{
  770. [dict setObject:labelStr forKey:@"Title"];
  771. [dict setObject:ids forKey:@"ids"];
  772. }
  773. }
  774. break;
  775. case Type_ONEB:
  776. {
  777. NSMutableDictionary * dict = self.selectArray[1];
  778. if (self.apprvovalType == WaitApprovalType) {
  779. [dict setObject:labelStr forKey:@"waitTitle"];
  780. [dict setObject:ids forKey:@"waitIds"];
  781. }else{
  782. [dict setObject:labelStr forKey:@"Title"];
  783. [dict setObject:ids forKey:@"ids"];
  784. }
  785. }
  786. break;
  787. case Type_ONEC:
  788. {
  789. NSMutableDictionary * dict = self.selectArray[2];
  790. if (self.apprvovalType == WaitApprovalType) {
  791. [dict setObject:labelStr forKey:@"waitTitle"];
  792. [dict setObject:ids forKey:@"waitIds"];
  793. }else{
  794. [dict setObject:labelStr forKey:@"Title"];
  795. [dict setObject:ids forKey:@"ids"];
  796. }
  797. }
  798. break;
  799. default:
  800. break;
  801. }
  802. [self headerRefresh];
  803. }
  804. - (TDNavigationBar *)myNavigationBar{
  805. if (!_myNavigationBar) {
  806. _myNavigationBar = [[TDNavigationBar alloc]initNavigationBar];
  807. _myNavigationBar.delegate = self;
  808. _myNavigationBar.backButton2.hidden = NO;
  809. _myNavigationBar.titleLabel.textColor = UIColorHex(#FFFFFF);
  810. _myNavigationBar.titleLabel.font = [UIFont systemFontOfSize:19.f];
  811. [_myNavigationBar.backButton2 setImage:IMG(@"快捷跳转") forState:UIControlStateNormal];
  812. [_myNavigationBar.backButton setImage:IMG(@"工作_返回") forState:UIControlStateNormal];
  813. }
  814. return _myNavigationBar;
  815. }
  816. - (UIView *)myBackImageView{
  817. if (!_myBackImageView) {
  818. _myBackImageView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kGXScreenHeigh, kNavigationHeight)];
  819. _myBackImageView.backgroundColor = [UIColor colorWithRed:92/255.0 green:118.0/255.0 blue:167.0/255.f alpha:1.0];
  820. }
  821. return _myBackImageView;
  822. }
  823. - (WorkFLowCollectionSelectView *)workFLowCollectionSelectView{
  824. if(!_workFLowCollectionSelectView){
  825. _workFLowCollectionSelectView = [[WorkFLowCollectionSelectView alloc] init];
  826. _workFLowCollectionSelectView.delegate = self;
  827. }
  828. return _workFLowCollectionSelectView;
  829. }
  830. - (DrawerView *)drawerView {
  831. if(!_drawerView) {
  832. _drawerView = [[DrawerView alloc] init];
  833. }
  834. return _drawerView;
  835. }
  836. @end