Browse Source

1.修改iOS Apex Drivers Update Order,增加Required检查。

Pen Li 7 years ago
parent
commit
96bdb12e6a

+ 14 - 0
Redant Drivers/Apex And Drivers.xcodeproj/project.pbxproj

@@ -121,6 +121,7 @@
 		429CF61C20E0E32E00CE8DAD /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 429CF61E20E0E32E00CE8DAD /* Localizable.strings */; };
 		42C1B2702134D61200637085 /* Filter.png in Resources */ = {isa = PBXBuildFile; fileRef = 42C1B26F2134D61100637085 /* Filter.png */; };
 		42C1B2742134F24C00637085 /* RADatePickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42C1B2732134F24C00637085 /* RADatePickerViewController.m */; };
+		42D187802140BACC00C822C0 /* RAEditRequiredAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D1877F2140BACC00C822C0 /* RAEditRequiredAlert.m */; };
 		42D8B8A320C2253E001C125F /* fake_order_list.json in Resources */ = {isa = PBXBuildFile; fileRef = 42D8B8A220C2253E001C125F /* fake_order_list.json */; };
 		42D8B8A820C23DD9001C125F /* RAOrderDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D8B8A720C23DD9001C125F /* RAOrderDetailViewController.m */; };
 		42D8B8AA20C23DF0001C125F /* Detail.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 42D8B8A920C23DF0001C125F /* Detail.storyboard */; };
@@ -390,6 +391,8 @@
 		42C1B26F2134D61100637085 /* Filter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Filter.png; sourceTree = "<group>"; };
 		42C1B2722134F24C00637085 /* RADatePickerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RADatePickerViewController.h; sourceTree = "<group>"; };
 		42C1B2732134F24C00637085 /* RADatePickerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RADatePickerViewController.m; sourceTree = "<group>"; };
+		42D1877E2140BACC00C822C0 /* RAEditRequiredAlert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAEditRequiredAlert.h; sourceTree = "<group>"; };
+		42D1877F2140BACC00C822C0 /* RAEditRequiredAlert.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAEditRequiredAlert.m; sourceTree = "<group>"; };
 		42D8B8A220C2253E001C125F /* fake_order_list.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = fake_order_list.json; sourceTree = "<group>"; };
 		42D8B8A620C23DD9001C125F /* RAOrderDetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAOrderDetailViewController.h; sourceTree = "<group>"; };
 		42D8B8A720C23DD9001C125F /* RAOrderDetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAOrderDetailViewController.m; sourceTree = "<group>"; };
@@ -879,6 +882,15 @@
 			path = DatePicker;
 			sourceTree = "<group>";
 		};
+		42D1877D2140BA7000C822C0 /* RequiredAlertVC */ = {
+			isa = PBXGroup;
+			children = (
+				42D1877E2140BACC00C822C0 /* RAEditRequiredAlert.h */,
+				42D1877F2140BACC00C822C0 /* RAEditRequiredAlert.m */,
+			);
+			path = RequiredAlertVC;
+			sourceTree = "<group>";
+		};
 		42D8B8A120C224EE001C125F /* FakeData */ = {
 			isa = PBXGroup;
 			children = (
@@ -911,6 +923,7 @@
 		42D8B8A520C23D75001C125F /* Update */ = {
 			isa = PBXGroup;
 			children = (
+				42D1877D2140BA7000C822C0 /* RequiredAlertVC */,
 				4255EC9020C526E600E5DA24 /* Model */,
 				4255EC7D20C518B000E5DA24 /* Cell */,
 				4255EC7520C5097200E5DA24 /* Edit.storyboard */,
@@ -1344,6 +1357,7 @@
 				4255EC7920C511E400E5DA24 /* RAOrderEditViewController+TableDataSource.m in Sources */,
 				42D8B8BB20C2486C001C125F /* RADetailActionSubCell.m in Sources */,
 				71EAA33320B9571B002F003C /* AppDelegate.m in Sources */,
+				42D187802140BACC00C822C0 /* RAEditRequiredAlert.m in Sources */,
 				4205FD6F20C13E2700DB42B4 /* RAHomeViewController+HomeTableDataSource.m in Sources */,
 				42D8B8C520C24AB4001C125F /* RADetailLocationModel.m in Sources */,
 				4281100220E4D47000315156 /* JLRefreshHeader.m in Sources */,

+ 68 - 0
Redant Drivers/Apex And Drivers/Update/Edit.storyboard

@@ -278,5 +278,73 @@
             </objects>
             <point key="canvasLocation" x="-18.399999999999999" y="178.56071964017991"/>
         </scene>
+        <!--Edit Required Alert-->
+        <scene sceneID="Ft3-hd-P7A">
+            <objects>
+                <viewController storyboardIdentifier="RAEditRequiredAlert" useStoryboardIdentifierAsRestorationIdentifier="YES" id="7Vb-rb-Bgc" customClass="RAEditRequiredAlert" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="5K8-ZT-R0M">
+                        <rect key="frame" x="0.0" y="0.0" width="300" height="200"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Warning" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wal-J9-Hg6">
+                                <rect key="frame" x="5" y="5" width="290" height="24"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="20"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9KF-7X-fM9">
+                                <rect key="frame" x="5" y="34" width="290" height="20.5"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oEg-jq-oWF">
+                                <rect key="frame" x="0.0" y="58" width="300" height="0.5"/>
+                                <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="0.5" id="ITW-9b-I21"/>
+                                </constraints>
+                            </view>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Rra-Ip-4wb">
+                                <rect key="frame" x="135" y="59.5" width="30" height="44"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="44" id="JbV-gE-wzg"/>
+                                </constraints>
+                                <state key="normal" title="Ok"/>
+                                <connections>
+                                    <action selector="okBtnClick:" destination="7Vb-rb-Bgc" eventType="touchUpInside" id="EzR-Ty-a1W"/>
+                                </connections>
+                            </button>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <constraints>
+                            <constraint firstItem="Rra-Ip-4wb" firstAttribute="centerX" secondItem="9KF-7X-fM9" secondAttribute="centerX" id="4Qu-Xc-ese"/>
+                            <constraint firstItem="wal-J9-Hg6" firstAttribute="leading" secondItem="r5t-37-G4F" secondAttribute="leading" constant="5" id="6M9-FT-0aL"/>
+                            <constraint firstItem="Rra-Ip-4wb" firstAttribute="top" secondItem="9KF-7X-fM9" secondAttribute="bottom" constant="5" id="F7e-bD-YAk"/>
+                            <constraint firstItem="9KF-7X-fM9" firstAttribute="top" secondItem="wal-J9-Hg6" secondAttribute="bottom" constant="5" id="Fb3-mK-tOs"/>
+                            <constraint firstItem="wal-J9-Hg6" firstAttribute="top" secondItem="r5t-37-G4F" secondAttribute="top" constant="5" id="Ie5-6m-cVN"/>
+                            <constraint firstItem="oEg-jq-oWF" firstAttribute="leading" secondItem="r5t-37-G4F" secondAttribute="leading" id="MzX-t3-y5K"/>
+                            <constraint firstItem="r5t-37-G4F" firstAttribute="trailing" secondItem="9KF-7X-fM9" secondAttribute="trailing" constant="5" id="bp0-Qi-Buq"/>
+                            <constraint firstItem="Rra-Ip-4wb" firstAttribute="top" secondItem="oEg-jq-oWF" secondAttribute="bottom" constant="1" id="j6g-LD-A7G"/>
+                            <constraint firstItem="9KF-7X-fM9" firstAttribute="leading" secondItem="r5t-37-G4F" secondAttribute="leading" constant="5" id="joY-Je-Y1H"/>
+                            <constraint firstItem="r5t-37-G4F" firstAttribute="trailing" secondItem="wal-J9-Hg6" secondAttribute="trailing" constant="5" id="mLM-aD-ewb"/>
+                            <constraint firstItem="r5t-37-G4F" firstAttribute="trailing" secondItem="oEg-jq-oWF" secondAttribute="trailing" id="xqh-Dt-IZh"/>
+                        </constraints>
+                        <viewLayoutGuide key="safeArea" id="r5t-37-G4F"/>
+                    </view>
+                    <value key="contentSizeForViewInPopover" type="size" width="300" height="200"/>
+                    <nil key="simulatedTopBarMetrics"/>
+                    <nil key="simulatedBottomBarMetrics"/>
+                    <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
+                    <size key="freeformSize" width="300" height="200"/>
+                    <connections>
+                        <outlet property="msgLabel" destination="9KF-7X-fM9" id="sgB-Et-Max"/>
+                        <outlet property="titleLabel" destination="wal-J9-Hg6" id="YbR-lo-fXv"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="nlm-8i-gIv" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="790.39999999999998" y="170.91454272863569"/>
+        </scene>
     </scenes>
 </document>

+ 82 - 49
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

@@ -20,6 +20,7 @@
 #import "AppDelegate.h"
 #import "UIScrollView+Empty.h"
 #import "RAEmptyView.h"
+#import "RAEditRequiredAlert.h"
 
 #import <CoreLocation/CoreLocation.h>
 
@@ -47,6 +48,7 @@
             case RAEditTypeLabel: {
                 
                 RAEditLabelModel *model = [RAEditLabelModel new];
+                model.required = YES;
                 [model setValuesForKeysWithDictionary:item];
                 [itemArr addObject:model];
             }
@@ -54,6 +56,7 @@
             case RAEditTypeInput: {
                 
                 RAEditInputModel *model = [RAEditInputModel new];
+                model.required = YES;
                 [model setValuesForKeysWithDictionary:item];
                 [itemArr addObject:model];
             }
@@ -61,6 +64,7 @@
             case RAEditTypeMultInput: {
                 
                 RAEditMultInputModel *model = [RAEditMultInputModel new];
+                model.required = YES;
                 [model setValuesForKeysWithDictionary:item];
                 [itemArr addObject:model];
             }
@@ -68,6 +72,7 @@
             case RAEditTypePhoto: {
                 
                 RAEditPhotoModel *model = [RAEditPhotoModel new];
+                model.required = YES;
                 [model setValuesForKeysWithDictionary:item];
                 [itemArr addObject:model];
             }
@@ -75,6 +80,7 @@
             case RAEditTypeSignature: {
                 
                 RAEditSignatureModel *model = [RAEditSignatureModel new];
+                model.required = YES;
                 [model setValuesForKeysWithDictionary:item];
                 [itemArr addObject:model];
             }
@@ -296,9 +302,6 @@
 
 - (void)updateBtnClick:(UIBarButtonItem *)sender {
     
-    // show progress
-    RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
-    
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     if (self.orderType2) {
         [params setObject:self.orderType2 forKey:@"orderType2"];
@@ -308,7 +311,21 @@
         NSString *latLon = [NSString stringWithFormat:@"%f,%f",location.coordinate.latitude,location.coordinate.longitude];
         [params setObject:latLon forKey:@"location"];
     }
-    NSMutableArray <RAEditImageBaseModel *> *photoArr = [self prepareParams:params];
+    NSMutableArray *emptyArr = [NSMutableArray array];
+    
+    NSMutableArray <RAEditImageBaseModel *> *photoArr = [self prepareParams:params checkRequired:emptyArr];
+    
+    if (emptyArr.count > 0) {
+        
+        
+        RAEditRequiredAlert *alertVC = [RAEditRequiredAlert alertWithTile:@"Warning" message:[NSString stringWithFormat:@"please complete missing field:\n%@",[emptyArr componentsJoinedByString:@"\n"]]];
+        
+        [self presentViewController:alertVC animated:YES completion:nil];
+        return;
+    }
+    
+    // show progress
+    RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
     
     __weak typeof(self) weakSelf = self;
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
@@ -541,10 +558,10 @@
     return _photoDir;
 }
 
-- (NSMutableArray <RAEditImageBaseModel *> *)prepareParams:(NSMutableDictionary *)params {
+- (NSMutableArray <RAEditImageBaseModel *> *)prepareParams:(NSMutableDictionary *)params checkRequired:(NSMutableArray *)emptyArr {
     
     if (params == nil) {
-        return nil;
+        return nil;;
     }
     
     NSMutableArray <RAEditImageBaseModel *> *photoArr = [NSMutableArray array];
@@ -567,6 +584,7 @@
     for (RAEditSectionModel *section in self.sectionArray) {
         for (int i = 0; i < [section itemCount]; i++) {
             RAEditBaseModel *model = [section itemModelForIndex:i];
+
             switch (model.type) {
                 case RAEditTypeLabel: {
                     
@@ -575,6 +593,11 @@
                 case RAEditTypeInput: {
                     
                     RAEditInputModel *inputModel = (RAEditInputModel *)model;
+                    if (model.required && inputModel.value.length == 0) {
+                        [emptyArr addObject:[NSString stringWithFormat:@"%ld.%@",emptyArr.count + 1,model.title]];
+                        continue;
+                    }
+                    
                     if (inputModel.key && inputModel.value.length > 0) {
                         [params setObject:inputModel.value forKey:inputModel.key];
                     }
@@ -583,6 +606,11 @@
                 case RAEditTypeMultInput: {
                     
                     RAEditMultInputModel *multInputModel = (RAEditMultInputModel *)model;
+                    if (model.required && multInputModel.value.length == 0) {
+                        [emptyArr addObject:[NSString stringWithFormat:@"%ld.%@",emptyArr.count + 1,model.title]];
+                        continue;
+                    }
+                    
                     if (multInputModel.key && multInputModel.value.length > 0) {
                         [params setObject:multInputModel.value forKey:multInputModel.key];
                     }
@@ -594,6 +622,11 @@
                     if (photoDir) {
                         
                         RAEditImageBaseModel *imageModel = (RAEditImageBaseModel *)model;
+                        if (model.required && imageModel.image == nil) {
+                            [emptyArr addObject:[NSString stringWithFormat:@"%ld.%@",emptyArr.count + 1,model.title]];
+                            continue;
+                        }
+                        
                         if (imageModel.image) {
                             
                             NSString *photoPath = [photoDir stringByAppendingPathComponent:imageModel.imageName];
@@ -620,48 +653,48 @@
     return photoArr;
 }
 
-- (NSMutableDictionary *)preparePackage {
-    
-    NSMutableDictionary *params = [NSMutableDictionary dictionary];
-    NSInteger photoCount = [self prepareParams:params].count;
-    NSString *photoDir = [self photoDir];
-    
-    NSMutableDictionary *task = [@{
-                                   @"order" : self.orderID,
-                                   @"action" : self.actionTitle,
-                                   @"url" : URL_HOST,
-                                   @"noFile" : @(YES)
-                                  } mutableCopy];
-    
-    if (photoCount > 0) {
-        
-        // 压缩文件
-        NSString *zipPath = [photoDir stringByAppendingPathExtension:@".zip"];
-        ZipArchive *zip = [[ZipArchive alloc] init];
-        [zip CreateZipFile2:zipPath];
-        NSArray *subPaths = [[NSFileManager defaultManager] subpathsAtPath:photoDir];
-        for (NSString *subPath in subPaths) {
-            NSString *fullPath = [photoDir stringByAppendingPathComponent:subPath];
-            BOOL isDir;
-            if([[NSFileManager defaultManager] fileExistsAtPath:fullPath isDirectory:&isDir]) {
-                if (!isDir) {
-                    [zip addFileToZip:fullPath newname:subPath];
-                }
-            }
-        }
-        [zip CloseZipFile2];
-        
-        [[NSFileManager defaultManager] removeItemAtPath:photoDir error:nil];
-
-        NSString *md5 = [RAUtils md5WithFile:zipPath];
-        
-        [params setObject:md5 forKey:@"md5"];
-        [task setObject:@"file" forKey:zipPath.lastPathComponent];
-    }
-    
-    [task setObject:params forKey:@"params"];
-    
-    return task;
-}
+//- (NSMutableDictionary *)preparePackage {
+//
+//    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+//    NSInteger photoCount = [self prepareParams:params].count;
+//    NSString *photoDir = [self photoDir];
+//
+//    NSMutableDictionary *task = [@{
+//                                   @"order" : self.orderID,
+//                                   @"action" : self.actionTitle,
+//                                   @"url" : URL_HOST,
+//                                   @"noFile" : @(YES)
+//                                  } mutableCopy];
+//
+//    if (photoCount > 0) {
+//
+//        // 压缩文件
+//        NSString *zipPath = [photoDir stringByAppendingPathExtension:@".zip"];
+//        ZipArchive *zip = [[ZipArchive alloc] init];
+//        [zip CreateZipFile2:zipPath];
+//        NSArray *subPaths = [[NSFileManager defaultManager] subpathsAtPath:photoDir];
+//        for (NSString *subPath in subPaths) {
+//            NSString *fullPath = [photoDir stringByAppendingPathComponent:subPath];
+//            BOOL isDir;
+//            if([[NSFileManager defaultManager] fileExistsAtPath:fullPath isDirectory:&isDir]) {
+//                if (!isDir) {
+//                    [zip addFileToZip:fullPath newname:subPath];
+//                }
+//            }
+//        }
+//        [zip CloseZipFile2];
+//
+//        [[NSFileManager defaultManager] removeItemAtPath:photoDir error:nil];
+//
+//        NSString *md5 = [RAUtils md5WithFile:zipPath];
+//
+//        [params setObject:md5 forKey:@"md5"];
+//        [task setObject:@"file" forKey:zipPath.lastPathComponent];
+//    }
+//
+//    [task setObject:params forKey:@"params"];
+//
+//    return task;
+//}
 
 @end

+ 15 - 0
Redant Drivers/Apex And Drivers/Update/RequiredAlertVC/RAEditRequiredAlert.h

@@ -0,0 +1,15 @@
+//
+//  RAEditRequiredAlert.h
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/9/6.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "JLCustomerAlertController.h"
+
+@interface RAEditRequiredAlert : JLCustomerAlertController
+
++ (instancetype)alertWithTile:(NSString *)title message:(NSString *)msg;
+
+@end

+ 57 - 0
Redant Drivers/Apex And Drivers/Update/RequiredAlertVC/RAEditRequiredAlert.m

@@ -0,0 +1,57 @@
+//
+//  RAEditRequiredAlert.m
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/9/6.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RAEditRequiredAlert.h"
+
+@interface RAEditRequiredAlert ()
+
+@property (strong, nonatomic) IBOutlet UILabel *titleLabel;
+@property (strong, nonatomic) IBOutlet UILabel *msgLabel;
+
+@property (nonatomic,copy) NSString *alertTitle;
+@property (nonatomic,copy) NSString *alertMessage;
+
+@end
+
+@implementation RAEditRequiredAlert
+
++ (instancetype)alertWithTile:(NSString *)title message:(NSString *)msg {
+    
+    RAEditRequiredAlert *alertVC = [[UIStoryboard storyboardWithName:@"Edit" bundle:nil] instantiateViewControllerWithIdentifier:NSStringFromClass(self)];
+    
+    alertVC.alertTitle = title;
+    alertVC.alertMessage = msg;
+    
+    return alertVC;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    self.titleLabel.text = self.alertTitle;
+    [self.titleLabel sizeToFit];
+    self.msgLabel.text = self.alertMessage;
+    [self.msgLabel sizeToFit];
+    
+    CGFloat h = CGRectGetHeight(self.titleLabel.bounds) + CGRectGetHeight(self.msgLabel.bounds) + 60.0f;
+    CGFloat w = 300.0f;
+    
+    self.preferredContentSize = CGSizeMake(w, h);
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (IBAction)okBtnClick:(id)sender {
+    [self dismissViewControllerAnimated:YES completion:nil];
+}
+
+@end