Commit 2274530b authored by Sandy's avatar Sandy

拓站文字显示错误修复、报修详情许可证无数据提示、hse巡检模糊查询、筛选逻辑bug修复

parent 41a6d86c
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
@"function_repairSee_icon" @"function_repairSee_icon"
,@"function_licenceSee_icon",nil]; ,@"function_licenceSee_icon",nil];
NSArray *titleArray = [NSArray arrayWithObjects: NSArray *titleArray = [NSArray arrayWithObjects:
@"拓" @"拓"
,@"HSE巡检",nil]; ,@"HSE巡检",nil];
NSDictionary *dict = @{@"image":[imageArray objectAtIndex:i],@"title":[titleArray objectAtIndex:i]}; NSDictionary *dict = @{@"image":[imageArray objectAtIndex:i],@"title":[titleArray objectAtIndex:i]};
[_datasArray[3] addObject:dict]; [_datasArray[3] addObject:dict];
...@@ -409,12 +409,7 @@ ...@@ -409,12 +409,7 @@
//根据个人查看权和本人查看权的范围确定是否有菜单权限 //根据个人查看权和本人查看权的范围确定是否有菜单权限
- (BOOL)permissionWithMaxNumber: (NSString *)maxNumber{ - (BOOL)permissionWithMaxNumber: (NSString *)maxNumber{
ICRUserUtil *userU = [ICRUserUtil sharedInstance]; ICRUserUtil *userU = [ICRUserUtil sharedInstance];
for(NSString *strNumber in userU.f_permissions){ return [userU.f_permissions containsObject:maxNumber];
if ([strNumber isEqualToString:maxNumber]) {
return YES;
}
}
return NO;
} }
......
...@@ -436,7 +436,7 @@ typedef NS_ENUM (NSUInteger, ICRFunctionID) { ...@@ -436,7 +436,7 @@ typedef NS_ENUM (NSUInteger, ICRFunctionID) {
[self PushViewController:pVC animated:YES]; [self PushViewController:pVC animated:YES];
} }
break; break;
case kFunctionPioneering://拓 case kFunctionPioneering://拓
{ {
GTOPioneeringListViewController *pioneeringVC = [[GTOPioneeringListViewController alloc]init]; GTOPioneeringListViewController *pioneeringVC = [[GTOPioneeringListViewController alloc]init];
[self PushViewController:pioneeringVC animated:YES]; [self PushViewController:pioneeringVC animated:YES];
......
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
// Copyright (c) 2015年 free. All rights reserved. // Copyright (c) 2015年 free. All rights reserved.
// //
#import "GTOPatrolPlanListViewController.h" #import "BoltMaskView.h"
#import "GTOAllPatrolPlanViewController.h"
#import "GTOPaging.h"
#import "GTOPatrolPlan.h" #import "GTOPatrolPlan.h"
#import "GTOPatrolPlanCellContentView.h" #import "GTOPatrolPlanCellContentView.h"
#import "GTOAllPatrolPlanViewController.h" #import "GTOPatrolPlanListViewController.h"
#import "GTOQuestion.h"
#import "MJRefresh.h" #import "MJRefresh.h"
#import "SortMaskView.h" #import "SortMaskView.h"
#import "BoltMaskView.h"
#import "GTOPaging.h"
#import "GTOQuestion.h"
#define TopMargin 44 #define TopMargin 44
#define TableHeight 120 #define TableHeight 120
#define LeftMargin 20 #define LeftMargin 20
...@@ -23,10 +23,11 @@ ...@@ -23,10 +23,11 @@
#define BtnSize 16 #define BtnSize 16
#define HexColor(colorStr) [UIColor colorWithHexString:colorStr] #define HexColor(colorStr) [UIColor colorWithHexString:colorStr]
#define GXF_DETAIL_COLOR [UIColor colorWithHexString:@"888888"]// HexColor(@"888888") #define GXF_DETAIL_COLOR \
[UIColor colorWithHexString:@"888888"] // HexColor(@"888888")
#define PATROL_PLAN_CELL_HEIGHT 153 #define PATROL_PLAN_CELL_HEIGHT 153
//typedef NS_ENUM(NSUInteger, PatrolSegmentsType) { // typedef NS_ENUM(NSUInteger, PatrolSegmentsType) {
// kPatrolSegUnFinished = 0, // kPatrolSegUnFinished = 0,
// kPatrolSegFinished, // kPatrolSegFinished,
//}; //};
...@@ -38,33 +39,36 @@ typedef enum : NSUInteger { ...@@ -38,33 +39,36 @@ typedef enum : NSUInteger {
} BtnTag; } BtnTag;
static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
@interface GTOPatrolPlanListViewController ()<UITableViewDataSource,UITableViewDelegate,IBTScrollViewRefreshDelegate,SortMaskViewDelegate,BoltMaskViewDelegate> @interface GTOPatrolPlanListViewController () <
{ UITableViewDataSource, UITableViewDelegate, IBTScrollViewRefreshDelegate,
SortMaskViewDelegate, BoltMaskViewDelegate> {
BOOL _isRefresh; BOOL _isRefresh;
BOOL _isLoadMore; BOOL _isLoadMore;
// NSInteger _currentPage; // NSInteger _currentPage;
} }
@property (strong, nonatomic) UITableView *m_tableView; @property(strong, nonatomic) UITableView *m_tableView;
@property (strong, nonatomic) NSMutableArray *m_arrAllData;//所以巡检任务 @property(strong, nonatomic) NSMutableArray *m_arrAllData; //所以巡检任务
@property (nonatomic, strong) UIBarButtonItem *c_sureBtn;//选择条件后确定按钮 @property(nonatomic, strong) UIBarButtonItem *c_sureBtn; //选择条件后确定按钮
@property (nonatomic, strong) UIButton *c_sortBtn;// 排序按钮 @property(nonatomic, strong) UIButton *c_sortBtn; // 排序按钮
@property (nonatomic, strong) UIButton *c_filterBtn;//筛选 @property(nonatomic, strong) UIButton *c_filterBtn; //筛选
@property (nonatomic, strong) UIButton *c_currentBtn;//目前点击的按钮 @property(nonatomic, strong) UIButton *c_currentBtn; //目前点击的按钮
@property (nonatomic, strong) UIView *c_maskView;//选择筛选条件时出现的灰色背景的view @property(nonatomic, strong)
@property (nonatomic, strong) SortMaskView *c_sortView;// 时间顺序 UIView *c_maskView; //选择筛选条件时出现的灰色背景的view
@property (nonatomic, strong) BoltMaskView *c_boltView; @property(nonatomic, strong) SortMaskView *c_sortView; // 时间顺序
@property (nonatomic, copy) NSString *d_state;//未提交=initial已提交=submitted调研中=insurvey已完成=finished @property(nonatomic, strong) BoltMaskView *c_boltView;
@property (nonatomic,strong)NSString *d_orderDirection;//asc(升序),desc(降序) @property(nonatomic, copy) NSString
*d_state; //未提交=initial已提交=submitted调研中=insurvey已完成=finished
@property(nonatomic, strong) NSString *d_orderDirection; // asc(升序),desc(降序)
@property (nonatomic, strong) NSString *d_titleLike; @property(nonatomic, strong) NSString *d_titleLike;
@property (nonatomic, strong) NSString *d_patrolCategory; @property(nonatomic, strong) NSString *d_patrolCategory;
@end @end
@implementation GTOPatrolPlanListViewController @implementation GTOPatrolPlanListViewController
- (instancetype)initWithTitle: (NSString *)title { - (instancetype)initWithTitle:(NSString *)title {
self = [super init]; self = [super init];
if (!self) { if (!self) {
return nil; return nil;
...@@ -75,7 +79,7 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -75,7 +79,7 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
} }
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// self.title = @"HSE巡检"; // self.title = @"HSE巡检";
[self p_initWithSubViews]; [self p_initWithSubViews];
[self createRefresh]; [self createRefresh];
[self createBackBtn]; [self createBackBtn];
...@@ -88,25 +92,28 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -88,25 +92,28 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
- (void)getLocalData { - (void)getLocalData {
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ DESC", [GTOPatrolPlan TableName],@"category",@"lastModify_time" ]; NSString *sql = [NSString
NSLog(@"%@, %@",sql,_d_patrolCategory); stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ DESC",
return [db executeQuery:sql,_d_patrolCategory]; [GTOPatrolPlan TableName], @"category",
@"lastModify_time"];
NSLog(@"%@, %@", sql, _d_patrolCategory);
return [db executeQuery:sql, _d_patrolCategory];
}; };
__weak typeof(self)weakSelf = self; __weak typeof(self) weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) { ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
if (!fetchedObjects || fetchedObjects.count < 1) { if (!fetchedObjects || fetchedObjects.count < 1) {
[strongSelf getHttpDataWithDate:[[NSDate date] httpParameterString] DateType:GTO_PATROL_DATE_TYPE_BEFORE]; [strongSelf getHttpDataWithDate:[[NSDate date] httpParameterString]
DateType:GTO_PATROL_DATE_TYPE_BEFORE];
} else { } else {
if (!strongSelf.m_arrAllData) { if (!strongSelf.m_arrAllData) {
strongSelf.m_arrAllData = [@[]mutableCopy]; strongSelf.m_arrAllData = [@[] mutableCopy];
} }
[strongSelf.m_arrAllData addObjectsFromArray:fetchedObjects]; [strongSelf.m_arrAllData addObjectsFromArray:fetchedObjects];
[strongSelf.m_tableView reloadData]; [strongSelf.m_tableView reloadData];
} }
}; };
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController]; ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
...@@ -114,23 +121,29 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -114,23 +121,29 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
fetchBlock:fetchBlk fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk]; fetchResultsBlock:fetchResultsBlk];
} }
- (void)getHttpDataByLocalDateWithDateType: (NSString *)dateType { - (void)getHttpDataByLocalDateWithDateType:(NSString *)dateType {
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ DESC", [GTOPatrolPlan TableName],@"category",@"lastModify_time" ]; NSString *sql = [NSString
NSLog(@"%@",sql); stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ DESC",
return [db executeQuery:sql,self.d_patrolCategory]; [GTOPatrolPlan TableName], @"category",
@"lastModify_time"];
NSLog(@"%@", sql);
return [db executeQuery:sql, self.d_patrolCategory];
}; };
__weak typeof(self)weakSelf = self; __weak typeof(self) weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) { ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
if (fetchedObjects.count < 1) return ; if (fetchedObjects.count < 1)
return;
GTOPatrolPlan *last = [fetchedObjects lastObject]; GTOPatrolPlan *last = [fetchedObjects lastObject];
GTOPatrolPlan *first = [fetchedObjects firstObject]; GTOPatrolPlan *first = [fetchedObjects firstObject];
if ([dateType isEqualToString:GTO_PATROL_DATE_TYPE_BEFORE]) { //旧数据 if ([dateType isEqualToString:GTO_PATROL_DATE_TYPE_BEFORE]) { //旧数据
[strongSelf getHttpDataWithDate:last.lastModify_time DateType:GTO_PATROL_DATE_TYPE_BEFORE]; [strongSelf getHttpDataWithDate:last.lastModify_time
DateType:GTO_PATROL_DATE_TYPE_BEFORE];
} }
if ([dateType isEqualToString:GTO_PATROL_DATE_TYPE_AFTER]) { //最新数据 if ([dateType isEqualToString:GTO_PATROL_DATE_TYPE_AFTER]) { //最新数据
[strongSelf getHttpDataWithDate:first.lastModify_time DateType:GTO_PATROL_DATE_TYPE_AFTER]; [strongSelf getHttpDataWithDate:first.lastModify_time
DateType:GTO_PATROL_DATE_TYPE_AFTER];
} }
}; };
[self endRefreshing]; [self endRefreshing];
...@@ -141,45 +154,39 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -141,45 +154,39 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
} }
/** 联网获取属数据 */ /** 联网获取属数据 */
- (void)getHttpDataWithDate: (NSString *)date DateType: (NSString *)dateType{ - (void)getHttpDataWithDate:(NSString *)date DateType:(NSString *)dateType {
//[ICRUserUtil sharedInstance].needFresh = NO; //[ICRUserUtil sharedInstance].needFresh = NO;
__weak typeof(self)weakSelf = self; __weak typeof(self) weakSelf = self;
void(^succ)(id) = ^(id data) { void (^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
[strongSelf fetchtPuchaseList:data DateType: dateType]; [strongSelf fetchtPuchaseList:data DateType:dateType];
}; };
void(^fail)(id) = ^(id data) { void (^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
ICRHTTPController *httpCtrl =
[ICRHTTPController sharedController]; //@"2015-10-16 21:46:03"
ICRHTTPController *httpCtrl = [ICRHTTPController sharedController]; //@"2015-10-16 21:46:03"
[httpCtrl getMyPatrolWithCategory:_d_patrolCategory [httpCtrl getMyPatrolWithCategory:_d_patrolCategory
startTime: date startTime:date
dateType:dateType dateType:dateType
pageNumber:0 pageSize:20 success:succ failure:fail]; pageNumber:0
// [httpCtrl getMyPatrolWithStartTime:date dateType:dateType pageNumber:0 pageSize:20 success:succ failure:fail]; pageSize:20
success:succ
// if (_isLoadMore && !_isRefresh) { failure:fail];
// [httpCtrl getMyPatrolWithStartTime:date dateType:GTO_PATROL_DATE_TYPE_BEFORE pageNumber:0 pageSize:20 success:succ failure:fail];
// }
// if (!_isLoadMore && _isRefresh) {
// [httpCtrl getMyPatrolWithStartTime:date dateType:GTO_PATROL_DATE_TYPE_AFTER pageNumber:0 pageSize:20 success:succ failure:fail];
// }
} }
//刷新列表 从服务器中获取数据 //刷新列表 从服务器中获取数据
- (void)fetchtPuchaseList:(id)data DateType: (NSString *)dateType{ - (void)fetchtPuchaseList:(id)data DateType:(NSString *)dateType {
if (data) { if (data) {
NSInteger success = [data[@"success"] integerValue]; NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ; NSString *message = data[@"message"];
if (success == 1) { if (success == 1) {
// NSString *string = [data JSONString]; // NSString *string = [data JSONString];
NSArray *recodesArr = data[ @"data" ][ @"records" ]; NSArray *recodesArr = data[@"data"][@"records"];
if ([dateType isEqualToString:GTO_PATROL_DATE_TYPE_BEFORE]) { if ([dateType isEqualToString:GTO_PATROL_DATE_TYPE_BEFORE]) {
if (recodesArr.count <= 0) { if (recodesArr.count <= 0) {
[self endRefreshing]; [self endRefreshing];
...@@ -192,14 +199,15 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -192,14 +199,15 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
[self endRefreshing]; [self endRefreshing];
return; return;
} }
for (int count = 0; count < recodesArr.count; count ++) { for (int count = 0; count < recodesArr.count; count++) {
NSDictionary *dict = recodesArr[count]; NSDictionary *dict = recodesArr[count];
GTOPatrolPlan *patrolPlan = [GTOPatrolPlan DBObject]; GTOPatrolPlan *patrolPlan = [GTOPatrolPlan DBObject];
[patrolPlan praseFromJsonDict:dict]; [patrolPlan praseFromJsonDict:dict];
int finishStores = 0; int totalStores = (int)patrolPlan.inspectors.count; int finishStores = 0;
for(NSDictionary *dict in patrolPlan.inspectors) { int totalStores = (int)patrolPlan.inspectors.count;
if ([dict[@"state" ] integerValue] == 1) { for (NSDictionary *dict in patrolPlan.inspectors) {
finishStores ++; if ([dict[@"state"] integerValue] == 1) {
finishStores++;
} }
} }
if (totalStores <= 0) { if (totalStores <= 0) {
...@@ -207,74 +215,73 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -207,74 +215,73 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
} }
patrolPlan.finishedStoreNumber = finishStores; patrolPlan.finishedStoreNumber = finishStores;
patrolPlan.totalStoreNumber = totalStores; patrolPlan.totalStoreNumber = totalStores;
if(patrolPlan.totalStoreNumber == 0) { if (patrolPlan.totalStoreNumber == 0) {
patrolPlan.processLength = 0.0; patrolPlan.processLength = 0.0;
} else { } else {
patrolPlan.processLength = finishStores * 1.0 / totalStores; patrolPlan.processLength = finishStores * 1.0 / totalStores;
} }
NSMutableArray *arrQuestionCategorys = [@[]mutableCopy]; NSMutableArray *arrQuestionCategorys = [@[] mutableCopy];
for(NSDictionary *dictQuestion in patrolPlan.questions) { for (NSDictionary *dictQuestion in patrolPlan.questions) {
[arrQuestionCategorys addObject:dictQuestion[@"category"]]; [arrQuestionCategorys addObject:dictQuestion[@"category"]];
} }
NSSet *setQuestionCategorys = [NSSet setWithArray:arrQuestionCategorys]; NSSet *setQuestionCategorys = [NSSet setWithArray:arrQuestionCategorys];
[arrQuestionCategorys removeAllObjects]; [arrQuestionCategorys removeAllObjects];
for(NSString *str in setQuestionCategorys) { for (NSString *str in setQuestionCategorys) {
[arrQuestionCategorys addObject:str]; [arrQuestionCategorys addObject:str];
} }
patrolPlan.questionCategorys = arrQuestionCategorys; patrolPlan.questionCategorys = arrQuestionCategorys;
if (!self.m_arrAllData) { if (!self.m_arrAllData) {
self.m_arrAllData = [@[]mutableCopy]; self.m_arrAllData = [@[] mutableCopy];
} }
[self.m_arrAllData addObject:patrolPlan]; [self.m_arrAllData addObject:patrolPlan];
// [self.m_tableView reloadData]; // [self.m_tableView reloadData];
if (count == recodesArr.count - 1) { if (count == recodesArr.count - 1) {
[self.m_tableView reloadData]; [self.m_tableView reloadData];
} }
[patrolPlan saveToDBWithHandleData:NULL complete:^{ [patrolPlan saveToDBWithHandleData:NULL
complete:^{
if (count == recodesArr.count - 1) { if (count == recodesArr.count - 1) {
[self endRefreshing]; [self endRefreshing];
[self p_getLocalData]; [self p_getLocalData];
} }
} fail:NULL]; }
fail:NULL];
} }
}else{ } else {
[self endRefreshing]; [self endRefreshing];
[IBTLoadingView showTips:message]; [IBTLoadingView showTips:message];
} }
}else{ } else {
[self endRefreshing]; [self endRefreshing];
[IBTLoadingView showTips:@" 无记录 "]; [IBTLoadingView showTips:@" 无记录 "];
} }
} }
- (void)p_getLocalData { - (void)p_getLocalData {
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ DESC", [GTOPatrolPlan TableName],@"category",@"lastModify_time" ]; NSString *sql = [NSString
NSLog(@"%@",sql); stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ DESC",
return [db executeQuery:sql,self.d_patrolCategory]; [GTOPatrolPlan TableName], @"category",
@"lastModify_time"];
NSLog(@"%@", sql);
return [db executeQuery:sql, self.d_patrolCategory];
}; };
__weak typeof(self)weakSelf = self; __weak typeof(self) weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) { ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
if (fetchedObjects.count < 1) { if (fetchedObjects.count < 1) {
// [strongSelf getHttpDataWithDate:[[NSDate date] httpParameterString] DateType:GTO_PATROL_DATE_TYPE_BEFORE];
// // [strongSelf getHttpDataWithDateType:GTO_PATROL_DATE_TYPE_BEFORE];
} else { } else {
if (!strongSelf.m_arrAllData) { if (!strongSelf.m_arrAllData) {
strongSelf.m_arrAllData = [@[]mutableCopy]; strongSelf.m_arrAllData = [@[] mutableCopy];
} }
[strongSelf.m_arrAllData removeAllObjects]; [strongSelf.m_arrAllData removeAllObjects];
[strongSelf.m_arrAllData addObjectsFromArray:fetchedObjects]; [strongSelf.m_arrAllData addObjectsFromArray:fetchedObjects];
[strongSelf.m_tableView reloadData]; [strongSelf.m_tableView reloadData];
} }
}; };
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController]; ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
...@@ -283,12 +290,14 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -283,12 +290,14 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
fetchResultsBlock:fetchResultsBlk]; fetchResultsBlock:fetchResultsBlk];
} }
- (void)createBackBtn{ - (void)createBackBtn {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
btn.frame = CGRectMake(0, 0, 12, 20); btn.frame = CGRectMake(0, 0, 12, 20);
[btn addTarget:self action:@selector(backClicked) forControlEvents:UIControlEventTouchUpInside]; [btn addTarget:self
UIBarButtonItem *back = [[UIBarButtonItem alloc]initWithCustomView:btn]; action:@selector(backClicked)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationItem.leftBarButtonItem = back; self.navigationItem.leftBarButtonItem = back;
} }
- (void)backClicked { - (void)backClicked {
...@@ -296,53 +305,82 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -296,53 +305,82 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
} }
- (void)p_initWithSubViews { - (void)p_initWithSubViews {
self.view.backgroundColor = XXFBgColor; self.view.backgroundColor = XXFBgColor;
self.m_tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)]; self.m_tableView = [[UITableView alloc]
[self.m_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:PatrolPlanCellIdentifier]; initWithFrame:(CGRectMake(0, TopMargin, ScreenSize.width,
ScreenSize.height - 64 - TopMargin))
style:(UITableViewStylePlain)];
[self.m_tableView registerClass:[UITableViewCell class]
forCellReuseIdentifier:PatrolPlanCellIdentifier];
self.m_tableView.delegate = self; self.m_tableView.delegate = self;
self.m_tableView.dataSource = self; self.m_tableView.dataSource = self;
[self.view addSubview:self.m_tableView]; [self.view addSubview:self.m_tableView];
self.c_sureBtn =
self.c_sureBtn = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClicked)]; [[UIBarButtonItem alloc] initWithTitle:@"确定"
style:UIBarButtonItemStylePlain
target:self
action:@selector(sureClicked)];
self.navigationItem.rightBarButtonItem = _c_sureBtn; self.navigationItem.rightBarButtonItem = _c_sureBtn;
self.c_sortBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, 10, BtnWidth, BtnHeight) target:self sel:@selector(sortClicked:) tag:SortTag image:@"black_arrow_down_with_text" title:nil titleColor:GXF_DETAIL_COLOR isCorner:NO corner:0 bgColor:nil]; self.c_sortBtn = [IBTCustomButtom
creatButtonWithFrame:CGRectMake(LeftMargin, 10, BtnWidth, BtnHeight)
self.c_filterBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(self.view.width-BtnWidth - LeftMargin,10,BtnWidth, BtnHeight) target:self sel:@selector(sortClicked:) tag:BoltTag image:@"black_filter_with_text" title:nil titleColor:GXF_DETAIL_COLOR isCorner:NO corner:0 bgColor:nil]; target:self
sel:@selector(sortClicked:)
tag:SortTag
image:@"black_arrow_down_with_text"
title:nil
titleColor:GXF_DETAIL_COLOR
isCorner:NO
corner:0
bgColor:nil];
self.c_filterBtn = [IBTCustomButtom
creatButtonWithFrame:CGRectMake(self.view.width - BtnWidth - LeftMargin,
10, BtnWidth, BtnHeight)
target:self
sel:@selector(sortClicked:)
tag:BoltTag
image:@"black_filter_with_text"
title:nil
titleColor:GXF_DETAIL_COLOR
isCorner:NO
corner:0
bgColor:nil];
_c_filterBtn.titleLabel.font = FontSize(BtnSize); _c_filterBtn.titleLabel.font = FontSize(BtnSize);
self.c_maskView = [[UIView alloc]
self.c_maskView = [[UIView alloc]initWithFrame:CGRectMake(0, TopMargin, ScreenSize.width, ScreenSize.height - 64- TopMargin)]; initWithFrame:CGRectMake(0, TopMargin, ScreenSize.width,
ScreenSize.height - 64 - TopMargin)];
self.c_maskView.backgroundColor = RGBA(0, 0, 0, 0.5); self.c_maskView.backgroundColor = RGBA(0, 0, 0, 0.5);
self.c_maskView.hidden = YES; self.c_maskView.hidden = YES;
[self.view addSubview:_c_maskView]; [self.view addSubview:_c_maskView];
[self.view addSubview:_c_sortBtn]; [self.view addSubview:_c_sortBtn];
[self.view addSubview:_c_filterBtn]; [self.view addSubview:_c_filterBtn];
} }
- (void)createRefresh{ - (void)createRefresh {
self.m_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ self.m_tableView.mj_header =
[MJRefreshNormalHeader headerWithRefreshingBlock:^{
if (_isRefresh) { if (_isRefresh) {
return ; return;
} }
_isRefresh = YES; _isRefresh = YES;
[self getHttpDataByLocalDateWithDateType:GTO_PATROL_DATE_TYPE_AFTER]; [self getHttpDataByLocalDateWithDateType:GTO_PATROL_DATE_TYPE_AFTER];
}]; }];
self.m_tableView.mj_header.lastUpdatedTimeKey = PurchaseNoticeUpdateDate; self.m_tableView.mj_header.lastUpdatedTimeKey = PurchaseNoticeUpdateDate;
self.m_tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ self.m_tableView.mj_footer =
[MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
if (_isLoadMore) { if (_isLoadMore) {
return ; return;
} }
_isLoadMore = YES; _isLoadMore = YES;
[self getHttpDataByLocalDateWithDateType:GTO_PATROL_DATE_TYPE_BEFORE]; [self getHttpDataByLocalDateWithDateType:GTO_PATROL_DATE_TYPE_BEFORE];
} ]; }];
} }
#pragma mark - 结束刷新 #pragma mark - 结束刷新
- (void)endRefreshing{ - (void)endRefreshing {
_isLoadMore = NO; _isLoadMore = NO;
_isRefresh = NO; _isRefresh = NO;
[self.m_tableView.mj_header endRefreshing]; [self.m_tableView.mj_header endRefreshing];
...@@ -353,33 +391,17 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -353,33 +391,17 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
- (void)p_fetchPatrolList { - (void)p_fetchPatrolList {
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@ DESC", [GTOPatrolPlan TableName], @"beginDate"];//??f_beginDate NSString *sql =
[NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@ DESC",
[GTOPatrolPlan TableName],
@"beginDate"]; //??f_beginDate
return [db executeQuery:sql]; return [db executeQuery:sql];
}; };
__weak typeof(self)weakSelf = self; __weak typeof(self) weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) { ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
strongSelf.m_arrAllData = fetchedObjects; strongSelf.m_arrAllData = fetchedObjects.mutableCopy;
//
// if (strongSelf.m_store) {
// NSMutableArray *arrMatched = [NSMutableArray array];
// for (GTOPatrolPlan *plan in fetchedObjects) {
// for (NSDictionary *dictStore in plan.stores) {
// NSInteger iStoreID = [dictStore[ @"id" ] integerValue];
// if (iStoreID == strongSelf.m_store.sID) {
// [arrMatched addObject:plan];
// break;
// }
// }
// }
//
// self.m_arrAllData = arrMatched.count > 0 ? arrMatched : nil;
// }
// else {
// strongSelf.m_arrAllData = fetchedObjects;
// }
}; };
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController]; ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
...@@ -394,18 +416,17 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -394,18 +416,17 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
} }
- (NSInteger)tableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section numberOfRowsInSection:(NSInteger)section {
{
return 1; return 1;
} }
- (UITableViewCell *)tableView:(UITableView *)tableView - (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath cellForRowAtIndexPath:(NSIndexPath *)indexPath {
{ // [tableView deselectRowAtIndexPath:indexPath animated:YES];
// [tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:PatrolPlanCellIdentifier forIndexPath:indexPath]; [tableView dequeueReusableCellWithIdentifier:PatrolPlanCellIdentifier
forIndexPath:indexPath];
[self configureCell:cell forRowAtIndexPath:indexPath]; [self configureCell:cell forRowAtIndexPath:indexPath];
...@@ -413,92 +434,111 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -413,92 +434,111 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
} }
- (void)configureCell:(UITableViewCell *)cell - (void)configureCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath forRowAtIndexPath:(NSIndexPath *)indexPath {
{ // cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// id data = _m_arrAllData[indexPath.section];//_m_arrData[ indexPath.row ]; // id data = _m_arrAllData[indexPath.section];//_m_arrData[ indexPath.row
// ];
UIView *contentView = cell.contentView; UIView *contentView = cell.contentView;
GTOPatrolPlanCellContentView *view = [contentView viewWithClass:[GTOPatrolPlanCellContentView class]]; GTOPatrolPlanCellContentView *view =
[contentView viewWithClass:[GTOPatrolPlanCellContentView class]];
if (!view) { if (!view) {
view = [[GTOPatrolPlanCellContentView alloc] initWithFrame:contentView.bounds]; view =
//view.m_bHiddenNumLabel = m_bIsInHome; [[GTOPatrolPlanCellContentView alloc] initWithFrame:contentView.bounds];
// view.m_bHiddenNumLabel = m_bIsInHome;
[view autoresizingWithStrechFullSize]; [view autoresizingWithStrechFullSize];
[contentView addSubview:view]; [contentView addSubview:view];
} }
GTOPatrolPlan *patrolPlan = _m_arrAllData[indexPath.section]; GTOPatrolPlan *patrolPlan = _m_arrAllData[indexPath.section];
[view updateWithPatrolPlan:patrolPlan]; [view updateWithPatrolPlan:patrolPlan];
} }
#pragma mark - UITableView Delegate #pragma mark - UITableView Delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return PATROL_PLAN_CELL_HEIGHT;//m_bIsInHome ? PATROL_PLAN_CELL_HEIGHT : 109; return PATROL_PLAN_CELL_HEIGHT; // m_bIsInHome ? PATROL_PLAN_CELL_HEIGHT :
// 109;
} }
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - (CGFloat)tableView:(UITableView *)tableView
heightForHeaderInSection:(NSInteger)section {
return section == 0 ? 1 : 10; return section == 0 ? 1 : 10;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES];
GTOPatrolPlan *plan = _m_arrAllData[indexPath.section]; GTOPatrolPlan *plan = _m_arrAllData[indexPath.section];
GTOAllPatrolPlanViewController *allPatrolPlanVC = [[GTOAllPatrolPlanViewController alloc] initWithPatrolPlan:plan]; GTOAllPatrolPlanViewController *allPatrolPlanVC =
[[GTOAllPatrolPlanViewController alloc] initWithPatrolPlan:plan];
[self PushViewController:allPatrolPlanVC animated:YES]; [self PushViewController:allPatrolPlanVC animated:YES];
} }
- (void)sortClicked:(UIButton *)btn {
- (void)sortClicked: (UIButton *)btn {
self.c_maskView.backgroundColor = RGBA(0, 0, 0, 0.5); self.c_maskView.backgroundColor = RGBA(0, 0, 0, 0.5);
_c_maskView.hidden = NO; _c_maskView.hidden = NO;
if (btn.tag == SortTag) { if (btn.tag == SortTag) {
if (_c_boltView) {//如果筛选的不为nil if (_c_boltView) { //如果筛选的不为nil
[self p_hiddenBoltMaskView:NO]; [self p_hiddenBoltMaskView:NO];
} }
if (_c_currentBtn == btn) { if (_c_currentBtn == btn) {
[btn setImage:[UIImage imageNamed:@"black_arrow_down_with_text"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"black_arrow_down_with_text"]
forState:UIControlStateNormal];
[self p_hiddenSortMaskView:YES]; [self p_hiddenSortMaskView:YES];
self.c_currentBtn = nil; self.c_currentBtn = nil;
} else { } else {
[btn setImage:[UIImage imageNamed:@"select_arrow_up_text"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"select_arrow_up_text"]
forState:UIControlStateNormal];
if (!_c_sortView) { if (!_c_sortView) {
self.c_sortView = [[SortMaskView alloc]initWithFrame:CGRectMake(0, -105, ScreenSize.width, 150) withOrderDirection:_d_orderDirection]; self.c_sortView = [[SortMaskView alloc]
self.c_sortView.dataArr = [[NSMutableArray alloc]initWithObjects:@"默认排序",@"按时间逆序",@"按时间顺序",nil]; initWithFrame:CGRectMake(0, -105, ScreenSize.width, 150)
withOrderDirection:_d_orderDirection];
self.c_sortView.dataArr = [[NSMutableArray alloc]
initWithObjects:@"默认排序", @"按时间逆序",
@"按时间顺序", nil];
self.c_sortView.delegate = self; self.c_sortView.delegate = self;
[_c_maskView addSubview:_c_sortView]; [_c_maskView addSubview:_c_sortView];
[UIView animateWithDuration:0.25 animations:^{ [UIView animateWithDuration:0.25
animations:^{
CGRect sortFrame = _c_sortView.frame; CGRect sortFrame = _c_sortView.frame;
sortFrame.origin.y = 0; sortFrame.origin.y = 0;
self.c_sortView.frame = sortFrame; self.c_sortView.frame = sortFrame;
} ]; }];
} }
self.c_currentBtn = btn; self.c_currentBtn = btn;
} }
} else if (btn.tag == BoltTag){ } else if (btn.tag == BoltTag) {
if (_c_sortView) { if (_c_sortView) {
[self p_hiddenSortMaskView:NO]; [self p_hiddenSortMaskView:NO];
} }
if (_c_currentBtn == btn) { if (_c_currentBtn == btn) {
[btn setImage:[UIImage imageNamed:@"black_filter_with_text"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"black_filter_with_text"]
forState:UIControlStateNormal];
[self p_hiddenBoltMaskView:YES]; [self p_hiddenBoltMaskView:YES];
_c_currentBtn = nil; _c_currentBtn = nil;
}else{ } else {
[btn setImage:[UIImage imageNamed:@"selected-filter_with_text"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"selected-filter_with_text"]
forState:UIControlStateNormal];
if (_c_boltView == nil) { if (_c_boltView == nil) {
self.c_boltView = [[BoltMaskView alloc]initWithFrame:CGRectMake(0, -105, ScreenSize.width, 274) state:_d_state title:@"" ]; self.c_boltView = [[BoltMaskView alloc]
initWithFrame:CGRectMake(0, -105, ScreenSize.width, 274)
state:_d_state
title:@""];
self.c_boltView.backgroundColor = XXFBgColor; self.c_boltView.backgroundColor = XXFBgColor;
self.c_boltView.delegate = self; self.c_boltView.delegate = self;
self.c_boltView.dataArr = [[NSMutableArray alloc]initWithObjects:@"不限",@"未提交",@"已提交" ,@"执行中",@"已完成" ,@"已取消",nil]; self.c_boltView.dataArr = [[NSMutableArray alloc]
initWithObjects:@"不限", @"未提交", @"已提交", @"执行中",
@"已完成", @"已取消", nil];
[self.c_maskView addSubview:_c_boltView]; [self.c_maskView addSubview:_c_boltView];
[UIView animateWithDuration:0.25 animations:^{ [UIView animateWithDuration:0.25
animations:^{
CGRect sortFrame = _c_boltView.frame; CGRect sortFrame = _c_boltView.frame;
sortFrame.origin.y = 0; sortFrame.origin.y = 0;
self.c_boltView.frame = sortFrame; self.c_boltView.frame = sortFrame;
...@@ -509,85 +549,91 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -509,85 +549,91 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
} }
} }
- (void)p_hiddenSortMaskView:(BOOL)isHide {
- (void)p_hiddenSortMaskView: (BOOL) isHide {
self.c_currentBtn = nil; self.c_currentBtn = nil;
[self p_checkSortBtnColor]; [self p_checkSortBtnColor];
if (isHide == NO) { if (isHide == NO) {
[_c_sortView removeFromSuperview]; [_c_sortView removeFromSuperview];
self.c_sortView = nil; self.c_sortView = nil;
} else { } else {
[UIView animateWithDuration:0.25 animations:^{ [UIView animateWithDuration:0.25
animations:^{
CGRect sortFrame = _c_sortView.frame; CGRect sortFrame = _c_sortView.frame;
sortFrame.origin.y = -105; sortFrame.origin.y = -105;
self.c_sortView.frame = sortFrame; self.c_sortView.frame = sortFrame;
self.c_maskView.backgroundColor = RGBA(0, 0, 0, 0); self.c_maskView.backgroundColor = RGBA(0, 0, 0, 0);
} completion:^(BOOL finished) { }
completion:^(BOOL finished) {
[_c_sortView removeFromSuperview]; [_c_sortView removeFromSuperview];
self.c_sortView = nil; self.c_sortView = nil;
self.c_maskView.hidden = YES; self.c_maskView.hidden = YES;
}]; }];
} }
} }
- (void)p_hiddenBoltMaskView: (BOOL)isHide { - (void)p_hiddenBoltMaskView:(BOOL)isHide {
self.c_currentBtn = nil; self.c_currentBtn = nil;
[self p_checkBoltBtnColor]; [self p_checkBoltBtnColor];
if (isHide == NO) { if (isHide == NO) {
[_c_boltView removeFromSuperview]; [_c_boltView removeFromSuperview];
self.c_boltView = nil; self.c_boltView = nil;
} else { } else {
[UIView animateWithDuration:0.25 animations:^{ [UIView animateWithDuration:0.25
CGRect sortFrame = _c_boltView .frame; animations:^{
CGRect sortFrame = _c_boltView.frame;
sortFrame.origin.y = -105; sortFrame.origin.y = -105;
self.c_boltView .frame = sortFrame; self.c_boltView.frame = sortFrame;
self.c_maskView.backgroundColor = RGBA(0, 0, 0, 0); self.c_maskView.backgroundColor = RGBA(0, 0, 0, 0);
} completion:^(BOOL finished) { }
completion:^(BOOL finished) {
[_c_boltView removeFromSuperview]; [_c_boltView removeFromSuperview];
self.c_boltView = nil; self.c_boltView = nil;
self.c_maskView.hidden = YES; self.c_maskView.hidden = YES;
}]; }];
} }
} }
//检测排序的颜色 //检测排序的颜色
- (void)p_checkSortBtnColor{ - (void)p_checkSortBtnColor {
if (self.d_orderDirection.length > 0) { if (self.d_orderDirection.length > 0) {
[_c_sortBtn setImage:[UIImage imageNamed:@"select_arrow_up_text"] forState:UIControlStateNormal]; [_c_sortBtn setImage:[UIImage imageNamed:@"select_arrow_up_text"]
}else{ forState:UIControlStateNormal];
[_c_sortBtn setImage:[UIImage imageNamed:@"black_arrow_down_with_text"] forState:UIControlStateNormal]; } else {
[_c_sortBtn setImage:[UIImage imageNamed:@"black_arrow_down_with_text"]
forState:UIControlStateNormal];
} }
} }
- (void)p_checkBoltBtnColor{ - (void)p_checkBoltBtnColor {
if (_d_state.length > 0 ){//|| self.billNumberLike.length > 0 || self.titleLike.length > 0) { if (_d_state.length >
[_c_filterBtn setImage:[UIImage imageNamed:@"selected-filter_with_text"] forState:UIControlStateNormal]; 0) { //|| self.billNumberLike.length > 0 || self.titleLike.length > 0) {
}else{ [_c_filterBtn setImage:[UIImage imageNamed:@"selected-filter_with_text"]
[_c_filterBtn setImage:[UIImage imageNamed:@"black_filter_with_text"] forState:UIControlStateNormal]; forState:UIControlStateNormal];
} else {
[_c_filterBtn setImage:[UIImage imageNamed:@"black_filter_with_text"]
forState:UIControlStateNormal];
} }
} }
#pragma mark - sortDelegate #pragma mark - sortDelegate
- (void)getSortValueSelectRow:(NSString *)state{ - (void)getSortValueSelectRow:(NSString *)state {
if (state.length > 0) { if (state.length > 0) {
CLog(@"%@",state); CLog(@"%@", state);
self.d_orderDirection = state; self.d_orderDirection = state;
[self reloadDateFromCondition];
} }
} }
#pragma mark - boltDelegate #pragma mark - boltDelegate
- (void)getBoltValueSelectRow:(NSString *)state{ - (void)getBoltValueSelectRow:(NSString *)state {
CLog(@"%@",state); CLog(@"%@", state);
self.d_state = state; self.d_state = state;
[self reloadDateFromCondition];
} }
- (void)getTitleLike:(NSString *)titleLike { - (void)getTitleLike:(NSString *)titleLike {
CLog(@"%@",titleLike); CLog(@"%@", titleLike);
self.d_titleLike = titleLike; self.d_titleLike = titleLike;
[self reloadDateFromCondition];
} }
//TODO // TODO
- (void)clearBoltInformation { - (void)clearBoltInformation {
self.d_state = nil; self.d_state = nil;
self.d_orderDirection = nil; self.d_orderDirection = nil;
...@@ -596,7 +642,10 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -596,7 +642,10 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
} }
#pragma button action #pragma button action
- (void)sureClicked { - (void)sureClicked {
if (self.d_state == nil && self.d_orderDirection == nil &&
self.d_titleLike == nil && self.m_arrAllData == nil) {
[self reloadDateFromCondition]; [self reloadDateFromCondition];
}
//还原数据 //还原数据
if (_c_sortView) { if (_c_sortView) {
[self p_hiddenSortMaskView:YES]; [self p_hiddenSortMaskView:YES];
...@@ -604,121 +653,138 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -604,121 +653,138 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
if (_c_boltView) { if (_c_boltView) {
[self p_hiddenBoltMaskView:YES]; [self p_hiddenBoltMaskView:YES];
} }
//
// if (_d_state.length > 0 ||_d_orderDirection.length > 0) { //|| self.titleLike.length > 0
// [_c_boltView.titleFiled resignFirstResponder];
// [self reloadDateFromCondition];
// //还原数据
// if (_c_sortView) {
// [self p_hiddenSortMaskView:YES];
// }
// if (_c_boltView) {
// [self p_hiddenBoltMaskView:YES];
// }
// }
} }
//根据排序和筛选条件重新返回列表数据 //根据排序和筛选条件重新返回列表数据
- (void)reloadDateFromCondition { - (void)reloadDateFromCondition {
// NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ DESC", [GTOPatrolPlan TableName],@"category",@"lastModify_time" ];
// NSLog(@"%@, %@",sql,_d_patrolCategory);
// return [db executeQuery:sql,_d_patrolCategory];
if ([self.d_state isEqualToString:@"none"]) { if ([self.d_state isEqualToString:@"none"]) {
self.d_state = nil; self.d_state = nil;
} }
// BOOL condition = !self.d_state && !self.d_orderDirection && !self.d_titleLike; NSString *sql = [NSString string];
// if (condition) { //0
// return;
// }
NSString * sql = [NSString string];
ICRDatabaseFetchBlock fetchBlk; ICRDatabaseFetchBlock fetchBlk;
if ([self.d_orderDirection isEqualToString:@"none"] ) { if ([self.d_orderDirection isEqualToString:@"none"]) {
self.d_orderDirection = @"desc"; self.d_orderDirection = @"desc";
} }
if(self.d_orderDirection && (!self.d_state && !self.d_titleLike)) { //1 if (self.d_orderDirection && (!self.d_state && !self.d_titleLike)) { // 1
if ([self.d_orderDirection isEqualToString:@"desc"]) { if ([self.d_orderDirection isEqualToString:@"desc"]) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ DESC",[GTOPatrolPlan TableName],@"category", @"lastModify_time"]; sql = [NSString
stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ DESC",
[GTOPatrolPlan TableName], @"category",
@"lastModify_time"];
} else { } else {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ ASC",[GTOPatrolPlan TableName],@"category", @"lastModify_time"]; sql = [NSString
stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@ ASC",
[GTOPatrolPlan TableName], @"category",
@"lastModify_time"];
} }
fetchBlk = ^FMResultSet *(FMDatabase *db) { fetchBlk = ^FMResultSet *(FMDatabase *db) {
return [db executeQuery:sql,_d_patrolCategory]; return [db executeQuery:sql, _d_patrolCategory];
}; };
} }
if(self.d_orderDirection && self.d_state && (!self.d_titleLike)) {//2 if (self.d_orderDirection && self.d_state && (!self.d_titleLike)) { // 2
if ([self.d_orderDirection isEqualToString:@"desc"]) { if ([self.d_orderDirection isEqualToString:@"desc"]) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ =? ORDER BY %@ DESC",[GTOPatrolPlan TableName],@"category",@"state", @"lastModify_time"]; sql = [NSString
stringWithFormat:
@"SELECT * FROM %@ WHERE %@=? AND %@ =? ORDER BY %@ DESC",
[GTOPatrolPlan TableName], @"category", @"state",
@"lastModify_time"];
} else { } else {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ =? ORDER BY %@ ASC",[GTOPatrolPlan TableName],@"category",@"state", @"lastModify_time"]; sql = [NSString
stringWithFormat:
@"SELECT * FROM %@ WHERE %@=? AND %@ =? ORDER BY %@ ASC",
[GTOPatrolPlan TableName], @"category", @"state",
@"lastModify_time"];
} }
fetchBlk = ^FMResultSet *(FMDatabase *db) { fetchBlk = ^FMResultSet *(FMDatabase *db) {
return [db executeQuery:sql,_d_patrolCategory,self.d_state]; return [db executeQuery:sql, _d_patrolCategory, self.d_state];
}; };
} }
if(self.d_orderDirection && (!self.d_state) && self.d_titleLike) {//3 if (self.d_orderDirection && (!self.d_state) && self.d_titleLike) { // 3
if ([self.d_orderDirection isEqualToString:@"desc"]) { if ([self.d_orderDirection isEqualToString:@"desc"]) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ like ? ORDER BY %@ DESC",[GTOPatrolPlan TableName],@"category",@"name", @"lastModify_time"]; sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ "
@"like '%%%@%%' ORDER BY %@ DESC",
[GTOPatrolPlan TableName], @"category",
@"name", self.d_titleLike,
@"lastModify_time"];
} else { } else {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ like ? ORDER BY %@ ASC",[GTOPatrolPlan TableName],@"category",@"name", @"lastModify_time"]; sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ "
@"like '%%%@%%' ORDER BY %@ ASC",
[GTOPatrolPlan TableName], @"category",
@"name", self.d_titleLike,
@"lastModify_time"];
} }
fetchBlk = ^FMResultSet *(FMDatabase *db) { fetchBlk = ^FMResultSet *(FMDatabase *db) {
return [db executeQuery:sql,_d_patrolCategory,self.d_titleLike]; return [db executeQuery:sql, _d_patrolCategory];
}; };
} }
if(self.d_orderDirection && self.d_state && self.d_titleLike) {//4 if (self.d_orderDirection && self.d_state && self.d_titleLike) { // 4
if ([self.d_orderDirection isEqualToString:@"desc"]) { if ([self.d_orderDirection isEqualToString:@"desc"]) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ =? AND %@ like ? ORDER BY %@ DESC",[GTOPatrolPlan TableName],@"category",@"state",@"name", @"lastModify_time"]; sql = [NSString
stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ =? AND %@ "
@"like '%%%@%%' ORDER BY %@ DESC",
[GTOPatrolPlan TableName], @"category", @"state",
@"name", self.d_titleLike, @"lastModify_time"];
} else { } else {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ =? AND %@ like ? ORDER BY %@ ASC",[GTOPatrolPlan TableName],@"category",@"state",@"name", @"lastModify_time"]; sql = [NSString
stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ =? AND %@ "
@"like '%%%@%%' ORDER BY %@ ASC",
[GTOPatrolPlan TableName], @"category", @"state",
@"name", self.d_titleLike, @"lastModify_time"];
} }
fetchBlk = ^FMResultSet *(FMDatabase *db) { fetchBlk = ^FMResultSet *(FMDatabase *db) {
return [db executeQuery:sql,_d_patrolCategory,self.d_state,self.d_titleLike]; return [db executeQuery:sql, _d_patrolCategory, self.d_state];
}; };
} }
if(!self.d_orderDirection && self.d_state && self.d_titleLike) { //5 if (!self.d_orderDirection && self.d_state && self.d_titleLike) { // 5
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ =? AND %@ like ? ORDER BY %@ DESC",[GTOPatrolPlan TableName],@"category",@"state",@"name", @"lastModify_time"]; sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ =? "
@"AND %@ like '%%%@%%' ORDER BY %@ DESC",
[GTOPatrolPlan TableName], @"category",
@"state", @"name", self.d_titleLike,
@"lastModify_time"];
fetchBlk = ^FMResultSet *(FMDatabase *db) { fetchBlk = ^FMResultSet *(FMDatabase *db) {
return [db executeQuery:sql,_d_patrolCategory,self.d_state,self.d_titleLike]; return [db executeQuery:sql, _d_patrolCategory, self.d_state];
}; };
} }
if(!self.d_orderDirection && (!self.d_state )&& self.d_titleLike) { //6 if (!self.d_orderDirection && (!self.d_state) && self.d_titleLike) { // 6
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ like ? ORDER BY %@ DESC",[GTOPatrolPlan TableName],@"category",@"name", @"lastModify_time"]; sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ like "
@"'%%%@%%' ORDER BY %@ DESC",
[GTOPatrolPlan TableName], @"category",
@"name", self.d_titleLike,
@"lastModify_time"];
fetchBlk = ^FMResultSet *(FMDatabase *db) { fetchBlk = ^FMResultSet *(FMDatabase *db) {
return [db executeQuery:sql,_d_patrolCategory,self.d_titleLike]; return [db executeQuery:sql, _d_patrolCategory];
}; };
} }
if(!self.d_orderDirection && self.d_state && (!self.d_titleLike)) {//7 if (!self.d_orderDirection && self.d_state && (!self.d_titleLike)) { // 7
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? AND %@ =? ORDER BY %@ DESC",[GTOPatrolPlan TableName],@"category",@"state", @"lastModify_time"]; sql = [NSString
stringWithFormat:
@"SELECT * FROM %@ WHERE %@=? AND %@ =? ORDER BY %@ DESC",
[GTOPatrolPlan TableName], @"category", @"state",
@"lastModify_time"];
fetchBlk = ^FMResultSet *(FMDatabase *db) { fetchBlk = ^FMResultSet *(FMDatabase *db) {
return [db executeQuery:sql,_d_patrolCategory,self.d_state]; return [db executeQuery:sql, _d_patrolCategory, self.d_state];
}; };
} }
if(!self.d_orderDirection && !self.d_state && !self.d_titleLike) {//8 if (!self.d_orderDirection && !self.d_state && !self.d_titleLike) { // 8
sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@ DESC",[GTOPatrolPlan TableName], @"lastModify_time"]; sql = [NSString stringWithFormat:
@"SELECT * FROM %@ WHERE category =? ORDER BY %@ DESC",
[GTOPatrolPlan TableName], @"lastModify_time"];
fetchBlk = ^FMResultSet *(FMDatabase *db) { fetchBlk = ^FMResultSet *(FMDatabase *db) {
return [db executeQuery:sql]; return [db executeQuery:sql, _d_patrolCategory];
}; };
} }
__weak typeof(self) weakSelf = self;
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
// ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { [dbCtrl runFetchForClass:[GTOPatrolPlan class]
// NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@ DESC", [GTOPatrolPlan TableName], @"beginDate"];//??f_beginDate fetchBlock:fetchBlk
// return [db executeQuery:sql]; fetchResultsBlock:^(NSArray *fetchedObjects) {
// }; __strong __typeof(weakSelf) strongSelf = weakSelf;
__weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (!strongSelf.m_arrAllData) { if (!strongSelf.m_arrAllData) {
strongSelf.m_arrAllData = [@[]mutableCopy]; strongSelf.m_arrAllData = [@[] mutableCopy];
} }
[strongSelf.m_arrAllData removeAllObjects]; [strongSelf.m_arrAllData removeAllObjects];
if (fetchedObjects) { if (fetchedObjects) {
...@@ -726,19 +792,11 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell"; ...@@ -726,19 +792,11 @@ static NSString *PatrolPlanCellIdentifier = @"PatrolPlanCell";
} }
[self.m_tableView reloadData]; [self.m_tableView reloadData];
}; }];
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[GTOPatrolPlan class]
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
@end @end
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
} else if ([category isEqualToString:@"辅助区"]) { } else if ([category isEqualToString:@"辅助区"]) {
imgV.image = [UIImage imageNamed:@"assist_area"]; imgV.image = [UIImage imageNamed:@"assist_area"];
} else { } else {
imgV.image = [UIImage imageNamed:@"public_area"]; imgV.image = [UIImage imageNamed:@"addOil_area"];
} }
} }
- (void)p_processWithFinishCategorysNumber:(NSInteger)finishNumber - (void)p_processWithFinishCategorysNumber:(NSInteger)finishNumber
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
- (void)updateWithPioneering: (GTOPioneering *)pioneering - (void)updateWithPioneering: (GTOPioneering *)pioneering
arrayDictDisplayResults: (NSArray *)arrDisplayResults arrayDictDisplayResults: (NSArray *)arrDisplayResults
{ {
self.m_planTimeLabel.text = [NSString stringWithFormat:@"拓人员:%@",pioneering.pioneer_name ]; self.m_planTimeLabel.text = [NSString stringWithFormat:@"拓人员:%@",pioneering.pioneer_name ];
self.m_startTimeLabel.text = [NSString stringWithFormat:@"开始时间:%@",pioneering.beginDate]; self.m_startTimeLabel.text = [NSString stringWithFormat:@"开始时间:%@",pioneering.beginDate];
self.m_processLabel.text = [NSString stringWithFormat:@"拓站总进度:" ]; self.m_processLabel.text = [NSString stringWithFormat:@"拓站总进度:" ];
......
...@@ -99,7 +99,8 @@ static NSString *cellID = @"pioneeringListCell"; ...@@ -99,7 +99,8 @@ static NSString *cellID = @"pioneeringListCell";
{ {
BOOL createPermission = [GTOCommonTools hasPermissionWithPermissionId:500503]; BOOL createPermission = [GTOCommonTools hasPermissionWithPermissionId:500503];
if (createPermission) { if (createPermission) {
UIBarButtonItem *rightBarBtn = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPioneeringClicked)]; UIBarButtonItem *rightBarBtn = [[UIBarButtonItem alloc] initWithTitle:@"新增" style:UIBarButtonItemStyleDone target:self action:@selector(addPioneeringClicked)];
// UIBarButtonItem *rightBarBtn = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPioneeringClicked)];
self.navigationItem.rightBarButtonItem = rightBarBtn; self.navigationItem.rightBarButtonItem = rightBarBtn;
} }
......
...@@ -108,7 +108,7 @@ UIAlertViewDelegate> ...@@ -108,7 +108,7 @@ UIAlertViewDelegate>
} }
- (void)updateAnsewer { - (void)updateAnsewer {
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@ = ? ORDER BY %@", [GTOAnswer TableName], @"pioneeringUuid",@"questionUuid" ]; NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@ = ? ORDER BY %@", [GTOAnswer TableName], @"pioneeringUuid",@"questionUuid"];
//答案的排序按照问题的uuid来,(此事的排序关系到结果页中答案的显示,按道理应该是根据答题的顺序,是不是后台给的问题应该排序?????) //答案的排序按照问题的uuid来,(此事的排序关系到结果页中答案的显示,按道理应该是根据答题的顺序,是不是后台给的问题应该排序?????)
NSLog(@"%@",sql); NSLog(@"%@",sql);
return [db executeQuery:sql,_d_pioneering.uuid]; return [db executeQuery:sql,_d_pioneering.uuid];
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// //
// GTOPatrolPlanResultTopItem.m // GTOPatrolPlanResultTopItem.m
// total // total
// 拓任务列表的cell的内容 // 拓任务列表的cell的内容
// Created by freecui on 15/9/28. // Created by freecui on 15/9/28.
// Copyright (c) 2015年 free. All rights reserved. // Copyright (c) 2015年 free. All rights reserved.
// //
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// //
// GTOPatrolPlanResultTopItem.m // GTOPatrolPlanResultTopItem.m
// total // total
// 拓任务列表的cell的内容 // 拓任务列表的cell的内容
// Created by freecui on 15/9/28. // Created by freecui on 15/9/28.
// Copyright (c) 2015年 free. All rights reserved. // Copyright (c) 2015年 free. All rights reserved.
// //
......
...@@ -6,27 +6,27 @@ ...@@ -6,27 +6,27 @@
// Copyright © 2015年 free. All rights reserved. // Copyright © 2015年 free. All rights reserved.
// //
#import "GTORepairDetailViewController.h" #import "GTOAlertInfoLicenceViewController.h"
#import "GTORepairDetailTopCellView.h" #import "GTOAnswer.h"
#import "GTORepairListCellContentView.h" #import "GTODisplayResult.h"
#import "GXFButtonAndLineView.h"
#import "GXFBottomView.h"
#import "GTORepair.h"
#import "GTOLicence.h" #import "GTOLicence.h"
#import "GTOLicenceNewViewController.h"
#import "GTOLicenceListSimpleCellContentView.h" #import "GTOLicenceListSimpleCellContentView.h"
#import "GTOPioneeringSurveyItem.h" #import "GTOLicenceNewViewController.h"
#import "GTODisplayResult.h"
#import "GTOAnswer.h"
#import "GTOAlertInfoLicenceViewController.h"
#import "GTOLiceneResultViewController.h" #import "GTOLiceneResultViewController.h"
#import "GTOPioneeringSurveyItem.h"
#import "GTORepair.h"
#import "GTORepairDetailTopCellView.h"
#import "GTORepairDetailViewController.h"
#import "GTORepairListCellContentView.h"
#import "GXFBottomView.h"
#import "GXFButtonAndLineView.h"
#import "GTOQuestionManager.h"
#import "GTORepairAddPhotoView.h" #import "GTORepairAddPhotoView.h"
#import "IBTImagePicker.h" #import "IBTImagePicker.h"
#import "ICRAttachmentView.h" #import "ICRAttachmentView.h"
#import "ICRPostAttachment.h" #import "ICRPostAttachment.h"
#import "JTImagePreviewer.h" #import "JTImagePreviewer.h"
#import "GTOQuestionManager.h"
static NSString *cellIDTop = @"topCell"; static NSString *cellIDTop = @"topCell";
static NSString *cellIDItem = @"itmeCell"; static NSString *cellIDItem = @"itmeCell";
static NSString *headID = @"headID"; static NSString *headID = @"headID";
...@@ -38,22 +38,27 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -38,22 +38,27 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
kBottomViewOneBackTag kBottomViewOneBackTag
}; };
@interface GTORepairDetailViewController ()<UITableViewDataSource,UITableViewDelegate,GXFBottomViewDelegate,GTOAlertInfoLicenceViewControllerDelegate,IBTImagePickerDelegate,ICRAttachmentViewDelegate,UIAlertViewDelegate> @interface GTORepairDetailViewController () <
@property (nonatomic, strong) UITableView *c_tableView; UITableViewDataSource, UITableViewDelegate, GXFBottomViewDelegate,
@property (nonatomic, strong) NSMutableArray *d_muArrLicences; GTOAlertInfoLicenceViewControllerDelegate, IBTImagePickerDelegate,
@property (nonatomic, strong) GTORepair *d_repair; ICRAttachmentViewDelegate, UIAlertViewDelegate>
@property (nonatomic, strong) GTOLicence *d_currentLicence;//当前点击的列表的cell @property(nonatomic, strong) UITableView *c_tableView;
@property (nonatomic, strong) GTOAlertInfoLicenceViewController *alertInfoVC; @property(nonatomic, strong) NSMutableArray *d_muArrLicences;
@property (nonatomic, strong) GTORepairAddPhotoView *c_addPhotoV; @property(nonatomic, strong) GTORepair *d_repair;
@property (strong, nonatomic) IBTImagePicker *m_imagePicker; @property(nonatomic, strong)
GTOLicence *d_currentLicence; //当前点击的列表的cell
@property (nonatomic, strong) NSMutableArray *d_muArrPhotos; @property(nonatomic, strong) GTOAlertInfoLicenceViewController *alertInfoVC;
@property (nonatomic, strong) ICRPostAttachment* d_postAttachment; @property(nonatomic, strong) GTORepairAddPhotoView *c_addPhotoV;
@property (nonatomic, strong) GXFBottomView *c_bottomView; @property(strong, nonatomic) IBTImagePicker *m_imagePicker;
@property (nonatomic, copy) NSString *d_repairUuid;
@property (assign, nonatomic) BOOL d_isDownLoadImg;//是否是从网络上下载的图片 @property(nonatomic, strong) NSMutableArray *d_muArrPhotos;
@property (assign, nonatomic) NSUInteger d_removeIndex; @property(nonatomic, strong) ICRPostAttachment *d_postAttachment;
@property (assign, nonatomic) BOOL d_applyFinish; @property(nonatomic, strong) GXFBottomView *c_bottomView;
@property(nonatomic, copy) NSString *d_repairUuid;
@property(assign, nonatomic) BOOL d_isDownLoadImg; //是否是从网络上下载的图片
@property(assign, nonatomic) NSUInteger d_removeIndex;
@property(assign, nonatomic) BOOL d_applyFinish;
@property (strong, nonatomic) UIImageView *imgNoData;
@end @end
@implementation GTORepairDetailViewController @implementation GTORepairDetailViewController
...@@ -67,7 +72,7 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -67,7 +72,7 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
return _m_imagePicker; return _m_imagePicker;
} }
- (instancetype)initWithRepairUuid:(NSString *)repairUuid{ - (instancetype)initWithRepairUuid:(NSString *)repairUuid {
self = [super init]; self = [super init];
if (!self) { if (!self) {
...@@ -80,6 +85,7 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -80,6 +85,7 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
} }
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
self.title = @"报修单详情"; self.title = @"报修单详情";
} }
...@@ -87,62 +93,60 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -87,62 +93,60 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
[self p_licences]; [self p_licences];
} }
- (void)p_repair { - (void)p_repair {
void(^succ)(id) = ^(id data) { ICRHTTPController *httpC = [ICRHTTPController sharedController];
[httpC getRepairItemsWithRepairUuid:_d_repairUuid
success:^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
NSInteger success = [data[@"success"] integerValue]; NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ; NSString *message = data[@"message"];
if (success == 1) { if (success == 1) {
NSDictionary *dictRepair = data[@"data"]; NSDictionary *dictRepair = data[@"data"];
self.d_repair = [GTORepair DBObject]; self.d_repair = [GTORepair DBObject];
[_d_repair praseFromJsonDict:dictRepair]; [_d_repair praseFromJsonDict:dictRepair];
[self initSubViews]; [self initSubViews];
[_c_tableView reloadData]; [_c_tableView reloadData];
} else {
[IBTLoadingView showTips:message];
} }
}; }
void(^fail)(id) = ^(id data) { failure:^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; }];
ICRHTTPController *httpC = [ICRHTTPController sharedController];
[httpC getRepairItemsWithRepairUuid:_d_repairUuid success:succ failure:fail];
} }
- (void)p_licences { - (void)p_licences {
__weak typeof(self)weakSelf = self; __weak typeof(self) weakSelf = self;
void(^succ)(id) = ^(id data) { NSDictionary *dict = @{
@"userUuid" : @"",
@"state" : [NSNull null], //@"", //
@"repairUuid" : _d_repairUuid,
@"repairNumberLike" : @"",
@"billNumberLike" : [NSNull null], //@"", //
@"riskGrade" : @"",
@"queryOrders" :
@[ @{@"field" : @"billNumber", @"direction" : @"desc"} ], // orderArr,
@"pageNumber" : @(0),
@"pageSize" : @(200)
};
ICRHTTPController *httpC = [ICRHTTPController sharedController];
[httpC getLicenceListWithData:dict success:^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
[strongSelf fetchtPuchaseList:data]; [strongSelf fetchtPuchaseList:data];
}; } failure:^(id data) {
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; }];
// [IBTLoadingView showProgressLabel:@"正在加载..."];
NSDictionary *dict = @{
@"userUuid":@"",
@"state":[NSNull null],//@"", //
@"repairUuid":_d_repairUuid,
@"repairNumberLike":@"",
@"billNumberLike":[NSNull null],//@"", //
@"riskGrade":@"",
@"queryOrders":@[@{@"field":@"billNumber",@"direction":@"desc"}],//orderArr,
@"pageNumber":@(0),
@"pageSize":@(200)};
ICRHTTPController *httpC = [ICRHTTPController sharedController];
[httpC getLicenceListWithData:dict success:succ failure:fail];
} }
- (void)fetchtPuchaseList:(id)data{ - (void)fetchtPuchaseList:(id)data {
if (data) { if (data) {
NSInteger success = [data[@"success"] integerValue]; NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ; NSString *message = data[@"message"];
if (success == 1) { if (success == 1) {
NSArray *recodesArr = data[ @"data" ][ @"records" ]; NSArray *recodesArr = data[@"data"][@"records"];
if (!_d_muArrLicences) { if (!_d_muArrLicences) {
self.d_muArrLicences = [NSMutableArray array]; self.d_muArrLicences = [NSMutableArray array];
} else { } else {
...@@ -155,83 +159,101 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -155,83 +159,101 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
[self.d_muArrLicences addObject:licence]; [self.d_muArrLicences addObject:licence];
} }
[self.c_tableView reloadData]; if (self.d_muArrLicences.count == 0) {
self.imgNoData.hidden = NO;
}else{ }else{
self.imgNoData.hidden = YES;
}
[self.c_tableView reloadData];
} else {
[IBTLoadingView showTips:message]; [IBTLoadingView showTips:message];
} }
}else{ } else {
[IBTLoadingView showTips:@" 无记录 "]; [IBTLoadingView showTips:@" 无记录 "];
} }
} }
- (void)initSubViews { - (void)initSubViews {
self.view.backgroundColor = XXFBgColor; self.view.backgroundColor = XXFBgColor;
self.c_tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height - BottomViewHeight - 60 - 10) style:UITableViewStyleGrouped]; self.c_tableView = [[UITableView alloc]
[self.c_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIDTop]; initWithFrame:CGRectMake(0, 0, self.view.width,
[self.c_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIDItem]; self.view.height - BottomViewHeight - 60 - 10)
[self.c_tableView registerClass:[UITableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:headID]; style:UITableViewStyleGrouped];
[self.c_tableView registerClass:[UITableViewCell class]
forCellReuseIdentifier:cellIDTop];
[self.c_tableView registerClass:[UITableViewCell class]
forCellReuseIdentifier:cellIDItem];
[self.c_tableView registerClass:[UITableViewHeaderFooterView class]
forHeaderFooterViewReuseIdentifier:headID];
self.c_tableView.dataSource = self; self.c_tableView.dataSource = self;
self.c_tableView.delegate = self; self.c_tableView.delegate = self;
[self.view addSubview:_c_tableView]; [self.view addSubview:_c_tableView];
[_c_tableView reloadData]; [_c_tableView reloadData];
self.c_addPhotoV = [[GTORepairAddPhotoView alloc]initWithFrame:(CGRect){ self.c_addPhotoV = [[GTORepairAddPhotoView alloc]
.origin.x = 0, initWithFrame:(CGRect){.origin.x = 0,
.origin.y = _c_tableView.bottom + 5, .origin.y = _c_tableView.bottom + 5,
.size.width = self.view.width, .size.width = self.view.width,
.size.height = 60}]; .size.height = 60}];
_c_addPhotoV.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; _c_addPhotoV.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
_c_addPhotoV.backgroundColor = XXFBgColor; _c_addPhotoV.backgroundColor = XXFBgColor;
_c_addPhotoV.m_photoAttachView.delegate = self; _c_addPhotoV.m_photoAttachView.delegate = self;
if([_d_repair.state isEqualToString:GTO_REPAIR_STATE_FINISHED]) { if ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_FINISHED]) {
[self p_getAttachmentUrls]; [self p_getAttachmentUrls];
[_c_addPhotoV.m_photoAttachView.m_addButton removeFromSuperview]; [_c_addPhotoV.m_photoAttachView.m_addButton removeFromSuperview];
} else { } else {
[_c_addPhotoV.m_photoAttachView.m_addButton addTarget:self [_c_addPhotoV.m_photoAttachView.m_addButton
addTarget:self
action:@selector(onShowImagePicker:) action:@selector(onShowImagePicker:)
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
} }
[self.view addSubview:_c_addPhotoV]; [self.view addSubview:_c_addPhotoV];
CGRect rect = CGRectMake(0, _c_addPhotoV.bottom +10, self.view.width, BottomViewHeight); CGRect rect = CGRectMake(0, _c_addPhotoV.bottom + 10, self.view.width,
GXFBottomView *bottomV = [[GXFBottomView alloc]initOneButtonWithFrame:rect buttonColor:GTO_RED_COLOR buttonTitle:@""]; BottomViewHeight);
GXFBottomView *bottomV =
[[GXFBottomView alloc] initOneButtonWithFrame:rect
buttonColor:GTO_RED_COLOR
buttonTitle:@""];
BOOL finishPermission = [GTOCommonTools hasPermissionWithPermissionId:500304]; BOOL finishPermission = [GTOCommonTools hasPermissionWithPermissionId:500304];
if([_d_repair.state isEqualToString:GTO_REPAIR_STATE_FINISHED] || !finishPermission ) { //加载下载的图片 if ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_FINISHED] ||
!finishPermission) { //加载下载的图片
bottomV.tag = kBottomViewOneBackTag; bottomV.tag = kBottomViewOneBackTag;
[bottomV.f_oneBtn setTitle:@"返回" forState:UIControlStateNormal]; [bottomV.f_oneBtn setTitle:@"返回" forState:UIControlStateNormal];
//显示后台上面的附件 //显示后台上面的附件
if (_d_repair.attachmentUrls.count > 0) { if (_d_repair.attachmentUrls.count > 0) {
for(NSDictionary *dict in _d_repair.attachmentUrls) { for (NSDictionary *dict in _d_repair.attachmentUrls) {
ICRPostAttachment *postAttachment = [ICRPostAttachment DBObject]; ICRPostAttachment *postAttachment = [ICRPostAttachment DBObject];
[postAttachment praseFromJsonDict:dict]; [postAttachment praseFromJsonDict:dict];
self.d_isDownLoadImg = YES; self.d_isDownLoadImg = YES;
[self addAttachment:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTP_LOCAL_BASE_URL ,postAttachment.fileUrl]]]; [self addAttachment:[NSURL
URLWithString:[NSString
stringWithFormat:
@"%@%@",
HTTP_LOCAL_BASE_URL,
postAttachment.fileUrl]]];
} }
} }
} else if ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_SUBMITTED] || } else if ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_SUBMITTED] ||
[_d_repair.state isEqualToString:GTO_REPAIR_STATE_PROCESSING]){ [_d_repair.state isEqualToString:GTO_REPAIR_STATE_PROCESSING]) {
self.c_addPhotoV.hidden = YES; self.c_addPhotoV.hidden = YES;
bottomV.tag = kBottomViewOneApplicationTag; bottomV.tag = kBottomViewOneApplicationTag;
[bottomV.f_oneBtn setTitle:@"申请结束报修" forState:UIControlStateNormal]; [bottomV.f_oneBtn setTitle:@"申请结束报修" forState:UIControlStateNormal];
} else if ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_APPLICATION] ) { } else if ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_APPLICATION]) {
bottomV.tag = kBottomViewOneFinishTag; bottomV.tag = kBottomViewOneFinishTag;
[bottomV.f_oneBtn setTitle:@"结束报修" forState:UIControlStateNormal]; [bottomV.f_oneBtn setTitle:@"结束报修" forState:UIControlStateNormal];
[self addLocalPhotos]; [self addLocalPhotos];
} else { } else {
} }
bottomV.delegate = self; bottomV.delegate = self;
self.c_bottomView = bottomV; self.c_bottomView = bottomV;
[self.view addSubview:_c_bottomView]; [self.view addSubview:_c_bottomView];
if ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_SUBMITTED] || if ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_SUBMITTED] ||
[_d_repair.state isEqualToString:GTO_REPAIR_STATE_PROCESSING]){ [_d_repair.state isEqualToString:GTO_REPAIR_STATE_PROCESSING]) {
self.c_tableView.height = self.view.height - BottomViewHeight - 10; self.c_tableView.height = self.view.height - BottomViewHeight - 10;
} }
} }
...@@ -240,11 +262,14 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -240,11 +262,14 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
// _d_muArrPhotos _d_postAttachment // _d_muArrPhotos _d_postAttachment
//加载本地图片 //加载本地图片
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString *sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@",[ICRPostAttachment TableName],@"repairUuid",@"addTime"]; NSString *sql =
return [db executeQuery:sql,_d_repair.uuid]; [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@=? ORDER BY %@",
[ICRPostAttachment TableName], @"repairUuid",
@"addTime"];
return [db executeQuery:sql, _d_repair.uuid];
}; };
__weak typeof (self) weakSelf = self; __weak typeof(self) weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultBlk = ^(NSArray *fetchedObjects) { ICRDatabaseFetchResultsBlock fetchResultBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf) strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
if (fetchedObjects.count > 0) { if (fetchedObjects.count > 0) {
...@@ -253,13 +278,13 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -253,13 +278,13 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
} }
if (!_d_muArrPhotos.count) { if (!_d_muArrPhotos.count) {
self.d_muArrPhotos = [NSMutableArray arrayWithArray:fetchedObjects]; self.d_muArrPhotos = [NSMutableArray arrayWithArray:fetchedObjects];
for(ICRPostAttachment *postAttachment in fetchedObjects) { for (ICRPostAttachment *postAttachment in fetchedObjects) {
if (postAttachment.content) { if (postAttachment.content) {
NSData *imageData = [NSData dataFromBase64String:postAttachment.content]; NSData *imageData =
[NSData dataFromBase64String:postAttachment.content];
UIImage *image = [UIImage imageWithData:imageData]; UIImage *image = [UIImage imageWithData:imageData];
[self addAttachment:image]; [self addAttachment:image];
} }
} }
} }
} }
...@@ -271,100 +296,128 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -271,100 +296,128 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
fetchResultsBlock:fetchResultBlk]; fetchResultsBlock:fetchResultBlk];
} }
//从网络上获取图片 //从网络上获取图片
- (UIImage *)p_getImageFromURL: (NSString *)fileURL { - (UIImage *)p_getImageFromURL:(NSString *)fileURL {
UIImage *result ; UIImage *result;
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]]; NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]];
result = [UIImage imageWithData:data]; result = [UIImage imageWithData:data];
return result; return result;
} }
- (void)p_getAttachmentUrls { - (void)p_getAttachmentUrls {
void(^succ)(id) = ^(id data) { void (^succ)(id) = ^(id data) {
CLog(@"%@",data); CLog(@"%@", data);
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
NSInteger success = [data[@"success"] integerValue]; NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ; NSString *message = data[@"message"];
if (success == 1) { if (success == 1) {
} }
}; };
void(^fail)(id) = ^(id data) { void (^fail)(id) = ^(id data) {
CLog(@"%@",data); CLog(@"%@", data);
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
}; };
ICRHTTPController *httpC = [ICRHTTPController sharedController]; ICRHTTPController *httpC = [ICRHTTPController sharedController];
[httpC getAttachmentUrlsWithEntityType:GTO_ENTITYTYPE_REPAIR andEntityUuid:_d_repair.attachmentId success:succ failure:fail]; [httpC getAttachmentUrlsWithEntityType:GTO_ENTITYTYPE_REPAIR
andEntityUuid:_d_repair.attachmentId
success:succ
failure:fail];
} }
#pragma ICRAttachmentViewDelegate #pragma ICRAttachmentViewDelegate
- (void)attachmentView:(ICRAttachmentView *)attachmentView removeContentAttachmentViewAtIndex:(NSUInteger)uiIndex { - (void)attachmentView:(ICRAttachmentView *)attachmentView
removeContentAttachmentViewAtIndex:(NSUInteger)uiIndex {
UIAlertView *alertV =[ [UIAlertView alloc]initWithTitle:@"是否删除图片" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
UIAlertView *alertV = [[UIAlertView alloc] initWithTitle:@"是否删除图片"
message:@""
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"确定", nil];
self.d_removeIndex = uiIndex; self.d_removeIndex = uiIndex;
} }
- (void)removePhotoAtIndex:(NSUInteger)uiIndex { - (void)removePhotoAtIndex:(NSUInteger)uiIndex {
ICRPostAttachment *postAttachment = _d_muArrPhotos[uiIndex]; ICRPostAttachment *postAttachment = _d_muArrPhotos[uiIndex];
ICRDataBaseController *dataBaseC = [ICRDataBaseController sharedController]; ICRDataBaseController *dataBaseC = [ICRDataBaseController sharedController];
[dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) { [dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) {
NSString *sql = [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@ = ?",[ICRPostAttachment TableName],@"fileName"]; NSString *sql =
[db executeUpdate:sql,postAttachment.fileName]; [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@ = ?",
[ICRPostAttachment TableName], @"fileName"];
[db executeUpdate:sql, postAttachment.fileName];
}]; }];
[self.d_muArrPhotos removeObjectAtIndex:uiIndex]; [self.d_muArrPhotos removeObjectAtIndex:uiIndex];
} }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) { if (buttonIndex == 1) {
CLog(@"delet"); CLog(@"delet");
[self removePhotoAtIndex:self.d_removeIndex]; [self removePhotoAtIndex:self.d_removeIndex];
} }
} }
#pragma UITableViewDataSource #pragma UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return section == 0 ? 1 : _d_muArrLicences.count; return section == 0 ? 1 : _d_muArrLicences.count;
} }
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2; return 2;
} }
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - (CGFloat)tableView:(UITableView *)tableView
heightForHeaderInSection:(NSInteger)section {
return section == 0 ? 0.1 : 44; return section == 0 ? 0.1 : 44;
} }
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) { if (indexPath.section == 0) {
return 210; return 210;
}else{ } else {
GTOLicence *licence = _d_muArrLicences[indexPath.row]; GTOLicence *licence = _d_muArrLicences[indexPath.row];
return [licence.state isEqualToString:@"rejected"] ? 110 + 20 : 110; return [licence.state isEqualToString:@"rejected"] ? 110 + 20 : 110;
} }
} }
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { - (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section {
if (section == 0) { if (section == 0) {
return nil; return nil;
} else { } else {
UITableViewHeaderFooterView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headID]; UITableViewHeaderFooterView *headerView =
[tableView dequeueReusableHeaderFooterViewWithIdentifier:headID];
[self configureHeaderView:headerView forHeaderInSection:section]; [self configureHeaderView:headerView forHeaderInSection:section];
return headerView; return headerView;
} }
} }
- (void)configureHeaderView: (UITableViewHeaderFooterView *)headerView forHeaderInSection: (NSInteger)section { - (void)configureHeaderView:(UITableViewHeaderFooterView *)headerView
forHeaderInSection:(NSInteger)section {
UIView *contentView = headerView.contentView; UIView *contentView = headerView.contentView;
CLog(@"%lf",contentView.height);//为什么为0?? CLog(@"%lf", contentView.height); //为什么为0??
contentView.backgroundColor = XXFBgColor; contentView.backgroundColor = XXFBgColor;
GXFButtonAndLineView *headLineV = [contentView viewWithClass:[GXFButtonAndLineView class]]; GXFButtonAndLineView *headLineV =
[contentView viewWithClass:[GXFButtonAndLineView class]];
if (!headLineV) { if (!headLineV) {
headLineV = [[GXFButtonAndLineView alloc]initViewLineAndButtonWithFrame:CGRectMake(0, 0, self.view.width * 0.5, 44 ) isSeleted:YES buttonTitle: @"许可证列表" selectColor:GTO_RED_COLOR]; headLineV = [[GXFButtonAndLineView alloc]
initViewLineAndButtonWithFrame:CGRectMake(0, 0, self.view.width * 0.5,
44)
isSeleted:YES
buttonTitle:@"许可证列表"
selectColor:GTO_RED_COLOR];
headLineV.f_btn.userInteractionEnabled = NO; headLineV.f_btn.userInteractionEnabled = NO;
BOOL createPermission = [GTOCommonTools hasPermissionWithPermissionId:500303]; BOOL createPermission =
BOOL condition = ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_INITIAL] [GTOCommonTools hasPermissionWithPermissionId:500303];
|| [_d_repair.state isEqualToString:GTO_REPAIR_STATE_SUBMITTED] BOOL condition =
|| [_d_repair.state isEqualToString:GTO_REPAIR_STATE_PROCESSING]) && createPermission; ([_d_repair.state isEqualToString:GTO_REPAIR_STATE_INITIAL] ||
if(condition) { [_d_repair.state isEqualToString:GTO_REPAIR_STATE_SUBMITTED] ||
UIButton *addBtn = [[UIButton alloc]initWithFrame:CGRectMake(headLineV.right + 5 , headLineV.y, headLineV.width, headLineV.height)]; [_d_repair.state isEqualToString:GTO_REPAIR_STATE_PROCESSING]) &&
[addBtn addTarget:self action:@selector(addLicenceClicked) forControlEvents:UIControlEventTouchUpInside]; createPermission;
[addBtn setImage:[UIImage imageNamed:@"add_icon"] forState:UIControlStateNormal]; if (condition) {
UIButton *addBtn = [[UIButton alloc]
initWithFrame:CGRectMake(headLineV.right + 5, headLineV.y,
headLineV.width, headLineV.height)];
[addBtn addTarget:self
action:@selector(addLicenceClicked)
forControlEvents:UIControlEventTouchUpInside];
[addBtn setImage:[UIImage imageNamed:@"add_icon"]
forState:UIControlStateNormal];
[addBtn setTitle:@"新增" forState:UIControlStateNormal]; [addBtn setTitle:@"新增" forState:UIControlStateNormal];
[addBtn setTitleColor:GTO_GRAY_TINT_COLOR forState:UIControlStateNormal]; [addBtn setTitleColor:GTO_GRAY_TINT_COLOR forState:UIControlStateNormal];
[contentView addSubview:addBtn]; [contentView addSubview:addBtn];
...@@ -372,51 +425,57 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -372,51 +425,57 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
[contentView addSubview:headLineV]; [contentView addSubview:headLineV];
} }
} }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = nil; UITableViewCell *cell = nil;
if (indexPath.section == 0) { if (indexPath.section == 0) {
cell = [tableView dequeueReusableCellWithIdentifier:cellIDTop forIndexPath:indexPath]; cell = [tableView dequeueReusableCellWithIdentifier:cellIDTop
forIndexPath:indexPath];
} else { } else {
cell = [tableView dequeueReusableCellWithIdentifier:cellIDItem forIndexPath:indexPath]; cell = [tableView dequeueReusableCellWithIdentifier:cellIDItem
forIndexPath:indexPath];
} }
[self configureCell:cell forRowAtIndexPath:indexPath]; [self configureCell:cell forRowAtIndexPath:indexPath];
return cell; return cell;
} }
- (void)configureCell:(UITableViewCell *)cell - (void)configureCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath forRowAtIndexPath:(NSIndexPath *)indexPath {
{
UIView *contentView = cell.contentView; UIView *contentView = cell.contentView;
if (indexPath.section == 0) { if (indexPath.section == 0) {
GTORepairDetailTopCellView *topView = [contentView viewWithClass:[GTORepairDetailTopCellView class]]; GTORepairDetailTopCellView *topView =
[contentView viewWithClass:[GTORepairDetailTopCellView class]];
if (!topView) { if (!topView) {
topView = [[GTORepairDetailTopCellView alloc]init]; topView = [[GTORepairDetailTopCellView alloc] init];
[topView autoresizingWithStrechFullSize]; [topView autoresizingWithStrechFullSize];
[contentView addSubview:topView]; [contentView addSubview:topView];
} }
[topView updateWithRepair:_d_repair]; [topView updateWithRepair:_d_repair];
} else { } else {
GTOLicenceListSimpleCellContentView *view = [contentView viewWithClass:[GTOLicenceListSimpleCellContentView class]]; GTOLicenceListSimpleCellContentView *view =
[contentView viewWithClass:[GTOLicenceListSimpleCellContentView class]];
if (!view) { if (!view) {
view = [[GTOLicenceListSimpleCellContentView alloc] initWithFrame:contentView.bounds]; view = [[GTOLicenceListSimpleCellContentView alloc]
//view.m_bHiddenNumLabel = m_bIsInHome; initWithFrame:contentView.bounds];
// view.m_bHiddenNumLabel = m_bIsInHome;
[view autoresizingWithStrechFullSize]; [view autoresizingWithStrechFullSize];
[contentView addSubview:view]; [contentView addSubview:view];
} }
GTOLicence *licence = _d_muArrLicences[indexPath.row]; GTOLicence *licence = _d_muArrLicences[indexPath.row];
[view updateWithLicence:licence]; [view updateWithLicence:licence];
} }
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO]; [tableView deselectRowAtIndexPath:indexPath animated:NO];
GTOLicence *licence = _d_muArrLicences[indexPath.row]; GTOLicence *licence = _d_muArrLicences[indexPath.row];
self.d_currentLicence = licence; self.d_currentLicence = licence;
[self p_httpGetLicenceItems]; [self p_httpGetLicenceItems];
} }
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
/* /*
UITableViewCellEditingStyleNone, UITableViewCellEditingStyleNone,
UITableViewCellEditingStyleDelete, UITableViewCellEditingStyleDelete,
...@@ -430,79 +489,91 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -430,79 +489,91 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
// return UITableViewCellEditingStyleDelete; // return UITableViewCellEditingStyleDelete;
return UITableViewCellEditingStyleNone; return UITableViewCellEditingStyleNone;
} }
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) { if (editingStyle == UITableViewCellEditingStyleDelete) {
GTOLicence *licence = _d_muArrLicences[indexPath.row]; GTOLicence *licence = _d_muArrLicences[indexPath.row];
[self p_deleteLicenceWithLicence: licence]; [self p_deleteLicenceWithLicence:licence];
[_d_muArrLicences removeObjectAtIndex:indexPath.row]; [_d_muArrLicences removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; [tableView deleteRowsAtIndexPaths:@[ indexPath ]
withRowAnimation:UITableViewRowAnimationFade];
} }
} }
- (void)p_deleteLicenceWithLicence: (GTOLicence *)licence { - (void)p_deleteLicenceWithLicence:(GTOLicence *)licence {
//后台删除 //后台删除
void(^succ)(id) = ^(id data) { void (^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
if ([data[@"success"] integerValue] == 1) { if ([data[@"success"] integerValue] == 1) {
//本地删除 许可证 //本地删除 许可证
ICRDataBaseController *dataBaseC = [ICRDataBaseController sharedController]; ICRDataBaseController *dataBaseC =
[ICRDataBaseController sharedController];
[dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) { [dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) {
NSString *strSql = [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@=?",[GTOLicence TableName],@"uuid" ]; NSString *strSql =
[db executeUpdate:strSql,licence.uuid]; [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@=?",
[GTOLicence TableName], @"uuid"];
[db executeUpdate:strSql, licence.uuid];
}]; }];
[dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) { [dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) {
NSString *strSql = [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@=?",[GTOQuestion TableName],@"licenceUuid" ]; NSString *strSql =
[db executeUpdate:strSql,licence.uuid]; [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@=?",
[GTOQuestion TableName], @"licenceUuid"];
[db executeUpdate:strSql, licence.uuid];
}]; }];
[dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) { [dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) {
NSString *strSql = [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@=?",[GTOAnswer TableName],@"licenceUuid" ]; NSString *strSql =
[db executeUpdate:strSql,licence.uuid]; [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@=?",
[GTOAnswer TableName], @"licenceUuid"];
[db executeUpdate:strSql, licence.uuid];
}]; }];
} else { } else {
[IBTLoadingView showTextOnly:data[@"message"] inView:self.view]; [IBTLoadingView showTextOnly:data[@"message"] inView:self.view];
} }
}; };
void(^fail)(id) = ^(id data) { void (^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
ICRHTTPController *httpC = [ICRHTTPController sharedController]; ICRHTTPController *httpC = [ICRHTTPController sharedController];
[httpC doLicenceRemoveWithLicenceUuid:licence.uuid version:licence.version success:succ failure:fail]; [httpC doLicenceRemoveWithLicenceUuid:licence.uuid
version:licence.version
success:succ
failure:fail];
} }
- (void)p_httpGetLicenceItems { - (void)p_httpGetLicenceItems {
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
void(^succ)(id) = ^(id data) { void (^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
[strongSelf p_saveLicenceItemsWithData:data]; [strongSelf p_saveLicenceItemsWithData:data];
}; };
void(^fail)(id) = ^(id data) { void (^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
ICRHTTPController *httpC = [ICRHTTPController sharedController]; ICRHTTPController *httpC = [ICRHTTPController sharedController];
[httpC getLicenceItemsWithLicenceUuid:_d_currentLicence.uuid success:succ failure:fail]; [httpC getLicenceItemsWithLicenceUuid:_d_currentLicence.uuid
success:succ
failure:fail];
} }
- (void)p_saveLicenceItemsWithData: (id)data { - (void)p_saveLicenceItemsWithData:(id)data {
NSInteger intSucc = [data[@"success"] integerValue]; NSInteger intSucc = [data[@"success"] integerValue];
if (intSucc == 1) { if (intSucc == 1) {
} }
NSArray *arrItems = [data[@"data"] objectForKey:@"items"]; NSArray *arrItems = [data[@"data"] objectForKey:@"items"];
NSMutableArray *muArrQuestions = [NSMutableArray array]; NSMutableArray *muArrQuestions = [NSMutableArray array];
NSMutableArray *muArrAnswers = [NSMutableArray array]; NSMutableArray *muArrAnswers = [NSMutableArray array];
NSMutableArray *muArrCategory = [NSMutableArray array]; NSMutableArray *muArrCategory = [NSMutableArray array];
for(NSDictionary *dictItem in arrItems) { for (NSDictionary *dictItem in arrItems) {
GTOPioneeringSurveyItem *item = [GTOPioneeringSurveyItem DBObject]; GTOPioneeringSurveyItem *item = [GTOPioneeringSurveyItem DBObject];
[item praseFromJsonDict:dictItem]; [item praseFromJsonDict:dictItem];
...@@ -510,34 +581,39 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -510,34 +581,39 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
[question praseFromJsonDict:dictItem]; [question praseFromJsonDict:dictItem];
question.licenceUuid = _d_currentLicence.uuid; question.licenceUuid = _d_currentLicence.uuid;
[question saveToDBWithHandleData:NULL complete:NULL fail:NULL]; [question saveToDBWithHandleData:NULL complete:NULL fail:NULL];
CLog(@"%@",question.uuid); CLog(@"%@", question.uuid);
[muArrQuestions addObject:[question dictForCommit]]; [muArrQuestions addObject:[question dictForCommit]];
/* /*
@property (assign, nonatomic) NSUInteger resultScore; //打分结果 @property (assign, nonatomic) NSUInteger resultScore; //打分结果
@property (copy, nonatomic) NSString *resultContent; @property (copy, nonatomic) NSString *resultContent;
@property (copy, nonatomic) NSString *resultRemark; @property (copy, nonatomic) NSString *resultRemark;
@property (copy, nonatomic) NSArray *resultDetails; @property (copy, nonatomic) NSArray *resultDetails;
@property (copy, nonatomic) NSString *resultAttachmentId; //结果附件id 没做 @property (copy, nonatomic) NSString *resultAttachmentId; //结果附件id
没做
*/ */
GTOAnswer *answer = [GTOAnswer DBObject]; GTOAnswer *answer = [GTOAnswer DBObject];
[answer praseFromJsonDict:dictItem]; [answer praseFromJsonDict:dictItem];
NSUInteger count = 0;//记录是否被回答:根据答案有无 NSUInteger count = 0; //记录是否被回答:根据答案有无
if(answer.resultScore) count++; if (answer.resultScore)
if(answer.resultContent) count++; count++;
if(answer.resultRemark) count++; if (answer.resultContent)
if(answer.resultDetails.count) count++; count++;
if (count > 0 ) { if (answer.resultRemark)
count++;
if (answer.resultDetails.count)
count++;
if (count > 0) {
answer.resultAttachmentUrls = item.resultAttachmentUrls; answer.resultAttachmentUrls = item.resultAttachmentUrls;
answer.resultAttachmentId = item.resultAttachmentId; answer.resultAttachmentId = item.resultAttachmentId;
answer.bIsAnswered = YES; answer.bIsAnswered = YES;
answer.questionUuid = item.uuid; answer.questionUuid = item.uuid;
answer.licenceUuid = _d_currentLicence.uuid; answer.licenceUuid = _d_currentLicence.uuid;
if(answer.resultAttachmentUrls.count > 0) answer.bIsDownLoadImgs = YES; if (answer.resultAttachmentUrls.count > 0)
for(NSDictionary *dict in answer.resultAttachmentUrls){ answer.bIsDownLoadImgs = YES;
for (NSDictionary *dict in answer.resultAttachmentUrls) {
ICRPostAttachment *postAttachment = [ICRPostAttachment DBObject]; ICRPostAttachment *postAttachment = [ICRPostAttachment DBObject];
[postAttachment praseFromJsonDict:dict]; [postAttachment praseFromJsonDict:dict];
postAttachment.is_localPhoto = NO; postAttachment.is_localPhoto = NO;
...@@ -553,15 +629,14 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -553,15 +629,14 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
} }
[muArrCategory addObject:item.category]; [muArrCategory addObject:item.category];
} }
_d_currentLicence.questions = muArrQuestions; _d_currentLicence.questions = muArrQuestions;
//GTODisplayResult // GTODisplayResult
NSSet *setCategory = [NSSet setWithArray:muArrCategory]; NSSet *setCategory = [NSSet setWithArray:muArrCategory];
NSMutableArray *muArrDisplayRs = [NSMutableArray array]; NSMutableArray *muArrDisplayRs = [NSMutableArray array];
for(NSString *category in setCategory) { for (NSString *category in setCategory) {
NSMutableArray *muArrQuestions = [NSMutableArray array]; NSMutableArray *muArrQuestions = [NSMutableArray array];
for(NSDictionary *dictQ in _d_currentLicence.questions) { for (NSDictionary *dictQ in _d_currentLicence.questions) {
GTOQuestion *question = [GTOQuestion DBObject]; GTOQuestion *question = [GTOQuestion DBObject];
[question praseFromJsonDict:dictQ]; [question praseFromJsonDict:dictQ];
if ([question.category isEqualToString:category]) { if ([question.category isEqualToString:category]) {
...@@ -576,7 +651,6 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -576,7 +651,6 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
[muArrDisplayRs addObject:[displayR dictForCommit]]; [muArrDisplayRs addObject:[displayR dictForCommit]];
} }
_d_currentLicence.arrDisplayResults = muArrDisplayRs; _d_currentLicence.arrDisplayResults = muArrDisplayRs;
[_d_currentLicence saveToDBWithHandleData:NULL [_d_currentLicence saveToDBWithHandleData:NULL
complete:^{ complete:^{
...@@ -585,9 +659,12 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -585,9 +659,12 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
fail:^(NSError *error) { fail:^(NSError *error) {
[IBTLoadingView hideHUDWithText:error.localizedDescription]; [IBTLoadingView hideHUDWithText:error.localizedDescription];
}];} }];
}
- (void)p_addAlerInfoLicenceView { - (void)p_addAlerInfoLicenceView {
GTOAlertInfoLicenceViewController *alertInfoVC = [[GTOAlertInfoLicenceViewController alloc]initWithLicence:_d_currentLicence]; GTOAlertInfoLicenceViewController *alertInfoVC =
[[GTOAlertInfoLicenceViewController alloc]
initWithLicence:_d_currentLicence];
self.alertInfoVC = alertInfoVC; self.alertInfoVC = alertInfoVC;
alertInfoVC.delegate = self; alertInfoVC.delegate = self;
[[UIApplication sharedApplication].keyWindow addSubview:_alertInfoVC.view]; [[UIApplication sharedApplication].keyWindow addSubview:_alertInfoVC.view];
...@@ -595,26 +672,30 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -595,26 +672,30 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
//找到对应的答案并跳转结果页面 //找到对应的答案并跳转结果页面
- (void)fetchResult { //答案的个数 - (void)fetchResult { //答案的个数
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@ = ? ORDER BY %@", [GTOAnswer TableName], @"licenceUuid",@"questionUuid" ]; NSString *sql = [NSString
stringWithFormat:@"SELECT * FROM %@ WHERE %@ = ? ORDER BY %@",
[GTOAnswer TableName], @"licenceUuid",
@"questionUuid"];
//答案的排序按照问题的uuid来,(此事的排序关系到结果页中答案的显示,按道理应该是根据答题的顺序,是不是后台给的问题应该排序?????) //答案的排序按照问题的uuid来,(此事的排序关系到结果页中答案的显示,按道理应该是根据答题的顺序,是不是后台给的问题应该排序?????)
NSLog(@"%@",sql); NSLog(@"%@", sql);
return [db executeQuery:sql,_d_currentLicence.uuid]; return [db executeQuery:sql, _d_currentLicence.uuid];
}; };
__weak typeof(self)weakSelf = self; __weak typeof(self) weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) { ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
NSMutableArray *muArrDisplayRs = [NSMutableArray array]; NSMutableArray *muArrDisplayRs = [NSMutableArray array];
for (int count = 0; count < _d_currentLicence.arrDisplayResults.count; count ++) { for (int count = 0; count < _d_currentLicence.arrDisplayResults.count;
count++) {
// NSInteger finiseNumber = 0; // NSInteger finiseNumber = 0;
GTODisplayResult *displayR = [GTODisplayResult DBObject]; GTODisplayResult *displayR = [GTODisplayResult DBObject];
[displayR praseFromJsonDict:_d_currentLicence.arrDisplayResults[count]]; [displayR praseFromJsonDict:_d_currentLicence.arrDisplayResults[count]];
//displayR.answerNumber = 0; // displayR.answerNumber = 0;
NSMutableArray *muArrAnswers = [NSMutableArray array]; NSMutableArray *muArrAnswers = [NSMutableArray array];
for (GTOAnswer *answer in fetchedObjects) { for (GTOAnswer *answer in fetchedObjects) {
if([answer.category isEqualToString:displayR.category]) if ([answer.category isEqualToString:displayR.category])
//displayR.answerNumber++; // displayR.answerNumber++;
[muArrAnswers addObject:[answer dictForCommit]]; [muArrAnswers addObject:[answer dictForCommit]];
} }
displayR.arrAnswers = muArrAnswers; displayR.arrAnswers = muArrAnswers;
...@@ -622,11 +703,16 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -622,11 +703,16 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
[muArrDisplayRs addObject:[displayR dictForCommit]]; [muArrDisplayRs addObject:[displayR dictForCommit]];
} }
_d_currentLicence.arrDisplayResults = muArrDisplayRs; _d_currentLicence.arrDisplayResults = muArrDisplayRs;
[_d_currentLicence saveToDBWithHandleData:nil complete:^{ [_d_currentLicence
GTOLiceneResultViewController *resultVC = [[GTOLiceneResultViewController alloc]initWithLicence:_d_currentLicence]; saveToDBWithHandleData:nil
//resultVC. complete:^{
GTOLiceneResultViewController *resultVC =
[[GTOLiceneResultViewController alloc]
initWithLicence:_d_currentLicence];
// resultVC.
[self PushViewController:resultVC animated:YES]; [self PushViewController:resultVC animated:YES];
} fail:nil]; }
fail:nil];
}; };
...@@ -636,10 +722,10 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -636,10 +722,10 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
fetchResultsBlock:fetchResultsBlk]; fetchResultsBlock:fetchResultsBlk];
} }
#pragma button Action #pragma button Action
- (void)addLicenceClicked { - (void)addLicenceClicked {
GTOLicenceNewViewController *newVC = [[GTOLicenceNewViewController alloc]init]; GTOLicenceNewViewController *newVC =
[[GTOLicenceNewViewController alloc] init];
newVC.d_repair = _d_repair; newVC.d_repair = _d_repair;
[self PushViewController:newVC animated:NO]; [self PushViewController:newVC animated:NO];
} }
...@@ -652,8 +738,8 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -652,8 +738,8 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
} }
- (void)onTapImage:(ICRAttachmentUnit *)unit { - (void)onTapImage:(ICRAttachmentUnit *)unit {
CGRect rect = [self.view.window convertRect:unit.frame CGRect rect =
fromView:unit.superview]; [self.view.window convertRect:unit.frame fromView:unit.superview];
UIImage *img = unit.m_oAttachmentWrap; UIImage *img = unit.m_oAttachmentWrap;
JTImagePreviewer *ipv = JTImagePreviewer *ipv =
...@@ -665,8 +751,8 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -665,8 +751,8 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
} }
- (void)onTapImageView:(ICRAttachmentUnit *)unit { - (void)onTapImageView:(ICRAttachmentUnit *)unit {
CGRect rect = [self.view.window convertRect:unit.frame CGRect rect =
fromView:unit.superview]; [self.view.window convertRect:unit.frame fromView:unit.superview];
UIImage *img = unit.m_imageView.image; UIImage *img = unit.m_imageView.image;
JTImagePreviewer *ipv = JTImagePreviewer *ipv =
...@@ -679,7 +765,8 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -679,7 +765,8 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
#pragma mark - IBTImagePickerDelegate #pragma mark - IBTImagePickerDelegate
- (void)imagePicker:(IBTImagePickerController *)picker - (void)imagePicker:(IBTImagePickerController *)picker
didImagePicked:(UIImage *)image referenceURL:(NSURL *)imageUrl { didImagePicked:(UIImage *)image
referenceURL:(NSURL *)imageUrl {
IBTFileData *imgFile = [IBTCommon saveImageToLocal:image]; IBTFileData *imgFile = [IBTCommon saveImageToLocal:image];
ICRPostAttachment *attE = [[ICRPostAttachment alloc] init]; ICRPostAttachment *attE = [[ICRPostAttachment alloc] init];
...@@ -704,12 +791,10 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) { ...@@ -704,12 +791,10 @@ typedef NS_ENUM(NSUInteger, bottomViewTag) {
[self.d_muArrPhotos addObject:attE]; [self.d_muArrPhotos addObject:attE];
[self addAttachment:image]; [self addAttachment:image];
} }
- (void)imagePicker:(IBTImagePickerController *)picker - (void)imagePicker:(IBTImagePickerController *)picker
didVideoPickedWithURL:(NSURL *)videoUrl { didVideoPickedWithURL:(NSURL *)videoUrl {
} }
- (void)addAttachment:(id)oAtt { // oAtt 可以为图片,也可以为url - (void)addAttachment:(id)oAtt { // oAtt 可以为图片,也可以为url
...@@ -718,7 +803,7 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -718,7 +803,7 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
UIImage *iconImg; UIImage *iconImg;
ICRAttachmentView *attachView = nil; ICRAttachmentView *attachView = nil;
if ([oAtt isKindOfClass:[UIImage class]]) {// if ([oAtt isKindOfClass:[UIImage class]]) { //
iconImg = oAtt; iconImg = oAtt;
selector = @selector(onTapImage:); selector = @selector(onTapImage:);
attachView = self.c_addPhotoV.m_photoAttachView; attachView = self.c_addPhotoV.m_photoAttachView;
...@@ -728,24 +813,31 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -728,24 +813,31 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
attachView = self.c_addPhotoV.m_photoAttachView; attachView = self.c_addPhotoV.m_photoAttachView;
} }
ICRAttachmentUnit *attV = [[ICRAttachmentUnit alloc]
ICRAttachmentUnit *attV = [[ICRAttachmentUnit alloc] initWithFrame:(CGRect){ initWithFrame:(CGRect){.origin.x = 0,
.origin.x = 0,
.origin.y = 0, .origin.y = 0,
.size.width = IBT_ATTACH_UNIT_DEFAULT_WIDTH, .size.width = IBT_ATTACH_UNIT_DEFAULT_WIDTH,
.size.height = IBT_ATTACH_UNIT_DEFAULT_WIDTH + 10 .size.height =
}]; IBT_ATTACH_UNIT_DEFAULT_WIDTH + 10}];
if(_d_isDownLoadImg) { if (_d_isDownLoadImg) {
attachView.isDownImg = YES; attachView.isDownImg = YES;
attV.m_imageView.backgroundColor = [UIColor grayColor]; attV.m_imageView.backgroundColor = [UIColor grayColor];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(
[attV updateWithType:kATTNormal masker:nil placeHolder:nil image:iconImg title:nil]; dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[attV updateWithType:kATTNormal
masker:nil
placeHolder:nil
image:iconImg
title:nil];
}); });
} else { } else {
[attV updateWithType:kATTCloseBtn masker:nil placeHolder:nil image:iconImg title:nil]; [attV updateWithType:kATTCloseBtn
masker:nil
placeHolder:nil
image:iconImg
title:nil];
} }
attV.m_oAttachmentWrap = oAtt; attV.m_oAttachmentWrap = oAtt;
[attV addTarget:self [attV addTarget:self
...@@ -756,44 +848,41 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -756,44 +848,41 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
} }
// 将字典或者数组转化为JSON串 // 将字典或者数组转化为JSON串
- (NSString *)toJSONData:(id)theData{ - (NSString *)toJSONData:(id)theData {
NSError *error = nil; NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:theData NSData *jsonData =
[NSJSONSerialization dataWithJSONObject:theData
options:NSJSONWritingPrettyPrinted options:NSJSONWritingPrettyPrinted
error:&error]; error:&error];
if ([jsonData length] > 0 && error == nil){ if ([jsonData length] > 0 && error == nil) {
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; return
[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}else{ } else {
return nil; return nil;
} }
} }
#pragma GXFBottomViewDelegate #pragma GXFBottomViewDelegate
- (void)bottomView:(GXFBottomView *)bottomView oneButtonClicked:(UIButton *)oneBtn { - (void)bottomView:(GXFBottomView *)bottomView
oneButtonClicked:(UIButton *)oneBtn {
switch (bottomView.tag) { switch (bottomView.tag) {
case kBottomViewOneBackTag: case kBottomViewOneBackTag: {
{
[self PopViewControllerAnimated:YES]; [self PopViewControllerAnimated:YES];
} }
break; break;
case kBottomViewOneApplicationTag: case kBottomViewOneApplicationTag: {
{ [self httpApplicationRepair]; //
[self httpApplicationRepair];// } break;
} case kBottomViewOneFinishTag: {
break;
case kBottomViewOneFinishTag:
{
//结束报修前,应先添加图片 //结束报修前,应先添加图片
[self httpUploadPhoto]; [self httpUploadPhoto];
} } break;
break;
default: default:
break; break;
...@@ -806,31 +895,36 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -806,31 +895,36 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
if ([licence.state isEqualToString:@"submitted"] || if ([licence.state isEqualToString:@"submitted"] ||
[licence.state isEqualToString:@"initial"] || [licence.state isEqualToString:@"initial"] ||
[licence.state isEqualToString:@"askforapprove"]) { [licence.state isEqualToString:@"askforapprove"]) {
[IBTLoadingView hideHUDWithText:@"有未提交或待审批的许可证,请处理完成后重试"]; [IBTLoadingView
hideHUDWithText:
@"有未提交或待审批的许可证,请处理完成后重试"];
return; return;
} }
} }
void(^succ)(id) = ^(id data) { void (^succ)(id) = ^(id data) {
if ([data[@"success"] integerValue] == 1) { if ([data[@"success"] integerValue] == 1) {
[IBTLoadingView hideHUDForView:self.view]; [IBTLoadingView hideHUDForView:self.view];
self.c_addPhotoV.hidden = NO; self.c_addPhotoV.hidden = NO;
self.c_bottomView.tag = kBottomViewOneFinishTag; self.c_bottomView.tag = kBottomViewOneFinishTag;
self.d_applyFinish = YES; self.d_applyFinish = YES;
[self.c_bottomView.f_oneBtn setTitle:@"结束报修" forState:UIControlStateNormal]; [self.c_bottomView.f_oneBtn setTitle:@"结束报修"
forState:UIControlStateNormal];
} else { } else {
[IBTLoadingView hideHUDWithText:data[@"message"]]; [IBTLoadingView hideHUDWithText:data[@"message"]];
} }
}; };
void(^fail)(id) = ^(id data) { void (^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
[IBTLoadingView showProgressLabel:@"申请结束报修 ..."]; [IBTLoadingView showProgressLabel:@"申请结束报修 ..."];
ICRHTTPController *httpC = [ICRHTTPController sharedController]; ICRHTTPController *httpC = [ICRHTTPController sharedController];
[httpC dorepairApplicationWithRepairUuid:_d_repair.uuid version:_d_repair.version success:succ failure:fail]; [httpC dorepairApplicationWithRepairUuid:_d_repair.uuid
version:_d_repair.version
success:succ
failure:fail];
} }
// 上传报修图片 // 上传报修图片
- (void)httpUploadPhoto { - (void)httpUploadPhoto {
...@@ -838,9 +932,8 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -838,9 +932,8 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
[IBTLoadingView showTextOnly:@"结束报修前,请先添加图片" inView:self.view]; [IBTLoadingView showTextOnly:@"结束报修前,请先添加图片" inView:self.view];
return; return;
} }
void(^succ)(id) = ^(id data) { void (^succ)(id) = ^(id data) {
if ([data[@"success"] integerValue] == 1) { if ([data[@"success"] integerValue] == 1) {
[IBTLoadingView hideHUDForView:self.view]; [IBTLoadingView hideHUDForView:self.view];
...@@ -852,7 +945,7 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -852,7 +945,7 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
} }
}; };
void(^fail)(id) = ^(id data) { void (^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
...@@ -860,24 +953,30 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -860,24 +953,30 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
}; };
// [IBTLoadingView showProgressLabel:@"正在上传图片"]; // [IBTLoadingView showProgressLabel:@"正在上传图片"];
ICRHTTPController *httpC = [ICRHTTPController sharedController]; ICRHTTPController *httpC = [ICRHTTPController sharedController];
[httpC multiPartUploadWithEntityType:_d_postAttachment.entityType entityUuid:_d_postAttachment.entityUuid arrayPostAttachments:_d_muArrPhotos success:succ failure:fail]; [httpC multiPartUploadWithEntityType:_d_postAttachment.entityType
entityUuid:_d_postAttachment.entityUuid
arrayPostAttachments:_d_muArrPhotos
success:succ
failure:fail];
} }
//结束报修 //结束报修
- (void)httpFinishRepair { - (void)httpFinishRepair {
void(^succ)(id) = ^(id data) { void (^succ)(id) = ^(id data) {
if ([data[@"success"] integerValue] == 1) { if ([data[@"success"] integerValue] == 1) {
[IBTLoadingView hideHUDForView:self.view]; [IBTLoadingView hideHUDForView:self.view];
ICRDataBaseController *dataBaseC = [ICRDataBaseController sharedController]; ICRDataBaseController *dataBaseC =
[ICRDataBaseController sharedController];
//删除本地图片 //删除本地图片
[dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) { [dataBaseC.m_dbQueue inDatabase:^(FMDatabase *db) {
NSString *sql = [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@ = ?",[ICRPostAttachment TableName],@"repairUuid"]; NSString *sql = [NSString
[db executeUpdate:sql,_d_repair.uuid]; stringWithFormat:@"DELETE FROM %@ WHERE %@ = ?",
[ICRPostAttachment TableName], @"repairUuid"];
[db executeUpdate:sql, _d_repair.uuid];
}]; }];
[self PopViewControllerAnimated:YES]; [self PopViewControllerAnimated:YES];
} else { } else {
...@@ -885,7 +984,7 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -885,7 +984,7 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
} }
}; };
void(^fail)(id) = ^(id data) { void (^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
...@@ -893,31 +992,47 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -893,31 +992,47 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
ICRHTTPController *httpC = [ICRHTTPController sharedController]; ICRHTTPController *httpC = [ICRHTTPController sharedController];
NSInteger version = 0; NSInteger version = 0;
version = _d_applyFinish ? _d_repair.version + 1 : _d_repair.version; version = _d_applyFinish ? _d_repair.version + 1 : _d_repair.version;
[httpC dorepairFinishWithRepairUuid:_d_repair.uuid version:version attachmentId:_d_postAttachment.entityUuid success:succ failure:fail]; //在这里传的报修单的版本应该说是后台那边直接增加我拿到,然后传,但是“申请结束报修后”version增加了:要不直接重新拿数据 [httpC
dorepairFinishWithRepairUuid:_d_repair.uuid
version:version
attachmentId:_d_postAttachment.entityUuid
success:succ
failure:
fail]; //在这里传的报修单的版本应该说是后台那边直接增加我拿到,然后传,但是“申请结束报修后”version增加了:要不直接重新拿数据
} }
#pragma GTOAlertInfoLicenceViewControllerDelegate #pragma GTOAlertInfoLicenceViewControllerDelegate
- (void)alertInfoLicenceViewController:(GTOAlertInfoLicenceViewController *)alertInfoLicence closeClickedWithBtton:(UIButton *)btn { - (void)alertInfoLicenceViewController:
//self.d_isClosed = YES; (GTOAlertInfoLicenceViewController *)alertInfoLicence
closeClickedWithBtton:(UIButton *)btn {
// self.d_isClosed = YES;
[_alertInfoVC.view removeFromSuperview]; [_alertInfoVC.view removeFromSuperview];
} }
- (void)alertInfoLicenceViewController:(GTOAlertInfoLicenceViewController *)alertInfoLicence seeResultClickedWithBtton:(UIButton *)btn { - (void)alertInfoLicenceViewController:
(GTOAlertInfoLicenceViewController *)alertInfoLicence
seeResultClickedWithBtton:(UIButton *)btn {
GTOLiceneResultViewController *resultVC = [[GTOLiceneResultViewController alloc]initWithLicence:_d_currentLicence]; GTOLiceneResultViewController *resultVC =
[[GTOLiceneResultViewController alloc] initWithLicence:_d_currentLicence];
//self.d_isClosed = YES; // self.d_isClosed = YES;
[_alertInfoVC.view removeFromSuperview]; [_alertInfoVC.view removeFromSuperview];
[self PushViewController:resultVC animated:YES]; [self PushViewController:resultVC animated:YES];
} }
- (void)alertInfoLicenceViewController:(GTOAlertInfoLicenceViewController *)alertInfoLicence nextClickedWithBtton:(UIButton *)btn { - (void)alertInfoLicenceViewController:
(GTOAlertInfoLicenceViewController *)alertInfoLicence
nextClickedWithBtton:(UIButton *)btn {
BOOL isAllFinished = YES; BOOL isAllFinished = YES;
for(NSDictionary *dict in _d_currentLicence.arrDisplayResults) { for (NSDictionary *dict in _d_currentLicence.arrDisplayResults) {
GTODisplayResult *displayR = [GTODisplayResult DBObject]; GTODisplayResult *displayR = [GTODisplayResult DBObject];
[displayR praseFromJsonDict:dict]; [displayR praseFromJsonDict:dict];
if (displayR.arrAnswers.count < displayR.arrQuestions.count) { if (displayR.arrAnswers.count < displayR.arrQuestions.count) {
GTOQuestionManager *mgr = [GTOQuestionManager sharedManager]; GTOQuestionManager *mgr = [GTOQuestionManager sharedManager];
mgr.d_category = displayR.category; mgr.d_category = displayR.category;
[mgr openQuestionVCFromViewControler:self Licence:_d_currentLicence Pioneering:nil]; [mgr openQuestionVCFromViewControler:self
[self alertInfoLicenceViewController:alertInfoLicence closeClickedWithBtton:nil]; Licence:_d_currentLicence
Pioneering:nil];
[self alertInfoLicenceViewController:alertInfoLicence
closeClickedWithBtton:nil];
isAllFinished = NO; isAllFinished = NO;
break; break;
} }
...@@ -929,48 +1044,79 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -929,48 +1044,79 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
[displayR praseFromJsonDict:dictR]; [displayR praseFromJsonDict:dictR];
GTOQuestionManager *mgr = [GTOQuestionManager sharedManager]; GTOQuestionManager *mgr = [GTOQuestionManager sharedManager];
mgr.d_category = displayR.category; mgr.d_category = displayR.category;
[mgr openQuestionVCFromViewControler:self Licence:_d_currentLicence Pioneering:nil]; [mgr openQuestionVCFromViewControler:self
[self alertInfoLicenceViewController:alertInfoLicence closeClickedWithBtton:nil]; Licence:_d_currentLicence
Pioneering:nil];
[self alertInfoLicenceViewController:alertInfoLicence
closeClickedWithBtton:nil];
} }
} }
- (void)alertInfoLicenceViewController:(GTOAlertInfoLicenceViewController *)alertInfoLicence didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)alertInfoLicenceViewController:
(GTOAlertInfoLicenceViewController *)alertInfoLicence
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
GTOQuestionManager *mgr = [GTOQuestionManager sharedManager]; GTOQuestionManager *mgr = [GTOQuestionManager sharedManager];
GTODisplayResult *displayR = [GTODisplayResult DBObject]; GTODisplayResult *displayR = [GTODisplayResult DBObject];
[displayR praseFromJsonDict:_d_currentLicence.arrDisplayResults[indexPath.row]]; [displayR
mgr.d_category = displayR.category;//alertInfoPioneering.d_arrCategorys[indexPath.row]; praseFromJsonDict:_d_currentLicence.arrDisplayResults[indexPath.row]];
[mgr openQuestionVCFromViewControler:self Licence:_d_currentLicence Pioneering:nil]; mgr.d_category =
displayR.category; // alertInfoPioneering.d_arrCategorys[indexPath.row];
[self alertInfoLicenceViewController:alertInfoLicence closeClickedWithBtton:nil]; [mgr openQuestionVCFromViewControler:self
Licence:_d_currentLicence
Pioneering:nil];
[self alertInfoLicenceViewController:alertInfoLicence
closeClickedWithBtton:nil];
} }
- (UIImageView *)imgNoData {
if (!_imgNoData) {
_imgNoData = [[UIImageView alloc] initWithFrame:CGRectMake(0, 300, 200, 100)];
_imgNoData.contentMode = UIViewContentModeScaleAspectFit;
_imgNoData.image = [UIImage imageNamed:@"no_data"];
[self.c_tableView addSubview:_imgNoData];
[_imgNoData mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.centerY.mas_equalTo(@100);
}];
_imgNoData.hidden = YES;
}
return _imgNoData;
}
//原生的多图片上传 //原生的多图片上传
//- (BOOL)sendPhotoToTumblr: (NSString *)photo withCaption: (NSString *)caption { //- (BOOL)sendPhotoToTumblr: (NSString *)photo withCaption: (NSString *)caption
//{
// //get image data from file // //get image data from file
// //photo为文件的 // //photo为文件的
// NSData *imageData = [NSData dataWithContentsOfFile:photo]; // NSData *imageData = [NSData dataWithContentsOfFile:photo];
// if (!imageData) return NO; // if (!imageData) return NO;
// //
// //create dictionary of post arguments // //create dictionary of post arguments
// NSArray *keys = [[NSArray alloc]initWithObjects:@"email",@"password",@"type",@"caption", nil]; // NSArray *keys = [[NSArray
// alloc]initWithObjects:@"email",@"password",@"type",@"caption", nil];
// //
// NSArray *objects = [[NSArray alloc] initWithObjects: // NSArray *objects = [[NSArray alloc] initWithObjects:
// [NSString stringWithFormat:@"%@",CFPreferencesCopyAppValue(CFSTR("TumblrEmail"), kCFPreferencesCurrentApplication)], // [NSString
// stringWithFormat:@"%@",CFPreferencesCopyAppValue(CFSTR("TumblrEmail"),
// kCFPreferencesCurrentApplication)],
// //
// [NSString stringWithFormat:@"%@",CFPreferencesCopyAppValue(CFSTR("TumblrPassword"), kCFPreferencesCurrentApplication)], // [NSString
// stringWithFormat:@"%@",CFPreferencesCopyAppValue(CFSTR("TumblrPassword"),
// kCFPreferencesCurrentApplication)],
// //
// @"photo", caption, nil]; // @"photo", caption, nil];
// NSDictionary *keysDict = [[NSDictionary alloc]initWithObjects:objects forKeys:keys]; // NSDictionary *keysDict = [[NSDictionary alloc]initWithObjects:objects
// forKeys:keys];
// //
// //create tumblr photo post // //create tumblr photo post
// NSURLRequest *tumblrPost = [self createTumblrRequest:keysDict withData:imageData]; // NSURLRequest *tumblrPost = [self createTumblrRequest:keysDict
// withData:imageData];
// //
// //
// //send request, returen YES if successful // //send request, returen YES if successful
// NSURLConnection *tumblrConnection = [[NSURLConnection alloc]initWithRequest:tumblrPost delegate:self]; // NSURLConnection *tumblrConnection = [[NSURLConnection
// alloc]initWithRequest:tumblrPost delegate:self];
// if (!tumblrConnection) { // if (!tumblrConnection) {
// CLog(@"Fail to submit request"); // CLog(@"Fail to submit request");
// } else { // } else {
...@@ -982,39 +1128,55 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -982,39 +1128,55 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
//} //}
// //
// //
//- (NSURLRequest *)createTumblrRequest: (NSDictionary *)postKeys withData: (NSData *)data { //- (NSURLRequest *)createTumblrRequest: (NSDictionary *)postKeys withData:
//(NSData *)data {
////tumblr:微博客 ////tumblr:微博客
// //create the URL POST Request to tumblr // //create the URL POST Request to tumblr
// NSURL *tumblrURL = [NSURL URLWithString:@""];//url // NSURL *tumblrURL = [NSURL URLWithString:@""];//url
// NSMutableURLRequest *tumblrPost = [NSMutableURLRequest requestWithURL:tumblrURL]; // NSMutableURLRequest *tumblrPost = [NSMutableURLRequest
// requestWithURL:tumblrURL];
// [tumblrPost setHTTPMethod:@"POST"]; //请求 // [tumblrPost setHTTPMethod:@"POST"]; //请求
// //
// //Add the header info // //Add the header info
// NSString *stringBoundary = @"0xKhTmLbOuNdArY";//????? // NSString *stringBoundary = @"0xKhTmLbOuNdArY";//?????
// NSString *contentType = [NSString stringWithFormat:@"multipart/form-data;boundary=%@",stringBoundary]; // NSString *contentType = [NSString
// stringWithFormat:@"multipart/form-data;boundary=%@",stringBoundary];
// [tumblrPost addValue:contentType forHTTPHeaderField:@"Content-Type"]; // [tumblrPost addValue:contentType forHTTPHeaderField:@"Content-Type"];
// //
// //
// //create the body // //create the body
// NSMutableData *postBody = [NSMutableData data]; // NSMutableData *postBody = [NSMutableData data];
// [postBody appendData:[[NSString stringWithFormat:@"--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; // [postBody appendData:[[NSString
// stringWithFormat:@"--%@\r\n",stringBoundary]
// dataUsingEncoding:NSUTF8StringEncoding]];
// //
// //add key values from the NSDictionary object // //add key values from the NSDictionary object
// NSEnumerator *keys = [postKeys keyEnumerator]; // NSEnumerator *keys = [postKeys keyEnumerator];
// int i; // int i;
// for (i = 0; i < [postKeys count]; i++) { // for (i = 0; i < [postKeys count]; i++) {
// NSString *tempKey = [keys nextObject]; // NSString *tempKey = [keys nextObject];
// [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",tempKey] dataUsingEncoding:NSUTF8StringEncoding]]; // [postBody appendData:[[NSString
// [postBody appendData:[[NSString stringWithFormat:@"%@",[postKeys objectForKey:tempKey]] dataUsingEncoding:NSUTF8StringEncoding]]; // stringWithFormat:@"Content-Disposition: form-data;
// [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; // name=\"%@\"\r\n\r\n",tempKey]
// dataUsingEncoding:NSUTF8StringEncoding]];
// [postBody appendData:[[NSString stringWithFormat:@"%@",[postKeys
// objectForKey:tempKey]] dataUsingEncoding:NSUTF8StringEncoding]];
// [postBody appendData:[[NSString
// stringWithFormat:@"\r\n--%@\r\n",stringBoundary]
// dataUsingEncoding:NSUTF8StringEncoding]];
// } // }
// //
// //add data field and file data // //add data field and file data
// // [NSString stringWithString:@"Content-Type:application/octet-stream\r\n\r\n"]; // // [NSString
// [postBody appendData:[@"Content-Disposition: form-data; name=\"data\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; // stringWithString:@"Content-Type:application/octet-stream\r\n\r\n"];
// [postBody appendData:[@"Content-Type:application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; // [postBody appendData:[@"Content-Disposition: form-data; name=\"data\"\r\n"
// dataUsingEncoding:NSUTF8StringEncoding]];
// [postBody appendData:[@"Content-Type:application/octet-stream\r\n\r\n"
// dataUsingEncoding:NSUTF8StringEncoding]];
// [postBody appendData:[NSData dataWithData:data]]; // [postBody appendData:[NSData dataWithData:data]];
// [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; // [postBody appendData:[[NSString
// stringWithFormat:@"\r\n--%@--\r\n",stringBoundary]
// dataUsingEncoding:NSUTF8StringEncoding]];
// //
// //add the body to the post // //add the body to the post
// [tumblrPost setHTTPBody:postBody]; // [tumblrPost setHTTPBody:postBody];
...@@ -1023,19 +1185,9 @@ didVideoPickedWithURL:(NSURL *)videoUrl { ...@@ -1023,19 +1185,9 @@ didVideoPickedWithURL:(NSURL *)videoUrl {
//} //}
// //
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
@end @end
{ {
"images" : [ "images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{ {
"size" : "29x29", "size" : "29x29",
"idiom" : "iphone", "idiom" : "iphone",
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "no_data@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "no_data@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
////正式环境 ////正式环境
//#define HTTP_REST_API_BASE_URL @"http://139.196.39.77:7080/total-server/rest" //#define HTTP_REST_API_BASE_URL @"http://139.196.39.77:7080/total-server/rest"
//#define HTTP_LOCAL_BASE_URL @"http://139.196.39.77:7080" //#define HTTP_LOCAL_BASE_URL @"http://139.196.39.77:7080"
//
//测试环境 //测试环境
//#define HTTP_REST_API_BASE_URL @"http://139.196.39.77:8180/total-server/rest" //#define HTTP_REST_API_BASE_URL @"http://139.196.39.77:8180/total-server/rest"
//#define HTTP_LOCAL_BASE_URL @"http://139.196.39.77:8180" //#define HTTP_LOCAL_BASE_URL @"http://139.196.39.77:8180"
......
...@@ -146,7 +146,7 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) { ...@@ -146,7 +146,7 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
- (void)doSavePioneeringResultWithData:(id)data - (void)doSavePioneeringResultWithData:(id)data
success:(void (^)(id))succ success:(void (^)(id))succ
failure:(void (^)(id))fail; failure:(void (^)(id))fail;
//6.2提交拓(写) //6.2提交拓(写)
- (void)doSubmitPioneeringResultWithData:(id)data - (void)doSubmitPioneeringResultWithData:(id)data
success:(void (^)(id))succ success:(void (^)(id))succ
failure:(void (^)(id))fail; failure:(void (^)(id))fail;
......
...@@ -84,9 +84,9 @@ typedef NS_ENUM(NSUInteger, ICRHTTPAction) { ...@@ -84,9 +84,9 @@ typedef NS_ENUM(NSUInteger, ICRHTTPAction) {
kGTOHTTP_LicenceApprove, kGTOHTTP_LicenceApprove,
kGTOHTTP_LicenceAskForApprove, kGTOHTTP_LicenceAskForApprove,
kGTOHTTP_LicenceGetLogs, kGTOHTTP_LicenceGetLogs,
//6.1 保存拓(写) //6.1 保存拓(写)
kGTOHTTP_PioneeringSaveResult, kGTOHTTP_PioneeringSaveResult,
//6.2 提交拓(写) //6.2 提交拓(写)
kGTOHTTP_PioneeringSubmitResult, kGTOHTTP_PioneeringSubmitResult,
//6.3 获取拓站列表(读) //6.3 获取拓站列表(读)
kGTOHTTP_PioneeringQuery, kGTOHTTP_PioneeringQuery,
...@@ -175,9 +175,9 @@ static NSString * const ICRHTTPInterface[] = { ...@@ -175,9 +175,9 @@ static NSString * const ICRHTTPInterface[] = {
[kGTOHTTP_LicenceAskForApprove] = @"licence/askforapprove", [kGTOHTTP_LicenceAskForApprove] = @"licence/askforapprove",
[kGTOHTTP_LicenceGetLogs] = @"licence/get_logs", [kGTOHTTP_LicenceGetLogs] = @"licence/get_logs",
//6.1 保存拓(写) //6.1 保存拓(写)
[kGTOHTTP_PioneeringSaveResult] = @"pioneering/save", [kGTOHTTP_PioneeringSaveResult] = @"pioneering/save",
//6.2 提交拓(写) //6.2 提交拓(写)
[kGTOHTTP_PioneeringSubmitResult] = @"pioneering/submit", [kGTOHTTP_PioneeringSubmitResult] = @"pioneering/submit",
//6.3 获取拓站列表(读) //6.3 获取拓站列表(读)
[kGTOHTTP_PioneeringQuery] = @"pioneering/query", [kGTOHTTP_PioneeringQuery] = @"pioneering/query",
...@@ -1107,7 +1107,7 @@ acceptTypeJson:YES ...@@ -1107,7 +1107,7 @@ acceptTypeJson:YES
failure:failure]; failure:failure];
} }
//6.2提交拓(写) //6.2提交拓(写)
- (void)doSubmitPioneeringResultWithData:(id)data - (void)doSubmitPioneeringResultWithData:(id)data
success:(void (^)(id))succ success:(void (^)(id))succ
failure:(void (^)(id))fail { failure:(void (^)(id))fail {
......
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