|
@@ -1,154 +0,0 @@
|
|
|
-//
|
|
|
|
|
-// ViewController.m
|
|
|
|
|
-// RedAnt Mobile
|
|
|
|
|
-//
|
|
|
|
|
-// Created by Ray on 06/09/2017.
|
|
|
|
|
-// Copyright © 2017 Ray. All rights reserved.
|
|
|
|
|
-//
|
|
|
|
|
-
|
|
|
|
|
-#import "RARootViewController.h"
|
|
|
|
|
-#import "RARootModeCell.h"
|
|
|
|
|
-#import "RAModel.h"
|
|
|
|
|
-#import "RAPredefQueryViewController.h"
|
|
|
|
|
-#import "RAQueryViewController.h"
|
|
|
|
|
-#import "ResultViewController.h"
|
|
|
|
|
-#import "SearchViewController.h"
|
|
|
|
|
-
|
|
|
|
|
-@interface RARootViewController () <UITableViewDelegate,UITableViewDataSource>
|
|
|
|
|
-
|
|
|
|
|
-@property (weak, nonatomic) IBOutlet UITableView *modeTableView;
|
|
|
|
|
-@property (nonatomic,strong) NSMutableArray<RAModel *> *modeArray;
|
|
|
|
|
-
|
|
|
|
|
-@end
|
|
|
|
|
-
|
|
|
|
|
-@implementation RARootViewController
|
|
|
|
|
-
|
|
|
|
|
-- (void)viewDidLoad {
|
|
|
|
|
- [super viewDidLoad];
|
|
|
|
|
- // Do any additional setup after loading the view, typically from a nib.
|
|
|
|
|
- [self removeFirstResponderTap]; // 截断了Cell响应
|
|
|
|
|
- self.automaticallyAdjustsScrollViewInsets = NO;
|
|
|
|
|
- self.modeTableView.tableHeaderView = [UIView new];
|
|
|
|
|
- self.modeTableView.tableFooterView = [UIView new];
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-- (void)didReceiveMemoryWarning {
|
|
|
|
|
- [super didReceiveMemoryWarning];
|
|
|
|
|
- // Dispose of any resources that can be recreated.
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-#pragma mark - Lazy Load
|
|
|
|
|
-
|
|
|
|
|
-- (NSMutableArray<RAModel *> *)modeArray {
|
|
|
|
|
- if (!_modeArray) {
|
|
|
|
|
- _modeArray = [NSMutableArray array];
|
|
|
|
|
- }
|
|
|
|
|
- return _modeArray;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-#pragma mark - Public
|
|
|
|
|
-
|
|
|
|
|
-- (void)setModeList:(NSArray *)modeList {
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < modeList.count; i++) {
|
|
|
|
|
-
|
|
|
|
|
- NSDictionary *mode_dic = [modeList objectAtIndex:i];
|
|
|
|
|
- RAModel *model = [[RAModel alloc] init];
|
|
|
|
|
- [model setValuesForKeysWithDictionary:mode_dic];
|
|
|
|
|
- [self.modeArray addObject:model];
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-#pragma mark - TableView Delegate & DataSource
|
|
|
|
|
-
|
|
|
|
|
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
|
|
- return self.modeArray.count;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
- RARootModeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mode_cell" forIndexPath:indexPath];
|
|
|
|
|
- RAModel *model = [self.modeArray objectAtIndex:indexPath.row];
|
|
|
|
|
- [cell setModel:model];
|
|
|
|
|
- return cell;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
- return 40.f;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
- RARootModeCell *cell = [tableView cellForRowAtIndexPath:indexPath];
|
|
|
|
|
- RAModel *model = cell.model;
|
|
|
|
|
-
|
|
|
|
|
- if ([model.type isEqualToString:@"predef_query"]) {
|
|
|
|
|
- [self processPredefQueryModel:model];
|
|
|
|
|
-
|
|
|
|
|
- } else if ([model.type isEqualToString:@"query"]) {
|
|
|
|
|
- [self processQueryModel:model];
|
|
|
|
|
-
|
|
|
|
|
- } else if ([model.type isEqualToString:@"local_func"]) {
|
|
|
|
|
- [self processLocalFunModel:model];
|
|
|
|
|
-
|
|
|
|
|
- } else if ([model.type isEqualToString:@"submode"]) {
|
|
|
|
|
- [self processSubmodeModel:model];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-#pragma mark - Private
|
|
|
|
|
-
|
|
|
|
|
-- (void) processPredefQueryModel:(RAModel *)model {
|
|
|
|
|
-// RAPredefQueryViewController *preQueryVC = [[UIStoryboard storyboardWithName:@"RAPredefQuery" bundle:nil] instantiateInitialViewController];
|
|
|
|
|
-// preQueryVC.query_id = [model.query_id integerValue];
|
|
|
|
|
-// preQueryVC.title = model.name;
|
|
|
|
|
-
|
|
|
|
|
- ResultViewController *preQueryVC = [[UIStoryboard storyboardWithName:@"Result" bundle:nil] instantiateViewControllerWithIdentifier:@"ResultViewController"];
|
|
|
|
|
- [preQueryVC setQueryParams: @{
|
|
|
|
|
- @"query_id" : model.query_id
|
|
|
|
|
- }];
|
|
|
|
|
-
|
|
|
|
|
- [self.navigationController pushViewController:preQueryVC animated:YES];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-- (void) processQueryModel:(RAModel *)model {
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- SearchViewController *queryVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"SearchViewController"];
|
|
|
|
|
-
|
|
|
|
|
- queryVC.params = [NSMutableDictionary dictionary];
|
|
|
|
|
- queryVC.request_url = @"search_ui";
|
|
|
|
|
- queryVC.url_type = URL_LOCAL;
|
|
|
|
|
-
|
|
|
|
|
- // BViewController *vc =[BViewController new];//[ self.storyboard instantiateViewControllerWithIdentifier:@"commonVC"];
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// [self presentViewController:vc animated:true completion:nil];
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// RAQueryViewController *queryVC = [[UIStoryboard storyboardWithName:@"RAQuery" bundle:nil] instantiateInitialViewController];
|
|
|
|
|
-// queryVC.url = model.url;
|
|
|
|
|
-// queryVC.title = model.name;
|
|
|
|
|
- [self.navigationController pushViewController:queryVC animated:YES];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-- (void) processLocalFunModel:(RAModel *)model {
|
|
|
|
|
-
|
|
|
|
|
- if ([model.module isEqualToString:@"tools_change_pwd"]) {
|
|
|
|
|
- NSLog(@"change password");
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-- (void) processSubmodeModel:(RAModel *)model {
|
|
|
|
|
- RARootViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"RARootViewController"];
|
|
|
|
|
- vc.title = model.name;
|
|
|
|
|
- [vc setModeList:model.mode_list];
|
|
|
|
|
- [self.navigationController pushViewController:vc animated:YES];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-@end
|
|
|