Browse Source

1.修改Apex Mobile Result,完成用户交互。
2.修改Apex Mobile History,增加网络访问。
3.修改Apex Mobile Search,解决按钮变灰。

Pen Li 8 years ago
parent
commit
1f85914269

+ 302 - 242
Apex Mobile/Apex Mobile/AMResultViewController.m

@@ -10,9 +10,15 @@
 #import "const.h"
 #import "const.h"
 #import "RANetwork.h"
 #import "RANetwork.h"
 #import "RAUtils.h"
 #import "RAUtils.h"
+#import "DetailTabBarController.h"
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored"-Wdeprecated-declarations"
 
 
 @interface AMResultViewController ()
 @interface AMResultViewController ()
 
 
+@property (nonatomic,assign) BOOL dirty;
+
 @end
 @end
 
 
 @implementation AMResultViewController
 @implementation AMResultViewController
@@ -55,14 +61,67 @@
 }
 }
 
 
 - (void)viewDidLoad {
 - (void)viewDidLoad {
+    
+    NSMutableArray* header_name =[[NSMutableArray alloc]init];
+    NSMutableArray* header_aname =[[NSMutableArray alloc]init];
+    [self getHeader:header_name header_aname:header_aname];
+    NSString* fields =@"";
+    for(int i=0;i<header_name.count;i++)
+    {
+        fields=[fields stringByAppendingFormat:@"%@,",header_name[i]];
+        
+    }
+    fields=[fields substringToIndex: fields.length-1];
+    
+    [self.params setValue:fields forKey:@"columns"];
+    
+    // 参数设置放在Super前
+    
     [super viewDidLoad];
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     // Do any additional setup after loading the view.
     
     
+//    NSString* title=@"";
+//    NSString *module_name = [self.params objectForKey:@"module_name"];
+//    if([module_name isEqualToString:@"Ocean Booking"])
+//        title = @"Booking Result";
+//    else if([module_name isEqualToString:@"Ocean B/L info."])
+//        title = @"B/L info. Result";
+//    else if([module_name isEqualToString:@"Container detail"])
+//        title = @"Container Result";
+//    else if([module_name isEqualToString:@"Download Document"])
+//        title = @"Document Result";
+//    self.title = title;
+    
+    
     [self resetContraint];
     [self resetContraint];
     [self configureTableView];
     [self configureTableView];
     
     
 }
 }
 
 
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+    
+    if(self.dirty ==true)
+    {
+        NSMutableArray* header_name =[[NSMutableArray alloc]init];
+        NSMutableArray* header_aname =[[NSMutableArray alloc]init];
+        [self getHeader:header_name header_aname:header_aname];
+
+        NSString* fields =@"";
+        for(int i=0;i<header_name.count;i++)
+        {
+            fields=[fields stringByAppendingFormat:@"%@,",header_name[i]];
+            
+        }
+        fields=[fields substringToIndex: fields.length-1];
+        
+        [self.params setValue:fields forKey:@"columns"];
+        [self loadContent];
+        
+        self.dirty = false;
+    }
+}
+
 - (void)didReceiveMemoryWarning {
 - (void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];
     [super didReceiveMemoryWarning];
     // Dispose of any resources that can be recreated.
     // Dispose of any resources that can be recreated.
@@ -98,12 +157,13 @@
         __weak typeof(self) weakSelf = self;
         __weak typeof(self) weakSelf = self;
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
             
             
-            NSString *path = [[NSBundle mainBundle] pathForResource:@"fake_search.json" ofType:nil];
-            NSData *data = [[NSData alloc] initWithContentsOfFile:path];
-            NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
-            
-            NSDictionary *contentDic = json;
+//            NSString *path = [[NSBundle mainBundle] pathForResource:@"fake_search.json" ofType:nil];
+//            NSData *data = [[NSData alloc] initWithContentsOfFile:path];
+//            NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
+//
+//            NSDictionary *contentDic = json;
             
             
+            NSDictionary *contentDic = [RANetwork search:[self.params mutableCopy]];
             
             
             NSInteger result = [[contentDic objectForKey:@"result"] integerValue];
             NSInteger result = [[contentDic objectForKey:@"result"] integerValue];
             dispatch_async(dispatch_get_main_queue(), ^{
             dispatch_async(dispatch_get_main_queue(), ^{
@@ -148,258 +208,258 @@
 }
 }
 
 
 
 
+
+- (void)showDetailForIndexPath:(NSIndexPath *)indexPath {
+    
+    NSArray *actions = [self getActions];
+    if (actions.count < 1) {
+        return;
+    }
+    
+    NSArray* arr_col=self.content_layout[@"header"][@"col"];
+    
+    NSArray* item =self.content_data[[NSString stringWithFormat:@"item_%ld",indexPath.row]];
+    
+    NSString *detail_id = item[arr_col.count];
+    NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary:self.params copyItems:true];
+    [params setValue:detail_id forKey:@"id"];
+    NSString *module_name = [self.params objectForKey:@"module_name"];
+    DetailTabBarController *detailViewController=[[DetailTabBarController alloc] init:module_name actions:actions params:params];
+    
+    if (detailViewController) {
+        [self.navigationController pushViewController:detailViewController animated:YES];
+    }
+}
+
 -(void)cellDoubleTapAction:(UIGestureRecognizer*)gestureRecognizer
 -(void)cellDoubleTapAction:(UIGestureRecognizer*)gestureRecognizer
 {
 {
-    
-    NSAssert(true, ([NSString stringWithFormat:@"%s cellDoubleTapAction not impl",object_getClassName([self class])]));
+    UITableViewCell *cell = (UITableViewCell *)[gestureRecognizer view];
+    NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
+    [self showDetailForIndexPath:indexPath];
+}
+
+- (void)presses3DTouchForIndexPath:(NSIndexPath *)indexPath {
+    [self showDetailForIndexPath:indexPath];
 }
 }
-//{
-//    NSLog(@"cell double tap");
-//        UITableViewCell* cell = (UITableViewCell*)[gestureRecognizer view];
-//    NSIndexPath* indexPath=[self.tableview indexPathForCell:cell];
-//    //strongSelf.content_action
-//    if(self.content_action!=nil)
+
+/*
+#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.
+}
+*/
+
+-(void)Export:(NSString*) url
+{
+//    if(self.download_query )
 //    {
 //    {
+//        self.documentPath = self.download_query;
+//        [self.navigationController pushViewController:self.quickLook animated:NO];
+//        return;
+//    }
 //
 //
-//        if(self.content_action.count==1)
-//        {
-//            NSDictionary* action =self.content_action.firstObject;
-//            NSString * module =  action[@"module"];
-//            if([module isEqualToString:@"quick_look"])
-//            {
-//
-//                //            +(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url
-//                NSMutableDictionary *params = action[@"params"];
-//                NSString* URL =action[@"url"];
-//                __weak typeof(self) weakSelf = self;
-//                dispatch_async(dispatch_get_global_queue(0, 0), ^{
-//
-//
-//                    NSString *path = [RANetwork download_file:params url:URL];
-//                    weakSelf.documentPath = path;
-//
-//                    if (path) {
-//                        dispatch_async(dispatch_get_main_queue(), ^{
-//                            [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
-//                        });
-//                    }
-//
-//                });
-//            }
-//            else if([module isEqualToString:@"kv_detail"])
-//            {
-//                NSMutableDictionary *params = [NSMutableDictionary new];
-//                params[@"query_id"] = self.params[@"query_id"];
-//
-//                NSMutableDictionary *criteria =[NSMutableDictionary new];
-//                for(NSString* key in [action[@"params"] allKeys] )
-//                {
-//                    NSArray* item =self.content_data[[NSString stringWithFormat:@"item_%ld",indexPath.row]];
-//                    int idx =[action[@"params"][key] intValue];
-//                    criteria[key]=item[ idx];
-//                }
-//
-//
-//                params[@"criteria"]=[RAConvertor dict2string:criteria] ;
-//
-//
-//
-//                UIAlertView * waitalert = [RAUtils waiting_alert:@"Loading..." title:@"Please wait"];
-//
-//
-//                __weak typeof(self) weakself = self;
-//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//
-//
-//                    NSDictionary* json =[RANetwork kv_detail:params];
-//
-//                    dispatch_async(dispatch_get_main_queue(), ^{
-//                        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//
-//                        if([[json valueForKey:@"result"] intValue]==2)
-//                        {
-//                            KVViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"KVViewController"];
-//                            vc.content = [json mutableCopy];
-//                            [weakself.navigationController pushViewController:vc animated:NO];
-//
-//                            //                        weakself.content_data_download = [weakself CopyDirty:weakself.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
-//                            //
-//                            //                        weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed: weakself.changed_data];
-//                            //
-//                            //
-//                            //                        [weakself download_success];
-//                            //                        [weakself.editorTable reloadData];
-//
-//                        }
-//                        else
-//                        {
-//                            [RAUtils message_alert:json[@"msg"] title:nil controller:weakself] ;
-//                        }
-//
-//
-//
-//
-//                    });
-//                });
-//            }
-//            else if([module isEqualToString:@"order_detail"])
-//            {
-//
-//                OrderDetailViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderDetailViewController"];
-//
-//
-//                vc.url_type = URL_REMOTE;
-//                vc.request_url=URL_ORDER_DETAIL;
+//    __weak typeof(self) weakSelf = self;
+//    dispatch_async(dispatch_get_global_queue(0, 0), ^{
 //
 //
+////        NSMutableDictionary *params = self.params.mutableCopy;
+////        if(add_params!=nil)
+////           [params addEntriesFromDictionary:add_params];
+//        NSString *path = [RANetwork download_query:url];
+//        weakSelf.download_query = path;
+//        weakSelf.documentPath = path;
 //
 //
-//                vc.params = [NSMutableDictionary dictionary];
-//                //                NSString *path = [[NSBundle mainBundle] pathForResource:@"search_ui.json" ofType:nil];
-//                //                NSData *data = [NSData dataWithContentsOfFile:path];
-//                //                vc.content_data_download = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil] mutableCopy];
-//                [self.navigationController pushViewController:vc animated:NO];
-//                return;
-//            }
+//        if (path) {
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//                [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
+//            });
 //        }
 //        }
-//        else
-//        {
-//
-//            UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"" message:nil preferredStyle:UIAlertControllerStyleAlert];
-//            //block代码块取代了delegate
-//
-//            __weak typeof(self) weakSelf = self;
-//            for(int i=0;i<self.content_action.count;i++)
-//            {
-//                NSMutableDictionary* json = self.content_action[i];
-//                NSString* title =json[@"title"];
-//                NSString* module = json[@"module"];
-//                NSMutableDictionary* add_params = json[@"params"];
-//                UIAlertAction *actioni = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-//
-//
-//                    if([module isEqualToString:@"quick_look"])
-//                    {
-//
-//                        //            +(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url
-//                        NSMutableDictionary *params = json[@"params"];
-//                        NSString* URL =json[@"url"];
-//                        __weak typeof(self) weakSelf = self;
-//                        dispatch_async(dispatch_get_global_queue(0, 0), ^{
-//
-//
-//                            NSString *path = [RANetwork download_file:params url:URL];
-//                            weakSelf.documentPath = path;
-//
-//                            if (path) {
-//                                dispatch_async(dispatch_get_main_queue(), ^{
-//                                    [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
-//                                });
-//                            }
-//
-//                        });
-//                    }
-//                    else if([module isEqualToString:@"kv_detail"])
-//                    {
-//                        NSMutableDictionary *params = json[@"params"];
-//
-//
-//                        UIAlertView * waitalert = [RAUtils waiting_alert:@"Loading..." title:@"Please wait"];
-//
-//
-//                        __weak typeof(self) weakself = self;
-//                        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//
-//
-//                            NSDictionary* json =[RANetwork kv_detail:params];
-//
-//                            dispatch_async(dispatch_get_main_queue(), ^{
-//                                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//
-//                                if([[json valueForKey:@"result"] intValue]==2)
-//                                {
-//                                    KVViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"KVViewController"];
-//                                    vc.content = [json mutableCopy];
-//                                    [weakself.navigationController pushViewController:vc animated:NO];
-//
-//                                    //                        weakself.content_data_download = [weakself CopyDirty:weakself.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
-//                                    //
-//                                    //                        weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed: weakself.changed_data];
-//                                    //
-//                                    //
-//                                    //                        [weakself download_success];
-//                                    //                        [weakself.editorTable reloadData];
-//
-//                                }
-//                                else
-//                                {
-//                                    [RAUtils message_alert:json[@"msg"] title:nil controller:weakself] ;
-//                                }
-//
-//
-//
-//
-//                            });
-//                        });
-//                    }
-//                    else if([module isEqualToString:@"order_detail"])
-//                    {
-//
-//                        OrderDetailViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderDetailViewController"];
-//
-//
-//                        vc.url_type = URL_REMOTE;
-//                        vc.request_url=URL_ORDER_DETAIL;
-//
-//
-//                        vc.params = [NSMutableDictionary dictionary];
-//                        //                NSString *path = [[NSBundle mainBundle] pathForResource:@"search_ui.json" ofType:nil];
-//                        //                NSData *data = [NSData dataWithContentsOfFile:path];
-//                        //                vc.content_data_download = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil] mutableCopy];
-//                        [self.navigationController pushViewController:vc animated:NO];
-//                        return;
-//                    }
-//                    // DebugLog(@"Cancel");
-////                    if([actiontype isEqualToString:@"download"])
-////                    {
-////                        [weakSelf Export:add_params];
-////                    }
-////                    else if([actiontype isEqualToString:@"save"])
-////                    {
-////                    }
-//                }];
-//                [alertControl addAction:actioni];
-//            }
-//
-//            UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-//                // DebugLog(@"Cancel");
-//
-//            }];
-//            [alertControl addAction:actionCancel];
-//
-//
 //
 //
+//    });
+}
+- (void)downloadItemClick:(UIBarButtonItem *)sender {
+
+//    if(self.download_query )
+//    {
+//        self.documentPath = self.download_query;
+//        [self.navigationController pushViewController:self.quickLook animated:NO];
+//        return;
+//    }
 //
 //
+//    __weak typeof(self) weakSelf = self;
+//    dispatch_async(dispatch_get_global_queue(0, 0), ^{
 //
 //
-//            [self presentViewController:alertControl animated:NO completion:nil];
+//        NSMutableDictionary *params = self.params.mutableCopy;
+//        NSString *path = [RANetwork download_query:params];
+//        weakSelf.download_query = path;
+//        weakSelf.documentPath = path;
 //
 //
+//        if (path) {
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//                [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
+//            });
 //        }
 //        }
 //
 //
-//    }
-//
-//
-//
-//}
-/*
-#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.
 }
 }
-*/
+
+- (void)save {
+    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"alert_title_create_tag", nil) message:NSLocalizedString(@"alert_msg_savehint", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", nil) otherButtonTitles:NSLocalizedString(@"save", nil),nil];
+    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
+    [alert show];
+}
+
+- (void)fieldSetting {
+    
+    NSString *module_name = [self.params objectForKey:@"module_name"];
+    CustomizeFieldViewController *ViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CustomizeFieldViewController"];
+    ViewController.function_name = module_name;
+    ViewController.behavior =BEHAVIOR_RESULT;
+    self.dirty=true;
+    
+    [self.navigationController pushViewController:ViewController animated:YES];
+}
+
+- (void)MenuClick:(UIBarButtonItem *)sender {
+    
+    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Menu" message:nil preferredStyle:UIAlertControllerStyleAlert];
+    //block代码块取代了delegate
+    
+    __weak typeof(self) weakSelf = self;
+    for(int i=0;i<self.content_menu.count;i++)
+    {
+        NSMutableDictionary* json = self.content_menu[i];
+        NSString* title =json[@"title"];
+        NSString* actiontype = json[@"action"];
+        NSString* url = json[@"url"];
+
+        UIAlertAction *actioni = [UIAlertAction actionWithTitle:NSLocalizedString([title lowercaseString], nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+
+            if([actiontype isEqualToString:@"download"])
+            {
+                [weakSelf Export:url];
+            }
+            else if([actiontype isEqualToString:@"save"])
+            {
+                [weakSelf save];
+            }
+            else if([actiontype isEqualToString:@"field_setting"])
+            {
+                [weakSelf fieldSetting];
+            }
+        }];
+        [alertControl addAction:actioni];
+    }
+    
+    UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+        // DebugLog(@"Cancel");
+        
+    }];
+    [alertControl addAction:actionCancel];
+    
+    [self presentViewController:alertControl animated:NO completion:nil];
+}
+
+
+#pragma mark - GridResult
+
+- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+{
+    
+    if(buttonIndex!=alertView.cancelButtonIndex)
+    {
+        UITextField * txt=[alertView textFieldAtIndex:0];
+        NSString* name = txt.text;
+        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.params
+                                                           options:0
+                                                             error:nil];
+        NSString* param = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
+        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+        NSString* user = appDelegate.user;
+        
+        sqlite3 *db =[ApexMobileDB get_db];
+        NSString *module_name = [self.params objectForKey:@"module_name"];
+        
+        [ApexMobileDB execSql: [NSString stringWithFormat: @"insert into history(params,name,module_name,user) values('%@','%@','%@','%@')",param,name,module_name,user] db:db];
+        
+        sqlite3_close(db);
+    }
+    
+    
+}
+
+- (NSArray*)getActions
+{
+    DebugLog(@"getActions");
+    
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    NSString *module_name = [self.params objectForKey:@"module_name"];
+    
+    NSMutableArray* actions = [[NSMutableArray alloc]init];
+    sqlite3 *db =[ApexMobileDB get_db];
+    NSString *quary = [NSString stringWithFormat:@"select name from actions_info where function_name='%@' and user='%@'order by priority",module_name, appDelegate.user];
+    
+    
+    
+    sqlite3_stmt *stmt;
+    
+    if (sqlite3_prepare_v2(db, [quary UTF8String], -1, &stmt, nil) == SQLITE_OK) {
+        DebugLog(@"sql:%@",quary);
+        DebugLog(@"=======================show tabs===================");
+        while (sqlite3_step(stmt)==SQLITE_ROW)
+        {
+            
+            NSString *name = [[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(stmt, 0)];
+            [actions addObject:name];
+            DebugLog(@"action name: %@",name);
+        }
+        DebugLog(@"=======================show tabs===================");
+        sqlite3_finalize(stmt);
+    }
+    //用完了一定记得关闭,释放内存
+    sqlite3_close(db);
+    return actions;
+}
+
+- (void)getHeader: (NSMutableArray*)header_name header_aname:(NSMutableArray*)header_aname
+{
+    //    NSMutableDictionary* header = [[NSMutableDictionary alloc] init];
+    //    [header setValue:@"aaa" forKey:@"bbb"];
+    DebugLog(@"initHeader");
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    NSString *module_name = [self.params objectForKey:@"module_name"];
+    
+    sqlite3 *db =[ApexMobileDB get_db];
+    NSString *quary = [NSString stringWithFormat:@"select aname,name from fields_info where function_name='%@' and user='%@' and behavior=%d and show=1 order by priority,aname",module_name, appDelegate.user,BEHAVIOR_RESULT];
+    
+    
+    
+    sqlite3_stmt *stmt;
+    
+    if (sqlite3_prepare_v2(db, [quary UTF8String], -1, &stmt, nil) == SQLITE_OK) {
+        DebugLog(@"sql:%@",quary);
+        DebugLog(@"=======================show fields===================");
+        while (sqlite3_step(stmt)==SQLITE_ROW)
+        {
+            NSString *aname = [[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(stmt, 0)];
+            NSString *name = [[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(stmt, 1)];
+            //            [header setValue:aname forKey:name];
+            [header_name addObject:name];
+            [header_aname addObject:aname];
+            DebugLog(@"%@",aname);
+            
+        }
+        DebugLog(@"=======================show fields===================");
+        sqlite3_finalize(stmt);
+    }
+    //用完了一定记得关闭,释放内存
+    sqlite3_close(db);
+    //    return header;
+}
 
 
 @end
 @end
+
+#pragma clang diagnostic pop

+ 1 - 1
Apex Mobile/Apex Mobile/AppDelegate.m

@@ -229,7 +229,7 @@ void UncaughtExceptionHandler(NSException *exception) {
     [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:APGRAYCOLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
     [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:APGRAYCOLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
     
     
     // Nav Bar
     // Nav Bar
-    [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:APREDCOLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
+    [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:APREDCOLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted];
     [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:APGRAYCOLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
     [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:APGRAYCOLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
     [[UIBarButtonItem appearance] setTintColor:APGRAYCOLOR];
     [[UIBarButtonItem appearance] setTintColor:APGRAYCOLOR];
 }
 }

+ 1 - 0
Apex Mobile/Apex Mobile/Base.lproj/Localizable.strings

@@ -47,3 +47,4 @@
 "alert_msg_change_success"="Change success.";
 "alert_msg_change_success"="Change success.";
 "alert_msg_password_notequal"="New password not equal confirm password!";
 "alert_msg_password_notequal"="New password not equal confirm password!";
 "ask_click"="\nClick for more detail";
 "ask_click"="\nClick for more detail";
+"fields setting"="Setting";

+ 12 - 4
Apex Mobile/Apex Mobile/HistoryViewController.m

@@ -7,6 +7,7 @@
 //
 //
 
 
 #import "HistoryViewController.h"
 #import "HistoryViewController.h"
+#import "AMResultViewController.h"
 
 
 @interface HistoryViewController ()
 @interface HistoryViewController ()
 
 
@@ -126,9 +127,9 @@
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
 {
     
     
-    GridResultViewController *resultViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ResultViewController"];
+//    GridResultViewController *resultViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ResultViewController"];
     
     
-    resultViewController.function_name = [self.data.pagedata[indexPath.row] valueForKey:@"module_name"];
+//    resultViewController.function_name = [self.data.pagedata[indexPath.row] valueForKey:@"module_name"];
 
 
     NSString* str_params =[self.data.pagedata[indexPath.row] valueForKey:@"params"];
     NSString* str_params =[self.data.pagedata[indexPath.row] valueForKey:@"params"];
     NSData* data_params = [str_params dataUsingEncoding:NSUTF8StringEncoding];
     NSData* data_params = [str_params dataUsingEncoding:NSUTF8StringEncoding];
@@ -140,8 +141,15 @@
                                                                                    options:NSJSONReadingMutableLeaves
                                                                                    options:NSJSONReadingMutableLeaves
                                                                                    error:nil] copyItems:true];
                                                                                    error:nil] copyItems:true];
 
 
-    resultViewController.params =params;
-    [self.navigationController pushViewController:resultViewController animated:YES];
+    [params setValue:[self.data.pagedata[indexPath.row] valueForKey:@"module_name"] forKey:@"module_name"];
+    
+//    resultViewController.params =params;
+//    [self.navigationController pushViewController:resultViewController animated:YES];
+    
+    
+    AMResultViewController *resultVC = [[AMResultViewController alloc] initWithNibName:@"Result" bundle:nil];
+    resultVC.params = params;
+    [self.navigationController pushViewController:resultVC animated:YES];
 }
 }
 - (UITableViewCellEditingStyle)tableView:(UITableView *)tv editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
 - (UITableViewCellEditingStyle)tableView:(UITableView *)tv editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
     
     

+ 42 - 44
Apex Mobile/Apex Mobile/OrderHistoryViewController.m

@@ -127,18 +127,28 @@ static const int history_delta = 7;
 - (void)loadContentWithOption:(int)option Complete:(void (^)(int result,int count))finish {
 - (void)loadContentWithOption:(int)option Complete:(void (^)(int result,int count))finish {
     
     
     NSInteger offset = 0;
     NSInteger offset = 0;
+    
     if (option == 2) {
     if (option == 2) {
         offset = self.shipArray.count;
         offset = self.shipArray.count;
+    } else {
+        offset = 0;
     }
     }
+    
     [self.loadIndicator startAnimating];
     [self.loadIndicator startAnimating];
     
     
+    NSMutableDictionary *params = [@{
+                                    @"offset" : @(offset),
+                                    @"limit"  : @(history_delta)
+                                    } mutableCopy];
+    
     __weak typeof(self) weakSelf = self;
     __weak typeof(self) weakSelf = self;
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
        
-        NSString *path = [[NSBundle mainBundle] pathForResource:@"fake_container_list.json" ofType:nil];
-        NSData *data = [[NSData alloc] initWithContentsOfFile:path];
-        NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
-        
+//        NSString *path = [[NSBundle mainBundle] pathForResource:@"fake_container_list.json" ofType:nil];
+//        NSData *data = [[NSData alloc] initWithContentsOfFile:path];
+//        NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
+
+        NSDictionary *json = [RANetwork requestOrderHistory:params];
         dispatch_async(dispatch_get_main_queue(), ^{
         dispatch_async(dispatch_get_main_queue(), ^{
             
             
             [weakSelf.loadIndicator stopAnimating];
             [weakSelf.loadIndicator stopAnimating];
@@ -152,19 +162,12 @@ static const int history_delta = 7;
                 count = (int)contentArray.count;
                 count = (int)contentArray.count;
                 
                 
                 switch (option) {
                 switch (option) {
-                    case 0: {
+                    case 0:
+                    case 1: {
                         [weakSelf.shipArray removeAllObjects];
                         [weakSelf.shipArray removeAllObjects];
                         [weakSelf.shipArray addObjectsFromArray:contentArray];
                         [weakSelf.shipArray addObjectsFromArray:contentArray];
                     }
                     }
                         break;
                         break;
-                    case 1: {
-                        [contentArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-                           
-                            [weakSelf.shipArray insertObject:obj atIndex:0];
-                            
-                        }];
-                    }
-                        break;
                     case 2: {
                     case 2: {
                         [weakSelf.shipArray addObjectsFromArray:contentArray];
                         [weakSelf.shipArray addObjectsFromArray:contentArray];
                     }
                     }
@@ -239,37 +242,32 @@ static const int history_delta = 7;
 
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     
     
-//    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
-//
-//    [params setObject:@"dumb" forKey:@"id"];
-//    NSString* h_field;
-//    //if(self.radioContainer.selected==true)
-//    //{
-//    //    [params setObject:@"1" forKey:@"criterion_type"];
-//    //    h_field = @"ctnr";
-//    //}
-//    //else
-//    {
-//        [params setObject:@"0" forKey:@"criterion_type"];
-//        h_field = @"h_bol";
-//    }
-//
-//    NSDictionary *item = [self.shipArray objectAtIndex:indexPath.section];
-//    NSString * cargo_criterion = item[@"hbol"];
-//    if(cargo_criterion==nil)
-//        cargo_criterion=@"";
-//    [params setObject:cargo_criterion forKey:@"cargo_criterion"];
-//
-//
-//    [ApexMobileDB savehistory:h_field value:cargo_criterion];
-//
-//    DetailTabBarController *detailViewController=[[DetailTabBarController alloc] init:@"Cargo Tracking" actions:[NSArray arrayWithObjects:@"Tracking",nil] params:params];
-//    [self.navigationController pushViewController:detailViewController animated:YES];
-    
-    
-    AMResultViewController *resultVC = [[AMResultViewController alloc] initWithNibName:@"Result" bundle:nil];
-    resultVC.params = [NSMutableDictionary dictionary];
-    [self.navigationController pushViewController:resultVC animated:YES];
+    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
+
+    [params setObject:@"dumb" forKey:@"id"];
+    NSString* h_field;
+    //if(self.radioContainer.selected==true)
+    //{
+    //    [params setObject:@"1" forKey:@"criterion_type"];
+    //    h_field = @"ctnr";
+    //}
+    //else
+    {
+        [params setObject:@"0" forKey:@"criterion_type"];
+        h_field = @"h_bol";
+    }
+
+    NSDictionary *item = [self.shipArray objectAtIndex:indexPath.section];
+    NSString * cargo_criterion = item[@"hbol"];
+    if(cargo_criterion==nil)
+        cargo_criterion=@"";
+    [params setObject:cargo_criterion forKey:@"cargo_criterion"];
+
+
+    [ApexMobileDB savehistory:h_field value:cargo_criterion];
+
+    DetailTabBarController *detailViewController=[[DetailTabBarController alloc] init:@"Cargo Tracking" actions:[NSArray arrayWithObjects:@"Tracking",nil] params:params];
+    [self.navigationController pushViewController:detailViewController animated:YES];
     
     
 }
 }
 
 

+ 2 - 0
Apex Mobile/Apex Mobile/RANetwork.h

@@ -38,4 +38,6 @@
 +(bool) UpdateServiceLocation;
 +(bool) UpdateServiceLocation;
 + (NSDictionary *)collectErrMsg:(NSString *)errMsg DeviceInfo:(NSString *)deviceInfo Time:(NSString *)time;
 + (NSDictionary *)collectErrMsg:(NSString *)errMsg DeviceInfo:(NSString *)deviceInfo Time:(NSString *)time;
 + (NSDictionary *)requestHome;
 + (NSDictionary *)requestHome;
++ (NSDictionary *)search:(NSMutableDictionary *)params;
++ (NSDictionary *)requestOrderHistory:(NSMutableDictionary *)params;
 @end
 @end

+ 38 - 0
Apex Mobile/Apex Mobile/RANetwork.m

@@ -1229,4 +1229,42 @@
     
     
 }
 }
 
 
++ (NSDictionary *)search:(NSMutableDictionary *)params {
+    
+    [params setObject:@"handset_search" forKey:@"action"];
+    
+    NSData* json=[self get_json:URL_REQUEST_COUNT parameters:params  file:nil];
+    
+    if (json==nil)
+    {
+        return @{
+                 @"result" : @RESULT_NET_ERROR,
+                 @"err_msg" : MSG_NET_ERROR
+                 };
+    }
+    
+    NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:nil];
+    
+    return resultDic;
+}
+
++ (NSDictionary *)requestOrderHistory:(NSMutableDictionary *)params {
+    
+    [params setObject:@"hand_new_home_list_all" forKey:@"action"];
+    
+    NSData* json=[self get_json:URL_HISTORY parameters:params  file:nil];
+    
+    if (json==nil)
+    {
+        return @{
+                 @"result" : @RESULT_NET_ERROR,
+                 @"err_msg" : MSG_NET_ERROR
+                 };
+    }
+    
+    NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:nil];
+    
+    return resultDic;
+}
+
 @end
 @end

+ 19 - 5
Apex Mobile/Apex Mobile/SearchViewController.m

@@ -100,6 +100,7 @@
 }
 }
 - (void)viewWillAppear:(BOOL)animated
 - (void)viewWillAppear:(BOOL)animated
 {
 {
+    [super viewWillAppear:animated];
       DebugLog(@"viewWillAppear");
       DebugLog(@"viewWillAppear");
     if(self.dirty ==true)
     if(self.dirty ==true)
     {
     {
@@ -110,12 +111,17 @@
         self.dirty=false;
         self.dirty=false;
     }
     }
     [self.table reloadData];
     [self.table reloadData];
+    
+    // 解决Items按钮灰色
+    self.navigationItem.rightBarButtonItem.enabled = false;
+    self.navigationItem.rightBarButtonItem.enabled = true;
 }
 }
 //-(void) viewWillDisappear:(BOOL)animated
 //-(void) viewWillDisappear:(BOOL)animated
 //{
 //{
 //    [[self view] endEditing:animated];
 //    [[self view] endEditing:animated];
 //}
 //}
 - (IBAction)onCustomize:(UIBarButtonItem *)sender {
 - (IBAction)onCustomize:(UIBarButtonItem *)sender {
+    
     CustomizeFieldViewController *ViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CustomizeFieldViewController"];
     CustomizeFieldViewController *ViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CustomizeFieldViewController"];
     ViewController.function_name = self.function_name;
     ViewController.function_name = self.function_name;
     ViewController.behavior =BEHAVIOR_SEARCH;
     ViewController.behavior =BEHAVIOR_SEARCH;
@@ -124,7 +130,6 @@
     //    ViewController.
     //    ViewController.
     
     
     [self.navigationController pushViewController:ViewController animated:YES];
     [self.navigationController pushViewController:ViewController animated:YES];
-    
 }
 }
 
 
 - (void)didReceiveMemoryWarning
 - (void)didReceiveMemoryWarning
@@ -316,8 +321,7 @@
 
 
 - (IBAction)SearchBtnOnClick:(UIButton *)sender {
 - (IBAction)SearchBtnOnClick:(UIButton *)sender {
     
     
-    GridResultViewController *resultViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ResultViewController"];
-    resultViewController.function_name = self.function_name;
+    
 //    if([self.function_name isEqualToString:@"Document Download"])
 //    if([self.function_name isEqualToString:@"Document Download"])
 //        resultViewController.fullrow_select =false;
 //        resultViewController.fullrow_select =false;
 //    else
 //    else
@@ -351,8 +355,18 @@
         }
         }
     }
     }
     [params setValue:self.function_name forKey:@"module_name"];
     [params setValue:self.function_name forKey:@"module_name"];
-    resultViewController.params =params;
-    [self.navigationController pushViewController:resultViewController animated:YES];
+    
+    
+//    GridResultViewController *resultViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ResultViewController"];
+//    resultViewController.function_name = self.function_name;
+//    resultViewController.params =params;
+//    [self.navigationController pushViewController:resultViewController animated:YES];
+    
+    
+    
+    AMResultViewController *resultVC = [[AMResultViewController alloc] initWithNibName:@"Result" bundle:nil];
+    resultVC.params = params;
+    [self.navigationController pushViewController:resultVC animated:YES];
     
     
 //    AMResultViewController *resultVC = [[AMResultViewController alloc] initWithNibName:@"Result" bundle:nil];
 //    AMResultViewController *resultVC = [[AMResultViewController alloc] initWithNibName:@"Result" bundle:nil];
 //    [self.navigationController pushViewController:resultVC animated:YES];
 //    [self.navigationController pushViewController:resultVC animated:YES];

+ 3 - 2
Apex Mobile/Apex Mobile/config.h

@@ -21,7 +21,8 @@
 
 
 
 
 #define URL_HOME                @"http://192.168.0.155/Online/Online/main_new.php"
 #define URL_HOME                @"http://192.168.0.155/Online/Online/main_new.php"
-#define URL_UPDATE_AUTH         @"http://192.168.0.155/Online/Online/login_new.php"
+#define URL_HISTORY             @"http://192.168.0.155/Online/Online/main_new.php"
+#define URL_UPDATE_AUTH         @"http://192.168.0.155/Online/Online/main_new.php"
 #define URL_REQUEST_COUNT       @"http://192.168.0.155/Online/Online/main_new.php"
 #define URL_REQUEST_COUNT       @"http://192.168.0.155/Online/Online/main_new.php"
 #define URL_REQUEST_RECORDS     @"http://192.168.0.155/Online/Online/main_new.php"
 #define URL_REQUEST_RECORDS     @"http://192.168.0.155/Online/Online/main_new.php"
 #define URL_RETRIEVE_PASS       @"http://192.168.0.155/Online/Online/main_new.php"
 #define URL_RETRIEVE_PASS       @"http://192.168.0.155/Online/Online/main_new.php"
@@ -36,7 +37,7 @@
 #else
 #else
 
 
 
 
-#define URL_UPDATE_AUTH         @"https://ra.apexshipping.com/login_new.php"
+#define URL_UPDATE_AUTH         @"https://ra.apexshipping.com/main_new.php"
 #define URL_REQUEST_COUNT       @"https://ra.apexshipping.com/main_new.php"
 #define URL_REQUEST_COUNT       @"https://ra.apexshipping.com/main_new.php"
 #define URL_REQUEST_RECORDS     @"https://ra.apexshipping.com/main_new.php"
 #define URL_REQUEST_RECORDS     @"https://ra.apexshipping.com/main_new.php"
 #define URL_RETRIEVE_PASS       @"https://ra.apexshipping.com/main_new.php"
 #define URL_RETRIEVE_PASS       @"https://ra.apexshipping.com/main_new.php"

+ 1 - 0
Apex Mobile/Apex Mobile/zh-Hans.lproj/Localizable.strings

@@ -46,3 +46,4 @@
 "alert_msg_change_success"="修改成功";
 "alert_msg_change_success"="修改成功";
 "alert_msg_password_notequal"="新密码两次输入不一致。";
 "alert_msg_password_notequal"="新密码两次输入不一致。";
 "ask_click"="\n点击查看详细信息";
 "ask_click"="\n点击查看详细信息";
+"fields setting"="设置字段";