Quellcode durchsuchen

实现闪退情况下Order编辑时的保存,以及重新启动应用登录时恢复编辑

Pen Li vor 9 Jahren
Ursprung
Commit
9320db969a

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 5 - 0
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -163,6 +163,11 @@
             // CreateOrderViewController
             [appDelegate.urgencyDic setValue:self.class_name forKey:@"firt_class_name"];
             
+            [appDelegate.urgencyDic setValue:appDelegate.order_code forKey:@"order_code"];
+
+            [appDelegate.urgencyDic setValue:[NSNumber numberWithInt:appDelegate.order_status ] forKey:@"order_status"];
+            
+            [appDelegate.urgencyDic setValue:appDelegate.order_customer_id forKey:@"order_customer_id"];
             
         } else if ([self.class_name isEqualToString:@"AddressEditorViewController"]) {
             // AddressEditorViewController

+ 2 - 0
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.h

@@ -16,6 +16,8 @@
 
 @property (strong,nonatomic) UIBarButtonItem *btnSubmitOrder;
 
+@property (nonatomic,assign) BOOL resumeOrder;///<恢复订单
+
 
 //@property (nonatomic , copy) void (^printPdfCallback)(NSString* url);
 

+ 5 - 2
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -152,7 +152,10 @@
 - (void)onCloseClick:(UIButton *)sender {
     
      AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
+    if (self.resumeOrder) {
+        [appDelegate.main_vc.navigationController popViewControllerAnimated:YES];
+        return;
+    }
     
     
 //    
@@ -201,7 +204,7 @@
     // Dispose of any resources that can be recreated.
 }
 - (IBAction)onSaveClick:(id)sender {
-    
+
     // add params check here.
     [self.lastedit endEditing:true];
     [self.lasttextview endEditing:true];

+ 54 - 10
RedAnt ERP Mobile/iSales-NPD/AppDelegate.m

@@ -19,7 +19,8 @@
 #import "iSalesNetwork.h"
 #import "NotificationNameCenter.h"
 #import "CustomerEditViewController.h"
-
+#import "CreateOrderViewController.h"
+#import "OrderDetailViewController.h"
 
 #define UNZIP_OPEN_FAILED 0
 #define UNZIP_SUCCESS 1
@@ -468,6 +469,7 @@ void UncaughtExceptionHandler(NSException *exception) {
     NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
     NSString *urgencyFile = [cachePath stringByAppendingPathComponent:@"urgency"];
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    NSLog(@"arkiver urgencyDic: %@",appDelegate.urgencyDic);
     [NSKeyedArchiver archiveRootObject:appDelegate.urgencyDic toFile:urgencyFile];
 }
 
@@ -529,16 +531,11 @@ void UncaughtExceptionHandler(NSException *exception) {
 
 - (void)handleUrgencyFile {
     
-//    id root = self.window.rootViewController;
-//    NSArray *child = self.window.rootViewController.childViewControllers;
-//    
-//    NSLog(@"rootViewController:%@",root);
-//    NSLog(@"child: %@",child);
-    
     NSLog(@"urgencyDic: %@",self.urgencyDic);
     if (self.urgencyDic.allKeys.count) {
         
         MainViewController *mainVC = [self.window.rootViewController.childViewControllers lastObject];
+        UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
         
         NSString *user = [self.urgencyDic objectForKey:@"user"];
         if (![user isEqualToString:self.user]) {
@@ -560,11 +557,10 @@ void UncaughtExceptionHandler(NSException *exception) {
            
             NSString *contact_id = [self.urgencyDic objectForKey:@"contact_id"];
             
-            NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-            
+            NSMutableDictionary *params = [NSMutableDictionary dictionary];
             
             [params setValue:contact_id forKey:@"contact_id"];
-            CustomerEditViewController * cuseditVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CustomerEditViewController"];
+            CustomerEditViewController * cuseditVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"CustomerEditViewController"];
             
             cuseditVC.bnewcustomer=false;
             cuseditVC.url_type = URL_REMOTE;
@@ -584,8 +580,56 @@ void UncaughtExceptionHandler(NSException *exception) {
         } else if ([firstClassName isEqualToString:@"CreateOrderViewController"]) {
             // CreateOrderViewController
             
+            NSString *order_code = [self.urgencyDic objectForKey:@"order_code"];
+            int order_status = [[self.urgencyDic objectForKey:@"order_status"] intValue];
+            NSString *order_customer_id = [self.urgencyDic objectForKey:@"order_customer_id"];
+            
+            self.order_customer_id = order_customer_id;
+            
+            // 首先通过order code 打开订单
+            NSDictionary* order_json = [iSalesNetwork open_Order:order_code];
+            
+            dispatch_async(dispatch_get_main_queue(), ^{
+//                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+                if([[order_json valueForKey:@"result"] intValue]==2)
+                {
+
+                    self.order_code = order_code;
+                    self.order_status = order_status;
+                    [self SetSo:order_code];
+                    
+                    
+                    self.customerInfo = [iSalesNetwork request_CustomerInfo:order_customer_id].mutableCopy;
+                    
+                    self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
+                    
+                    [mainVC reloadOrder:true immediately:false];
+                    [mainVC reloadCart:true immediately:false];
+                    
+                    
+                }
+                else
+                {
+                    [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:mainVC] ;
+                }
+            });
+
+            
+            
+            // 再place order
+            
+            NSMutableDictionary *params = [NSMutableDictionary dictionary];
+
+            CreateOrderViewController * orderinfoVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"CreateOrderViewController"];
             
+            orderinfoVC.disable_dropdown_refresh=true;
+            orderinfoVC.url_type = URL_REMOTE;
+            orderinfoVC.request_url=URL_CARTDELIVERY;
+            orderinfoVC.params = params;
+            orderinfoVC.changed_data = changed_data;
+            orderinfoVC.resumeOrder = YES;
             
+            [mainVC.navigationController pushViewController:orderinfoVC animated:true];
             
             
         } else if ([firstClassName isEqualToString:@"AddressEditorViewController"]) {