|
|
@@ -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
|