Преглед изворни кода

ERP MOBILE
关闭scanner 调试开关
cart 价格刷新通知和新方式统一
去掉部分cart 冗余逻辑

Ray Zhang пре 7 година
родитељ
комит
c2bab42435

+ 134 - 122
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -35,7 +35,7 @@
 
 //#define ALERT_FREE 1024
 #define ALERT_DEL 1025
-#define ALERT_SET_FREE 1026
+//#define ALERT_SET_FREE 1026
 #define ALERT_RESTORE_FREE 1027
 
 @interface CartViewController ()
@@ -75,7 +75,9 @@
 
 
 - (void)dealloc {
+        #ifndef RA_NOTIFICATION
     [[NSNotificationCenter defaultCenter] removeObserver:self];
+#endif
 }
 
 -(void) logout
@@ -934,8 +936,10 @@
     self.label_net_err.layer.cornerRadius=15;
     self.label_net_err.layer.masksToBounds=true;
     
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(priceTypeChanged:) name:Change_Price_Type_Notification object:nil];
     
+    #ifndef RA_NOTIFICATION
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(priceTypeChanged:) name:Change_Price_Type_Notification object:nil];
+#endif
     
     UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
     //            tap.minimumPressDuration = 0.8; //定义按的时间
@@ -1183,52 +1187,52 @@
 
 
 
-- (IBAction)onDelete:(UIButton *)sender {
-    return ;
-    NSMutableArray* checked = [[NSMutableArray alloc] init];
-    
-    
-    
-    long count = self.content_arr.count;//[[self.content_data valueForKey:@"count"] intValue];
-    for(int i=0;i<count;i++)
-    {
-        NSMutableDictionary * item_json = [self.content_arr[i] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
-        bool check = [[item_json valueForKey:@"check"] boolValue];
-        if(check)
-        {
-            [checked addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
-            
-        }
-    }
-    // disable for debug
-    if(checked.count==0)
-        return;
-    
-    //    NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-    NSString * string = [checked componentsJoinedByString:@","];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* cart_json = [RANetwork cart_remove:string];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-            
-            
-            if([[cart_json valueForKey:@"result"] intValue]==2)
-            {
-                
-                [self reload_data];
-            }
-            else
-            {
-                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-            }
-            
-            
-            
-        });
-    });
-}
+//- (IBAction)onDelete:(UIButton *)sender {
+//    return ;
+//    NSMutableArray* checked = [[NSMutableArray alloc] init];
+//
+//
+//
+//    long count = self.content_arr.count;//[[self.content_data valueForKey:@"count"] intValue];
+//    for(int i=0;i<count;i++)
+//    {
+//        NSMutableDictionary * item_json = [self.content_arr[i] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
+//        bool check = [[item_json valueForKey:@"check"] boolValue];
+//        if(check)
+//        {
+//            [checked addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
+//
+//        }
+//    }
+//    // disable for debug
+//    if(checked.count==0)
+//        return;
+//
+//    //    NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
+//    NSString * string = [checked componentsJoinedByString:@","];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* cart_json = [RANetwork cart_remove:string];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//            if([[cart_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//                [self reload_data];
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+//            }
+//
+//
+//
+//        });
+//    });
+//}
 
 -(void)refresh_total
 {
@@ -2250,10 +2254,12 @@
                     
                     
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"WatchListViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
                     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                     [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                    
 #endif
                     
                     
@@ -2915,79 +2921,79 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 //
 //        }
 //    }
-    else if(alertView.tag==ALERT_SET_FREE)
-    {
-        if(buttonIndex!=alertView.cancelButtonIndex)
-        {
-            [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
-            NSMutableDictionary * item_json = nil;
-            if (self.back_order_flag) {
-                item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
-            } else {
-                item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
-            }
-            
-            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
-            
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* cart_json = [RANetwork cart_setFree:ids isfree:true];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    
-                    
-                    if([[cart_json valueForKey:@"result"] intValue]==2)
-                    {
-                        [self reload_data];
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Set Free Model" controller:self] ;
-                    }
-                    
-                });
-            });
-            
-        }
-    }
-    else if(alertView.tag==ALERT_RESTORE_FREE)
-    {
-        if(buttonIndex!=alertView.cancelButtonIndex)
-        {
-            [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
-            NSMutableDictionary * item_json = nil;
-            if (self.back_order_flag) {
-                item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
-            } else {
-                item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
-            }
-            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
-            
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* cart_json = [RANetwork cart_setFree:ids isfree:false];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    
-                    
-                    if([[cart_json valueForKey:@"result"] intValue]==2)
-                    {
-                        [self reload_data];
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Restore Model Price" controller:self] ;
-                    }
-                    
-                });
-            });
-            
-        }
-    }
+//    else if(alertView.tag==ALERT_SET_FREE)
+//    {
+//        if(buttonIndex!=alertView.cancelButtonIndex)
+//        {
+//            [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+//            NSMutableDictionary * item_json = nil;
+//            if (self.back_order_flag) {
+//                item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
+//            } else {
+//                item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
+//            }
+//
+//            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
+//
+//
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* cart_json = [RANetwork cart_setFree:ids isfree:true];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                    if([[cart_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        [self reload_data];
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Set Free Model" controller:self] ;
+//                    }
+//
+//                });
+//            });
+//
+//        }
+//    }
+//    else if(alertView.tag==ALERT_RESTORE_FREE)
+//    {
+//        if(buttonIndex!=alertView.cancelButtonIndex)
+//        {
+//            [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+//            NSMutableDictionary * item_json = nil;
+//            if (self.back_order_flag) {
+//                item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
+//            } else {
+//                item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
+//            }
+//            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
+//
+//
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* cart_json = [RANetwork cart_setFree:ids isfree:false];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                    if([[cart_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        [self reload_data];
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Restore Model Price" controller:self] ;
+//                    }
+//
+//                });
+//            });
+//
+//        }
+//    }
 }
 
 #pragma mark - Support scanner
@@ -3274,6 +3280,12 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 
 - (void)priceTypeChanged:(id)notification {
     [self reload_data];
+#ifdef RA_NOTIFICATION
+    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
 }
 
 #pragma mark - button action

+ 4 - 4
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -147,10 +147,10 @@
 }
 - (IBAction)onSelectClick:(id)sender {
 //    
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-    [appDelegate test_onDecodedDataResult:@"108530-HS01"];
-    return;
+//    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//    
+//    [appDelegate test_onDecodedDataResult:@"108530-HS01"];
+//    return;
     
     [self begin_select];
 }

+ 3 - 3
RedAnt ERP Mobile/common/Functions/sidemenu/ScannerSettingViewController.m

@@ -183,9 +183,9 @@
 - (IBAction)onEmailClicked:(id)sender {
     
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-    [appDelegate test_onDecodedDataResult:@"SCANNER TEST"];
-    return;
+//
+//    [appDelegate test_onDecodedDataResult:@"SCANNER TEST"];
+//    return;
     
 //    UIApplication * app = [UIApplication sharedApplication];
 //    AppDelegate *appDelegate = (AppDelegate *)[app delegate];