Commit f8c90bc0 authored by admin's avatar admin

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

parent 26922a4d
......@@ -140,6 +140,8 @@
#define kRefreshInspectPointNotification @"refreshInspectPoint"
#define kRefreshQuestionNotification @"refershQuestionList"
#define kQuestionGroupNotification @"questionGroup"
#define kTAxisBtnTag 500232
......
......@@ -74,5 +74,9 @@
// 抽查评分
#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 */
......@@ -51,7 +51,6 @@
GroupItems *scopeItem = [[GroupItems alloc] initWithTitle:@"问题范围" view:_scopeTableView];
self.groupTableView = [[GroupTableView alloc] init];
_groupTableView.groupDeleagte = self.categoryTableView;
GroupItems *groupItem = [[GroupItems alloc] initWithTitle:@"问题分组" view:_groupTableView];
self.categoryTableView = [[CategoryTableView alloc] init];
......
......@@ -11,11 +11,11 @@
@protocol CategoryTableViewDelegate <NSObject>
- (void)categoryTableViewClick:(NSInteger)row;
- (void)categoryTableViewClick:(NSString *)categoryName GroupTitle:(NSString *)groupTitle;
@end
@interface CategoryTableView : UITableView <GroupTableViewDelegate>
@interface CategoryTableView : UITableView
@property (nonatomic, assign) id <CategoryTableViewDelegate>categroyDeleagte;
@end
......@@ -7,8 +7,12 @@
//
#import "CategoryTableView.h"
#import "HttpClient.h"
@interface CategoryTableView ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) NSMutableArray *titleArray;
@property (nonatomic, strong) NSMutableArray *categoryArray;
@end
@implementation CategoryTableView
......@@ -35,27 +39,49 @@
{
self.delegate = self;
self.dataSource = self;
self.titleArray = [NSMutableArray arrayWithObjects:@"基础环境",@"人员", @"停车场",@"卫生间", @"物料标识", nil];
self.titleArray = [NSMutableArray array];
self.categoryArray = [NSMutableArray array];
NSInteger selectedIndex = 0;
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
[self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
//注册通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadCurrentTableView:) name:kQuestionGroupNotification object:nil];
}
//- (void)groupTableViewClick:(NSInteger)row
//{
// if (row == 0) {
// [self reloadData];
// } else {
// self.titleArray = [NSMutableArray arrayWithObjects:@"211",@"322", nil];
// [self reloadData];
//
// }
//}
- (void)reloadCurrentTableView:(NSNotification *)notification
{
NSString *url = [NSString stringWithFormat:@"%@%@%@",kRedStarURL, kQuestionCategoryURL, notification.userInfo[@"groupName"]];
HttpClient *http = [[HttpClient alloc] initWithUrl:url];
[http getQuestionCategoryWithCompletion:^(id response, NSError *error) {
NSLog(@"分类categaory response= %@", response);
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
{
return _titleArray.count;
......@@ -78,8 +104,10 @@
// cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (_categroyDeleagte) {
[_categroyDeleagte categoryTableViewClick:indexPath.row];
NSString *cateName = _categoryArray[indexPath.row];
NSString *group = _titleArray[indexPath.row];
if (_categroyDeleagte && [_categroyDeleagte respondsToSelector:@selector(categoryTableViewClick:GroupTitle:)]) {
[_categroyDeleagte categoryTableViewClick:cateName GroupTitle:group];
}
}
......
......@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
@protocol GroupTableViewDelegate <NSObject>
- (void)groupTableViewClick:(NSInteger)row;
- (void)groupTableViewClick:(NSString *)groupName;
@end
@interface GroupTableView : UITableView
......
......@@ -7,6 +7,8 @@
//
#import "GroupTableView.h"
#import "HttpClient.h"
@interface GroupTableView ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) NSMutableArray *titleArray;
@end
......@@ -33,16 +35,20 @@
- (void)setup
{
self.titleArray = [NSMutableArray arrayWithObjects:@"全部",@"服务",@"环境企划",@"环境物业", nil];
self.delegate = self;
self.dataSource = self;
NSInteger selectedIndex = 0;
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
[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
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
......@@ -67,8 +73,12 @@
// cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (_groupDeleagte) {
[_groupDeleagte groupTableViewClick:indexPath.row];
NSString *title = [NSString stringWithFormat:@"%@", _titleArray[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 @@
@property (nonatomic, assign) NSInteger page;
@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 timeRow;
......@@ -71,7 +74,6 @@
[self setupNav];
// [self requestQuestionList];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(requestQuestionList)
......@@ -79,6 +81,8 @@
object:nil];
_page = 0;
//[self requestGroupTitle];
}
- (void)dealloc
......@@ -97,14 +101,29 @@
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#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
{
......@@ -363,8 +382,8 @@
if (!_screenView) {
_screenView = [[MoreScreenView alloc] init];
_screenView.backgroundColor = [UIColor whiteColor];
_screenView.scopeTableView.scopeDeleagte = self;
_screenView.groupTableView.groupDeleagte = self;
_screenView.scopeTableView.scopeDeleagte = self;
_screenView.categoryTableView.categroyDeleagte = self;
_screenView.stateTableView.stateDeleagte = self;
_screenView.timeTableView.timeDeleagte = self;
......@@ -455,30 +474,15 @@
@"direction":@"asc"}];
[parameters setObject:array forKey:@"queryOrders"];
} else if (_screenView.groupTabBar.selectNumber == 1) {
if (_groupRow == 0) {
} else if (_groupRow == 1) {
[parameters setObject:@"服务" forKey:@"group"];
} else if (_groupRow == 2) {
[parameters setObject:@"环境企划" forKey:@"group"];
} else {
[parameters setObject:@"环境物业" forKey:@"group"];
}
// 分组
[parameters setObject:_groupName forKey:@"group"];
NSArray *array = @[@{@"field":@"group",
@"direction":@"asc"}];
[parameters setObject:array forKey:@"queryOrders"];
} else if (_screenView.groupTabBar.selectNumber == 2) {
if (_categoryRow == 0) {
[parameters setObject:@"基础环境" forKey:@"category"];
} else if (_categoryRow == 1) {
[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"];
}
[parameters setObject:_groupTitle forKey:@"group"];
[parameters setObject:_categoryName forKey:@"category"];
NSArray *array = @[@{@"field":@"category",
@"direction":@"asc"}];
[parameters setObject:array forKey:@"queryOrders"];
......@@ -607,14 +611,15 @@
_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
......
......@@ -484,15 +484,15 @@
[parameters setObject:weekStr forKey:@"beginDateFrom"];
[parameters setObject:todayStr forKey:@"endDateTo"];
NSLog(@"onwek = %@", parameters);
} else if (_timeSelectNum == 1) {
NSDate *oneMonth = [self getPriousorLaterDateFromDate:today withMonth:-1];
NSString *oneMonthStr = [dateFormatter stringFromDate:oneMonth];
NSLog(@"oneMonth = %@", oneMonthStr);
[parameters setObject:oneMonthStr forKey:@"beginDateFrom"];
[parameters setObject:todayStr forKey:@"endDateTo"];
NSLog(@"oneMonth = %@", parameters);
} else if (_timeSelectNum == 2) {
NSDate *threeMonth = [self getPriousorLaterDateFromDate:today withMonth:-3];
NSString *threeMonthStr = [dateFormatter stringFromDate:threeMonth];
......@@ -514,11 +514,10 @@
NSArray *array = @[@{@"field":@"lastModifyInfo",
@"direction":@"asc"}];
[parameters setObject:array forKey:@"queryOrders"];
NSLog(@"parameters = %@",parameters);
}
NSLog(@"parameters = %@",parameters);
......
......@@ -83,4 +83,9 @@ typedef void (^completionBlock) (id response, NSError *error);
// 抽查评分
- (void)gradeCheckResultWithParameters:(id)parameters completion:(completionBlock)completion;
// 获取问题专业组
- (void)getQuestionGroupWithCompletion:(completionBlock)completion;
// 获取问题专业组
- (void)getQuestionCategoryWithCompletion:(completionBlock)completion;
@end
......@@ -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
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