Browse Source

1.修改iOS Apex Mobile保存Result。

Pen Li 7 years ago
parent
commit
17532fc9cb

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

@@ -46,5 +46,6 @@
 
 + (NSDictionary *)uploadUserSql:(NSString *)sql;
 + (NSDictionary *)fetchResultParameters:(NSMutableDictionary *)params;
++ (NSDictionary *)saveSearchParameters:(NSString *)paramStr forModule:(NSString *)module;
 
 @end

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

@@ -1561,4 +1561,30 @@
     
 }
 
++ (NSDictionary *)saveSearchParameters:(NSString *)paramStr forModule:(NSString *)module {
+    if (!paramStr || !module) {
+        return @{
+                 @"result" : @RESULT_FALSE,
+                 @"err_msg" : @"Sorry, something is wrong."
+                 };
+    }
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    [params setValue:paramStr forKey:@"params"];
+    [params setValue:module forKey:@"module_name"];
+    
+    NSData *json=[self get_json:URL_SAVE_RESULT 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

+ 21 - 13
Apex Mobile/Apex Mobile/Result/ApexResultViewController.m

@@ -16,6 +16,8 @@
 #import "RAProgressHUD.h"
 #import "RAUtils.h"
 #import "MyQLPreviewController.h"
+#import "CustomizeFieldViewController.h"
+
 
 @interface ApexResultViewController ()<ApexResultProtocol, JLRefreshDelegate>
 
@@ -26,6 +28,8 @@
 @property (nonatomic,strong) ApexResultPresenter *presenter;
 @property (nonatomic,strong) MyQLPreviewController *quickLook;
 
+@property (nonatomic,assign) BOOL dirty;
+
 @end
 
 @implementation ApexResultViewController
@@ -49,6 +53,15 @@
     [self.presenter loadData];
 }
 
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+    
+    if (self.dirty) {
+        self.dirty = NO;
+        [self.presenter loadData];
+    }
+}
+
 #pragma mark - Setup
 
 - (void)setupPresenter {
@@ -84,11 +97,6 @@
     self.navigationItem.backBarButtonItem = backItem;
 }
 
-- (void)_setParameters:(NSDictionary *)params {
-    self.params = params;
-    [self.presenter modifyParameters:params];
-}
-
 #pragma mark - Getter
 
 - (UITableView *)tableView {
@@ -229,14 +237,14 @@
 
 - (void)showFieldsSetting {
     
-//    // 返回show fields
-//    NSArray *showFields;
-//
-//    // 修改params
-//    NSString *columns = [showFields componentsJoinedByString:@","];
-//    NSMutableDictionary *mParams = [self.presenter.params mutableCopy];
-//    mParams[@"columns"] = columns;
-//    [self _setParameters:mParams.copy];
+    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 = YES;
+    
+    [self.navigationController pushViewController:ViewController animated:YES];
+    
 }
 
 @end

+ 35 - 0
Apex Mobile/Apex Mobile/Result/Presenter/ApexResultPresenter.m

@@ -152,6 +152,41 @@ static const NSInteger detal = 20;
 
 - (void)saveSearchParameters {
     
+    NSString *module_name = [self.params objectForKey:@"module_name"];
+    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.params options:NSJSONWritingPrettyPrinted error:nil];
+    NSString *paramStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
+    
+    if (self.delegate) {
+        [self.delegate onStartLoading];
+    }
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+       
+        NSDictionary *json = [RANetwork saveSearchParameters:paramStr forModule:module_name];
+        int result = [[json objectForKey:@"result"] intValue];
+        if (result == RESULT_TRUE) {
+            
+            dispatch_async(dispatch_get_main_queue(), ^{
+                
+                if (self.delegate) {
+                    [self.delegate onStopLoading];
+                }
+            });
+            
+        } else {
+            NSString *err_msg = [json objectForKey:@"err_msg"];
+            if (err_msg.length == 0) {
+                err_msg = @"Sorry, something is wrong.";
+            }
+            dispatch_async(dispatch_get_main_queue(), ^{
+                
+                if (self.delegate) {
+                    [self.delegate onStopLoading];
+                    [self.delegate onFailed:err_msg];
+                }
+            });
+        }
+        
+    });
 }
 
 #pragma mark - Field Modify

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

@@ -38,6 +38,7 @@
 
 // 2019.1.4
 #define URL_UPLOAD_SQL     @"http://192.168.2.138/Online/Online/main_new.php"
+#define URL_SAVE_RESULT     @"http://192.168.2.138/Online/Online/main_new.php"
 
 #else
 
@@ -58,6 +59,7 @@
 
 // 2019.1.4
 #define URL_UPLOAD_SQL     @"https://ra.apexshipping.com/main_new.php"
+#define URL_SAVE_RESULT     @"https://ra.apexshipping.com/main_new.php"
 
 #endif