Selaa lähdekoodia

1.修改iOS Apex Mobile Result本地数据保存与查询。

Pen Li 7 vuotta sitten
vanhempi
commit
51548e28bb

+ 5 - 5
Apex Mobile/Apex Mobile/Result/ApexResultViewController.m

@@ -29,7 +29,6 @@
 @property (nonatomic,strong) MyQLPreviewController *quickLook;
 
 @property (nonatomic,strong) NSDictionary *params;
-@property (nonatomic,assign) BOOL dirty;
 
 @end
 
@@ -59,8 +58,7 @@
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     
-    if (self.dirty) {
-        self.dirty = NO;
+    if (self.presenter.dirty) {
         [self.presenter loadData];
     }
 }
@@ -241,11 +239,13 @@
 
 - (void)showFieldsSetting {
     
+    self.presenter.dirty = YES;
+    
     NSString *module_name = [self.params objectForKey:@"module_name"];
-    CustomizeFieldViewController *ViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CustomizeFieldViewController"];
+    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];
     

+ 2 - 0
Apex Mobile/Apex Mobile/Result/Presenter/ApexResultPresenter.h

@@ -20,6 +20,8 @@
 @property (nonatomic,readonly,strong) NSArray *rowActions;
 @property (nonatomic,readonly,strong) NSArray *actions;///< Detail Parameter, from query table actions_info
 @property (nonatomic,strong) NSDictionary *actionParams;///< Click Cell Action Parameters
+@property (nonatomic,assign) BOOL dirty;
+
 
 - (instancetype)initWithParameters:(NSDictionary *)params;
 

+ 16 - 6
Apex Mobile/Apex Mobile/Result/Presenter/ApexResultPresenter.m

@@ -40,6 +40,12 @@ static const NSInteger detal = 20;
             params = [NSDictionary dictionary];
         }
         self.params = params;
+        
+        if ([params.allKeys containsObject:@"columns"]) {
+            self.dirty = NO;
+        } else {
+            self.dirty = YES;
+        }
     }
     return self;
 }
@@ -124,11 +130,10 @@ static const NSInteger detal = 20;
 
 - (void)loadData {
     
-    NSString *module_name = [self.params objectForKey:@"module_name"];
-    NSString *displayFields = [RANetwork getDisplayFieldsForFunction:module_name];
-    if ([displayFields isEqualToString:self.displayFields]) {
-        return;
-    } else {
+    if (self.dirty) {
+        self.dirty = NO;
+        NSString *module_name = [self.params objectForKey:@"module_name"];
+        NSString *displayFields = [RANetwork getDisplayFieldsForFunction:module_name];
         self.displayFields = displayFields;
     }
     
@@ -171,7 +176,12 @@ static const NSInteger detal = 20;
 - (void)saveSearchParameters:(NSString *)name {
     
     NSString *module_name = [self.params objectForKey:@"module_name"];
-    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.params options:NSJSONWritingPrettyPrinted error:nil];
+    
+    NSMutableDictionary *params = [self.params mutableCopy];
+    if (self.displayFields) {
+        [params setValue:self.displayFields forKey:@"columns"];
+    }
+    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:NSJSONWritingPrettyPrinted error:nil];
     NSString *paramStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
     
     if (self.delegate) {