WaringDetailList.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. //
  2. // WaringDetailList.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/8/12.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "WaringDetailList.h"
  9. #import "WarDetailCell.h"
  10. #import "MengBanView.h"
  11. @interface WaringDetailList ()<UITableViewDelegate,UITableViewDataSource>
  12. {
  13. //解除报警
  14. NSMutableArray *_selectedIndexPathes;//记录选中的cell
  15. UIButton *_notifyBtn;
  16. UIButton *_allBtn;
  17. UIButton *_cancelBtn;
  18. HolderView *_holderV;
  19. }
  20. @property(nonatomic,strong)UITableView *tableView;
  21. @property(nonatomic,strong)NSMutableArray *dataArray;
  22. @property(nonatomic,strong)MengBanView *mengBanView;
  23. @end
  24. @implementation WaringDetailList
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. NSArray * titleArray = @[@"遇到抢劫",@"交通事故",@"车辆故障",@"超速报警",@"卫星定位",@"天线状态",@"电源断电",@"超市停车",@"围栏越界",@"碰撞报警",@"侧翻报警",@"非法开门报警"];
  28. self.navigationItem.title = titleArray[[_type integerValue]-1];
  29. self.navigationController.navigationBar.translucent = NO;
  30. [self goBackByNavigation];
  31. // [self customRightBtn];
  32. _dataArray = [NSMutableArray new];
  33. _selectedIndexPathes = [[NSMutableArray alloc] init];
  34. [self myInit];
  35. [self getCarWarningList];
  36. }
  37. -(void)myInit{
  38. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kFrame.size.width, kFrame.size.height-kNavOffSet) style:UITableViewStylePlain];
  39. _tableView.rowHeight = 52.0f;
  40. _tableView.delegate = self;
  41. _tableView.dataSource = self;
  42. _tableView.backgroundColor = KBackGroundColor;
  43. _tableView.showsVerticalScrollIndicator = NO;
  44. [self.view addSubview:_tableView];
  45. [_tableView registerNib:[UINib nibWithNibName:@"WillDoCell" bundle:nil] forCellReuseIdentifier:@"WillDoCellId"];
  46. UIView *view = [UIView new];
  47. _tableView.tableFooterView = view;
  48. _holderV = [[HolderView alloc]initWithFrame:_tableView.frame];
  49. [_holderV freshBlock:^{
  50. [self getCarWarningList];
  51. }];
  52. [self.view addSubview:_holderV];
  53. // [self createSelectBtn];
  54. }
  55. //-(void)customRightBtn{
  56. //
  57. // UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
  58. // btn.frame = CGRectMake(0, 0, 43, 44);
  59. // btn.titleLabel.font = [UIFont systemFontOfSize:17];
  60. // [btn setTitle:@"筛选" forState:UIControlStateNormal];
  61. // [btn setTitleColor:defGreen forState:UIControlStateNormal];
  62. // [btn addTarget:self action:@selector(setMengbanView) forControlEvents:UIControlEventTouchUpInside];
  63. // self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  64. //
  65. //}
  66. //
  67. //-(void)setMengbanView{
  68. //
  69. // if (_mengBanView) {
  70. // [_mengBanView showView];
  71. // return;
  72. // }
  73. //
  74. // NSArray * btnarr = @[@"未解除",@"已解除"];
  75. // NSString *start = @"开始时间";
  76. // NSString *end = @"结束时间";
  77. // NSArray * buttonsArray = @[@[@"1",btnarr],@[@"2",start],@[@"2",end]];
  78. //
  79. // _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:buttonsArray isAllbtn:NO block:^(NSArray *array) {
  80. //
  81. // //确认解除报警 0 已解除 1 未解除(默认查未解除)
  82. // if ([array[0] isEqualToString:@"已解除"]) {
  83. // _status = @"0";
  84. // }else if ([array[0] isEqualToString:@"未解除"]){
  85. // _status = @"1";
  86. // }
  87. //
  88. //
  89. // if (![array[1] isEqualToString:@"开始时间"]) {
  90. // _startDate = array[1];
  91. // }
  92. // if (![array[2] isEqualToString:@"结束时间"]) {
  93. // _endDate = array[2];
  94. // }
  95. //
  96. // [self getCarWarningList];
  97. // }];
  98. // [_mengBanView showView];
  99. //}
  100. #pragma mark - 解除报警相关
  101. //-(void)createSelectBtn{
  102. //
  103. // _notifyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  104. // _notifyBtn.backgroundColor = defGreen;
  105. // _notifyBtn.frame = CGRectMake(kSize.width-80, kSize.height-90-kNavOffSet, 60, 60);
  106. // [_notifyBtn setTitle:@"解除\n报警" forState:UIControlStateNormal];
  107. // [_notifyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  108. // _notifyBtn.titleLabel.numberOfLines = 0;
  109. // _notifyBtn.layer.masksToBounds = YES;
  110. // _notifyBtn.layer.cornerRadius = 30;
  111. // [_notifyBtn addTarget:self action:@selector(notifiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  112. //
  113. // _notifyBtn.hidden = YES;
  114. // [self.view addSubview:_notifyBtn];
  115. //}
  116. //
  117. //-(void)notifiBtnClick:(UIButton *)sender{
  118. //
  119. // if (self.dataArray.count == 0) {
  120. // return;
  121. // }
  122. //
  123. // if (!self.tableView.editing) {
  124. // [self.tableView setEditing:YES];//进入编辑模式
  125. // self.navigationItem.rightBarButtonItem = nil;
  126. //
  127. // [sender setTitle:@"提交" forState:UIControlStateNormal];
  128. //
  129. // CGRect frame = sender.frame;;
  130. // _allBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  131. // _allBtn.backgroundColor = [UIColor lightGrayColor];
  132. // _allBtn.frame = CGRectMake(frame.origin.x + 30, frame.origin.y, 0, 30);
  133. // [_allBtn setTitle:@"全选" forState:UIControlStateNormal];
  134. // [_allBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  135. // [_allBtn setTitleColor:defGreen forState:UIControlStateSelected];
  136. //
  137. // [_allBtn addTarget:self action:@selector(allClick:) forControlEvents:UIControlEventTouchUpInside];
  138. // [self.view addSubview:_allBtn];
  139. //
  140. //
  141. // _cancelBtn = [UIButton buttonWithType:UIButtonTypeSystem];
  142. // _cancelBtn.backgroundColor = [UIColor lightGrayColor];
  143. // _cancelBtn.frame = CGRectMake(frame.origin.x + 30, frame.origin.y + 30, 0, 30);
  144. // [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
  145. // [_cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  146. // [_cancelBtn addTarget:self action:@selector(cancelClick:) forControlEvents:UIControlEventTouchUpInside];
  147. // [self.view addSubview:_cancelBtn];
  148. //
  149. // [UIView animateWithDuration:.4 animations:^{
  150. // _allBtn.frame = CGRectMake(frame.origin.x-100, frame.origin.y - 5, 80, 30);
  151. // _cancelBtn.frame = CGRectMake(frame.origin.x-100, frame.origin.y + 35, 80, 30);
  152. // }];
  153. //
  154. // return;
  155. // }
  156. //
  157. // NSMutableArray * allId = [NSMutableArray new];
  158. // for (NSIndexPath *indexPath in _selectedIndexPathes) {
  159. //
  160. // [allId addObject:self.dataArray[indexPath.row][@"ID"]];
  161. // }
  162. //
  163. // if (allId.count > 0) {
  164. //
  165. // [self.tableView setEditing:NO];
  166. // [self customRightBtn];
  167. //
  168. // [sender setTitle:@"解除\n报警" forState:UIControlStateNormal];
  169. // [_allBtn removeFromSuperview];
  170. // [_cancelBtn removeFromSuperview];
  171. // [_selectedIndexPathes removeAllObjects];
  172. //
  173. // [self dealWithIds:allId];
  174. //
  175. // }else{
  176. // ShowMsg(@"请选择终端设备");
  177. // }
  178. //}
  179. //
  180. //-(void)allClick:(UIButton *)button{
  181. //
  182. // button.selected = !button.selected;
  183. // //获取表格视图内容的尺寸
  184. // CGSize size = self.tableView.contentSize;
  185. // CGRect rect = CGRectMake(0, 0, size.width, size.height);
  186. // //获取指定区域的cell的indexPath
  187. // NSArray *indexPathes = [self.tableView indexPathsForRowsInRect:rect];
  188. // if (button.selected) {
  189. // for (NSIndexPath *indexPath in indexPathes) {
  190. // //使用代码方式选中一行
  191. // [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
  192. // }
  193. // //更新选中数组
  194. // _selectedIndexPathes.array = indexPathes;
  195. // } else {
  196. // for (NSIndexPath *indexPath in indexPathes) {
  197. // //使用代码方式取消选中一行
  198. // [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  199. // }
  200. // //清空选中cell的记录数组
  201. // [_selectedIndexPathes removeAllObjects];
  202. // }
  203. //}
  204. //
  205. //
  206. //- (void)cancelClick:(UIButton *)sender {
  207. //
  208. // [self.tableView setEditing:NO];
  209. // [self customRightBtn];
  210. //
  211. // [_notifyBtn setTitle:@"解除\n报警" forState:UIControlStateNormal];
  212. // [_allBtn removeFromSuperview];
  213. // [_cancelBtn removeFromSuperview];
  214. //
  215. // [_selectedIndexPathes removeAllObjects];
  216. //}
  217. //
  218. //-(void)dealWithIds:(NSArray *)ids{
  219. //
  220. // NSMutableString *mStr = [[NSMutableString alloc]init];
  221. // for (NSString *str in ids) {
  222. // [mStr appendFormat:@",%@",str];
  223. // }
  224. // [self removeMacWarningWithMwIdStr:[mStr substringFromIndex:1]];
  225. //}
  226. #pragma mark tableview代理方法
  227. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  228. return _dataArray.count;
  229. }
  230. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  231. WarDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId'"];
  232. if (!cell) {
  233. cell = [[[NSBundle mainBundle] loadNibNamed:@"WarDetailCell" owner:nil options:nil] lastObject];
  234. }
  235. cell.dic = _dataArray[indexPath.row];
  236. return cell;
  237. }
  238. //-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  239. //
  240. // if (self.tableView.editing) {
  241. // //当选中cell时,记录其indexPath
  242. // if (![_selectedIndexPathes containsObject:indexPath]) {
  243. // [_selectedIndexPathes addObject:indexPath];
  244. // }
  245. // return;
  246. // }
  247. //
  248. //}
  249. //
  250. //- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
  251. // //当取消选中cell时,从记录的数组中删除其indexPath
  252. //
  253. // if ([_selectedIndexPathes containsObject:indexPath] && self.tableView.editing) {
  254. // [_selectedIndexPathes removeObject:indexPath];
  255. // if (_allBtn.selected) {
  256. // _allBtn.selected = NO;
  257. // }
  258. // }
  259. //}
  260. //
  261. //- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  262. // return UITableViewCellEditingStyleInsert |UITableViewCellEditingStyleDelete;
  263. //}
  264. #pragma mark 网络请求
  265. -(void)getCarWarningList{
  266. if (![NetManager connectedToNetWork]) {
  267. showMsgUnconnect();
  268. return;
  269. }
  270. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  271. [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
  272. [dic setObject:self.status forKey:@"status"];
  273. [dic setObject:self.type forKey:@"kind"];
  274. [dic setObject:_startDate forKey:@"startTime"];
  275. [dic setObject:_endDate forKey:@"endTime"];
  276. NSString *method = @"getCarWarningList";
  277. [MBProgressHUD showLoadToView:self.view];
  278. [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  279. [MBProgressHUD hideHUDForView:self.view];
  280. _holderV.hidden = NO;
  281. if (!root) {
  282. ShowMsg(@"数据请求失败,请重试");
  283. return;
  284. }
  285. if ([root[@"code"] integerValue] == 1) {
  286. ShowMsg(root[@"msg"]);
  287. NSLog(@"%@",root[@"msg"]);
  288. return;
  289. }
  290. _dataArray = root[@"body"];
  291. [_tableView reloadData];
  292. if (_dataArray.count) {
  293. _holderV.hidden = YES;
  294. }
  295. // if (_dataArray.count != 0 && [_status isEqualToString:@"1"]) {
  296. // _notifyBtn.hidden = NO;
  297. // }else{
  298. // _notifyBtn.hidden = YES;
  299. // }
  300. }];
  301. }
  302. //-(void)removeMacWarningWithMwIdStr:(NSString *)mwIdStr{
  303. //
  304. // if (![NetManager connectedToNetWork]) {
  305. // showMsgUnconnect();
  306. // return;
  307. // }
  308. //
  309. // NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  310. // [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
  311. // [dic setObject:mwIdStr forKey:@"mwId"];
  312. // [dic setObject:self.type forKey:@"kind"];
  313. // [dic setObject:@"" forKey:@"sim"];
  314. //
  315. //
  316. // NSString *method = @"removeMacWarning";
  317. // [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  318. //
  319. // if (!root) {
  320. // ShowMsg(@"数据请求失败,请重试");
  321. // return;
  322. // }
  323. // if ([root[@"code"] integerValue] == 1) {
  324. // ShowMsg(root[@"msg"]);
  325. // return;
  326. // }
  327. //
  328. // ShowMsg(@"操作成功");
  329. //
  330. // [self getCarWarningList];
  331. // }];
  332. //}
  333. - (void)didReceiveMemoryWarning {
  334. [super didReceiveMemoryWarning];
  335. // Dispose of any resources that can be recreated.
  336. }
  337. /*
  338. #pragma mark - Navigation
  339. // In a storyboard-based application, you will often want to do a little preparation before navigation
  340. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  341. // Get the new view controller using [segue destinationViewController].
  342. // Pass the selected object to the new view controller.
  343. }
  344. */
  345. @end