TerminalListVC.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. //
  2. // TerminalListVC.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/8/3.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "TerminalListVC.h"
  9. #import "TerminalListCell.h"
  10. #import "TerminalListCell2.h"
  11. #import "SportPathVC.h"
  12. #import "Ter_SendMsg.h"
  13. @interface TerminalListVC ()<UITableViewDataSource,UITableViewDelegate>
  14. @property(nonatomic,strong)UITableView *tableView;
  15. @end
  16. @implementation TerminalListVC
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. self.title = @"终端列表";
  20. [self goBackByNavigation];
  21. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet) style:UITableViewStyleGrouped];
  22. _tableView.dataSource = self;
  23. _tableView.delegate = self;
  24. [self.view addSubview:_tableView];
  25. _tableView.backgroundColor = KBackGroundColor;
  26. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  27. _tableView.estimatedSectionHeaderHeight = 0;
  28. _tableView.estimatedSectionFooterHeight = 0;
  29. }
  30. #pragma mark tableview代理
  31. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  32. return self.dataArr.count;
  33. }
  34. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  35. return 1;
  36. }
  37. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  38. return 15;
  39. }
  40. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  41. return .1f;
  42. }
  43. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  44. NSString *str = _dataArr[indexPath.section][@"TDI_TERMTYPE"];
  45. if ([str isEqualToString:@"1"]) {
  46. return 108;
  47. }else{
  48. return 70;
  49. }
  50. }
  51. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  52. NSString *str = _dataArr[indexPath.section][@"TDI_TERMTYPE"];
  53. if ([str isEqualToString:@"1"]) {//计时终端类型(1:车载计程计时终端; 2:课堂教学计时终端; 3:模拟训练计时终端;)
  54. TerminalListCell *cell = [TerminalListCell cellForTableView:tableView];
  55. cell.dic = _dataArr[indexPath.section];
  56. NSString *sim = [NSString stringWithFormat:@"%@",_dataArr[indexPath.section][@"TDI_SIM"]];
  57. cell.clickBlock = ^(NSNumber *type) {
  58. switch ([type integerValue]) {
  59. case 1:
  60. {
  61. [Tools permissionValidationWithID:@"92" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  62. if (!isCan) {
  63. if (failureStr) {
  64. showMsgByAlert(self, failureStr);
  65. }
  66. return;
  67. }
  68. SportPathVC *vc = [[SportPathVC alloc]init];
  69. vc.carNum = _dataArr[indexPath.section][@"TCO_LICNUM"];
  70. vc.simStr = sim;
  71. vc.deviceId = _dataArr[indexPath.section][@"TDI_ID"];
  72. [self navPushHideTabbarToVC:vc];
  73. }];
  74. }
  75. break;
  76. case 2:
  77. {
  78. [Tools permissionValidationWithID:@"1263" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  79. if (!isCan) {
  80. if (failureStr) {
  81. showMsgByAlert(self, failureStr);
  82. }
  83. return;
  84. }
  85. Ter_SendMsg *vc = [[Ter_SendMsg alloc]init];
  86. vc.sim = sim;
  87. [self navPushHideTabbarToVC:vc];
  88. }];
  89. }
  90. break;
  91. case 3:
  92. {
  93. [Tools permissionValidationWithID:@"1265" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  94. if (!isCan) {
  95. if (failureStr) {
  96. showMsgByAlert(self, failureStr);
  97. }
  98. return;
  99. }
  100. [self removeMacWarningWithSim:sim];
  101. }];
  102. }
  103. break;
  104. case 4:
  105. {
  106. [Tools permissionValidationWithID:@"2037" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  107. if (!isCan) {
  108. if (failureStr) {
  109. showMsgByAlert(self, failureStr);
  110. }
  111. return;
  112. }
  113. [self captureVideoWithSim:sim];
  114. }];
  115. }
  116. break;
  117. case 5:
  118. {
  119. if (self.block) {
  120. self.block([NSString stringWithFormat:@"%d",(int)indexPath.section]);
  121. }
  122. [self.navigationController popViewControllerAnimated:YES];
  123. }
  124. break;
  125. default:
  126. break;
  127. }
  128. };
  129. return cell;
  130. }
  131. TerminalListCell2 *cell = [TerminalListCell2 cellForTableView:tableView];
  132. cell.dic = _dataArr[indexPath.section];
  133. return cell;
  134. }
  135. #pragma mark - 网络请求
  136. -(void)captureVideoWithSim:(NSString *)simStr{
  137. if (![NetManager connectedToNetWork]) {
  138. showMsgUnconnect();
  139. return;
  140. }
  141. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  142. [dic setObject:simStr forKey:@"sim"];
  143. NSString *method = @"captureVideo";
  144. [MBProgressHUD showLoadToView:self.view];
  145. [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  146. [MBProgressHUD hideHUDForView:self.view];
  147. if (!root) {
  148. ShowMsg(@"解除失败,请重试");
  149. return;
  150. }
  151. if ([root[@"code"] integerValue] == 1) {
  152. ShowMsg(root[@"msg"]);
  153. return;
  154. }
  155. ShowMsg(@"操作成功");
  156. }];
  157. }
  158. -(void)removeMacWarningWithSim:(NSString *)simStr{
  159. if (![NetManager connectedToNetWork]) {
  160. showMsgUnconnect();
  161. return;
  162. }
  163. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  164. [dic setObject:@"" forKey:@"schoolId"];//这里要求传空,报警删除全部
  165. // [dic setObject:@"" forKey:@"mwId"];
  166. // [dic setObject:@"" forKey:@"kind"];
  167. [dic setObject:simStr forKey:@"sim"];
  168. NSString *method = @"removeMacWarning";
  169. [MBProgressHUD showLoadToView:self.view];
  170. [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  171. [MBProgressHUD hideHUDForView:self.view];
  172. if (!root) {
  173. ShowMsg(@"解除失败,请重试");
  174. return;
  175. }
  176. if ([root[@"code"] integerValue] == 1) {
  177. ShowMsg(root[@"msg"]);
  178. return;
  179. }
  180. ShowMsg(@"操作成功");
  181. }];
  182. }
  183. - (void)didReceiveMemoryWarning {
  184. [super didReceiveMemoryWarning];
  185. // Dispose of any resources that can be recreated.
  186. }
  187. /*
  188. #pragma mark - Navigation
  189. // In a storyboard-based application, you will often want to do a little preparation before navigation
  190. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  191. // Get the new view controller using [segue destinationViewController].
  192. // Pass the selected object to the new view controller.
  193. }
  194. */
  195. @end