Commit f8c90bc0 authored by admin's avatar admin

问题与知识的筛选接口完成

parent 26922a4d
...@@ -140,6 +140,8 @@ ...@@ -140,6 +140,8 @@
#define kRefreshInspectPointNotification @"refreshInspectPoint" #define kRefreshInspectPointNotification @"refreshInspectPoint"
#define kRefreshQuestionNotification @"refershQuestionList" #define kRefreshQuestionNotification @"refershQuestionList"
#define kQuestionGroupNotification @"questionGroup"
#define kTAxisBtnTag 500232 #define kTAxisBtnTag 500232
......
...@@ -74,5 +74,9 @@ ...@@ -74,5 +74,9 @@
// 抽查评分 // 抽查评分
#define kGradeCheckResultURL @"redstar-server/rest/spotcheck/grade?time=" #define kGradeCheckResultURL @"redstar-server/rest/spotcheck/grade?time="
// 获取问题专业组
#define kQuestionGroupURL @"redstar-server/rest/question/queryGroup"
// 获取问题分类
#define kQuestionCategoryURL @"redstar-server/rest/question/queryCategory?groupUuid="
#endif /* Url_h */ #endif /* Url_h */
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
GroupItems *scopeItem = [[GroupItems alloc] initWithTitle:@"问题范围" view:_scopeTableView]; GroupItems *scopeItem = [[GroupItems alloc] initWithTitle:@"问题范围" view:_scopeTableView];
self.groupTableView = [[GroupTableView alloc] init]; self.groupTableView = [[GroupTableView alloc] init];
_groupTableView.groupDeleagte = self.categoryTableView;
GroupItems *groupItem = [[GroupItems alloc] initWithTitle:@"问题分组" view:_groupTableView]; GroupItems *groupItem = [[GroupItems alloc] initWithTitle:@"问题分组" view:_groupTableView];
self.categoryTableView = [[CategoryTableView alloc] init]; self.categoryTableView = [[CategoryTableView alloc] init];
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
@protocol CategoryTableViewDelegate <NSObject> @protocol CategoryTableViewDelegate <NSObject>
- (void)categoryTableViewClick:(NSInteger)row; - (void)categoryTableViewClick:(NSString *)categoryName GroupTitle:(NSString *)groupTitle;
@end @end
@interface CategoryTableView : UITableView <GroupTableViewDelegate> @interface CategoryTableView : UITableView
@property (nonatomic, assign) id <CategoryTableViewDelegate>categroyDeleagte; @property (nonatomic, assign) id <CategoryTableViewDelegate>categroyDeleagte;
@end @end
...@@ -7,8 +7,12 @@ ...@@ -7,8 +7,12 @@
// //
#import "CategoryTableView.h" #import "CategoryTableView.h"
#import "HttpClient.h"
@interface CategoryTableView ()<UITableViewDelegate, UITableViewDataSource> @interface CategoryTableView ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) NSMutableArray *titleArray; @property (nonatomic, strong) NSMutableArray *titleArray;
@property (nonatomic, strong) NSMutableArray *categoryArray;
@end @end
@implementation CategoryTableView @implementation CategoryTableView
...@@ -35,27 +39,49 @@ ...@@ -35,27 +39,49 @@
{ {
self.delegate = self; self.delegate = self;
self.dataSource = self; self.dataSource = self;
self.titleArray = [NSMutableArray arrayWithObjects:@"基础环境",@"人员", @"停车场",@"卫生间", @"物料标识", nil]; self.titleArray = [NSMutableArray array];
self.categoryArray = [NSMutableArray array];
NSInteger selectedIndex = 0; NSInteger selectedIndex = 0;
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0]; NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
[self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; [self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
//注册通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadCurrentTableView:) name:kQuestionGroupNotification object:nil];
} }
//- (void)groupTableViewClick:(NSInteger)row - (void)reloadCurrentTableView:(NSNotification *)notification
//{ {
// if (row == 0) { NSString *url = [NSString stringWithFormat:@"%@%@%@",kRedStarURL, kQuestionCategoryURL, notification.userInfo[@"groupName"]];
// [self reloadData]; HttpClient *http = [[HttpClient alloc] initWithUrl:url];
// } else { [http getQuestionCategoryWithCompletion:^(id response, NSError *error) {
// self.titleArray = [NSMutableArray arrayWithObjects:@"211",@"322", nil]; NSLog(@"分类categaory response= %@", response);
// [self reloadData]; if (response[@"success"]) {
// NSDictionary *dictData = response[@"data"];
// } NSArray *array = dictData[@"records"];
//} NSMutableArray *groupArray = [NSMutableArray array];
NSMutableArray *categoryArray = [NSMutableArray array];
for (NSDictionary *dict in array) {
NSString *category = [NSString stringWithFormat:@"%@", dict[@"name"]];
NSString *group = [NSString stringWithFormat:@"%@", dict[@"groupName"]];
[categoryArray addObject:category];
[groupArray addObject:group];
}
_titleArray = categoryArray;
_categoryArray = categoryArray;
[self reloadData];
}
}];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:kQuestionGroupNotification object:nil];
}
#pragma mark - TableView Delegate/DataSource
#pragma mark - TableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ {
return _titleArray.count; return _titleArray.count;
...@@ -78,8 +104,10 @@ ...@@ -78,8 +104,10 @@
// cell点击事件 // cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (_categroyDeleagte) { NSString *cateName = _categoryArray[indexPath.row];
[_categroyDeleagte categoryTableViewClick:indexPath.row]; NSString *group = _titleArray[indexPath.row];
if (_categroyDeleagte && [_categroyDeleagte respondsToSelector:@selector(categoryTableViewClick:GroupTitle:)]) {
[_categroyDeleagte categoryTableViewClick:cateName GroupTitle:group];
} }
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol GroupTableViewDelegate <NSObject> @protocol GroupTableViewDelegate <NSObject>
- (void)groupTableViewClick:(NSInteger)row; - (void)groupTableViewClick:(NSString *)groupName;
@end @end
@interface GroupTableView : UITableView @interface GroupTableView : UITableView
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
// //
#import "GroupTableView.h" #import "GroupTableView.h"
#import "HttpClient.h"
@interface GroupTableView ()<UITableViewDelegate, UITableViewDataSource> @interface GroupTableView ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) NSMutableArray *titleArray; @property (nonatomic, strong) NSMutableArray *titleArray;
@end @end
...@@ -33,16 +35,20 @@ ...@@ -33,16 +35,20 @@
- (void)setup - (void)setup
{ {
self.titleArray = [NSMutableArray arrayWithObjects:@"全部",@"服务",@"环境企划",@"环境物业", nil];
self.delegate = self;
self.dataSource = self;
NSInteger selectedIndex = 0; NSInteger selectedIndex = 0;
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0]; NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
[self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; [self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
NSMutableArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:@"groupTitle"];
self.titleArray = [NSMutableArray arrayWithArray:array];
self.delegate = self;
self.dataSource = self;
} }
#pragma mark - TableView Delegate/DataSource #pragma mark - TableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
...@@ -67,8 +73,12 @@ ...@@ -67,8 +73,12 @@
// cell点击事件 // cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (_groupDeleagte) { NSString *title = [NSString stringWithFormat:@"%@", _titleArray[indexPath.row]];
[_groupDeleagte groupTableViewClick:indexPath.row]; NSDictionary *dict =[[NSDictionary alloc] initWithObjectsAndKeys:title, @"groupName", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kQuestionGroupNotification object:self userInfo:dict];
if(_groupDeleagte && [_groupDeleagte respondsToSelector:@selector(groupTableViewClick:)]) {
[_groupDeleagte groupTableViewClick:title];
} }
} }
......
...@@ -46,8 +46,11 @@ ...@@ -46,8 +46,11 @@
@property (nonatomic, assign) NSInteger page; @property (nonatomic, assign) NSInteger page;
@property (nonatomic, assign) NSInteger scopeRow; @property (nonatomic, assign) NSInteger scopeRow;
@property (nonatomic, assign) NSInteger groupRow; // 分组
@property (nonatomic, assign) NSInteger categoryRow; @property (nonatomic, copy) NSString *groupName;
// 分类
@property (nonatomic, copy) NSString *groupTitle;
@property (nonatomic, copy) NSString *categoryName;
@property (nonatomic, assign) NSInteger stateRow; @property (nonatomic, assign) NSInteger stateRow;
@property (nonatomic, assign) NSInteger timeRow; @property (nonatomic, assign) NSInteger timeRow;
...@@ -71,7 +74,6 @@ ...@@ -71,7 +74,6 @@
[self setupNav]; [self setupNav];
// [self requestQuestionList];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(requestQuestionList) selector:@selector(requestQuestionList)
...@@ -79,6 +81,8 @@ ...@@ -79,6 +81,8 @@
object:nil]; object:nil];
_page = 0; _page = 0;
//[self requestGroupTitle];
} }
- (void)dealloc - (void)dealloc
...@@ -97,14 +101,29 @@ ...@@ -97,14 +101,29 @@
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Private Methods #pragma mark - Private Methods
//- (void)requestGroupTitle
//{
// NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionGroupURL];
// HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
// // 请求问题列表
// [httpClient getQuestionGroupWithCompletion:^(id response, NSError *error) {
// NSLog(@"请求问题专业分组 res = %@", response);
// NSLog(@"请求问题专业分组 error = %@", error);
// if (response[@"success"]) {
// NSDictionary *dataDict = response[@"data"];
// NSArray *array = dataDict[@"records"];
// NSMutableArray *titleArray = [NSMutableArray array];
// for (NSDictionary *dict in array) {
// NSString *name = dict[@"name"];
// [titleArray addObject:name];
// }
// NSLog(@"titleArray 2222= %@", titleArray);
// [[NSUserDefaults standardUserDefaults] setObject:titleArray forKey:@"groupTitle"];
// }
//
// }];
//}
- (void)requestQuestionList - (void)requestQuestionList
{ {
...@@ -363,8 +382,8 @@ ...@@ -363,8 +382,8 @@
if (!_screenView) { if (!_screenView) {
_screenView = [[MoreScreenView alloc] init]; _screenView = [[MoreScreenView alloc] init];
_screenView.backgroundColor = [UIColor whiteColor]; _screenView.backgroundColor = [UIColor whiteColor];
_screenView.scopeTableView.scopeDeleagte = self;
_screenView.groupTableView.groupDeleagte = self; _screenView.groupTableView.groupDeleagte = self;
_screenView.scopeTableView.scopeDeleagte = self;
_screenView.categoryTableView.categroyDeleagte = self; _screenView.categoryTableView.categroyDeleagte = self;
_screenView.stateTableView.stateDeleagte = self; _screenView.stateTableView.stateDeleagte = self;
_screenView.timeTableView.timeDeleagte = self; _screenView.timeTableView.timeDeleagte = self;
...@@ -455,30 +474,15 @@ ...@@ -455,30 +474,15 @@
@"direction":@"asc"}]; @"direction":@"asc"}];
[parameters setObject:array forKey:@"queryOrders"]; [parameters setObject:array forKey:@"queryOrders"];
} else if (_screenView.groupTabBar.selectNumber == 1) { } else if (_screenView.groupTabBar.selectNumber == 1) {
if (_groupRow == 0) { // 分组
[parameters setObject:_groupName forKey:@"group"];
} else if (_groupRow == 1) {
[parameters setObject:@"服务" forKey:@"group"];
} else if (_groupRow == 2) {
[parameters setObject:@"环境企划" forKey:@"group"];
} else {
[parameters setObject:@"环境物业" forKey:@"group"];
}
NSArray *array = @[@{@"field":@"group", NSArray *array = @[@{@"field":@"group",
@"direction":@"asc"}]; @"direction":@"asc"}];
[parameters setObject:array forKey:@"queryOrders"]; [parameters setObject:array forKey:@"queryOrders"];
} else if (_screenView.groupTabBar.selectNumber == 2) { } else if (_screenView.groupTabBar.selectNumber == 2) {
if (_categoryRow == 0) {
[parameters setObject:@"基础环境" forKey:@"category"]; [parameters setObject:_groupTitle forKey:@"group"];
} else if (_categoryRow == 1) { [parameters setObject:_categoryName forKey:@"category"];
[parameters setObject:@"人员" forKey:@"category"];
} else if (_categoryRow == 2) {
[parameters setObject:@"停车场" forKey:@"category"];
} else if (_categoryRow == 3) {
[parameters setObject:@"卫生间" forKey:@"category"];
} else {
[parameters setObject:@"物料标识" forKey:@"category"];
}
NSArray *array = @[@{@"field":@"category", NSArray *array = @[@{@"field":@"category",
@"direction":@"asc"}]; @"direction":@"asc"}];
[parameters setObject:array forKey:@"queryOrders"]; [parameters setObject:array forKey:@"queryOrders"];
...@@ -607,14 +611,15 @@ ...@@ -607,14 +611,15 @@
_scopeRow = row; _scopeRow = row;
} }
- (void)groupTableViewClick:(NSInteger)row - (void)groupTableViewClick:(NSString *)groupName
{ {
_groupRow = row; _groupName = groupName;
} }
- (void)categoryTableViewClick:(NSInteger)row - (void)categoryTableViewClick:(NSString *)categoryName GroupTitle:(NSString *)groupTitle
{ {
_categoryRow = row; _categoryName = categoryName;
_groupTitle = groupTitle;
} }
- (void)stateTableViewClick:(NSInteger)row - (void)stateTableViewClick:(NSInteger)row
......
...@@ -484,15 +484,15 @@ ...@@ -484,15 +484,15 @@
[parameters setObject:weekStr forKey:@"beginDateFrom"]; [parameters setObject:weekStr forKey:@"beginDateFrom"];
[parameters setObject:todayStr forKey:@"endDateTo"]; [parameters setObject:todayStr forKey:@"endDateTo"];
NSLog(@"onwek = %@", parameters);
} else if (_timeSelectNum == 1) { } else if (_timeSelectNum == 1) {
NSDate *oneMonth = [self getPriousorLaterDateFromDate:today withMonth:-1]; NSDate *oneMonth = [self getPriousorLaterDateFromDate:today withMonth:-1];
NSString *oneMonthStr = [dateFormatter stringFromDate:oneMonth]; NSString *oneMonthStr = [dateFormatter stringFromDate:oneMonth];
NSLog(@"oneMonth = %@", oneMonthStr);
[parameters setObject:oneMonthStr forKey:@"beginDateFrom"]; [parameters setObject:oneMonthStr forKey:@"beginDateFrom"];
[parameters setObject:todayStr forKey:@"endDateTo"]; [parameters setObject:todayStr forKey:@"endDateTo"];
NSLog(@"oneMonth = %@", parameters);
} else if (_timeSelectNum == 2) { } else if (_timeSelectNum == 2) {
NSDate *threeMonth = [self getPriousorLaterDateFromDate:today withMonth:-3]; NSDate *threeMonth = [self getPriousorLaterDateFromDate:today withMonth:-3];
NSString *threeMonthStr = [dateFormatter stringFromDate:threeMonth]; NSString *threeMonthStr = [dateFormatter stringFromDate:threeMonth];
...@@ -514,11 +514,10 @@ ...@@ -514,11 +514,10 @@
NSArray *array = @[@{@"field":@"lastModifyInfo", NSArray *array = @[@{@"field":@"lastModifyInfo",
@"direction":@"asc"}]; @"direction":@"asc"}];
[parameters setObject:array forKey:@"queryOrders"]; [parameters setObject:array forKey:@"queryOrders"];
NSLog(@"parameters = %@",parameters);
} }
NSLog(@"parameters = %@",parameters);
......
...@@ -83,4 +83,9 @@ typedef void (^completionBlock) (id response, NSError *error); ...@@ -83,4 +83,9 @@ typedef void (^completionBlock) (id response, NSError *error);
// 抽查评分 // 抽查评分
- (void)gradeCheckResultWithParameters:(id)parameters completion:(completionBlock)completion; - (void)gradeCheckResultWithParameters:(id)parameters completion:(completionBlock)completion;
// 获取问题专业组
- (void)getQuestionGroupWithCompletion:(completionBlock)completion;
// 获取问题专业组
- (void)getQuestionCategoryWithCompletion:(completionBlock)completion;
@end @end
...@@ -302,4 +302,25 @@ ...@@ -302,4 +302,25 @@
}]; }];
} }
// 获取问题专业组
- (void)getQuestionGroupWithCompletion:(completionBlock)completion
{
[self getParameters:nil completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
}];
}
// 获取问题专业组
- (void)getQuestionCategoryWithCompletion:(completionBlock)completion
{
[self getParameters:nil completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
}];
}
@end @end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment