Bläddra i källkod

Redant mobile
修复common editor 带排序的多选控件无法排序和偶尔闪退的bug。
修复查询结果行双击闪退的问题。这个是后台传的数据有问题。
修改查询结果行双击,支持多重操作。单一操作直接执行,多重操作让用户选择。
修复查询结果下拉刷新没有清空旧数据的问题

Ray Zhang 8 år sedan
förälder
incheckning
f7d787ebf2

BIN
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/ray.xcuserdatad/UserInterfaceState.xcuserstate


+ 1 - 1
RedAnt ERP Mobile/common/CommonEditor/EnumSelectAndSort/EnumModel.h

@@ -13,7 +13,7 @@
 @property (nonatomic,assign) BOOL check;
 @property (nonatomic,assign) NSString* value_id;
 @property (nonatomic,copy) NSString *value;
-@property (nonatomic,assign) NSInteger sort_id;
+//@property (nonatomic,assign) NSInteger sort_id;
 
 - (void)setJsonValue:(NSDictionary *)json forSortId:(NSInteger)sortId;
 

+ 1 - 1
RedAnt ERP Mobile/common/CommonEditor/EnumSelectAndSort/EnumModel.m

@@ -16,7 +16,7 @@
 
 - (void)setJsonValue:(NSDictionary *)json forSortId:(NSInteger)sortId {
     [self setValuesForKeysWithDictionary:json];
-    self.sort_id = sortId;
+//    self.sort_id = sortId;
 }
 
 @end

+ 26 - 20
RedAnt ERP Mobile/common/CommonEditor/EnumSelectAndSort/EnumSelectAndSortViewController.m

@@ -153,18 +153,18 @@
         
     }
     
-    [_arrayDataSource sortUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {
-     
-        EnumModel *model1 = (EnumModel *)obj1;
-        EnumModel *model2 = (EnumModel *)obj2;
-        
-        if (model1.sort_id > model2.sort_id) {
-            return NSOrderedDescending;
-        } else {
-            return NSOrderedAscending;
-        }
-        
-    }];
+//    [_arrayDataSource sortUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {
+//
+//        EnumModel *model1 = (EnumModel *)obj1;
+//        EnumModel *model2 = (EnumModel *)obj2;
+//
+//        if (model1.sort_id > model2.sort_id) {
+//            return NSOrderedDescending;
+//        } else {
+//            return NSOrderedAscending;
+//        }
+//
+//    }];
     
     [self.enumTableView reloadData];
 }
@@ -235,6 +235,9 @@
 
 -(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
     
+    if(sourceIndexPath.row == destinationIndexPath.row)
+        return;
+    
     EnumModel *source_model = [_arrayDataSource objectAtIndex:sourceIndexPath.row];
     
     // 修改数据源中的排序
@@ -243,16 +246,19 @@
         [_arrayDataSource insertObject:source_model atIndex:destinationIndexPath.row];
     } else {
         [_arrayDataSource removeObject:source_model];
-        [_arrayDataSource insertObject:source_model atIndex:destinationIndexPath.row - 1];
+        [_arrayDataSource insertObject:source_model atIndex:destinationIndexPath.row];
     }
     
-    // 修改Model Sort Id
-    [_arrayDataSource enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
-        EnumModel *model = (EnumModel *)obj;
-        model.sort_id = idx;
-        
-    }];
+    NSLog(@"move %ld to %ld",sourceIndexPath.row,destinationIndexPath.row);
+//    // 修改Model Sort Id
+//    [_arrayDataSource enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+//
+//        EnumModel *model = (EnumModel *)obj;
+//        model.sort_id = idx;
+//
+//    }];
+    
+    
 }
 
 #pragma mark - Action

+ 1 - 1
RedAnt Mobile/RedAnt Mobile/ResultViewController.h

@@ -12,7 +12,7 @@
 @property (weak, nonatomic) IBOutlet UITableView *tableview;
 @property (weak, nonatomic) IBOutlet UIScrollView *scrollview;
 @property (strong, nonatomic) NSMutableDictionary* content_layout;
-@property (strong, nonatomic) NSMutableDictionary* content_action;
+@property (strong, nonatomic) NSMutableArray* content_action;
 @property (strong, nonatomic) NSMutableDictionary* content_data;
 @property (strong, nonatomic) NSMutableArray* content_menu;
 @property (strong, nonatomic) UILabel *label;

+ 202 - 60
RedAnt Mobile/RedAnt Mobile/ResultViewController.m

@@ -104,90 +104,220 @@ static const int delta = 25;
     //strongSelf.content_action
     if(self.content_action!=nil)
     {
-        NSString * module =  self.content_action[@"module"];
-        if([module isEqualToString:@"quick_look"])
+        
+        if(self.content_action.count==1)
         {
-            
-//            +(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url
-            NSMutableDictionary *params = self.content_action[@"params"];
-            NSString* URL =self.content_action[@"url"];
-            __weak typeof(self) weakSelf = self;
-            dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            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 = action[@"params"];
                 
                 
-                NSString *path = [RANetwork download_file:params url:URL];
-                weakSelf.documentPath = path;
+                UIAlertView * waitalert = [RAUtils waiting_alert:@"Loading..." title:@"Please wait"];
                 
-                if (path) {
+                
+                __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(), ^{
-                        [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
+                        [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"])
+            {
                 
-            });
-        }
-        else if([module isEqualToString:@"kv_detail"])
-        {
-                NSMutableDictionary *params = self.content_action[@"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), ^{
+                OrderDetailViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderDetailViewController"];
                 
                 
+                vc.url_type = URL_REMOTE;
+                vc.request_url=URL_ORDER_DETAIL;
                 
-                NSDictionary* json =[RANetwork kv_detail:params];
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+                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;
+            }
+        }
+        else
+        {
+            
+            UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Menu" 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([[json valueForKey:@"result"] intValue]==2)
+                    if([module isEqualToString:@"quick_look"])
                     {
-                        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];
+                        //            +(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
+                    else if([module isEqualToString:@"order_detail"])
                     {
-                        [RAUtils message_alert:json[@"msg"] title:nil controller:weakself] ;
+                        
+                        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;
                     }
-                    
-                    
-                    
-                    
-                });
-            });
-        }
-        else if([module isEqualToString:@"order_detail"])
-        {
-            
-                OrderDetailViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderDetailViewController"];
+                    // 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");
                 
-                vc.url_type = URL_REMOTE;
-                vc.request_url=URL_ORDER_DETAIL;
+            }];
+            [alertControl addAction:actionCancel];
             
             
-                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;
+            
+            
+            
+            [self presentViewController:alertControl animated:NO completion:nil];
+            
         }
+
     }
     
   
@@ -618,6 +748,10 @@ static const int delta = 25;
             case 0:
             case 1: {
                 self.offset = 0;
+                self.content_layout =nil;
+                self.content_action = nil;
+                self.content_menu = nil;
+                self.content_data = nil;
             }
             break;
             case 2: {
@@ -749,8 +883,16 @@ static const int delta = 25;
     int option = 0;
     if ([refresh isEqual:self.tableview.jl_header]) {
         option = 1;
+        
+        
+        
+
+        
+        
     }
     if (refresh == self.tableview.jl_footer) {
+        if(refresh.state==JLRefreshStateNoMore) //数据取完不再加载
+            return;
         option = 2;
     }
     __weak typeof(self) weakSelf = self;

+ 2 - 2
RedAnt Mobile/RedAnt Mobile/predef_query.json

@@ -20,7 +20,7 @@
              "action": "save"
              }
              ],
-    "row_action": {
+    "row_action": [{
         "title": "demo title",
         "module0":"quick_look",
         "module1": "kv_detail",
@@ -28,7 +28,7 @@
         "url": "http://1.1.1.1",
         "params": {
             "order#": 0
-        }
+        }]
     },
     "data": {
         "count": 17,

+ 4 - 1
common/NetworkUtils.m

@@ -142,7 +142,8 @@ repeat:
         NSHTTPURLResponse* urlResponse = nil;
         
         NSError *error = nil;
-        
+        NSLog(@"begin request");
+
         NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
         
         
@@ -150,6 +151,8 @@ repeat:
         
         DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
         
+        
+        NSLog(@"get response");
         if (responseData==nil) {
             
             //            DebugLog(@"response error:%@", [error localizedDescription]);