Quellcode durchsuchen

Recant mobile

command editor. 修改自动完成
Ray Zhang vor 8 Jahren
Ursprung
Commit
32d48c18ed

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

@@ -3442,6 +3442,7 @@
                     
                     
                     cell.textfield.keyboardType=UIKeyboardTypeDecimalPad;
+//                    cell.textfield.keyboardType=UIKeyboardTypeNumbersAndPunctuation;
                     
                     
                     
@@ -3455,6 +3456,7 @@
                     
                     
                     cell.textfield.keyboardType=UIKeyboardTypeNumberPad;
+//                    cell.textfield.keyboardType=UIKeyboardTypeNumbersAndPunctuation;
                     
                     
                     
@@ -5817,6 +5819,7 @@
         self.autocompleteView.active_field = textField;
         self.autocompleteView.hidden = false;
         self.autocompleteView.searchInput.keyboardType=textField.keyboardType;
+        self.autocompleteView.searchInput.text= textField.text;
         [self.autocompleteView.searchInput becomeFirstResponder];
         __weak typeof(self) weakself = self;
         self.autocompleteView.returnValue = ^(NSString *str) {

+ 1 - 0
RedAnt Mobile/RedAnt Mobile/RANetwork.m

@@ -590,6 +590,7 @@
     params[ @"_action"]=@"ant_mobile";
     params[ @"_operate"]=@"query_autocomplete";
     
+
     
     // params[@"_operate"]=@"valid_upload";
 //    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

+ 2 - 1
RedAnt Mobile/RedAnt Mobile/SearchViewController.m

@@ -107,7 +107,7 @@
 }
 
 #pragma mark- autocomplete
--(nullable NSArray*)sync_loadCadidate:(nonnull NSString*)str
+-( NSArray* )sync_loadCadidate:( NSString*)str //search_id:(NSString*) search_id
 {
     NSIndexPath * indexPath = [self.editorTable indexPathForCell:self.editingcell];
     NSDictionary* item_json =((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row];
@@ -116,6 +116,7 @@
     params[@"query_id"]=self.params[@"query_id"];
     params[@"name"]=item_json[@"name"];
     params[@"keyword"]=str;
+//    params[@"request_id"]
     NSMutableDictionary* json = [RANetwork queryAutoComplete:params];
 //
     NSMutableArray* ret= json[@"cadedate"];

+ 2 - 0
common/customUI/commoneditor/CommonEditorAutoCompleteView.h

@@ -10,6 +10,7 @@
 @class CommonEditorAutoCompleteView;
 @protocol AutoCompleteDataSource<NSObject>
 @required
+//-( NSArray* )sync_loadCadidate:( NSString*)str search_id:(NSString*) search_id;
 -( NSArray* )sync_loadCadidate:( NSString*)str;
 @end
 
@@ -29,6 +30,7 @@
 @property (strong, nonatomic) UITextField* active_field;
 @property (weak, nonatomic) IBOutlet UITextField *searchInput;
 @property (strong, nonatomic) NSString* keyword;
+@property (strong, nonatomic) NSString* lastSearchID;
 
 @property (nonatomic , copy) void (^returnValue)(NSString* str);
 

+ 27 - 10
common/customUI/commoneditor/CommonEditorAutoCompleteView.m

@@ -21,14 +21,14 @@
 //    [self.active_field endEditing:true];
 //    self.hidden = true;
     
-    
+//    self.searchInput.text = nil;
     [self.searchInput endEditing:true];
-    self.searchInput.text = nil;
+    
     self.arr_result = nil;
     self.hidden=true;
     [self.ResultTableView reloadData];
 }
-#pragma mark - SearchBar Delegate
+#pragma mark - TextField Delegate
 
 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
 //    autocompleteTableView.hidden = NO;
@@ -53,6 +53,14 @@
 
 
 
+}
+
+- (void)textFieldDidEndEditing:(UITextField *)textField
+{
+    if(self.returnValue)
+        self.returnValue(textField.text);
+    textField.text = nil;
+
 }
 //- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;        // return NO to disallow editing.
 //- (void)textFieldDidBeginEditing:(UITextField *)textField;           // became first responder
@@ -75,13 +83,20 @@
         [self.ResultTableView reloadData];
         return;
     }
-    
+        __weak typeof(self) weakself = self;
     if(self.dataSource)
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
-        
-        self.arr_result =  [self.dataSource sync_loadCadidate:keyword];
+        NSString* searchid=[[NSUUID new] UUIDString];
+        weakself.lastSearchID=searchid;
+        NSArray* arr_ret=[weakself.dataSource sync_loadCadidate:keyword ];
+//        NSArray* arr_ret=[weakself.dataSource sync_loadCadidate:keyword search_id:weakself.lastSearchID];
+//        self.arr_result =  [self.dataSource sync_loadCadidate:keyword search_id:[[NSUUID new] UUIDString]];
         dispatch_async(dispatch_get_main_queue(), ^{
-            [self.ResultTableView reloadData];
+            if([searchid isEqualToString:weakself.lastSearchID])
+            {
+                self.arr_result = arr_ret;
+                [self.ResultTableView reloadData];
+            }
 
             
         });
@@ -130,10 +145,12 @@
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     
     
-    if(self.returnValue)
-        self.returnValue(self.arr_result[indexPath.row][@"value"]);
+//    if(self.returnValue)
+//        self.returnValue(self.arr_result[indexPath.row][@"value"]);
+    
+    self.searchInput.text = self.arr_result[indexPath.row][@"value"];
     [self.searchInput endEditing:true];
-    self.searchInput.text = nil;
+//    self.searchInput.text = nil;
     self.arr_result = nil;
     self.hidden=true;
     [self.ResultTableView reloadData];

+ 3 - 2
common/customUI/commoneditor/CommonEditorAutoCompleteView.xib

@@ -21,7 +21,7 @@
                         <barButtonItem style="plain" systemItem="flexibleSpace" id="Akz-J7-8Vx"/>
                         <barButtonItem style="plain" id="5fn-gW-pw6">
                             <textField key="customView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="h2N-Y1-mnQ">
-                                <rect key="frame" x="73" y="7" width="225" height="30"/>
+                                <rect key="frame" x="87" y="7" width="225" height="30"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <nil key="textColor"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -31,7 +31,8 @@
                                 </connections>
                             </textField>
                         </barButtonItem>
-                        <barButtonItem title="Cancel" id="mqZ-WV-nJ5">
+                        <barButtonItem width="15" style="plain" systemItem="fixedSpace" id="qhe-Oj-gEi"/>
+                        <barButtonItem title="OK" id="mqZ-WV-nJ5">
                             <connections>
                                 <action selector="onCancelClick:" destination="iN0-l3-epB" id="1d9-Xw-nNX"/>
                             </connections>