TCSListVC.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. //
  2. // TCSListVC.m
  3. // LN_School
  4. //
  5. // Created by apple on 2017/12/12.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "TCSListVC.h"
  9. #import "RegionsCell.h"
  10. #import "NewTrainSiteVC.h"
  11. #import "NewClassroomVC.h"
  12. #import "NewSignUpPointVC.h"
  13. #import "TrainDetailVC.h"
  14. #import "ClassDetailVC.h"
  15. #import "SignDetailVC.h"
  16. @interface TCSListVC ()<UITableViewDelegate,UITableViewDataSource>
  17. {
  18. NSMutableDictionary * _requsetDic;
  19. UITableView * _tableView;
  20. NSMutableArray *_dataSurce;
  21. HolderView * holderV;
  22. }
  23. @end
  24. @implementation TCSListVC
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.view.backgroundColor = [UIColor whiteColor];
  28. if ([_vcType isEqualToString:@"T"]) {
  29. self.navigationItem.title = @"训练场地列表";
  30. [Tools permissionValidationWithID:@"2042" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  31. if (isCan) {
  32. [self customRightBtn];
  33. }
  34. }];
  35. }else if ([_vcType isEqualToString:@"C"]) {
  36. self.navigationItem.title = @"理论教室列表";
  37. [Tools permissionValidationWithID:@"1246" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  38. if (isCan) {
  39. [self customRightBtn];
  40. }
  41. }];
  42. }else if ([_vcType isEqualToString:@"S"]) {
  43. self.navigationItem.title = @"报名点列表";
  44. [Tools permissionValidationWithID:@"1147" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  45. if (isCan) {
  46. [self customRightBtn];
  47. }
  48. }];
  49. }
  50. self.navigationController.navigationBar.translucent = NO;
  51. [self goBackByNavigation];
  52. _dataSurce = [NSMutableArray new];
  53. _requsetDic = [NSMutableDictionary new];
  54. [self myInit];
  55. }
  56. - (void)viewWillAppear:(BOOL)animated {
  57. [super viewWillAppear:animated];
  58. [self getData];
  59. }
  60. -(void)myInit{
  61. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet)];
  62. _tableView.dataSource = self;
  63. _tableView.delegate = self;
  64. _tableView.rowHeight = 75;
  65. _tableView.tableFooterView = [UIView new];
  66. [self.view addSubview:_tableView];
  67. holderV = [[HolderView alloc]initWithFrame:_tableView.frame];
  68. [holderV freshBlock:^{
  69. [self getData];
  70. }];
  71. [self.view addSubview:holderV];
  72. }
  73. -(void)customRightBtn{
  74. UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
  75. btn.frame = CGRectMake(0, 0, 43, 44);
  76. btn.titleLabel.font = [UIFont systemFontOfSize:17];
  77. [btn setTitle:@"新增" forState:UIControlStateNormal];
  78. [btn setTitleColor:defGreen forState:UIControlStateNormal];
  79. [btn addTarget:self action:@selector(addMoreAction) forControlEvents:UIControlEventTouchUpInside];
  80. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  81. }
  82. - (void)addMoreAction {
  83. // if (!myDelegate.isSchool) {
  84. // ShowMsg(@"驾校管理员才可以新增操作");
  85. // return;
  86. // }
  87. if ([_vcType isEqualToString:@"T"]) {
  88. NewTrainSiteVC *vc = [[NewTrainSiteVC alloc] init];
  89. [self.navigationController pushViewController:vc animated:YES];
  90. }else if ([_vcType isEqualToString:@"C"]) {
  91. NewClassroomVC *vc = [[NewClassroomVC alloc] init];
  92. [self.navigationController pushViewController:vc animated:YES];
  93. }else if ([_vcType isEqualToString:@"S"]) {
  94. NewSignUpPointVC *vc = [[NewSignUpPointVC alloc] init];
  95. [self.navigationController pushViewController:vc animated:YES];
  96. }
  97. }
  98. #pragma mark tableview代理方法
  99. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  100. return _dataSurce.count;
  101. }
  102. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath{
  103. RegionsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  104. if (!cell) {
  105. cell = [[[NSBundle mainBundle] loadNibNamed:@"RegionsCell" owner:nil options:nil]lastObject];
  106. cell.statusLab.hidden = YES;
  107. }
  108. [cell upDataWithDic:_dataSurce[indexPath.row]];
  109. return cell;
  110. }
  111. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  112. if ([_vcType isEqualToString:@"T"]) {
  113. TrainDetailVC *vc = [[TrainDetailVC alloc] init];
  114. vc.dataSource = _dataSurce[indexPath.row];
  115. [self navPushHideTabbarToVC:vc];
  116. }else if ([_vcType isEqualToString:@"C"]) {
  117. ClassDetailVC *vc = [[ClassDetailVC alloc] init];
  118. vc.dataSource = _dataSurce[indexPath.row];
  119. [self navPushHideTabbarToVC:vc];
  120. }else if ([_vcType isEqualToString:@"S"]) {
  121. SignDetailVC *vc = [[SignDetailVC alloc] init];
  122. vc.dataSource = _dataSurce[indexPath.row];
  123. [self navPushHideTabbarToVC:vc];
  124. }
  125. }
  126. #pragma mark 数据请求
  127. - (void)getData{
  128. //判断网络是否连接
  129. if (![NetManager connectedToNetWork]) {
  130. showMsgUnconnect();
  131. return;
  132. }
  133. NSMutableDictionary * mdic = [NSMutableDictionary new];
  134. [mdic setValue:defUser.userDict[@"id"] forKey:@"userId"];
  135. [mdic setValue:defUser.userDict[@"school"] forKey:@"schoolId"];
  136. [mdic setValue:defUser.userDict[@"dqbh"] forKey:@"dqbh"];
  137. [mdic setValue:defUser.userDict[@"qxbh"] forKey:@"qxbh"];
  138. [mdic setValue:@"" forKey:@"isPage"];
  139. [mdic setValue:@"" forKey:@"pageSize"];
  140. [mdic setValue:@"" forKey:@"currentPage"];
  141. NSString *method = @"";
  142. if ([_vcType isEqualToString:@"T"]) {
  143. [mdic setValue:@"" forKey:@"name"];
  144. method = @"trainingFieldList";
  145. }else if ([_vcType isEqualToString:@"C"]) {
  146. [mdic setValue:@"" forKey:@"trName"];
  147. [mdic setValue:@"" forKey:@"trAddress"];
  148. [mdic setValue:@"" forKey:@"type"];
  149. [mdic setValue:@"" forKey:@"auditStatus"];
  150. method = @"theoryRoomList";
  151. }else if ([_vcType isEqualToString:@"S"]) {
  152. [mdic setValue:@"" forKey:@"name"];
  153. [mdic setValue:@"" forKey:@"address"];
  154. [mdic setValue:@"" forKey:@"logout"];
  155. method = @"schoolPointList";
  156. }
  157. _requsetDic = mdic;
  158. [MBProgressHUD showLoadToView:self.view];
  159. [NetManager requestAnythingWithURL:method dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
  160. [MBProgressHUD hideHUDForView:self.view];
  161. holderV.hidden = NO;
  162. if (!root) {
  163. ShowMsg(@"数据请求失败,请重试");
  164. return;
  165. }
  166. if ([root[@"code"] integerValue] == 1) {
  167. ShowMsg(root[@"msg"]);
  168. return;
  169. }
  170. _dataSurce = root[@"body"];
  171. if (_dataSurce.count > 0) {
  172. holderV.hidden = YES;
  173. }
  174. [_tableView reloadData];
  175. }];
  176. }
  177. - (void)didReceiveMemoryWarning {
  178. [super didReceiveMemoryWarning];
  179. }
  180. @end