|
@@ -105,90 +105,90 @@ static const NSInteger detal = 20;
|
|
|
|
|
|
|
|
__weak typeof(self) weakSelf = self;
|
|
__weak typeof(self) weakSelf = self;
|
|
|
|
|
|
|
|
-//
|
|
|
|
|
-// NSMutableDictionary *params = [self.params mutableCopy];
|
|
|
|
|
-// [params setObject:[NSNumber numberWithInteger:offset] forKey:@"offset"];
|
|
|
|
|
-// [params setObject:[NSNumber numberWithInteger:detal] forKey:@"limit"];
|
|
|
|
|
-// [params setObject:displayFields forKey:@"columns"];
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// [RANetwork request_result:params completionHandler:^(NSMutableDictionary *result) {
|
|
|
|
|
-//
|
|
|
|
|
-// NSMutableDictionary * json = result;
|
|
|
|
|
-// __strong typeof(weakSelf) strongSelf = weakSelf;
|
|
|
|
|
-//
|
|
|
|
|
-// int resultcode = [[json objectForKey:@"result"] intValue];
|
|
|
|
|
-// if (resultcode == RESULT_TRUE) {
|
|
|
|
|
-//
|
|
|
|
|
-// NSMutableArray *modelsArr = [NSMutableArray array];
|
|
|
|
|
-// if (option == ApexResultFetchDataTypeLoadMore && strongSelf.dataArray != nil && strongSelf.dataArray.count > 0) {
|
|
|
|
|
-// [modelsArr addObjectsFromArray:strongSelf.dataArray];
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// NSArray *items = [json objectForKey:@"items"];
|
|
|
|
|
-// for (NSDictionary *item in items) {
|
|
|
|
|
-//
|
|
|
|
|
-// NSInteger type = [[item objectForKey:@"type"] integerValue];
|
|
|
|
|
-//
|
|
|
|
|
-// switch (type) {
|
|
|
|
|
-// case ApexResultTypeBooking: {
|
|
|
|
|
-// ApexResultBookingModel *model = [ApexResultBookingModel new];
|
|
|
|
|
-// [model setValuesForKeysWithDictionary:item];
|
|
|
|
|
-// [modelsArr addObject:model];
|
|
|
|
|
-// }
|
|
|
|
|
-// break;
|
|
|
|
|
-// case ApexResultTypeBLInfo: {
|
|
|
|
|
-// ApexResultBLInfoModel *model = [ApexResultBLInfoModel new];
|
|
|
|
|
-// [model setValuesForKeysWithDictionary:item];
|
|
|
|
|
-// [modelsArr addObject:model];
|
|
|
|
|
-// }
|
|
|
|
|
-// break;
|
|
|
|
|
-// case ApexResultTypeContainer: {
|
|
|
|
|
-// ApexResultContainerModel *model = [ApexResultContainerModel new];
|
|
|
|
|
-// [model setValuesForKeysWithDictionary:item];
|
|
|
|
|
-// [modelsArr addObject:model];
|
|
|
|
|
-// }
|
|
|
|
|
-// break;
|
|
|
|
|
-// case ApexResultTypeDocument: {
|
|
|
|
|
-// ApexResultDocumentModel *model = [ApexResultDocumentModel new];
|
|
|
|
|
-// [model setValuesForKeysWithDictionary:item];
|
|
|
|
|
-// [modelsArr addObject:model];
|
|
|
|
|
-// }
|
|
|
|
|
-// break;
|
|
|
|
|
-// default:
|
|
|
|
|
-// break;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// } // for
|
|
|
|
|
-// strongSelf.offset = modelsArr.count;
|
|
|
|
|
-//
|
|
|
|
|
-// NSString *title = [json objectForKey:@"title"];
|
|
|
|
|
-// strongSelf.rowActions = [json objectForKey:@"row_actions"];
|
|
|
|
|
-// strongSelf.actions = [json objectForKey:@"actions"];
|
|
|
|
|
-//
|
|
|
|
|
-// // menu
|
|
|
|
|
-// NSArray *menuArr = [json objectForKey:@"menu"];
|
|
|
|
|
-// if (menuArr) {
|
|
|
|
|
-// NSMutableArray *tmpArr = [NSMutableArray array];
|
|
|
|
|
-// for (NSDictionary *item in menuArr) {
|
|
|
|
|
-//
|
|
|
|
|
-// ApexResultMenuItem *menuItem = [ApexResultMenuItem new];
|
|
|
|
|
-// [menuItem setValuesForKeysWithDictionary:item];
|
|
|
|
|
-// [tmpArr addObject:menuItem];
|
|
|
|
|
-// }
|
|
|
|
|
-// strongSelf.menuItems = [tmpArr copy];
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// // refresh UI
|
|
|
|
|
-// [strongSelf loadDataSuccessWithTitle:title itemsArray:modelsArr itemCount:items.count];
|
|
|
|
|
-//
|
|
|
|
|
-// } else {
|
|
|
|
|
-// [strongSelf loadDataFailed];
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// }];
|
|
|
|
|
-//
|
|
|
|
|
-// return;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary *params = [self.params mutableCopy];
|
|
|
|
|
+ [params setObject:[NSNumber numberWithInteger:offset] forKey:@"offset"];
|
|
|
|
|
+ [params setObject:[NSNumber numberWithInteger:detal] forKey:@"limit"];
|
|
|
|
|
+ [params setObject:displayFields forKey:@"columns"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [RANetwork request_result:params completionHandler:^(NSMutableDictionary *result) {
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary * json = result;
|
|
|
|
|
+ __strong typeof(weakSelf) strongSelf = weakSelf;
|
|
|
|
|
+
|
|
|
|
|
+ int resultcode = [[json objectForKey:@"result"] intValue];
|
|
|
|
|
+ if (resultcode == RESULT_TRUE) {
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableArray *modelsArr = [NSMutableArray array];
|
|
|
|
|
+ if (option == ApexResultFetchDataTypeLoadMore && strongSelf.dataArray != nil && strongSelf.dataArray.count > 0) {
|
|
|
|
|
+ [modelsArr addObjectsFromArray:strongSelf.dataArray];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ NSArray *items = [json objectForKey:@"items"];
|
|
|
|
|
+ for (NSDictionary *item in items) {
|
|
|
|
|
+
|
|
|
|
|
+ NSInteger type = [[item objectForKey:@"type"] integerValue];
|
|
|
|
|
+
|
|
|
|
|
+ switch (type) {
|
|
|
|
|
+ case ApexResultTypeBooking: {
|
|
|
|
|
+ ApexResultBookingModel *model = [ApexResultBookingModel new];
|
|
|
|
|
+ [model setValuesForKeysWithDictionary:item];
|
|
|
|
|
+ [modelsArr addObject:model];
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ApexResultTypeBLInfo: {
|
|
|
|
|
+ ApexResultBLInfoModel *model = [ApexResultBLInfoModel new];
|
|
|
|
|
+ [model setValuesForKeysWithDictionary:item];
|
|
|
|
|
+ [modelsArr addObject:model];
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ApexResultTypeContainer: {
|
|
|
|
|
+ ApexResultContainerModel *model = [ApexResultContainerModel new];
|
|
|
|
|
+ [model setValuesForKeysWithDictionary:item];
|
|
|
|
|
+ [modelsArr addObject:model];
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ApexResultTypeDocument: {
|
|
|
|
|
+ ApexResultDocumentModel *model = [ApexResultDocumentModel new];
|
|
|
|
|
+ [model setValuesForKeysWithDictionary:item];
|
|
|
|
|
+ [modelsArr addObject:model];
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } // for
|
|
|
|
|
+ strongSelf.offset = modelsArr.count;
|
|
|
|
|
+
|
|
|
|
|
+ NSString *title = [json objectForKey:@"title"];
|
|
|
|
|
+ strongSelf.rowActions = [json objectForKey:@"row_actions"];
|
|
|
|
|
+ strongSelf.actions = [json objectForKey:@"actions"];
|
|
|
|
|
+
|
|
|
|
|
+ // menu
|
|
|
|
|
+ NSArray *menuArr = [json objectForKey:@"menu"];
|
|
|
|
|
+ if (menuArr) {
|
|
|
|
|
+ NSMutableArray *tmpArr = [NSMutableArray array];
|
|
|
|
|
+ for (NSDictionary *item in menuArr) {
|
|
|
|
|
+
|
|
|
|
|
+ ApexResultMenuItem *menuItem = [ApexResultMenuItem new];
|
|
|
|
|
+ [menuItem setValuesForKeysWithDictionary:item];
|
|
|
|
|
+ [tmpArr addObject:menuItem];
|
|
|
|
|
+ }
|
|
|
|
|
+ strongSelf.menuItems = [tmpArr copy];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // refresh UI
|
|
|
|
|
+ [strongSelf loadDataSuccessWithTitle:title itemsArray:modelsArr itemCount:items.count];
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ [strongSelf loadDataFailed];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
|