| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- //
- // SearchViewController.m
- // RedAnt Mobile
- //
- // Created by Ray on 10/11/2017.
- // Copyright © 2017 Ray. All rights reserved.
- //
- #import "SearchViewController.h"
- #import "RANetwork.h"
- #import "RAUtils.h"
- #import "RAResultViewController.h"
- #import "RAConvertor.h"
- @interface SearchViewController ()
- @end
- @implementation SearchViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- self.params[ @"_action"]=@"ant_mobile";
- self.params[ @"_operate"]=@"getCondition";
- self.automaticallyAdjustsScrollViewInsets = NO;
- [self setupNavigationBar];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
-
- // 解决Items按钮灰色
- self.navigationItem.rightBarButtonItem.enabled = false;
- self.navigationItem.rightBarButtonItem.enabled = true;
- }
- #pragma mark - customize editor
- - (UIView*)get_tableHeader
- {
-
- UILabel * headerview = [UILabel new];
- headerview.frame = CGRectMake(0, 0, self.editorTable.frame.size.width, 44);
- headerview.numberOfLines = 0;
- headerview.textAlignment = NSTextAlignmentCenter;
- // headerview.lineBreakMode=
- headerview.text = @"";
- return headerview;
- }
- -(void) resize_tableHeader
- {
- //利用systemLayoutSizeFittingSize:计算出真实高度
- // CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)
- // self.editorTable.tableHeaderView.frame= CGRectMake(self.editorTable.tableHeaderView.frame.origin.x, self.editorTable.tableHeaderView.frame.origin.y, self.editorTable.tableHeaderView.frame.size.width, 10000);
- CGFloat height = [self.editorTable.tableHeaderView systemLayoutSizeFittingSize:CGSizeMake(self.editorTable.tableHeaderView.frame.size.width, 10000)].height;
- CGRect headerFrame = self.editorTable.tableHeaderView.frame;
- headerFrame.size.height = height+20;//20是留的上下边距
- //修改tableHeaderView的frame
- self.editorTable.tableHeaderView.frame = headerFrame;
- }
- #pragma mark - Setup UI
- - (void)setupNavigationBar {
-
- // UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(saveItemClick:)];
- UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithTitle:@"Search" style:UIBarButtonItemStylePlain target:self action:@selector(searchItemClick:)];
-
- self.navigationItem.rightBarButtonItems = @[searchItem];
- }
- #pragma mark - Action
- - (void)searchItemClick:(UIBarButtonItem *)item {
-
- // self.content_data_download[@"hidden_params"];
-
-
-
-
- NSMutableDictionary* upparams = [self check_cancommit:false];
- [upparams addEntriesFromDictionary:self.content_data_download[@"hidden_params"]];
-
-
- NSArray* criteria = [RAConvertor Dict2KVArray:upparams trim:true];
-
-
- NSMutableDictionary* result_params = [NSMutableDictionary new];
- result_params[@"criteria"] = [RAConvertor dict2string:criteria];//criteria;
- result_params[@"query_id"]=self.params[@"query_id"];
- result_params[@"title"]=self.params[@"title"];
- // ResultViewController *preQueryVC = [[UIStoryboard storyboardWithName:@"Result" bundle:nil] instantiateViewControllerWithIdentifier:@"ResultViewController"];
- // [preQueryVC setQueryParams: result_params];
-
- RAResultViewController *preQueryVC = [RAResultViewController buildInstanceWithParams:result_params];
-
- [self.navigationController pushViewController:preQueryVC animated:YES];
-
- // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Searching"];
- // __weak typeof(self) weakSelf = self;
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- // NSDictionary *contentDic = [RANetwork query:dic];
- // NSInteger result = [[contentDic objectForKey:@"result"] integerValue];
- // dispatch_async(dispatch_get_main_queue(), ^{
- // if (weakSelf) {
- // __strong typeof(weakSelf) strongSelf = weakSelf;
- // if (result == RESULT_TRUE) {
- // strongSelf.content_layout = [contentDic objectForKey:@"layout"];
- // strongSelf.content_action = [contentDic objectForKey:@"row_action"];
- // strongSelf.content_menu = [[contentDic objectForKey:@"menu"] mutableCopy];
- // strongSelf.content_data = [contentDic objectForKey:@"data"];
- // [strongSelf updateTableFrame];
- // [strongSelf.tableview reloadData];
- // } else {
- // [RAUtils message_alert:[contentDic objectForKey:@"err_msg"] title:@"Warning" controller:strongSelf];
- // }
- //
- // if (finish) {
- // finish((int)result,(int)[self resultItemCount]);
- // }
- //
- // }
- //
- // });
- // });
-
- }
- - (void)saveItemClick:(UIBarButtonItem *)item {
-
- }
- #pragma mark Request Editor
- -(NSDictionary*)request_Editor:(NSString*) request_url params:(NSMutableDictionary*)params
- {
- NSAssert(true, @"request_editor");
- return nil;
- // NSDictionary* ret =[RANetwork require_query_ui:request_url params:params];
- // dispatch_async(dispatch_get_main_queue(), ^{
- // UILabel * headerview=(UILabel *)self.editorTable.tableHeaderView;
- // headerview.text = ret[@"table_title"];
- // [self resize_tableHeader];
- // });
- // return ret;
- }
- #pragma mark- autocomplete
- -( NSArray* )sync_loadCadidate:( NSString*)str //search_id:(NSString*) search_id
- {
- NSAssert(true, @"sync_loadCadidate");
- return nil;
- // NSIndexPath * indexPath = [self.editorTable indexPathForCell:self.editingcell];
- // NSDictionary* item_json =((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row];
- //
- // NSMutableDictionary* params = [NSMutableDictionary new];
- // params[@"query_id"]=self.params[@"query_id"];
- // params[@"name"]=item_json[@"name"];
- // params[@"keyword"]=str;
- //// params[@"request_id"]
- // NSMutableDictionary* json = [RANetwork queryAutoComplete:params];
- ////
- // NSMutableArray* ret= json[@"cadedate"];
- //// if(ret==nil)
- //// ret = [NSMutableArray new];
- //// // NSMutableArray* ret = [NSMutableArray new];
- //// // [ret addObject:@"autocomplete"];
- //// // [ret addObject:@"datasource"];
- //// // [ret addObject:@"loadCadidate"];
- //// // [ret addObject:@"does"];
- //// // [ret addObject:@"not"];
- //// // [ret addObject:@"impl"];
- // return ret;
- }
- @end
|