Răsfoiți Sursa

Recant mobile

command editor. Range 提取参数
Ray Zhang 8 ani în urmă
părinte
comite
35e904b469

+ 122 - 1
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -790,7 +790,128 @@
                         }
                     }
                 }
-            
+            else if ([[itemjson valueForKey:@"control"] isEqualToString:@"range"])
+            {
+               
+                if([itemjson valueForKey:@"min_value"]!=nil && ![[itemjson valueForKey:@"min_value"]isEqualToString:@""] &&[itemjson valueForKey:@"max_value"]!=nil && ![[itemjson valueForKey:@"max_value"]isEqualToString:@""])
+                {
+                    NSMutableDictionary* valjson = [NSMutableDictionary new];
+                    if([itemjson valueForKey:@"min_value"]!=nil && ![[itemjson valueForKey:@"min_value"]isEqualToString:@""])
+                        valjson[@"min"] = itemjson[@"min_value"];
+             if([itemjson valueForKey:@"max_value"]!=nil && ![[itemjson valueForKey:@"max_value"]isEqualToString:@""])
+                 valjson[@"max"] = itemjson[@"max_value"];
+                    
+                    NSString* val=[RAConvertor dict2string:valjson];
+//                    NSString *keyboard_type = [itemjson objectForKey:@"keyboard"];
+//                    BOOL check_max = [itemjson objectForKey:@"max_type"] != nil ? YES : NO;
+//                    BOOL check_min = [itemjson objectForKey:@"min_type"] != nil ? YES : NO;
+//                    if ([keyboard_type isEqualToString:@"number"] && (check_max || check_min)) {
+//                        // 检查最大值最小值
+//                        int max_type = [[itemjson objectForKey:@"max_type"] intValue];
+//                        int min_type = [[itemjson objectForKey:@"min_type"] intValue];
+//
+//                        float max_value = MAXFLOAT;
+//                        float min_value = 0;
+//
+//                        NSString *mfield = nil;
+////                        float f_value = [check_len_val floatValue];
+////
+////                        if (check_max) {
+////
+////                            if (max_type > 0) {
+////                                // key
+////                                NSString *max_key = [itemjson objectForKey:@"max"];
+////                                id max_obj = [self downloadValueForKey:max_key];
+////                                if (max_obj) {
+////                                    max_value = [max_obj floatValue];
+////                                }
+////
+////                            } else {
+////                                // value
+////                                id max_obj = [itemjson objectForKey:@"max"];
+////                                if (max_obj != nil) {
+////                                    max_value = [max_obj floatValue];
+////                                }
+////
+////                            }
+////
+////                            if (max_value < f_value) {
+////                                mfield =[NSString stringWithFormat:@"%ld. the value of %@ must be not larger than %.2f",fields.count+1,itemjson[@"aname"],max_value];
+////                            }
+////                        }
+//
+////                        if (check_min) {
+////
+////                            if (min_type > 0) {
+////                                // key
+////                                NSString *min_key = [itemjson objectForKey:@"min"];
+////                                id min_obj = [self downloadValueForKey:min_key];
+////                                if (min_obj) {
+////                                    min_value = [min_obj floatValue];
+////                                }
+////                            } else {
+////                                // value
+////                                id min_obj = [itemjson objectForKey:@"min"];
+////                                if (min_obj != nil) {
+////                                    min_value = [min_obj floatValue];
+////                                }
+////                            }
+////
+////                            if (min_value > f_value) {
+////                                mfield =[NSString stringWithFormat:@"%ld. the value of %@ must be not smaller than %.2f",fields.count+1,itemjson[@"aname"],min_value];
+////                            }
+////                        }
+//
+//
+////                        if (check_min && check_max) {
+////                            if (f_value < min_value || f_value > max_value) {
+////                                mfield =[NSString stringWithFormat:@"%ld. the value of %@ must between %.2f and %.2f",fields.count+1,itemjson[@"aname"],min_value,max_value];
+////                            }
+////                        }
+//
+//                        if (mfield != nil) {
+//                            self.cancommit = false;
+//                            [fields addObject:mfield];
+//                            NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
+//                            if(alert)
+//                                [self unhide_section:(int)indexpath.section];
+//                            if(fields.count==1)
+//                            {
+//                                self.first_miss_pos =  indexpath;
+//
+//                            }
+//                        } else {
+//                            [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
+//                        }
+//
+//                    } else
+//                    {
+                        [upparams setValue:val forKey:[itemjson valueForKey:@"name"]];
+//                    }
+                    
+                }
+                else
+                {
+                    if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
+                    {
+                        self.cancommit = false;
+                        NSString* mfield =[NSString stringWithFormat:@"%lu. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                        
+                        
+                        [fields addObject:mfield];
+                        
+                        
+                        NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
+                        if(alert)
+                            [self unhide_section:indexpath.section];
+                        if(fields.count==1)
+                        {
+                            self.first_miss_pos =  indexpath;
+                            
+                        }
+                    }
+                }
+            }
                 else
                 {
                     if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])