123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- //
- // SafeList.m
- // LNManager
- //
- // Created by EchoShacolee on 2017/4/9.
- // Copyright © 2017年 lee. All rights reserved.
- //
- #import "SafeList.h"
- #import "SafeDetail.h"
- @interface SafeList ()
- @end
- @implementation SafeList
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.navigationItem.title = @"安全员列表";
-
- [self getData];
-
- __weak typeof(self) weakSelf = self;
- _block = ^{
- [weakSelf getData];
- };
- }
- -(void)getData{
-
- NSMutableDictionary * mdic = [NSMutableDictionary new];
- [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_DQBH"]] forKey:@"dqbh"];
- [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_QXBH"]] forKey:@"qxbh"];
- [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_INSCODE"]] forKey:@"inscode"];
- [mdic setValue:@"" forKey:@"securityguardsName"];
- [mdic setValue:@"" forKey:@"idcard"];
- [mdic setValue:@"" forKey:@"isPage"];
- [mdic setValue:@"" forKey:@"pageSize"];
- [mdic setValue:@"" forKey:@"currentPage"];
- [mdic setValue:@"" forKey:@"phone"];
-
- [self getDataWithDic:mdic method:@"securityguards" block:^(NSDictionary *successdic) {
- NSArray * arr = successdic[@"body"];
- if (arr.count != 0) {
- self.holderV.hidden = YES;
- }
-
- for (NSDictionary * dic in arr) {
- if (![_sectionTitles containsObject:dic[@"ZM"]]) {
- [_sectionTitles addObject:dic[@"ZM"]];
- [_dataSource addObject:[NSMutableArray new]];
- }
- }
-
- //排序
- [_sectionTitles sortUsingSelector:@selector(compare:)];
-
- for (NSDictionary * dic in arr) {
- NSInteger location = [_sectionTitles indexOfObject:dic[@"ZM"]];
- [_dataSource[location] addObject:dic];
- }
-
- [self.tableView reloadData];
- }];
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSMutableDictionary * dic;
- if (_hasSearch) {
- dic = _resultArray[indexPath.row];
- }else{
- dic = _dataSource[indexPath.section][indexPath.row];
- }
-
- UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId" forIndexPath:indexPath];
- if ([_dataSource[indexPath.section] count] > 0) {
- cell.textLabel.text = dic[@"SI_NAME"];
- }
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- NSMutableDictionary * dic;
- if (_hasSearch) {
- dic = _resultArray[indexPath.row];
- }else{
- dic = _dataSource[indexPath.section][indexPath.row];
- }
-
- SafeDetail * vc = [[SafeDetail alloc]init];
- vc.dataSource = dic;
- [self.navigationController pushViewController:vc animated:YES];
-
- }
- #pragma mark - 搜索代理
- - (void)updateSearchResultsForSearchController:(UISearchController *)searchController
- {
- NSString *searchString = _searchController.searchBar.text;
- // NSLog(@"searchString-->%@",searchString);
- _hasSearch = NO;
- if (searchString.length > 0) {
- [_resultArray removeAllObjects];
- if ([searchString integerValue] == 0)
- {//汉字
-
- for (NSArray *sectionArr in _dataSource)
- {
- for (NSDictionary *dic in sectionArr)
- {
- if ([dic[@"CI_NAME"] rangeOfString:searchString].location != NSNotFound)
- {
- [_resultArray addObject:dic];
- }
- }
- }
-
- }else{
-
- for (NSArray *sectionArr in _dataSource)
- {
- for (NSDictionary *dic in sectionArr)
- {
- BOOL isTrue1 = [[NSString stringWithFormat:@"%@",dic[@"SI_MOBILE"]] rangeOfString:searchString].location != NSNotFound;
- BOOL isTrue2 = [[NSString stringWithFormat:@"%@",dic[@"SI_IDCARD"]] rangeOfString:searchString].location != NSNotFound;
- if (isTrue2)
- {
- [_resultArray addObject:dic];
- }else if(isTrue1)
- {
- [_resultArray addObject:dic];
- }
- }
- }
- }
- _hasSearch = YES;
- }
- [self.tableView reloadData];
- }
- - (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
|