WorkFlowSearchDetailVC.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. //
  2. // WorkFlowSearchDetailVC.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/11/5.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "WorkFlowSearchDetailVC.h"
  9. #import "InfoSearchView.h"
  10. #import "MyApprovalModel.h"
  11. #import "MyApprovalBCell.h"
  12. #import "MyApprovalPageDetail.h"
  13. @interface WorkFlowSearchDetailVC ()<InfoSearchViewDelegate,UITableViewDelegate,UITableViewDataSource>
  14. @property (nonatomic, strong) InfoSearchView *topNavSearch;
  15. @property (nonatomic, strong) UIView *myBackImageView;
  16. @property (nonatomic, strong) TDTableView *mytableView;
  17. @property (nonatomic, strong) NSMutableArray <MyApprovalModel*>*waitApprovalDataArray;
  18. @property (nonatomic, strong) NSMutableArray <MyApprovalModel*>*approvalDataArray;
  19. @property (nonatomic, assign) NSInteger isfreshFlag;
  20. @end
  21. @implementation WorkFlowSearchDetailVC
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.isfreshFlag = 1;
  25. [self.view addSubview:self.myBackImageView];
  26. [self.view addSubview:self.mytableView];
  27. self.fd_prefersNavigationBarHidden = YES;
  28. self.view.backgroundColor = UIColorHex(EEEEEE);
  29. [self.view addSubview:self.topNavSearch];
  30. [self.mytableView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.equalTo(self.view);
  32. make.right.equalTo(self.view);
  33. make.top.equalTo(self.view).offset(kNavigationHeight);
  34. if (@available(iOS 11.0, *)) {
  35. make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
  36. } else {
  37. make.bottom.equalTo(self.view.mas_bottom);
  38. }
  39. }];
  40. self.apprvovalType = WaitApprovalType;
  41. [self addNoDataMessageToViewCenter:self.mytableView message:@"暂无审批内容"];
  42. }
  43. #pragma mark - 数据加载
  44. - (void)goDetailController:(NSString *)search{
  45. [self.topNavSearch setNowSearchData:search];
  46. SHOWLOADING
  47. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,WorkFlowAddApproval_Post] parameters:@{@"Keyword":search,@"PerPage":@(10),@"Page":@(1),@"Type":self.typeString} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  48. NSLog(@"%@",responseObject);
  49. NSDictionary *dic = responseObject;
  50. id result = dic[@"Items"];
  51. NSMutableArray *array = [NSMutableArray array];
  52. if (result == [NSNull null]) {
  53. }else {
  54. NSArray *arr = result;
  55. for (NSDictionary *dic2 in arr) {
  56. MyApprovalModel *model = [[MyApprovalModel alloc]initWithDictionary:dic2 error:nil];
  57. [array addObject:model];
  58. }
  59. }
  60. switch (self.apprvovalType) {
  61. case WaitApprovalType:{
  62. if (self.isfreshFlag == 1){
  63. self.waitApprovalDataArray = array;
  64. }else{
  65. if (array.count == 0){
  66. }else{
  67. [self.waitApprovalDataArray addObjectsFromArray:array];
  68. }
  69. }
  70. }break;
  71. case ApprovalType:{
  72. if (self.isfreshFlag == 1){
  73. self.approvalDataArray = array;
  74. }else{
  75. if (array.count == 0){
  76. }else{
  77. [self.approvalDataArray addObjectsFromArray:array];
  78. }
  79. }
  80. }break;
  81. }
  82. [self changeMessageStatusWithNumber:array.count];
  83. [self.mytableView.mj_header endRefreshing];
  84. [self.mytableView.mj_footer endRefreshing];
  85. [self.mytableView reloadData];
  86. REMOVESHOW
  87. } failure:^(NSError * _Nonnull error) {
  88. SHOWERROR([ZYCTool handerResultData:error])
  89. }];
  90. }
  91. #pragma mark - InfoSearchViewDelegate
  92. - (void)searchButtonAction:(UISearchBar *)searchBar {
  93. [self goDetailController:searchBar.text];
  94. }
  95. - (ApprovalPageSelectType)apprvovalType{
  96. return 0;
  97. }
  98. #pragma mark - setter
  99. - (InfoSearchView *)topNavSearch {
  100. if (!_topNavSearch) {
  101. _topNavSearch = [[InfoSearchView alloc] initWithFrame:CGRectMake(0, (IS_IPHONEX?40:20), kGXScreenWidth, 45) type:InfoSearchViewTypeCancel];
  102. _topNavSearch.delegate = self;
  103. WEAKSELF
  104. _topNavSearch.backBlock = ^{
  105. STRONGSELF
  106. [strongSelf.navigationController popViewControllerAnimated:YES];
  107. };
  108. [_topNavSearch showLineView];
  109. _topNavSearch.cancelBlock = ^{
  110. STRONGSELF
  111. [strongSelf.navigationController popViewControllerAnimated:YES];
  112. };
  113. }
  114. return _topNavSearch;
  115. }
  116. - (UIView *)myBackImageView{
  117. if (!_myBackImageView) {
  118. _myBackImageView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kGXScreenHeigh, kNavigationHeight)];
  119. _myBackImageView.backgroundColor = [UIColor whiteColor];
  120. }
  121. return _myBackImageView;
  122. }
  123. #pragma mark - setter
  124. - (TDTableView *)mytableView{
  125. if (!_mytableView) {
  126. _mytableView = [[TDTableView alloc]init];
  127. _mytableView.backgroundColor = UIColorHex(0xeeeeee);
  128. _mytableView.delegate = self;
  129. _mytableView.dataSource = self;
  130. [_mytableView registerNib:[UINib nibWithNibName:@"MyApprovalBCell" bundle:nil] forCellReuseIdentifier:@"MyApprovalBCell"];
  131. }
  132. return _mytableView;
  133. }
  134. #pragma mark -
  135. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  136. return 1;
  137. }
  138. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  139. switch (self.apprvovalType) {
  140. case WaitApprovalType:
  141. return self.waitApprovalDataArray.count;
  142. break;
  143. case ApprovalType:
  144. return self.approvalDataArray.count;
  145. break;
  146. default:
  147. break;
  148. }
  149. return 5;
  150. }
  151. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  152. MyApprovalModel *model;
  153. switch (self.apprvovalType) {
  154. case WaitApprovalType:
  155. model = self.waitApprovalDataArray[indexPath.row];
  156. break;
  157. case ApprovalType:
  158. model = self.approvalDataArray[indexPath.row];
  159. break;
  160. }
  161. NSString *cellIdentifier = @"MyApprovalBCell";
  162. MyApprovalBCell *cell = (MyApprovalBCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  163. [cell loadApprovalData:model];
  164. cell.falgLab.hidden = YES;
  165. return cell;
  166. }
  167. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  168. return 159.f;
  169. }
  170. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  171. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  172. MyApprovalModel *model;
  173. switch (self.apprvovalType) {
  174. case WaitApprovalType:
  175. model = self.waitApprovalDataArray[indexPath.row];
  176. break;
  177. case ApprovalType:
  178. model = self.approvalDataArray[indexPath.row];
  179. break;
  180. }
  181. if (model.Id > 0) {
  182. MyApprovalPageDetail * myApprovalPageDetail = [[MyApprovalPageDetail alloc]init];
  183. myApprovalPageDetail.pageType = self.pageType;
  184. myApprovalPageDetail.indexId = model.Id;
  185. myApprovalPageDetail.title = model.Title;
  186. myApprovalPageDetail.TodoId = model.TodoId;
  187. myApprovalPageDetail.userId = model.UserId;
  188. [self.navigationController pushViewController:myApprovalPageDetail animated:YES];
  189. }
  190. }
  191. - (NSMutableArray <MyApprovalModel *>*)approvalDataArray{
  192. if (!_approvalDataArray) {
  193. _approvalDataArray = [NSMutableArray array];
  194. }
  195. return _approvalDataArray;
  196. }
  197. - (NSMutableArray <MyApprovalModel *>*)waitApprovalDataArray{
  198. if (!_waitApprovalDataArray) {
  199. _waitApprovalDataArray = [NSMutableArray array];
  200. }
  201. return _waitApprovalDataArray;
  202. }
  203. @end