Просмотр исходного кода

1.修改UWA Signature为当前所打开的Order才能操作。

Pen Li 7 лет назад
Родитель
Сommit
e049262698
1 измененных файлов с 87 добавлено и 59 удалено
  1. 87 59
      RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

+ 87 - 59
RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

@@ -1005,7 +1005,40 @@
 }
 - (IBAction)onSignOrderClick:(id)sender {
     
-    //    SignatureViewController * vc;
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    if (appDelegate.order_code.length > 0 && [self.order_code isEqualToString:appDelegate.order_code]) {
+        
+        [self showSignaturePanel];
+        
+    } else {
+        
+        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"you need open the order first" preferredStyle:UIAlertControllerStyleAlert];
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+        }];
+        
+        [alertVC addAction:cancelAction];
+        
+        __weak typeof(self) weakSelf = self;
+        UIAlertAction *openAction = [UIAlertAction actionWithTitle:@"Open" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+            [self opentOrder:^{
+               
+                [weakSelf showSignaturePanel];
+            }];
+            
+        }];
+        
+        [alertVC addAction:openAction];
+        
+        [self presentViewController:alertVC animated:YES completion:nil];
+        
+    }
+    
+    
+}
+
+- (void)showSignaturePanel {
     
     __block UIImage* signimg=nil;
     SignatureViewController * vc =[ [UIStoryboard storyboardWithName:@"signature" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"SignatureViewController"];
@@ -1019,20 +1052,54 @@
         
         
     };
-    //    orderinfoVC.url_type = URL_REMOTE;
-    //    orderinfoVC.request_url=URL_CARTDELIVERY;
-    //
-    //    orderinfoVC.params = params;
-    //
-    //    orderinfoVC.delegate=self;
-    //
-    //    if(checked.count==count)
-    //    {
-    //    orderinfoVC.have_tail = true
-    //    }
     
     [self.navigationController pushViewController:vc animated:NO];
 }
+
+- (void)opentOrder:(void(^)(void))completionBlk {
+    
+    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Open Order"];
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        
+        NSDictionary* order_json = [RANetwork open_Order:self.order_code];
+        
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+            if([[order_json valueForKey:@"result"] intValue]==2)
+            {
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = self.order_code;
+                appDelegate.order_status = self.order_status;
+                [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
+                
+                
+                appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
+                
+                appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
+                [self.navigationController popViewControllerAnimated:false];
+                
+                
+                if (completionBlk) {
+                    completionBlk();
+                }
+                
+                if(self.selectOrder)
+                    self.selectOrder(self.content_data);
+                
+                
+            }
+            else
+            {
+                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
+            }
+            
+            
+            
+        });
+    });
+    
+}
+
 - (IBAction)onOpenOrderClick:(id)sender {
     // get customer info
     
@@ -1043,57 +1110,18 @@
     
     
     UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-     
-        {
-            UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Open Order"];
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* order_json = [RANetwork open_Order:self.order_code];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-                    if([[order_json valueForKey:@"result"] intValue]==2)
-                    {
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        appDelegate.order_code = self.order_code;
-                        appDelegate.order_status = self.order_status;
-                        [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
-                        
-                        
-                        appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
-                        
-                        appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
-                        [self.navigationController popViewControllerAnimated:false];
-                        
 
-                        
-                        
+        [self opentOrder:^{
+            
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"CartViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+            [ActiveViewController Notify:@"CartViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-//                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+            [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
 #endif
-                        if(self.selectOrder)
-                            self.selectOrder(self.content_data);
-                        
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
-                    }
-                    
-                    
-                    
-                });
-            });
-        }
-        
-        
-        
-        
+            
+        }];
         
         
     }];