123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- //
- // WaringDetailList.m
- // LN_School
- //
- // Created by EchoShacolee on 2017/8/12.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "WaringDetailList.h"
- #import "WarDetailCell.h"
- #import "MengBanView.h"
- @interface WaringDetailList ()<UITableViewDelegate,UITableViewDataSource>
- {
- //解除报警
- NSMutableArray *_selectedIndexPathes;//记录选中的cell
- UIButton *_notifyBtn;
- UIButton *_allBtn;
- UIButton *_cancelBtn;
- HolderView *_holderV;
- }
- @property(nonatomic,strong)UITableView *tableView;
- @property(nonatomic,strong)NSMutableArray *dataArray;
- @property(nonatomic,strong)MengBanView *mengBanView;
- @end
- @implementation WaringDetailList
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- NSArray * titleArray = @[@"遇到抢劫",@"交通事故",@"车辆故障",@"超速报警",@"卫星定位",@"天线状态",@"电源断电",@"超市停车",@"围栏越界",@"碰撞报警",@"侧翻报警",@"非法开门报警"];
- self.navigationItem.title = titleArray[[_type integerValue]-1];
- self.navigationController.navigationBar.translucent = NO;
- [self goBackByNavigation];
- // [self customRightBtn];
-
- _dataArray = [NSMutableArray new];
- _selectedIndexPathes = [[NSMutableArray alloc] init];
-
- [self myInit];
- [self getCarWarningList];
- }
- -(void)myInit{
-
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kFrame.size.width, kFrame.size.height-kNavOffSet) style:UITableViewStylePlain];
- _tableView.rowHeight = 52.0f;
- _tableView.delegate = self;
- _tableView.dataSource = self;
-
- _tableView.backgroundColor = KBackGroundColor;
- _tableView.showsVerticalScrollIndicator = NO;
- [self.view addSubview:_tableView];
-
- [_tableView registerNib:[UINib nibWithNibName:@"WillDoCell" bundle:nil] forCellReuseIdentifier:@"WillDoCellId"];
-
- UIView *view = [UIView new];
- _tableView.tableFooterView = view;
-
- _holderV = [[HolderView alloc]initWithFrame:_tableView.frame];
- [_holderV freshBlock:^{
- [self getCarWarningList];
- }];
- [self.view addSubview:_holderV];
-
- // [self createSelectBtn];
- }
- //-(void)customRightBtn{
- // UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"筛选" style:UIBarButtonItemStylePlain target:self action:@selector(setMengbanView)];
- // item.tintColor = RQMianColor;
- // self.navigationItem.rightBarButtonItem = item;
- //}
- //
- //-(void)setMengbanView{
- //
- // if (_mengBanView) {
- // [_mengBanView showView];
- // return;
- // }
- //
- // NSArray * btnarr = @[@"未解除",@"已解除"];
- // NSString *start = @"开始时间";
- // NSString *end = @"结束时间";
- // NSArray * buttonsArray = @[@[@"1",btnarr],@[@"2",start],@[@"2",end]];
- //
- // _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:buttonsArray isAllbtn:NO block:^(NSArray *array) {
- //
- // //确认解除报警 0 已解除 1 未解除(默认查未解除)
- // if ([array[0] isEqualToString:@"已解除"]) {
- // _status = @"0";
- // }else if ([array[0] isEqualToString:@"未解除"]){
- // _status = @"1";
- // }
- //
- //
- // if (![array[1] isEqualToString:@"开始时间"]) {
- // _startDate = array[1];
- // }
- // if (![array[2] isEqualToString:@"结束时间"]) {
- // _endDate = array[2];
- // }
- //
- // [self getCarWarningList];
- // }];
- // [_mengBanView showView];
- //}
- #pragma mark - 解除报警相关
- //-(void)createSelectBtn{
- //
- // _notifyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- // _notifyBtn.backgroundColor = RQMianColor;
- // _notifyBtn.frame = CGRectMake(kSize.width-80, kSize.height-90-knavoff, 60, 60);
- // [_notifyBtn setTitle:@"解除\n报警" forState:UIControlStateNormal];
- // [_notifyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- // _notifyBtn.titleLabel.numberOfLines = 0;
- // _notifyBtn.layer.masksToBounds = YES;
- // _notifyBtn.layer.cornerRadius = 30;
- // [_notifyBtn addTarget:self action:@selector(notifiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- //
- // _notifyBtn.hidden = YES;
- // [self.view addSubview:_notifyBtn];
- //}
- //
- //-(void)notifiBtnClick:(UIButton *)sender{
- //
- // if (self.dataArray.count == 0) {
- // return;
- // }
- //
- // if (!self.tableView.editing) {
- // [self.tableView setEditing:YES];//进入编辑模式
- // self.navigationItem.rightBarButtonItem = nil;
- //
- // [sender setTitle:@"提交" forState:UIControlStateNormal];
- //
- // CGRect frame = sender.frame;;
- // _allBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- // _allBtn.backgroundColor = [UIColor lightGrayColor];
- // _allBtn.frame = CGRectMake(frame.origin.x + 30, frame.origin.y, 0, 30);
- // [_allBtn setTitle:@"全选" forState:UIControlStateNormal];
- // [_allBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- // [_allBtn setTitleColor:RQMianColor forState:UIControlStateSelected];
- //
- // [_allBtn addTarget:self action:@selector(allClick:) forControlEvents:UIControlEventTouchUpInside];
- // [self.view addSubview:_allBtn];
- //
- //
- // _cancelBtn = [UIButton buttonWithType:UIButtonTypeSystem];
- // _cancelBtn.backgroundColor = [UIColor lightGrayColor];
- // _cancelBtn.frame = CGRectMake(frame.origin.x + 30, frame.origin.y + 30, 0, 30);
- // [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
- // [_cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- // [_cancelBtn addTarget:self action:@selector(cancelClick:) forControlEvents:UIControlEventTouchUpInside];
- // [self.view addSubview:_cancelBtn];
- //
- // [UIView animateWithDuration:.4 animations:^{
- // _allBtn.frame = CGRectMake(frame.origin.x-100, frame.origin.y - 5, 80, 30);
- // _cancelBtn.frame = CGRectMake(frame.origin.x-100, frame.origin.y + 35, 80, 30);
- // }];
- //
- // return;
- // }
- //
- // NSMutableArray * allId = [NSMutableArray new];
- // for (NSIndexPath *indexPath in _selectedIndexPathes) {
- //
- // [allId addObject:self.dataArray[indexPath.row][@"ID"]];
- // }
- //
- // if (allId.count > 0) {
- //
- // [self.tableView setEditing:NO];
- // [self customRightBtn];
- //
- // [sender setTitle:@"解除\n报警" forState:UIControlStateNormal];
- // [_allBtn removeFromSuperview];
- // [_cancelBtn removeFromSuperview];
- // [_selectedIndexPathes removeAllObjects];
- //
- // [self dealWithIds:allId];
- //
- // }else{
- // ShowMsg(@"请选择终端设备");
- // }
- //}
- //
- //-(void)allClick:(UIButton *)button{
- //
- // button.selected = !button.selected;
- // //获取表格视图内容的尺寸
- // CGSize size = self.tableView.contentSize;
- // CGRect rect = CGRectMake(0, 0, size.width, size.height);
- // //获取指定区域的cell的indexPath
- // NSArray *indexPathes = [self.tableView indexPathsForRowsInRect:rect];
- // if (button.selected) {
- // for (NSIndexPath *indexPath in indexPathes) {
- // //使用代码方式选中一行
- // [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
- // }
- // //更新选中数组
- // _selectedIndexPathes.array = indexPathes;
- // } else {
- // for (NSIndexPath *indexPath in indexPathes) {
- // //使用代码方式取消选中一行
- // [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
- // }
- // //清空选中cell的记录数组
- // [_selectedIndexPathes removeAllObjects];
- // }
- //}
- //
- //
- //- (void)cancelClick:(UIButton *)sender {
- //
- // [self.tableView setEditing:NO];
- // [self customRightBtn];
- //
- // [_notifyBtn setTitle:@"解除\n报警" forState:UIControlStateNormal];
- // [_allBtn removeFromSuperview];
- // [_cancelBtn removeFromSuperview];
- //
- // [_selectedIndexPathes removeAllObjects];
- //}
- //
- //-(void)dealWithIds:(NSArray *)ids{
- //
- // NSMutableString *mStr = [[NSMutableString alloc]init];
- // for (NSString *str in ids) {
- // [mStr appendFormat:@",%@",str];
- // }
- // [self removeMacWarningWithMwIdStr:[mStr substringFromIndex:1]];
- //}
- #pragma mark tableview代理方法
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return _dataArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- WarDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId'"];
- if (!cell) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"WarDetailCell" owner:nil options:nil] lastObject];
- }
- cell.dic = _dataArray[indexPath.row];
-
- return cell;
- }
- //-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- //
- // if (self.tableView.editing) {
- // //当选中cell时,记录其indexPath
- // if (![_selectedIndexPathes containsObject:indexPath]) {
- // [_selectedIndexPathes addObject:indexPath];
- // }
- // return;
- // }
- //
- //}
- //
- //- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
- // //当取消选中cell时,从记录的数组中删除其indexPath
- //
- // if ([_selectedIndexPathes containsObject:indexPath] && self.tableView.editing) {
- // [_selectedIndexPathes removeObject:indexPath];
- // if (_allBtn.selected) {
- // _allBtn.selected = NO;
- // }
- // }
- //}
- //
- //- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
- // return UITableViewCellEditingStyleInsert |UITableViewCellEditingStyleDelete;
- //}
- #pragma mark 网络请求
- -(void)getCarWarningList{
-
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
- [dic setObject:self.status forKey:@"status"];
- [dic setObject:self.type forKey:@"kind"];
- [dic setObject:_startDate forKey:@"startTime"];
- [dic setObject:_endDate forKey:@"endTime"];
-
- NSString *method = @"getCarWarningList";
- [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
-
- _holderV.hidden = NO;
-
- if (!root) {
- ShowMsg(@"数据请求失败,请重试");
- return;
- }
- if ([root[@"code"] integerValue] == 1) {
- ShowMsg(root[@"msg"]);
- NSLog(@"%@",root[@"msg"]);
- return;
- }
-
- _dataArray = root[@"body"];
- [_tableView reloadData];
-
- if (_dataArray.count) {
- _holderV.hidden = YES;
- }
-
- // if (_dataArray.count != 0 && [_status isEqualToString:@"1"]) {
- // _notifyBtn.hidden = NO;
- // }else{
- // _notifyBtn.hidden = YES;
- // }
- }];
- }
- //-(void)removeMacWarningWithMwIdStr:(NSString *)mwIdStr{
- //
- // if (![NetManager connectedToNetWork]) {
- // showMsgUnconnect();
- // return;
- // }
- //
- // NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- // [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
- // [dic setObject:mwIdStr forKey:@"mwId"];
- // [dic setObject:self.type forKey:@"kind"];
- // [dic setObject:@"" forKey:@"sim"];
- //
- //
- // NSString *method = @"removeMacWarning";
- // [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
- //
- // if (!root) {
- // ShowMsg(@"数据请求失败,请重试");
- // return;
- // }
- // if ([root[@"code"] integerValue] == 1) {
- // ShowMsg(root[@"msg"]);
- // return;
- // }
- //
- // ShowMsg(@"操作成功");
- //
- // [self getCarWarningList];
- // }];
- //}
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|