Procházet zdrojové kódy

pdf:tearsheets_id ---> _id
修改保存PDF,区分同步数据和离线新建。

Pen Li před 9 roky
rodič
revize
62274c6315

binární
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 13 - 3
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -10236,6 +10236,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     [resultDictionary setObject:@"Regular Mode" forKey:@"mode"];
     
     NSMutableDictionary * values = params[@"replaceValue"];
+    NSNumber *tear_sheet_id = [params objectForKey:@"tearsheetsId"]; // _id
     
     NSString *tear_name = [self valueInParams:params key:@"pdfName"];
     
@@ -10357,7 +10358,11 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
 
     // 在preview情况下保存,则不需要新建了
     if (direct) {
-        NSData *pdfData = [self offline_request_tearsheet:params]; // 新建PDF,获取本地路径
+        NSMutableDictionary *tear_sheet_params = params;
+        if (tear_sheet_id) {
+            tear_sheet_params = values;
+        }
+        NSData *pdfData = [self offline_request_tearsheet:tear_sheet_params]; // 新建PDF,获取本地路径
         
         NSDictionary *pdfInfo = [NSJSONSerialization JSONObjectWithData:pdfData options:NSJSONReadingMutableContainers error:nil];
         pdf_path = [pdfInfo objectForKey:@"pdf_path"];
@@ -10406,6 +10411,11 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     
     NSString *save_pdf_sql = [NSString stringWithFormat:@"insert into offline_pdf (tearsheets_id,pdf_path,create_user,tear_note,tear_name,model_info,configureParams,is_local,off_params) values ((select ifnull(max(tearsheets_id),0) from offline_pdf) + 1,'%@','%@','%@','%@','%@','%@',1,'%@');",pdf_path,create_user,tear_note,tear_name,model_info,configureParams,off_params];
     
+    if (tear_sheet_id) {
+        int _id = [tear_sheet_id integerValue];
+        save_pdf_sql = [NSString stringWithFormat:@"update offline_pdf set pdf_path = '%@' where _id = %d;",pdf_path,_id];
+    }
+    
     int result = [iSalesDB execSql:save_pdf_sql];
     
     [resultDictionary setObject:[NSNumber numberWithInt:result] forKey:@"result"];
@@ -10442,7 +10452,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         where = [NSString stringWithFormat:@"where (is_delete is null or is_delete = 0 ) and lower(create_user) like '%%%@%%' or lower(tear_note) like '%%%@%%'  or lower(tear_name) like '%%%@%%'",keyword.lowercaseString,keyword.lowercaseString,keyword.lowercaseString];
     }
     
-    NSString *sql = [NSString stringWithFormat:@"select tear_name,tear_note,createtime,create_user,pdf_path,tearsheets_id,model_info,off_params from offline_pdf %@ order by createtime desc limit %d offset %d;",where,limit,offset];
+    NSString *sql = [NSString stringWithFormat:@"select tear_name,tear_note,createtime,create_user,pdf_path,_id,model_info,off_params from offline_pdf %@ order by createtime desc limit %d offset %d;",where,limit,offset];// tearsheets_id ---> _id
     
     __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
     
@@ -10756,7 +10766,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     NSInteger tearsheetsId = [[params objectForKey:@"tearsheetsId"] integerValue];
     NSString *user = [params objectForKey:@"user"];
     
-    NSString *create_user = [iSalesDB jk_queryText:[NSString stringWithFormat:@"select create_user from offline_pdf where tearsheets_id = %d;",tearsheetsId]];
+    NSString *create_user = [iSalesDB jk_queryText:[NSString stringWithFormat:@"select create_user from offline_pdf where _id = %d;",tearsheetsId]]; // tearsheets_id ---> _id
     if (![create_user isEqualToString:user]) {
         [dic setObject:[NSNumber numberWithInt:RESULT_FALSE] forKey:@"result"];
         [dic setObject:@"Regular Mode" forKey:@"mode"];