Ray Zhang 10 лет назад
Родитель
Сommit
cfedb2f03c

+ 49 - 1
RedAnt ERP Mobile/common/Functions/DefaultAppearance.m

@@ -17,7 +17,7 @@
 #import "ContactListTableViewCell.h"
 #import "CategoryCellNPD.h"
 #import "CommonEditorCellMAction.h"
-
+#import "DefaultImageButton.h"
 @implementation DefaultAppearance
 +(void)init_appearance
 {
@@ -104,6 +104,27 @@
             return [UIButton appearanceWhenContainedIn: arr_container[0], nil];
         }
     }
+    if([control isEqualToString:@"UISearchBar"])
+    {
+        if(container_json==nil)
+            return [UISearchBar appearance];
+        else
+        {
+            NSArray* arr_container = [self appearance_container:container_json];
+            return [UISearchBar appearanceWhenContainedIn: arr_container[0], nil];
+        }
+    }
+    if([control isEqualToString:@"DefaultImageButton"])
+    {
+        if(container_json==nil)
+            return [DefaultImageButton appearance];
+        else
+        {
+            NSArray* arr_container = [self appearance_container:container_json];
+            return [DefaultImageButton appearanceWhenContainedIn: arr_container[0], nil];
+        }
+    }
+    
     else if([control isEqualToString:@"UIActivityIndicatorView"])
         {
             if(container_json==nil)
@@ -190,8 +211,35 @@
     // json 中添加 function 类型必须在此函数中添加对应代码
     if([function isEqualToString:@"setTitleColor.Normal"])
     {
+        if([value isEqualToString:@"#clearColor"])
+        {
+            [appearance setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
+        }
+        else
+        {
         unsigned long color = strtoul([value UTF8String],0,16);
         [appearance setTitleColor:UIColorFromRGB(color) forState:UIControlStateNormal];
+        }
+    }
+    if([function isEqualToString:@"autocapitalizationType"])
+    {
+        if([value isEqualToString:@"UITextAutocapitalizationTypeNone"])
+        {
+            [appearance setAutocapitalizationType:UITextAutocapitalizationTypeNone];
+        }
+        if([value isEqualToString:@"UITextAutocapitalizationTypeWords"])
+        {
+            [appearance setAutocapitalizationType:UITextAutocapitalizationTypeWords];
+        }
+        if([value isEqualToString:@"UITextAutocapitalizationTypeSentences"])
+        {
+            [appearance setAutocapitalizationType:UITextAutocapitalizationTypeSentences];
+        }
+        if([value isEqualToString:@"UITextAutocapitalizationTypeAllCharacters"])
+        {
+            [appearance setAutocapitalizationType:UITextAutocapitalizationTypeAllCharacters];
+        }
+
     }
     else if([function isEqualToString:@"setColor"])
     {

+ 20 - 2
RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.h

@@ -8,18 +8,36 @@
 
 #import <UIKit/UIKit.h>
 #import "EnumSelectViewController.h"
-@interface CategorySearchFilterViewController : UIViewController//<EnumSelectViewControllerDelegate>
+#import "RATreeView.h"
+@interface CategorySearchFilterViewController : UIViewController<RATreeViewDelegate, RATreeViewDataSource>//<EnumSelectViewControllerDelegate>
 @property (strong, nonatomic) NSDictionary* alert_cadedate;
 @property (strong, nonatomic) NSDictionary* qty_cadedate;
 @property (strong, nonatomic) NSDictionary* availability_cadedate;
 @property (strong, nonatomic) NSDictionary* price_cadedate;
+@property (strong, nonatomic) NSDictionary* bestseller_cadedate;
+
+@property (strong,nonatomic) NSString*  categoryid;
+
+@property (strong, nonatomic) IBOutlet UIView *treeContainer;
+@property (weak, nonatomic) RATreeView *treeView;
 
 @property (strong, nonatomic) IBOutlet UIButton *buttonQTY;
 @property (strong, nonatomic) IBOutlet UIButton *buttonAlert;
 @property (strong, nonatomic) IBOutlet UIButton *buttonAvailability;
 @property (strong, nonatomic) IBOutlet UIButton *buttonPrice;
+@property (strong, nonatomic) IBOutlet UIButton *buttonBestSeller;
+
 
 @property (strong, nonatomic) IBOutlet UILabel *labelPrice;
-@property (nonatomic , copy) void (^OkClick)(NSString* available,NSString* QTY,NSString* alert,NSString* price);
+@property (nonatomic , copy) void (^OkClick)(NSString* modelname,NSString* modeldescrip,NSString* available,NSString* QTY,NSString* alert,NSString* price , NSString* bestseller);
 @property (nonatomic , copy) void (^ResetClick)(void);
+
+@property (strong, nonatomic) NSString* modelname;
+@property (strong, nonatomic) NSString* modeldescrip;
+@property (strong, nonatomic) IBOutlet UITextField *textModelName;
+@property (strong, nonatomic) IBOutlet UITextField *textModelDescription;
+
+
+
+@property (strong,nonatomic)NSDictionary* categoryMenu;
 @end

+ 266 - 140
RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.m

@@ -8,6 +8,7 @@
 
 #import "CategorySearchFilterViewController.h"
 #import "AppDelegate.h"
+#import "DefaultAppearance.h"
 
 @interface CategorySearchFilterViewController ()
 
@@ -19,6 +20,60 @@
     [super viewDidLoad];
     
     
+    RATreeView *treeView = [[RATreeView alloc] initWithFrame:self.treeContainer.frame];
+    
+    treeView.delegate = self;
+    treeView.dataSource = self;
+    treeView.separatorStyle = RATreeViewCellSeparatorStyleSingleLine;
+    
+    [treeView reloadData];
+    //  [treeView expandRowForItem:phone withRowAnimation:RATreeViewRowAnimationLeft]; //expands Row
+    [treeView setBackgroundColor:UIColorFromRGB(0xF7F7F7)];
+    
+    self.treeView = treeView;
+    //    treeView.allowsSelection = true;
+    //    treeView.allowsMultipleSelection = true;
+    
+    /*
+     
+     UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 100.000001)];
+     
+     [line setBackgroundColor:[UIColor clearColor]];
+     self.treeView.treeHeaderView = line;
+     */
+    
+    
+    NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultColor" valuename:@"frontcolor"];
+    
+    if(value==nil)
+        value=@"";
+    unsigned long frontcolor = strtoul([value UTF8String],0,16);
+    
+    UILabel *CategoryLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5.5, self.view.frame.size.width, 33)];
+    CategoryLabel.textColor=UIColorFromRGB(frontcolor);
+    //    CategoryLabel.backgroundColor = [UIColor redColor];
+    CategoryLabel.text=NSLocalizedString(@" Category", nil);
+    //    [CategoryLabel sizeToFit];
+    
+    self.treeView.treeHeaderView = CategoryLabel;
+    
+    [self.treeContainer addSubview:treeView];
+
+//    self.treeView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.treeView.bounds].CGPath;
+//    self.treeView.layer.masksToBounds = false;
+//    //添加四个边阴影
+//    
+//    self.treeView.layer.shadowColor = [UIColor blackColor].CGColor;
+//    self.treeView.layer.shadowOffset = CGSizeMake(0, 0);
+//    self.treeView.layer.shadowOpacity = 0.5;
+//    self.treeView.layer.shadowRadius = 2.0;
+    self.treeView.layer.borderColor=[UIColor lightGrayColor].CGColor;
+        self.treeView.layer.borderWidth = 0.5;
+//        self.treeView.layer.shadowRadius = 2.0;
+    self.textModelName.text = self.modelname;
+    
+    self.textModelDescription.text = self.modeldescrip;
+    
     UIApplication * app = [UIApplication sharedApplication];
     AppDelegate *appDelegate = (AppDelegate *)[app delegate];
     if(appDelegate.bLogin)
@@ -120,6 +175,24 @@
         if(alert.length>0)
             [self.buttonAlert setTitle:alert forState:UIControlStateNormal];
     }
+    
+    
+    {
+        NSString* bestseller =@"";
+        int count = [[self.bestseller_cadedate valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[self.bestseller_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                bestseller = [bestseller stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        if(bestseller.length>0)
+            [self.buttonBestSeller setTitle:bestseller forState:UIControlStateNormal];
+    }
     // Do any additional setup after loading the view.
 }
 
@@ -183,6 +256,45 @@
     
     [self.navigationController pushViewController:enumvc animated:true];
 }
+
+- (IBAction)onBestSellerClick:(id)sender {
+    EnumSelectViewController* enumvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
+    //   enumvc.delegate = self;
+    enumvc.max_select = 1;
+    //enumvc.updatePosition = indexPath;
+    //        if([[required lowercaseString] isEqualToString:@"true"])
+    //        enumvc.canbeEmpty = false;
+    //        else
+    //        enumvc.canbeEmpty =true;
+    enumvc.cadedate = [self.bestseller_cadedate mutableCopy];
+    enumvc.title = @"";
+    //       enumvc.value = [value_json mutableCopy];
+    enumvc.single_select =true;
+    
+    
+    enumvc.returnValue = ^(NSMutableDictionary* value){
+        self.bestseller_cadedate = value;
+        
+        
+        NSString* qty =@"";
+        int count = [[value valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[value objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                qty = [qty stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        
+        [self.buttonBestSeller setTitle:qty forState:UIControlStateNormal];
+    };
+    
+    [self.navigationController pushViewController:enumvc animated:true];
+}
+
 - (IBAction)onQTYClick:(id)sender {
     EnumSelectViewController* enumvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
  //   enumvc.delegate = self;
@@ -303,6 +415,13 @@
 }
 - (IBAction)onSearchClick:(id)sender {
     
+    NSString* modelname = self.textModelName.text;
+    if(modelname.length==0)
+        modelname = nil;
+    
+    NSString* modeldescrip = self.textModelDescription.text;
+    if(modeldescrip.length==0)
+        modeldescrip = nil;
     
     NSString* qty = [self.buttonQTY titleForState:UIControlStateNormal];
     if(qty.length==0 || [qty isEqualToString:@"Click to select"])
@@ -320,156 +439,163 @@
     if(alert.length==0 || [alert isEqualToString:@"Click to select"])
         alert = nil;
     
+    NSString* bestseller = [self.buttonBestSeller titleForState:UIControlStateNormal];
+    if(bestseller.length==0 || [bestseller isEqualToString:@"Click to select"])
+        alert = nil;
+
     
     if(self.OkClick)
-        self.OkClick( available, qty, alert,price);
+        self.OkClick( modelname, modeldescrip,available, qty, alert,price,bestseller);
     [self dismissViewControllerAnimated:true completion:nil];
 }
+#pragma mark TreeView Delegate methods
+- (CGFloat)treeView:(RATreeView *)treeView heightForRowForItem:(id)item treeNodeInfo:(RATreeNodeInfo *)treeNodeInfo
+{
+    return 47;
+}
 
-//
-//#pragma mark EnumSelectViewControllerDelegate
-//-(void) EnumValueChanged:(NSMutableDictionary *)value indexPath :(NSIndexPath*) indexPath
-//{
-//    
-//    
-//    self.alert_cadedate = value;
-//    
-//    
-//    NSString* alert =@"";
-//    int count = [[value valueForKey:@"count"] intValue];
-//    for(int i=0;i<count;i++)
+- (NSInteger)treeView:(RATreeView *)treeView indentationLevelForRowForItem:(id)item treeNodeInfo:(RATreeNodeInfo *)treeNodeInfo
+{
+    return 3 * treeNodeInfo.treeDepthLevel;
+}
+
+- (BOOL)treeView:(RATreeView *)treeView shouldExpandItem:(id)item treeNodeInfo:(RATreeNodeInfo *)treeNodeInfo
+{
+    return YES;
+}
+
+- (BOOL)treeView:(RATreeView *)treeView shouldItemBeExpandedAfterDataReload:(id)item treeDepthLevel:(NSInteger)treeDepthLevel
+{
+    if([item[@"id"] isEqualToString:self.categoryid] )
+        return YES;
+    return NO;
+}
+
+- (void)treeView:(RATreeView *)treeView didSelectRowForItem:(id)item treeNodeInfo:(RATreeNodeInfo *)treeNodeInfo
+{
+    
+//    NSDictionary *data = item;
+//    int count = [[data valueForKey:@"count"] intValue];
+//    if(count==0)
 //    {
-//        NSDictionary* val_json =[value objectForKey:[NSString stringWithFormat:@"val_%d",i]];
-//        int check = [[val_json valueForKey:@"check"] intValue];
+//        
+//        
+//        
+//        
+//        NSString* _id =  [data valueForKey:@"cid"];
+//        
+//        NSDictionary* ddd=[self check:_id source:[self.categoryMenu mutableCopy]];
+//        self.categoryMenu=ddd;
+//        UITableViewCell *cell = (UITableViewCell *)[self.treeView cellForItem:item];
+//        
+//        
+//        
+//        int check=[self is_check:_id source:self.categoryMenu];
 //        if(check==1)
-//        {
-//            alert = [alert stringByAppendingString:[val_json valueForKey:@"value"]];
-//            break;
-//        }
+//            cell.accessoryType = UITableViewCellAccessoryCheckmark;
+//        else
+//            cell.accessoryType=UITableViewCellAccessoryNone;
+//        
+//        
+//        
 //    }
 //    
-//    [self.buttonAlert setTitle:alert forState:UIControlStateNormal];
 //    
-//    //    UITableViewCell *cell = [self.editorTable cellForRowAtIndexPath:indexPath];
-//    //
-//    //
-//    //    //    if(/*self.cancommit==false &&*/ string.length==0 && (textField.text.length<=1|| textField.text==nil))
-//    //    //    {
-//    //    //        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;
-//    //    }
-//    //
-//    //    NSLog(@"enum changed %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];
-//    //
-//    //
-//    //    //    NSString* param_name=[item_json valueForKey:@"name"];
-//    //    //    NSString* param_val=nil;
-//    //    //
-//    //    //    bool single_select =[[item_json valueForKey:@"single_select"] boolValue];
-//    //    //
-//    //    //    int cade_count = [[value valueForKey:@"count"] intValue];
-//    //    //
-//    //    //    NSMutableArray* arr_val = [[NSMutableArray alloc] init];
-//    //    //
-//    //    //
-//    //    //    for(int cc=0;cc<cade_count;cc++)
-//    //    //    {
-//    //    //        NSDictionary * valjson=[value objectForKey:[NSString stringWithFormat:@"val_%d",cc ]];
-//    //    //        if([[valjson valueForKey:@"check"] boolValue])
-//    //    //        {
-//    //    //            [arr_val addObject: [valjson valueForKey:@"value_id"]];
-//    //    //            if(single_select)
-//    //    //                break;
-//    //    //        }
-//    //    //
-//    //    //    }
-//    //    //
-//    //    //    param_val = [arr_val componentsJoinedByString:@","];
-//    //    //
-//    //    //    [self.changed_data setObject:param_val forKey:param_name];
-//    //
-//    //    int refresh = [[item_json valueForKey:@"refresh"] intValue];
-//    //
-//    //
-//    //    NSString* subid=[item_json valueForKey:@"subid"];
-//    //
-//    //    [item_json setObject:value forKey:@"cadedate"];
-//    //
-//    //
-//    //    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
-//    //    {
-//    //        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 ]];
-//    //
-//    //    }
-//    //
-//    //
-//    //    //    [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 ]];
-//    //
-//    //    self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
-//    //
-//    //
-//    //    if(refresh==1)
-//    //    {
-//    //        [self refresh] ;
-//    //        return ;
-//    //    }
-//    //
-//    //
-//    //    NSLog(@"CONTENT UPDATE:%@",[iSalesNetwork DataTOjsonString:self.content_data_download]);
-//    //
-//    //
-//    //
-//    //    //    NSLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
-//    //    [self.editorTable reloadData ];
 //    
+//    
+//    
+//    NSLog(@"menu select %@",data);
+}
+
+//- (void)treeView:(RATreeView *)treeView willDisplayCell:(UITableViewCell *)cell forItem:(id)item treeNodeInfo:(RATreeNodeInfo *)treeNodeInfo
+//{
+//    if (treeNodeInfo.treeDepthLevel == 0) {
+//        cell.backgroundColor = UIColorFromRGB(0xF7F7F7);
+//    } else if (treeNodeInfo.treeDepthLevel == 1) {
+//        cell.backgroundColor = UIColorFromRGB(0xD1EEFC);
+//    } else if (treeNodeInfo.treeDepthLevel == 2) {
+//        cell.backgroundColor = UIColorFromRGB(0xE0F8D8);
+//    }
 //}
+
+- (void)treeView:(RATreeView *)treeView willDisplayCell:(UITableViewCell *)cell forItem:(id)item treeNodeInfo:(RATreeNodeInfo *)treeNodeInfo
+{
+    if (treeNodeInfo.treeDepthLevel == 0) {
+        cell.backgroundColor = [UIColor whiteColor];
+    } else if (treeNodeInfo.treeDepthLevel == 1) {
+        cell.backgroundColor = UIColorFromRGB(0xD1EEFC);
+    } else if (treeNodeInfo.treeDepthLevel == 2) {
+        cell.backgroundColor = UIColorFromRGB(0xE0F8D8);
+    }
+}
+
+#pragma mark TreeView Data Source
+
+- (UITableViewCell *)treeView:(RATreeView *)treeView cellForItem:(id)item treeNodeInfo:(RATreeNodeInfo *)treeNodeInfo
+{
+    //  NSInteger numberOfChildren = [treeNodeInfo.children count];
+    
+    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
+    //    if(numberOfChildren>0)
+    //        cell.detailTextLabel.text = [NSString stringWithFormat:@"Number of children %@", [@(numberOfChildren) stringValue]];
+    cell.textLabel.text = [((NSDictionary *)item) valueForKey:@"title"];
+    cell.selectionStyle = UITableViewCellSelectionStyleNone;
+    cell.accessoryType =UITableViewCellAccessoryNone;
+    //  if (treeNodeInfo.treeDepthLevel == 0) {
+    //      cell.detailTextLabel.textColor = [UIColor blackColor];
+    NSString* _id =  [((NSDictionary *)item) valueForKey:@"cid"];
+    //    int check=[self is_check:_id source:self.categoryMenu];
+    if([[((NSDictionary *)item) valueForKey:@"id"] isEqualToString:self.categoryid]&& [item[@"count"] intValue]==0)
+    {
+        cell.accessoryType = UITableViewCellAccessoryCheckmark;
+    }
+    else
+        cell.accessoryType =UITableViewCellAccessoryNone;
+    
+    
+    
+    
+    return cell;
+}
+
+- (NSInteger)treeView:(RATreeView *)treeView numberOfChildrenOfItem:(id)item
+{
+    if (item == nil) {
+        
+        //        UIApplication * app = [UIApplication sharedApplication];
+        //        AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+        return [[self.categoryMenu valueForKey:@"count" ] intValue];
+        //   return [self.data count];
+    }
+    
+    NSDictionary* data = item;
+    return [[data valueForKey:@"count"] intValue];
+    //  RADataObject *data = item;
+    //  return [data.children count];
+}
+
+- (id)treeView:(RATreeView *)treeView child:(NSInteger)index ofItem:(id)item
+{
+    NSDictionary *data = item;
+    
+    if (item == nil) {
+        
+        //        UIApplication * app = [UIApplication sharedApplication];
+        //        AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+        NSDictionary * ret =[self.categoryMenu objectForKey:[NSString stringWithFormat:@"category_%ld",(long)index] ];
+        return  ret;
+    }
+    
+    return[data objectForKey:[NSString stringWithFormat:@"category_%ld",(long)index]];
+    /*
+     
+     RADataObject *data = item;
+     if (item == nil) {
+     return [self.data objectAtIndex:index];
+     }
+     
+     return [data.children objectAtIndex:index];
+     */
+}
+
 @end

+ 9 - 1
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.h

@@ -13,11 +13,18 @@
 #import "RAViewController.h"
 #import "ActiveViewController.h"
 
+#import "CategoryHeaderView.h"
+
 typedef void (^add_to_cart_Handler)(void);
 
 
 @interface CategoryViewController : ActiveViewController<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout/*,UITableViewDataSource,UITableViewDelegate*/,UIScrollViewDelegate,/*SearchFilterDelegate,*/CategoryMenuDelegate,UIAlertViewDelegate>
-@property (strong, nonatomic) IBOutlet UIView *headerView;
+//@property (strong, nonatomic) IBOutlet UIView *headerView;
+
+@property (strong,nonatomic) NSString* modelname;
+@property (strong,nonatomic) NSString* modeldescrip;
+@property bool showalert;
+@property (strong, nonatomic) IBOutlet CategoryHeaderView *headerView;
 @property (strong, nonatomic) IBOutlet UICollectionView *collectionview;
 @property (strong, nonatomic) IBOutlet UITableView *tableview;
 @property bool showDetail;
@@ -60,6 +67,7 @@ typedef void (^add_to_cart_Handler)(void);
 @property (strong,nonatomic) NSString* p_available;
 @property (strong,nonatomic) NSString* p_QTY;
 @property (strong,nonatomic) NSString* p_price;
+@property (strong,nonatomic) NSString* p_bestseller;
 //@property (copy, nonatomic)void (^add_to_cart_Handler)(void);
 @property (copy, nonatomic) add_to_cart_Handler handler;
 //@property bool disable_refresh;

+ 36 - 7
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m

@@ -140,8 +140,17 @@
 
 - (IBAction)onFilterClicked:(id)sender {
     
+    UIApplication * app = [UIApplication sharedApplication];
+    
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    NSMutableDictionary* menu =             [appDelegate.categoryMenu mutableCopy];
+    
+    
+    
     CategorySearchFilterViewController * filterVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CategorySearchFilterViewController"];
     
+    filterVC.categoryid = self.categoryid;
+    
     //----------fake category filter----------------
 //    NSData* json =nil;
 //    json=[NSData dataWithContentsOfFile:[[NSBundle mainBundle]  pathForResource:@"debug_category_filter" ofType:@"json" ]];
@@ -150,17 +159,26 @@
 //    [self.category_data setObject:filter forKey:@"filter"];
     //----------fake category filter----------------
     
+    
+    filterVC.modelname=[[self.category_data objectForKey:@"filter"] valueForKey:@"model_name"];
+    filterVC.modeldescrip=[[self.category_data objectForKey:@"filter"] valueForKey:@"model_description"];
+    filterVC.categoryMenu = menu;
     filterVC.alert_cadedate =[[self.category_data objectForKey:@"filter"] objectForKey:@"alert"];
     filterVC.qty_cadedate=[[self.category_data objectForKey:@"filter"] objectForKey:@"qty"];
     filterVC.availability_cadedate=[[self.category_data objectForKey:@"filter"] objectForKey:@"availability"];
     filterVC.price_cadedate=[[self.category_data objectForKey:@"filter"] objectForKey:@"price"];
-    filterVC.OkClick =^(NSString* available,NSString* QTY,NSString* alert,NSString* price)
+    filterVC.bestseller_cadedate=[[self.category_data objectForKey:@"filter"] objectForKey:@"best_seller"];
+    
+    filterVC.OkClick =^(NSString* modelname,NSString* modeldescrip,NSString* available,NSString* QTY,NSString* alert,NSString* price,NSString* bestseller)
     {
+        
+        self.modelname = modelname;
+        self.modeldescrip = modeldescrip;
         self.p_alert=alert;
         self.p_QTY=QTY;
         self.p_available=available;
         self.p_price=price;
-        
+        self.p_bestseller=bestseller;
         self.offset = 0;
         [self reload];
         
@@ -168,12 +186,13 @@
     
     filterVC.ResetClick =^()
     {
-        
+        self.modelname = nil;
+        self.modeldescrip = nil;
         self.p_alert=nil;
         self.p_QTY=nil;
         self.p_available=nil;
         self.p_price=nil;
-        
+        self.p_bestseller=nil;
         self.offset = 0;
         [self reload];
         
@@ -819,7 +838,11 @@
     dispatch_async(dispatch_get_main_queue(), ^{
         if(self.loadall)
         {
-            [RAUtils message_alert:@"All loaded" title:@"Loading Category" controller:self] ;
+            if(self.showalert)
+            {
+                self.showalert=false;
+                [RAUtils message_alert:@"All loaded" title:@"Loading Category" controller:self] ;
+            }
             return;
             
         }
@@ -831,7 +854,7 @@
         self.isrefreshing=true;
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             
-            NSDictionary* category_more=[iSalesNetwork Category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price] ;
+            NSDictionary* category_more=[iSalesNetwork Category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip] ;
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 [self.mum stopAnimating];
@@ -887,6 +910,7 @@
     dispatch_async(dispatch_get_main_queue(), ^{
         if(self.isrefreshing)
             return;
+        self.showalert=true;
         self.isrefreshing=true;
         
         self.loadall = false;
@@ -916,7 +940,7 @@
         
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             
-            NSDictionary* category_data=[iSalesNetwork Category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:0 limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price];
+            NSDictionary* category_data=[iSalesNetwork Category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:0 limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip];
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 
@@ -1374,6 +1398,10 @@
     
     NSString* value =[DefaultAppearance get_noneappearance_value:@"CategoryViewController" valuename:@"cell_border_color"];
 
+    
+    
+    
+    
     if(value==nil)
         value=@"";
     unsigned long color = strtoul([value UTF8String],0,16);
@@ -1872,6 +1900,7 @@
     
     //    self showdetail
     
+    
     NSMutableDictionary* items =[[self.category_data objectForKey:@"items"] mutableCopy];
     
     NSMutableDictionary* item = [[items objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];

+ 2 - 2
RedAnt ERP Mobile/iSales-NPD/config.h

@@ -118,9 +118,9 @@
 #define  URL_NPD_POLICY  @"http://192.168.0.111:8080/site/isales/generalPolicy.htm"
 
 
-#define  URL_CHECK_OFFLINE  @"http://192.168.1.3/check.json"
+#define  URL_CHECK_OFFLINE  @"http://192.168.0.111/pj/offline/initDatas.htm"
 
-#define  URL_DOWNLOAD_OFFLINE  @"http://192.168.1.3/update.json"
+#define  URL_DOWNLOAD_OFFLINE  @"http://192.168.0.111/pj/offline/downloadDatas.htm"
 
 //
 //

+ 213 - 0
RedAnt ERP Mobile/iSales-NPD/default_appearance.json

@@ -0,0 +1,213 @@
+{
+    "appearance": {
+        "count": 4,
+        "group_0": {
+            "name": "global",
+            "count": 11,
+            "item_0": {
+                "note": "全局按钮",
+                "control": "UIButton",
+                "function": "setTitleColor.Normal",
+                "value": "0x996633",
+                "info": "NPD BROWN"
+            },
+            "item_1": {
+                "note": "全局菊花标记",
+                "control": "UIActivityIndicatorView",
+                "function": "setColor",
+                "value": "0x996633",
+                "info": "NPD BROWN"
+            },
+            "item_2": {
+                "note": "全局navigation barButton",
+                "control": "UIBarButtonItem",
+                "function": "TintColor",
+                "value": "0x996633",
+                "info": "NPD BROWN",
+                "container1": {
+                    "count": 1,
+                    "item_0": "UINavigationBar"
+                }
+            },
+            "item_3": {
+                "note": "全局wishlist,cart,portfolio action 按钮",
+                "control": "UIButton",
+                "function": "setTitleColor.Normal",
+                "value": "0xffffff",
+                "info": "whiteColor",
+                "container": {
+                    "count": 1,
+                    "item_0": "ModelItemCell"
+                }
+            },
+            "item_4": {
+                "note": "全局portfolio list action 按钮",
+                "control": "UIButton",
+                "function": "setTitleColor.Normal",
+                "value": "0xffffff",
+                "info": "whiteColor",
+                "container": {
+                    "count": 1,
+                    "item_0": "PDFListTableViewCell"
+                }
+            },
+            "item_5": {
+                "note": "全局toolbar barButton",
+                "control": "UIBarButtonItem",
+                "function": "TintColor",
+                "value": "0x996633",
+                "info": "NPD BROWN",
+                "container": {
+                    "count": 1,
+                    "item_0": "UIToolbar"
+                }
+            },
+            "item_6": {
+                "note": "全局UINavigationBar ",
+                "control": "UINavigationBar",
+                "function": "TintColor",
+                "value": "0x996633",
+                "info": "NPD BROWN"
+            },
+            "item_7": {
+                "note": "common editor multi action 按钮背景",
+                "control": "UIButton",
+                "function": "setBackgroundColor",
+                "value": "0x996633",
+                "info": "NPD BROWN",
+                "container": {
+                    "count": 1,
+                    "item_0": "CommonEditorCellMAction"
+                }
+            },
+            "item_8": {
+                "note": "common editor multi action 按钮文字",
+                "control": "UIButton",
+                "function": "setTitleColor.Normal",
+                "value": "0xffffff",
+                "info": "whiteColor",
+                "container": {
+                    "count": 1,
+                    "item_0": "CommonEditorCellMAction"
+                }
+            },
+            "item_9": {
+                "note": "图片按钮文字颜色",
+                "control": "DefaultImageButton",
+                "function": "setTitleColor.Normal",
+                "value": "#clearColor",
+                "info": "clearColor"
+            },
+            "item_10": {
+                "note": "全局section header 按钮",
+                "control": "UIButton",
+                "function": "setTitleColor.Normal",
+                "value": "0xffffff",
+                "info": "whiteColor",
+                "container": {
+                    "count": 1,
+                    "item_0": "DefaultTableHeaderView"
+                }
+            }
+            
+            
+        },
+        "group_1": {
+            "name": "category",
+            "count": 2,
+            "item_0": {
+                "control": "UILabel",
+                "function": "setTextColor",
+                "value": "0x996633",
+                "info": "NPD BROWN",
+                "container": {
+                    "count": 1,
+                    "item_0": "CategoryHeaderView"
+                }
+            },
+            "item_1": {
+                "control": "UILabel",
+                "function": "setTextColor",
+                "value": "0x000000",
+                "info": "blackColor",
+                "container": {
+                    "count": 1,
+                    "item_0": "CategoryCellNPD"
+                }
+                
+            },
+            "item_2": {
+                "note": "NO USE!!!!!",
+                "control": "UILabel",
+                "function": "setFont.Bold",
+                "value": "200",
+                "info": "bold 20",
+                "container": {
+                    "count": 1,
+                    "item_0": "CategoryHeaderView"
+                }
+            }
+        },
+        "group_2": {
+            "name": "model detail",
+            "count": 2,
+            "item_0": {
+                "control": "DefaultTableHeaderView",
+                "function": "setBackgroundColor",
+                "value": "0xEFEAE5",
+                "info": "NPD Gray"
+            },
+            "item_1": {
+                "control": "CategoryCellSmall",
+                "function": "setBackgroundColor",
+                "value": "0xffffff",
+                "info": "whiteColor"
+            }
+        },
+        "group_3": {
+            "name": "contact",
+            "count": 0,
+            "item_0": {
+                "control": "UIButton",
+                "function": "TintColor",
+                "value": "0x996633",
+                "info": "NPD BROWN",
+                "container": {
+                    "count": 1,
+                    "item_0": "ContactListTableViewCell"
+                }
+            }
+        }
+    },
+    "none_appearance": {
+        "count": 3,
+        "CategoryViewController": {
+            "cell_border_color": "0xffffff"
+        },
+        "DefaultTableHeaderView": {
+            "title_text_color": "0xffffff"
+        },
+        "DetailTableHeaderView": {
+            "title_text_color": "0x474747",
+            "refresh_button_color": "0x007aff"
+        }
+        ,
+        "DefaultColor": {
+            "frontcolor": "0x996633",
+            "labelcolor": "0x000000"
+        },
+        "MainLogo": {
+            "x": 49.0,
+            "y": 21.0,
+            "width": 69.0,
+            "height": 50.0
+        },
+        "ModePos": {
+            "x": 126.0,
+            "y": 30.0,
+            "width": 32.0,
+            "height": 30.0
+        }
+    },
+    "name": "NPD DEFAULT"
+}