Commit b8f86f8d authored by admin's avatar admin

问题分类接口完成

parent e9bb3198
......@@ -13,38 +13,6 @@
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redstar/Classes/Module/Function/Question/AddQuestion/ViewController/AddQuestionViewController.m"
timestampString = "473677271.6783"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "315"
endingLineNumber = "315"
landmarkName = "-alertView:clickedButtonAtIndex:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redstar/Classes/Module/Function/Question/AddQuestion/ViewController/AddQuestionViewController.m"
timestampString = "473677272.558419"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "312"
endingLineNumber = "312"
landmarkName = "-alertView:clickedButtonAtIndex:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
......
......@@ -123,7 +123,7 @@
} else {
imageName = [CommonFunc md5Data:data];
NSString *fullPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", imageName]];
[_imageNameArray addObject:imageName];
// [_imageNameArray addObject:imageName];
[data writeToFile:fullPath atomically:NO];
}
......
......@@ -49,19 +49,23 @@
@property (nonatomic, strong) NSMutableDictionary *saveDict;
@property (nonatomic, strong) NSMutableArray *categoryArray;
@property (nonatomic, strong) NSMutableDictionary *questionDict;
@property (nonatomic, strong) NSMutableArray *questionArray;
@property (nonatomic, assign) NSInteger categoryNum;
@property (nonatomic, assign) NSInteger questionNum;
@property (nonatomic) BOOL isComplete;
@property (nonatomic) BOOL isLoad;
@property (nonatomic, strong) NSMutableDictionary *groupUuidDict;
@end
@implementation AddQuestionViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self createNewDict];
self.categoryArray = [NSMutableArray array];
self.questionArray = [NSMutableArray array];
self.view.backgroundColor = kFootViewBackGroundColor;
......@@ -82,40 +86,73 @@
self.imageNameArray = [NSMutableArray array];
self.titleArray = [NSArray arrayWithObjects:@"选择对应专业组", @"选择问题分类", nil];
[self addTableView];
// takePhoto代理
[self.footerView.reportBtn addTarget:self action:@selector(upLoadQuestionPic:) forControlEvents:UIControlEventTouchUpInside];
// self.saveDict = [NSMutableDictionary dictionary];
// [_saveDict setObject:@"请选择" forKey:@"selectLabel"];
// [_saveDict setObject:@"请选择" forKey:@"selectLabel1"];
[self requestGroupTitle];
_rowNumber = 4;
_categoryNum = 0;
_questionNum = 0;
_isComplete = NO;
_isLoad = NO;
}
//
- (void)createNewDict
// 请求问题专业组
- (void)requestGroupTitle
{
self.categoryArray = [NSMutableArray arrayWithObjects:@"服务", @"环境企划", @"环境物业",@"价格",@"质量",@"商户信用分类",@"审批比价采购",@"送货跟单",@"指标",@"其他", nil];
self.questionDict = [NSMutableDictionary dictionary];
[_questionDict setObject:[NSArray arrayWithObjects:@"15分钟退单",@"便民服务",@"基础管理",@"轻松购系统",@"营运物料",@"服务承诺",@"人员形象",@"全员服务",@"其他", nil] forKey:@"服务"];
[_questionDict setObject:[NSArray arrayWithObjects:@"导视系统",@"背景音乐",@"物料规范",@"儿童区",@"休息区",@"其他", nil] forKey:@"环境企划"];
[_questionDict setObject:[NSArray arrayWithObjects:@"基础环境",@"物料标识",@"停车场",@"卫生间",@"硬件改造",@"人员",@"其他", nil] forKey:@"环境物业"];
[_questionDict setObject:[NSArray arrayWithObjects:@"七折管理",@"价签物料",@"其他", nil] forKey:@"价格"];
[_questionDict setObject:[NSArray arrayWithObjects:@"绿色陈展",@"三年质保",@"其他", nil] forKey:@"质量"];
[_questionDict setObject:[NSArray arrayWithObjects:@"商户信用分类", nil] forKey:@"商户信用分类"];
[_questionDict setObject:[NSArray arrayWithObjects:@"审批、比价、采购", nil] forKey:@"审批比价采购"];
[_questionDict setObject:[NSArray arrayWithObjects:@"送货跟单", nil] forKey:@"送货跟单"];
[_questionDict setObject:[NSArray arrayWithObjects:@"指标", nil] forKey:@"指标"];
[_questionDict setObject:[NSArray arrayWithObjects:@"其他", nil] forKey:@"其他"];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:[NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionGroupURL]];
[httpClient getQuestionGroupWithCompletion:^(id response, NSError *error) {
NSLog(@"问题与专业分组 === %@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSMutableArray *nameArray = [NSMutableArray array];
for (NSDictionary *groupDict in dataArray) {
NSString *name = [NSString stringWithFormat:@"%@", groupDict[@"name"]];
NSString *groupUuid = [NSString stringWithFormat:@"%@", groupDict[@"uuid"]];
[dict setObject:groupUuid forKey:name];
[nameArray addObject:name];
}
_groupUuidDict = dict;
_categoryArray = nameArray;
_isComplete = YES;
if (nameArray.count != 0) {
NSString *nameStr = [NSString stringWithFormat:@"%@", nameArray[0]];
[self requestCategoryWithGroupUuid:[dict objectForKey:nameStr]];
}
[self.tableView reloadData];
}];
}
- (void)requestCategoryWithGroupUuid:(NSString *)groupUuid
{
NSString *url = [NSString stringWithFormat:@"%@%@%@",kRedStarURL, kQuestionCategoryURL, groupUuid];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
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 *categoryArray = [NSMutableArray array];
for (NSDictionary *dict in array) {
NSString *category = [NSString stringWithFormat:@"%@", dict[@"name"]];
[categoryArray addObject:category];
}
_questionArray = categoryArray;
_isLoad = YES;
[self.tableView reloadData];
}
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
......@@ -282,8 +319,8 @@
NSDictionary *parameters;
if (_imageNameArray.count == 0) {
parameters = @{@"category":_selectLabel.text,
@"group":_selectLabel1.text,
parameters = @{@"category":_selectLabel1.text,
@"group":_selectLabel.text,
@"title":content,
@"content":title
};
......@@ -302,8 +339,8 @@
[imageArray addObject:dict];
}
parameters = @{@"category":_selectLabel.text,
@"group":_selectLabel1.text,
parameters = @{@"category":_selectLabel1.text,
@"group":_selectLabel.text,
@"title":content,
@"content":title,
@"attachments":imageArray};
......@@ -367,8 +404,19 @@
line.backgroundColor = kSeparateLineColor;
[cell.contentView addSubview:line];
NSString *cateStr = nil;
if (_categoryArray.count != 0) {
if (_isComplete) {
cateStr = _categoryArray[_categoryNum];
} else {
cateStr = @"";
}
} else {
cateStr = @"";
}
NSString *cateStr = _categoryArray[_categoryNum];
if (indexPath.row == 0) {
if (!self.selectLabel) {
_selectLabel = [[UILabel alloc] init];
......@@ -400,8 +448,19 @@
if (!self.selectLabel1) {
self.selectLabel1 = [[UILabel alloc] init];
}
NSArray *seleArray = [_questionDict objectForKey:cateStr];
_selectLabel1.text = seleArray[_questionNum];
if (_questionArray.count != 0) {
if (_isLoad) {
_selectLabel1.text = _questionArray[_questionNum];
} else {
_selectLabel1.text = @"";
}
} else {
_selectLabel1.text = @"";
}
_selectLabel1.translatesAutoresizingMaskIntoConstraints = NO;
_selectLabel1.textColor = kOnLineCellDetailColor;
_selectLabel1.textAlignment = NSTextAlignmentRight;
......@@ -506,15 +565,19 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
self.categoryActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:CATEGORYLIST];
self.categoryActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:nil];
for (NSString *groupName in _categoryArray) {
[_categoryActionSheet addButtonWithTitle:groupName];
}
_categoryActionSheet.delegate = self;
[_categoryActionSheet showInView:self.view];
} else if (indexPath.row == 1) {
self.questionActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:nil];
NSString *cateStr = _categoryArray[_categoryNum];
NSArray *seleArray = [_questionDict objectForKey:cateStr];
for (NSString *selectStr in seleArray) {
for (NSString *selectStr in _questionArray) {
[_questionActionSheet addButtonWithTitle:selectStr];
}
......@@ -555,18 +618,19 @@
if (actionSheet == _categoryActionSheet) {
if (buttonIndex < _categoryArray.count) {
_selectLabel.text = [_categoryArray objectAtIndex:buttonIndex];
_categoryNum = buttonIndex;
if ((buttonIndex -1) < _categoryArray.count) {
_selectLabel.text = [_categoryArray objectAtIndex:(buttonIndex -1)];
_categoryNum = (buttonIndex -1);
NSString *groupUuid = [_groupUuidDict objectForKey:_selectLabel.text];
_isLoad = NO;
[self requestCategoryWithGroupUuid:groupUuid];
_questionNum = 0;
[self.tableView reloadData];
}
} else if (actionSheet == _questionActionSheet){
NSString *cateStr = _categoryArray[_categoryNum];
NSArray *seleArray = [_questionDict objectForKey:cateStr];
if ((buttonIndex - 1) < seleArray.count) {
_selectLabel1.text = [seleArray objectAtIndex:(buttonIndex - 1)];
if ((buttonIndex -1) < _questionArray.count) {
_selectLabel1.text = [_questionArray objectAtIndex:(buttonIndex -1)];
_questionNum = buttonIndex - 1;
}
}
......
......@@ -11,7 +11,7 @@
@protocol CategoryTableViewDelegate <NSObject>
- (void)categoryTableViewClick:(NSString *)categoryName GroupTitle:(NSString *)groupTitle;
- (void)categoryTableViewClick:(NSString *)categoryName;
@end
......
......@@ -40,61 +40,59 @@
- (void)setup
{
self.questionDict = [NSMutableDictionary dictionary];
[_questionDict setObject:[NSArray arrayWithObjects:@"15分钟退单",@"便民服务",@"基础管理",@"轻松购系统",@"营运物料",@"服务承诺",@"人员形象",@"全员服务",@"其他", nil] forKey:@"服务"];
[_questionDict setObject:[NSArray arrayWithObjects:@"导视系统",@"背景音乐",@"物料规范",@"儿童区",@"休息区",@"其他", nil] forKey:@"环境企划"];
[_questionDict setObject:[NSArray arrayWithObjects:@"基础环境",@"物料标识",@"停车场",@"卫生间",@"硬件改造",@"人员",@"其他", nil] forKey:@"环境物业"];
[_questionDict setObject:[NSArray arrayWithObjects:@"七折管理",@"价签物料",@"其他", nil] forKey:@"价格"];
[_questionDict setObject:[NSArray arrayWithObjects:@"绿色陈展",@"三年质保",@"其他", nil] forKey:@"质量"];
[_questionDict setObject:[NSArray arrayWithObjects:@"商户信用分类", nil] forKey:@"商户信用分类"];
[_questionDict setObject:[NSArray arrayWithObjects:@"审批、比价、采购", nil] forKey:@"审批比价采购"];
[_questionDict setObject:[NSArray arrayWithObjects:@"送货跟单", nil] forKey:@"送货跟单"];
[_questionDict setObject:[NSArray arrayWithObjects:@"指标", nil] forKey:@"指标"];
[_questionDict setObject:[NSArray arrayWithObjects:@"其他", nil] forKey:@"其他"];
self.delegate = self;
self.dataSource = self;
self.titleArray = [NSMutableArray arrayWithArray:[NSArray arrayWithObjects:@"15分钟退单",@"便民服务",@"基础管理",@"轻松购系统",@"营运物料",@"服务承诺",@"人员形象",@"全员服务",@"其他", 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];
NSMutableArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:@"groupAllName"];
NSMutableDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"groupTitle"];
if (array.count != 0) {
NSString *name = array[0];
NSString *groupUuid = [dict objectForKey:name];
[self requestCategoryListWithGroupUuid:groupUuid];
}
//注册通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadCurrentTableView:) name:kQuestionGroupNotification object:nil];
}
- (void)requestCategoryListWithGroupUuid:(NSString *)groupUuid
{
NSString *url = [NSString stringWithFormat:@"%@%@%@",kRedStarURL, kQuestionCategoryURL, groupUuid];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
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)reloadCurrentTableView:(NSNotification *)notification
{
_cateStr = [NSString stringWithFormat:@"%@",notification.userInfo[@"groupName"]];
NSArray *selectArray = [NSArray arrayWithArray:[_questionDict objectForKey:_cateStr]];
_titleArray = [NSMutableArray arrayWithArray:selectArray];
[self reloadData];
// NSString *url = [NSString stringWithFormat:@"%@%@%@",kRedStarURL, kQuestionCategoryURL, notification.userInfo[@"groupName"]];
// url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
// 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];
// }
// }];
[self requestCategoryListWithGroupUuid:notification.userInfo[@"groupUuid"]];
}
- (void)dealloc
......@@ -126,10 +124,9 @@
// cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// NSString *cateName = _categoryArray[indexPath.row];
NSString *group = _titleArray[indexPath.row];
if (_categroyDeleagte && [_categroyDeleagte respondsToSelector:@selector(categoryTableViewClick:GroupTitle:)]) {
[_categroyDeleagte categoryTableViewClick:_cateStr GroupTitle:group];
NSString *cateName = _titleArray[indexPath.row];
if (_categroyDeleagte && [_categroyDeleagte respondsToSelector:@selector(categoryTableViewClick:)]) {
[_categroyDeleagte categoryTableViewClick:cateName];
}
}
......
......@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
@protocol GroupTableViewDelegate <NSObject>
- (void)groupTableViewClick:(NSString *)groupName;
- (void)groupTableViewClick:(NSInteger)groupRow;
@end
@interface GroupTableView : UITableView
......
......@@ -41,9 +41,9 @@
[self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
// NSMutableArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:@"groupTitle"];
// self.titleArray = [NSMutableArray arrayWithArray:array];
_titleArray = [NSMutableArray arrayWithObjects:@"服务", @"环境企划", @"环境物业",@"价格",@"质量",@"商户信用分类",@"审批比价采购",@"送货跟单",@"指标",@"其他", nil];
NSMutableArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:@"groupAllName"];
self.titleArray = [NSMutableArray arrayWithArray:array];
self.delegate = self;
self.dataSource = self;
......@@ -76,11 +76,12 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *title = [NSString stringWithFormat:@"%@", _titleArray[indexPath.row]];
NSDictionary *dict =[[NSDictionary alloc] initWithObjectsAndKeys:title, @"groupName", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kQuestionGroupNotification object:self userInfo:dict];
NSMutableDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"groupTitle"];
NSString *groupUuid = [dict objectForKey:title];
NSDictionary *categaryDict =[[NSDictionary alloc] initWithObjectsAndKeys:groupUuid, @"groupUuid", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kQuestionGroupNotification object:self userInfo:categaryDict];
if(_groupDeleagte && [_groupDeleagte respondsToSelector:@selector(groupTableViewClick:)]) {
[_groupDeleagte groupTableViewClick:title];
[_groupDeleagte groupTableViewClick:indexPath.row];
}
}
......
......@@ -47,9 +47,10 @@
@property (nonatomic, assign) NSInteger scopeRow;
// 分组
@property (nonatomic, copy) NSString *groupName;
@property (nonatomic, assign) NSInteger groupRow;
@property (nonatomic, strong) NSMutableArray *allGroupNameArray;
// 分类
@property (nonatomic, copy) NSString *groupTitle;
@property (nonatomic, copy) NSString *categoryName;
@property (nonatomic, assign) NSInteger stateRow;
@property (nonatomic, assign) NSInteger timeRow;
......@@ -81,8 +82,32 @@
object:nil];
_page = 0;
//[self requestGroupTitle];
_groupRow = 0;
[self requestGroupTitle];
}
// 请求问题专业组
- (void)requestGroupTitle
{
self.allGroupNameArray = [NSMutableArray array];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:[NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionGroupURL]];
[httpClient getQuestionGroupWithCompletion:^(id response, NSError *error) {
NSLog(@"问题与专业分组 === %@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSMutableArray *nameArray = [NSMutableArray array];
for (NSDictionary *groupDict in dataArray) {
NSString *name = [NSString stringWithFormat:@"%@", groupDict[@"name"]];
NSString *groupUuid = [NSString stringWithFormat:@"%@", groupDict[@"uuid"]];
[dict setObject:groupUuid forKey:name];
[nameArray addObject:name];
}
[[NSUserDefaults standardUserDefaults] setObject:dict forKey:@"groupTitle"];
[[NSUserDefaults standardUserDefaults] setObject:nameArray forKey:@"groupAllName"];
_allGroupNameArray = nameArray;
}];
}
- (void)dealloc
......@@ -468,13 +493,13 @@
[parameters setObject:array forKey:@"queryOrders"];
} else if (_screenView.groupTabBar.selectNumber == 1) {
// 分组
[parameters setObject:_groupName forKey:@"group"];
[parameters setObject:_allGroupNameArray[_groupRow] forKey:@"group"];
NSArray *array = @[@{@"field":@"group",
@"direction":@"asc"}];
[parameters setObject:array forKey:@"queryOrders"];
} else if (_screenView.groupTabBar.selectNumber == 2) {
[parameters setObject:_groupTitle forKey:@"group"];
[parameters setObject:_allGroupNameArray[_groupRow] forKey:@"group"];
[parameters setObject:_categoryName forKey:@"category"];
NSArray *array = @[@{@"field":@"category",
@"direction":@"asc"}];
......@@ -604,15 +629,14 @@
_scopeRow = row;
}
- (void)groupTableViewClick:(NSString *)groupName
- (void)groupTableViewClick:(NSInteger)groupRow
{
_groupName = groupName;
_groupRow = groupRow;
}
- (void)categoryTableViewClick:(NSString *)categoryName GroupTitle:(NSString *)groupTitle
- (void)categoryTableViewClick:(NSString *)categoryName
{
_categoryName = categoryName;
_groupTitle = groupTitle;
}
- (void)stateTableViewClick:(NSInteger)row
......
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