WaringDetailList.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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. // UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"筛选" style:UIBarButtonItemStylePlain target:self action:@selector(setMengbanView)];
  57. // item.tintColor = RQMianColor;
  58. // self.navigationItem.rightBarButtonItem = item;
  59. //}
  60. //
  61. //-(void)setMengbanView{
  62. //
  63. // if (_mengBanView) {
  64. // [_mengBanView showView];
  65. // return;
  66. // }
  67. //
  68. // NSArray * btnarr = @[@"未解除",@"已解除"];
  69. // NSString *start = @"开始时间";
  70. // NSString *end = @"结束时间";
  71. // NSArray * buttonsArray = @[@[@"1",btnarr],@[@"2",start],@[@"2",end]];
  72. //
  73. // _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:buttonsArray isAllbtn:NO block:^(NSArray *array) {
  74. //
  75. // //确认解除报警 0 已解除 1 未解除(默认查未解除)
  76. // if ([array[0] isEqualToString:@"已解除"]) {
  77. // _status = @"0";
  78. // }else if ([array[0] isEqualToString:@"未解除"]){
  79. // _status = @"1";
  80. // }
  81. //
  82. //
  83. // if (![array[1] isEqualToString:@"开始时间"]) {
  84. // _startDate = array[1];
  85. // }
  86. // if (![array[2] isEqualToString:@"结束时间"]) {
  87. // _endDate = array[2];
  88. // }
  89. //
  90. // [self getCarWarningList];
  91. // }];
  92. // [_mengBanView showView];
  93. //}
  94. #pragma mark - 解除报警相关
  95. //-(void)createSelectBtn{
  96. //
  97. // _notifyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  98. // _notifyBtn.backgroundColor = RQMianColor;
  99. // _notifyBtn.frame = CGRectMake(kSize.width-80, kSize.height-90-knavoff, 60, 60);
  100. // [_notifyBtn setTitle:@"解除\n报警" forState:UIControlStateNormal];
  101. // [_notifyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  102. // _notifyBtn.titleLabel.numberOfLines = 0;
  103. // _notifyBtn.layer.masksToBounds = YES;
  104. // _notifyBtn.layer.cornerRadius = 30;
  105. // [_notifyBtn addTarget:self action:@selector(notifiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  106. //
  107. // _notifyBtn.hidden = YES;
  108. // [self.view addSubview:_notifyBtn];
  109. //}
  110. //
  111. //-(void)notifiBtnClick:(UIButton *)sender{
  112. //
  113. // if (self.dataArray.count == 0) {
  114. // return;
  115. // }
  116. //
  117. // if (!self.tableView.editing) {
  118. // [self.tableView setEditing:YES];//进入编辑模式
  119. // self.navigationItem.rightBarButtonItem = nil;
  120. //
  121. // [sender setTitle:@"提交" forState:UIControlStateNormal];
  122. //
  123. // CGRect frame = sender.frame;;
  124. // _allBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  125. // _allBtn.backgroundColor = [UIColor lightGrayColor];
  126. // _allBtn.frame = CGRectMake(frame.origin.x + 30, frame.origin.y, 0, 30);
  127. // [_allBtn setTitle:@"全选" forState:UIControlStateNormal];
  128. // [_allBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  129. // [_allBtn setTitleColor:RQMianColor forState:UIControlStateSelected];
  130. //
  131. // [_allBtn addTarget:self action:@selector(allClick:) forControlEvents:UIControlEventTouchUpInside];
  132. // [self.view addSubview:_allBtn];
  133. //
  134. //
  135. // _cancelBtn = [UIButton buttonWithType:UIButtonTypeSystem];
  136. // _cancelBtn.backgroundColor = [UIColor lightGrayColor];
  137. // _cancelBtn.frame = CGRectMake(frame.origin.x + 30, frame.origin.y + 30, 0, 30);
  138. // [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
  139. // [_cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  140. // [_cancelBtn addTarget:self action:@selector(cancelClick:) forControlEvents:UIControlEventTouchUpInside];
  141. // [self.view addSubview:_cancelBtn];
  142. //
  143. // [UIView animateWithDuration:.4 animations:^{
  144. // _allBtn.frame = CGRectMake(frame.origin.x-100, frame.origin.y - 5, 80, 30);
  145. // _cancelBtn.frame = CGRectMake(frame.origin.x-100, frame.origin.y + 35, 80, 30);
  146. // }];
  147. //
  148. // return;
  149. // }
  150. //
  151. // NSMutableArray * allId = [NSMutableArray new];
  152. // for (NSIndexPath *indexPath in _selectedIndexPathes) {
  153. //
  154. // [allId addObject:self.dataArray[indexPath.row][@"ID"]];
  155. // }
  156. //
  157. // if (allId.count > 0) {
  158. //
  159. // [self.tableView setEditing:NO];
  160. // [self customRightBtn];
  161. //
  162. // [sender setTitle:@"解除\n报警" forState:UIControlStateNormal];
  163. // [_allBtn removeFromSuperview];
  164. // [_cancelBtn removeFromSuperview];
  165. // [_selectedIndexPathes removeAllObjects];
  166. //
  167. // [self dealWithIds:allId];
  168. //
  169. // }else{
  170. // ShowMsg(@"请选择终端设备");
  171. // }
  172. //}
  173. //
  174. //-(void)allClick:(UIButton *)button{
  175. //
  176. // button.selected = !button.selected;
  177. // //获取表格视图内容的尺寸
  178. // CGSize size = self.tableView.contentSize;
  179. // CGRect rect = CGRectMake(0, 0, size.width, size.height);
  180. // //获取指定区域的cell的indexPath
  181. // NSArray *indexPathes = [self.tableView indexPathsForRowsInRect:rect];
  182. // if (button.selected) {
  183. // for (NSIndexPath *indexPath in indexPathes) {
  184. // //使用代码方式选中一行
  185. // [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
  186. // }
  187. // //更新选中数组
  188. // _selectedIndexPathes.array = indexPathes;
  189. // } else {
  190. // for (NSIndexPath *indexPath in indexPathes) {
  191. // //使用代码方式取消选中一行
  192. // [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  193. // }
  194. // //清空选中cell的记录数组
  195. // [_selectedIndexPathes removeAllObjects];
  196. // }
  197. //}
  198. //
  199. //
  200. //- (void)cancelClick:(UIButton *)sender {
  201. //
  202. // [self.tableView setEditing:NO];
  203. // [self customRightBtn];
  204. //
  205. // [_notifyBtn setTitle:@"解除\n报警" forState:UIControlStateNormal];
  206. // [_allBtn removeFromSuperview];
  207. // [_cancelBtn removeFromSuperview];
  208. //
  209. // [_selectedIndexPathes removeAllObjects];
  210. //}
  211. //
  212. //-(void)dealWithIds:(NSArray *)ids{
  213. //
  214. // NSMutableString *mStr = [[NSMutableString alloc]init];
  215. // for (NSString *str in ids) {
  216. // [mStr appendFormat:@",%@",str];
  217. // }
  218. // [self removeMacWarningWithMwIdStr:[mStr substringFromIndex:1]];
  219. //}
  220. #pragma mark tableview代理方法
  221. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  222. return _dataArray.count;
  223. }
  224. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  225. WarDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId'"];
  226. if (!cell) {
  227. cell = [[[NSBundle mainBundle] loadNibNamed:@"WarDetailCell" owner:nil options:nil] lastObject];
  228. }
  229. cell.dic = _dataArray[indexPath.row];
  230. return cell;
  231. }
  232. //-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  233. //
  234. // if (self.tableView.editing) {
  235. // //当选中cell时,记录其indexPath
  236. // if (![_selectedIndexPathes containsObject:indexPath]) {
  237. // [_selectedIndexPathes addObject:indexPath];
  238. // }
  239. // return;
  240. // }
  241. //
  242. //}
  243. //
  244. //- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
  245. // //当取消选中cell时,从记录的数组中删除其indexPath
  246. //
  247. // if ([_selectedIndexPathes containsObject:indexPath] && self.tableView.editing) {
  248. // [_selectedIndexPathes removeObject:indexPath];
  249. // if (_allBtn.selected) {
  250. // _allBtn.selected = NO;
  251. // }
  252. // }
  253. //}
  254. //
  255. //- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  256. // return UITableViewCellEditingStyleInsert |UITableViewCellEditingStyleDelete;
  257. //}
  258. #pragma mark 网络请求
  259. -(void)getCarWarningList{
  260. if (![NetManager connectedToNetWork]) {
  261. showMsgUnconnect();
  262. return;
  263. }
  264. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  265. [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
  266. [dic setObject:self.status forKey:@"status"];
  267. [dic setObject:self.type forKey:@"kind"];
  268. [dic setObject:_startDate forKey:@"startTime"];
  269. [dic setObject:_endDate forKey:@"endTime"];
  270. NSString *method = @"getCarWarningList";
  271. [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  272. _holderV.hidden = NO;
  273. if (!root) {
  274. ShowMsg(@"数据请求失败,请重试");
  275. return;
  276. }
  277. if ([root[@"code"] integerValue] == 1) {
  278. ShowMsg(root[@"msg"]);
  279. NSLog(@"%@",root[@"msg"]);
  280. return;
  281. }
  282. _dataArray = root[@"body"];
  283. [_tableView reloadData];
  284. if (_dataArray.count) {
  285. _holderV.hidden = YES;
  286. }
  287. // if (_dataArray.count != 0 && [_status isEqualToString:@"1"]) {
  288. // _notifyBtn.hidden = NO;
  289. // }else{
  290. // _notifyBtn.hidden = YES;
  291. // }
  292. }];
  293. }
  294. //-(void)removeMacWarningWithMwIdStr:(NSString *)mwIdStr{
  295. //
  296. // if (![NetManager connectedToNetWork]) {
  297. // showMsgUnconnect();
  298. // return;
  299. // }
  300. //
  301. // NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  302. // [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
  303. // [dic setObject:mwIdStr forKey:@"mwId"];
  304. // [dic setObject:self.type forKey:@"kind"];
  305. // [dic setObject:@"" forKey:@"sim"];
  306. //
  307. //
  308. // NSString *method = @"removeMacWarning";
  309. // [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  310. //
  311. // if (!root) {
  312. // ShowMsg(@"数据请求失败,请重试");
  313. // return;
  314. // }
  315. // if ([root[@"code"] integerValue] == 1) {
  316. // ShowMsg(root[@"msg"]);
  317. // return;
  318. // }
  319. //
  320. // ShowMsg(@"操作成功");
  321. //
  322. // [self getCarWarningList];
  323. // }];
  324. //}
  325. - (void)didReceiveMemoryWarning {
  326. [super didReceiveMemoryWarning];
  327. // Dispose of any resources that can be recreated.
  328. }
  329. /*
  330. #pragma mark - Navigation
  331. // In a storyboard-based application, you will often want to do a little preparation before navigation
  332. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  333. // Get the new view controller using [segue destinationViewController].
  334. // Pass the selected object to the new view controller.
  335. }
  336. */
  337. @end