|
|
@@ -60,23 +60,23 @@
|
|
|
-(void)getRecentData{
|
|
|
|
|
|
NSString *filePath = [self getRecentDataPath];
|
|
|
-
|
|
|
+
|
|
|
NSMutableArray *cacheArr = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
|
|
|
-
|
|
|
+
|
|
|
self.recentArr = [cacheArr mutableCopy];
|
|
|
-
|
|
|
+
|
|
|
if (self.recentArr == nil) {
|
|
|
|
|
|
self.recentArr = [NSMutableArray array];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
-(void)getDataFromSever{
|
|
|
|
|
|
-
|
|
|
[MBProgressHUD showMessage:@"" toView:self.view];
|
|
|
-
|
|
|
+
|
|
|
NSArray * arr = @[Color(47, 149, 221, 1),Color(155, 125,201, 1),Color(222, 147, 91, 1),Color(245, 116, 116, 1),Color(139, 214, 127, 1),Color(104, 210, 201, 1)];
|
|
|
color = [arr mutableCopy];
|
|
|
NSString *sessionId=[[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
|
|
|
@@ -85,7 +85,7 @@
|
|
|
NSString *sessionUser = [[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
|
|
|
// /common/getSearchByTree.action
|
|
|
NSString *url = [NSString stringWithFormat:@"%@/common/getSearchByTree.action?emcode=%@&master=%@&sessionUser=%@&sessionId=%@",[UASUserInfo shareManager].urlIp,emcode,master,sessionUser,sessionId];
|
|
|
-
|
|
|
+
|
|
|
UASNetworkManager * manager = [UASNetworkManager shareManager];
|
|
|
[manager POST:url parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
|
|
|
SLog(@"返回的数据是:%@",responseObject);
|
|
|
@@ -93,6 +93,9 @@
|
|
|
NSMutableArray * mutArr = [[NSMutableArray alloc]init];
|
|
|
NSMutableArray * dicArr = [[NSMutableArray alloc]init];
|
|
|
|
|
|
+ [_alldataArr removeAllObjects];
|
|
|
+ [_modelNameArr removeAllObjects];
|
|
|
+ [_ColorArr removeAllObjects];
|
|
|
for (int i = 0; i<_partDataArr.count; i++) {
|
|
|
|
|
|
dicArr = [_partDataArr[i] objectForKey:@"list"];
|
|
|
@@ -102,11 +105,11 @@
|
|
|
[mutArr removeAllObjects];
|
|
|
|
|
|
for (int j=0; j<dicArr.count; j++) {
|
|
|
-
|
|
|
+
|
|
|
ReportMenuModel * model = [ReportMenuModel mj_objectWithKeyValues:dicArr[j]];
|
|
|
-
|
|
|
+
|
|
|
[mutArr addObject:model];
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
[_alldataArr addObject:[mutArr copy]];
|
|
|
|
|
|
@@ -115,12 +118,52 @@
|
|
|
for (int i = 0; i< (double)_partDataArr.count/6; i++) {
|
|
|
[_ColorArr addObjectsFromArray:[arr copy]];
|
|
|
}
|
|
|
+
|
|
|
+ //比对缓存的项目中是否有项目已经不存在
|
|
|
+ for (int i=0; i<_recentArr.count; i++) {
|
|
|
+
|
|
|
+ BOOL isExist = NO;
|
|
|
+
|
|
|
+ ReportMenuModel *recModel = _recentArr[i];
|
|
|
+
|
|
|
+ for (int j=0 ; j<_alldataArr.count;j++) {
|
|
|
+
|
|
|
+ NSArray *arr = _alldataArr[j];
|
|
|
+
|
|
|
+ for (ReportMenuModel *rModel in arr) {
|
|
|
+
|
|
|
+ if ([rModel.caller isEqualToString:recModel.caller]) {
|
|
|
+
|
|
|
+ isExist = YES;
|
|
|
+ //存在的情况,更新匹配正确的颜色
|
|
|
+ if (j<_ColorArr.count) {
|
|
|
+
|
|
|
+ recModel.cellColor = _ColorArr[j];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (!isExist) {//不存在移除
|
|
|
+
|
|
|
+ [_recentArr removeObject:recModel];
|
|
|
+ i--;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if(_alldataArr.count > 0){
|
|
|
|
|
|
if (_recentArr.count != 0) {
|
|
|
- if (self.recentArr.count != 0) {
|
|
|
+ if (self.recentArr.count != 0 && ![_alldataArr containsObject:_recentArr]) {
|
|
|
|
|
|
- [_modelNameArr insertObject:@"最近查询业务" atIndex:0];
|
|
|
+ [_modelNameArr insertObject:@"最近浏览" atIndex:0];
|
|
|
[self.alldataArr insertObject:_recentArr atIndex:0];
|
|
|
|
|
|
}
|
|
|
@@ -136,27 +179,33 @@
|
|
|
|
|
|
}
|
|
|
[self.collectionView reloadData];
|
|
|
+
|
|
|
+ [self.collectionView.mj_header endRefreshing];
|
|
|
+
|
|
|
//SLog(@"获取的标题是:%@",_titleArr);
|
|
|
SLog(@"获取的模型是:%@",_alldataArr);
|
|
|
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
-
|
|
|
+
|
|
|
} failure:^(NSURLSessionDataTask *task, NSError *error) {
|
|
|
-
|
|
|
+
|
|
|
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
- SLog(@"返回的错误是什么呢:%@",error);
|
|
|
+
|
|
|
NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
|
|
|
if (returnData) {
|
|
|
NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
|
|
|
-
|
|
|
+
|
|
|
NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
|
|
|
-
|
|
|
- DLog(@"错误的原因:%@",errorStr);
|
|
|
+
|
|
|
[JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:nil];
|
|
|
- }
|
|
|
- else{
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
[JOShowMessageFromNavi showDropViewWithMessage:@"请检查网络情况" ToNavi:self.navigationController withColor:nil];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ [self.collectionView.mj_header endRefreshing];
|
|
|
+
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
@@ -173,7 +222,6 @@
|
|
|
|
|
|
-(void)initNavigation{
|
|
|
|
|
|
-
|
|
|
self.title = @"BI报表";
|
|
|
|
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
|
@@ -185,7 +233,7 @@
|
|
|
[btn2 addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
|
|
|
self.navigationItem.leftBarButtonItems = @[bbi2];
|
|
|
-
|
|
|
+
|
|
|
UICollectionViewFlowLayout *layoutView = [[UICollectionViewFlowLayout alloc] init];
|
|
|
layoutView.scrollDirection = UICollectionViewScrollDirectionVertical;
|
|
|
layoutView.itemSize = CGSizeMake(100, 95);
|
|
|
@@ -193,7 +241,7 @@
|
|
|
layoutView.footerReferenceSize = CGSizeMake(SCREEN_HEIGHT, 0.3);
|
|
|
layoutView.sectionInset = UIEdgeInsetsMake(0.3, 0, 0, 0);
|
|
|
self.navigationController.automaticallyAdjustsScrollViewInsets = YES;
|
|
|
-
|
|
|
+
|
|
|
_searchBarView=[[UIView alloc]initWithFrame:CGRectMake(0,0,self_width,40)];
|
|
|
_searchBarView.backgroundColor=Color(235,233,233,1.0);
|
|
|
JOSearchBar * searcher=[JOSearchBar new];
|
|
|
@@ -224,6 +272,13 @@
|
|
|
make.left.right.bottom.equalTo(self.view);
|
|
|
|
|
|
}];
|
|
|
+
|
|
|
+ self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
|
|
+
|
|
|
+ [self getDataFromSever];
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
self.collectionView.delegate = self;
|
|
|
self.collectionView.dataSource = self;
|
|
|
[self.collectionView registerClass:[DataSearchCell class] forCellWithReuseIdentifier:@"YRBiServiceCellID"];
|
|
|
@@ -358,10 +413,9 @@
|
|
|
DataSearcherHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"reusableView" forIndexPath:indexPath];
|
|
|
headerView.lable2.text = _modelNameArr[indexPath.section];
|
|
|
headerView.lable1.backgroundColor = [UIColor blackColor];
|
|
|
-
|
|
|
+
|
|
|
return headerView;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}else{
|
|
|
|
|
|
DataSearcherHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"reusableView" forIndexPath:indexPath];
|
|
|
@@ -497,7 +551,7 @@
|
|
|
if (_recentArr.count == 0) {
|
|
|
|
|
|
[_alldataArr insertObject:_recentArr atIndex:0];
|
|
|
- [_modelNameArr insertObject:@"最近查询业务" atIndex:0];
|
|
|
+ [_modelNameArr insertObject:@"最近浏览" atIndex:0];
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -571,13 +625,11 @@
|
|
|
if (!_recentArr) {
|
|
|
|
|
|
_recentArr = [NSMutableArray array];
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return _recentArr;
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@end
|