Procházet zdrojové kódy

1.修改NPD离线Place Order Ship From 、Freight Bill To、Merchandise Bill To、Return To数据结构,并完成Save。
2.修改NPD Place Order增加数据变更时Enum类型判断。

Pen Li před 8 roky
rodič
revize
46218edc2d

+ 3 - 0
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.h

@@ -116,4 +116,7 @@
 #pragma mark - request Editor
 -(NSDictionary*)request_Editor:(NSString*) request_url params:(NSMutableDictionary*)params;
 
+// plae order 有调用
+-(NSMutableDictionary*) enum_subitem_changed:(NSMutableDictionary *) item subid:(NSArray*) subid value:(NSMutableDictionary*)value step:(int) step;
+
 @end

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 576 - 252
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m


+ 419 - 0
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -3894,5 +3894,424 @@
     });
 }
 
+-(void) handle_action_return:(NSMutableDictionary *)value indexPath :(NSIndexPath*) indexPath action:(int) action_code
+{
+    DebugLog(@"commoneditor return %ld_%ld",(long)indexPath.section,(long)indexPath.row);
+    NSMutableDictionary* section_json=nil;
+    
+    NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
+    
+    bool is_subaction = [value[@"is_subaction"] boolValue];
+    int subaction_tag= [value[@"subaction_tag"] intValue];
+    [value removeObjectForKey:@"is_subaction"];
+    [value removeObjectForKey:@"subaction_tag"];
+    if(is_subaction)
+    {
+        NSMutableDictionary* sub_action = [[item_json objectForKey:[NSString stringWithFormat:@"item_%d",subaction_tag]] mutableCopy];
+        int refresh = [[sub_action valueForKey:@"refresh"] intValue];
+        NSString* refresh_trigger = [sub_action valueForKey:@"name"];
+        NSDictionary * restore_json=[sub_action objectForKeyedSubscript:@"restore"];
+        
+        
+        
+        NSString* subid=[sub_action valueForKey:@"subid"];
+        
+        UITableViewCell *cell = [self.editorTable cellForRowAtIndexPath:indexPath];
+        
+        NSString* required = [sub_action valueForKey:@"required"];
+        if([required isEqualToString:@"true"] && value.count==0)
+        {
+            CALayer *layer = [cell.contentView layer];
+            //            layer.borderColor = [[UIColor redColor] CGColor];
+            //            layer.borderWidth = 1.0;
+            
+            layer.shadowColor = [UIColor redColor].CGColor;
+            layer.shadowOffset = CGSizeMake(0, 0);
+            layer.shadowOpacity = 1;
+            layer.shadowRadius = 2.0;
+        }
+        else
+        {
+            CALayer *layer = [cell.contentView layer];
+            //            layer.borderColor = [[UIColor redColor] CGColor];
+            //            layer.borderWidth = 1.0;
+            
+            layer.shadowColor = [UIColor clearColor].CGColor;
+            layer.shadowOffset = CGSizeMake(0, 0);
+            layer.shadowOpacity = 1;
+            layer.shadowRadius = 2.0;
+        }
+        if(value.count!=0)
+        {
+            
+            if(action_code==ACTION_SAVE_DATA)
+            {
+                [sub_action setObject:value forKey:@"data"];
+                
+                
+                if(subid==nil)
+                {
+                    [sub_action setValue:@"true" forKey:@"dirty"];
+                    section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+                    int count=0;
+                    
+                    count=[[section_json valueForKey:@"count"] intValue];
+                    
+                    for(int i=0;i<count;i++)
+                    {
+                        NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]];
+                        if([[olditem valueForKey:@"name"] isEqualToString:[sub_action valueForKey:@"name" ]])
+                        {
+                            // sub_action = [item_json objectForKey:[NSString stringWithFormat:@"item_%d",[value[@"subaction_tag"] intValue]]];
+                            [item_json setObject:sub_action forKey:[NSString stringWithFormat:@"item_%d",[value[@"subaction_tag"] intValue]]];
+                            [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",i ]];
+                        }
+                        
+                    }
+                }
+                else
+                {
+                    
+                    assert(@"not impl");
+                    NSArray* idarr=[subid componentsSeparatedByString:@"_"];
+                    int section = [(NSString*)idarr[0] intValue];
+                    int item=[(NSString*)idarr[1] intValue];
+                    
+                    
+                    section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
+                    NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]];
+                    sub_action= [self enum_subitem_changed:[olditem mutableCopy] subid:idarr value:sub_action step:2];
+                    [sub_action setValue:@"true" forKey:@"dirty"];
+                    
+                    [item_json setObject:sub_action forKey:[NSString stringWithFormat:@"item_%d",[value[@"subaction_tag"] intValue]]];
+                    [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",item ]];
+                    
+                }
+            }
+            else if(action_code==ACTION_FILL_SECTION)
+            {
+                
+                if(subid==nil)
+                {
+                    NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
+                    section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+                    int icount=[[section_json valueForKey:@"count"] intValue];
+                    for (int ic=0;ic<icount;ic++)
+                    {
+                        NSMutableDictionary* modify_item= [[section_json objectForKey:[NSString stringWithFormat:@"item_%d",ic ]] mutableCopy];
+                        
+                        NSString* valuefrom= [jsonmap valueForKey:[modify_item valueForKey:@"name"]];
+                        
+                        NSString* valuestr= [value valueForKey:valuefrom];
+                        
+                        if(valuestr !=nil)
+                        {
+                            // 2018-01-19 Place Order Select Ship To未刷新State Enum
+                            NSString *control = [modify_item objectForKey:@"control"];
+                            if ([control isEqualToString:@"enum"]) {
+                                NSMutableDictionary *cadedate = [[modify_item objectForKey:@"cadedate"] mutableCopy];
+                                int count = [[cadedate objectForKey:@"count"] intValue];
+                                for (int i = 0; i < count; i++) {
+                                    NSString *key = [NSString stringWithFormat:@"val_%d",i];
+                                    NSMutableDictionary *val = [[cadedate objectForKey:key] mutableCopy];
+                                    int check = [[val objectForKey:@"check"] intValue];
+                                    NSString *val_id = [val objectForKey:@"value_id"];
+                                    NSString *val_value = [val objectForKey:@"value"];
+                                    // state 通过id判断, country 通过value判断
+                                    if (check == 1 && (![val_id isEqualToString:valuestr] && ![val_value isEqualToString:valuestr])) {
+                                        check = 0;
+                                        [val setObject:@(check) forKey:@"check"];
+                                        [cadedate setObject:val forKey:key];
+                                    }
+                                    
+                                    if ([val_id isEqualToString:valuestr] || [val_value isEqualToString:valuestr]) {
+                                        check = 1;
+                                        [val setObject:@(check) forKey:@"check"];
+                                        [cadedate setObject:val forKey:key];
+                                    }
+                                    
+                                }
+                                [modify_item setObject:cadedate forKey:@"cadedate"];
+                            } else {
+                                [modify_item setValue:valuestr forKey:@"value"];
+                            }
+                            
+                            //                            [modify_item setValue:valuestr forKey:@"value"];
+                            
+                            [modify_item setValue:@"true" forKey:@"dirty"];
+                            [section_json setObject:modify_item  forKey:[NSString stringWithFormat:@"item_%d",ic ]];
+                        }
+                    }
+                }
+                else
+                {
+                    
+                    NSArray* idarr=[subid componentsSeparatedByString:@"_"];
+                    int section = [(NSString*)idarr[0] intValue];
+                    int item=[(NSString*)idarr[1] intValue];
+                    NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
+                    
+                    section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
+                    NSMutableDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]] mutableCopy];
+                    NSMutableDictionary* olditem_sub_action = [[olditem objectForKey:[NSString stringWithFormat:@"item_%d",subaction_tag]] mutableCopy];
+                    
+                    olditem_sub_action=   [self fill_switch_subitem:olditem subid:nil source:value mapping:jsonmap ];
+                    
+                    
+                    [olditem_sub_action setValue:@"true" forKey:@"dirty"];
+                    [olditem setObject:olditem_sub_action forKey:[NSString stringWithFormat:@"item_%d",[value[@"subaction_tag"] intValue]]];
+                    [section_json setObject:olditem  forKey:[NSString stringWithFormat:@"item_%d",item ]];
+                    
+                }
+                
+                
+                
+            }
+            
+            
+            
+            //    [section_json setObject:sub_action forKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row ]];
+            
+            [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+        }
+        
+        DebugLog(@"CONTENT UPDATE:%@",[RAConvertor DataTOjsonString:self.content_data_download]);
+        self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
+        
+        
+        
+        if(refresh==1)
+        {
+            
+            if(restore_json!=nil)
+            {
+                int rc=[[restore_json valueForKey:@"count"] intValue];
+                for(int ir=0;ir<rc;ir++)
+                {
+                    NSString* name = [restore_json valueForKey:[NSString stringWithFormat:@"item_%d",ir]];
+                    
+                    
+                    int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
+                    for(int i=0;i<section_count;i++)
+                    {
+                        NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
+                        //                    NSMutableDictionary * to_sectionjson = [[to objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
+                        int item_count = [[sectionjson valueForKey:@"count"] intValue];
+                        for(int j=0;j<item_count;j++)
+                        {
+                            NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
+                            //             NSMutableDictionary * to_itemjson=[[to_sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
+                            
+                            if([[itemjson valueForKey:@"name"] isEqualToString:name])
+                            {
+                                [itemjson removeObjectForKey:@"dirty"];
+                                [sectionjson setObject:itemjson forKey:[NSString stringWithFormat:@"item_%d",j ]];
+                            }
+                            
+                        }
+                        [self.content_data_download setObject:sectionjson forKey:[NSString stringWithFormat:@"section_%d",i ]];
+                    }
+                    
+                    
+                }
+                
+            }
+            [self refresh:refresh_trigger] ;
+            return ;
+        }
+        
+        
+        
+        //    DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
+        [self.editorTable reloadData ];
+        
+    }
+    else
+    {
+        
+        
+        
+        int refresh = [[item_json valueForKey:@"refresh"] intValue];
+        NSString* refresh_trigger = [item_json valueForKey:@"name"];
+        NSDictionary * restore_json=[item_json objectForKeyedSubscript:@"restore"];
+        
+        
+        
+        NSString* subid=[item_json valueForKey:@"subid"];
+        
+        UITableViewCell *cell = [self.editorTable cellForRowAtIndexPath:indexPath];
+        
+        NSString* required = [item_json valueForKey:@"required"];
+        if([required isEqualToString:@"true"] && value.count==0)
+        {
+            CALayer *layer = [cell.contentView layer];
+            //            layer.borderColor = [[UIColor redColor] CGColor];
+            //            layer.borderWidth = 1.0;
+            
+            layer.shadowColor = [UIColor redColor].CGColor;
+            layer.shadowOffset = CGSizeMake(0, 0);
+            layer.shadowOpacity = 1;
+            layer.shadowRadius = 2.0;
+        }
+        else
+        {
+            CALayer *layer = [cell.contentView layer];
+            //            layer.borderColor = [[UIColor redColor] CGColor];
+            //            layer.borderWidth = 1.0;
+            
+            layer.shadowColor = [UIColor clearColor].CGColor;
+            layer.shadowOffset = CGSizeMake(0, 0);
+            layer.shadowOpacity = 1;
+            layer.shadowRadius = 2.0;
+        }
+        if(value.count!=0)
+        {
+            
+            if(action_code==ACTION_SAVE_DATA)
+            {
+                [item_json setObject:value forKey:@"data"];
+                
+                
+                if(subid==nil)
+                {
+                    [item_json setValue:@"true" forKey:@"dirty"];
+                    section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+                    int count=0;
+                    
+                    count=[[section_json valueForKey:@"count"] intValue];
+                    
+                    for(int i=0;i<count;i++)
+                    {
+                        NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]];
+                        if([[olditem valueForKey:@"name"] isEqualToString:[item_json valueForKey:@"name" ]])
+                            [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",i ]];
+                        
+                        
+                    }
+                }
+                else
+                {
+                    
+                    assert(@"not impl");
+                    NSArray* idarr=[subid componentsSeparatedByString:@"_"];
+                    int section = [(NSString*)idarr[0] intValue];
+                    int item=[(NSString*)idarr[1] intValue];
+                    
+                    
+                    section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
+                    NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]];
+                    item_json= [self enum_subitem_changed:[olditem mutableCopy] subid:idarr value:item_json step:2];
+                    [item_json setValue:@"true" forKey:@"dirty"];
+                    [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",item ]];
+                    
+                }
+            }
+            else if(action_code==ACTION_FILL_SECTION)
+            {
+                
+                if(subid==nil)
+                {
+                    NSDictionary* jsonmap=[item_json valueForKey:@"key_map"];
+                    section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+                    int icount=[[section_json valueForKey:@"count"] intValue];
+                    for (int ic=0;ic<icount;ic++)
+                    {
+                        NSMutableDictionary* modify_item= [[section_json objectForKey:[NSString stringWithFormat:@"item_%d",ic ]] mutableCopy];
+                        
+                        NSString* valuefrom= [jsonmap valueForKey:[modify_item valueForKey:@"name"]];
+                        
+                        NSString* valuestr= [value valueForKey:valuefrom];
+                        
+                        if(valuestr !=nil)
+                        {
+                            
+                            [modify_item setValue:valuestr forKey:@"value"];
+                            
+                            [modify_item setValue:@"true" forKey:@"dirty"];
+                            [section_json setObject:modify_item  forKey:[NSString stringWithFormat:@"item_%d",ic ]];
+                        }
+                    }
+                }
+                else
+                {
+                    
+                    NSArray* idarr=[subid componentsSeparatedByString:@"_"];
+                    int section = [(NSString*)idarr[0] intValue];
+                    int item=[(NSString*)idarr[1] intValue];
+                    NSDictionary* jsonmap=[item_json valueForKey:@"key_map"];
+                    
+                    section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
+                    NSMutableDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]] mutableCopy];
+                    
+                    olditem=   [self fill_switch_subitem:olditem subid:nil source:value mapping:jsonmap ];
+                    
+                    
+                    [olditem setValue:@"true" forKey:@"dirty"];
+                    [section_json setObject:olditem  forKey:[NSString stringWithFormat:@"item_%d",item ]];
+                    
+                }
+                
+                
+                
+            }
+            
+            
+            
+            //    [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row ]];
+            
+            [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+        }
+        
+        DebugLog(@"CONTENT UPDATE:%@",[RAConvertor DataTOjsonString:self.content_data_download]);
+        self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
+        
+        
+        
+        if(refresh==1)
+        {
+            
+            if(restore_json!=nil)
+            {
+                int rc=[[restore_json valueForKey:@"count"] intValue];
+                for(int ir=0;ir<rc;ir++)
+                {
+                    NSString* name = [restore_json valueForKey:[NSString stringWithFormat:@"item_%d",ir]];
+                    
+                    
+                    int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
+                    for(int i=0;i<section_count;i++)
+                    {
+                        NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
+                        //                    NSMutableDictionary * to_sectionjson = [[to objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
+                        int item_count = [[sectionjson valueForKey:@"count"] intValue];
+                        for(int j=0;j<item_count;j++)
+                        {
+                            NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
+                            //             NSMutableDictionary * to_itemjson=[[to_sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
+                            
+                            if([[itemjson valueForKey:@"name"] isEqualToString:name])
+                            {
+                                [itemjson removeObjectForKey:@"dirty"];
+                                [sectionjson setObject:itemjson forKey:[NSString stringWithFormat:@"item_%d",j ]];
+                            }
+                            
+                        }
+                        [self.content_data_download setObject:sectionjson forKey:[NSString stringWithFormat:@"section_%d",i ]];
+                    }
+                    
+                    
+                }
+                
+            }
+            [self refresh:refresh_trigger] ;
+            return ;
+        }
+        
+        
+        
+        //    DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
+        [self.editorTable reloadData ];
+    }
+}
 
 @end

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů