Commit 2274530b authored by Sandy's avatar Sandy

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

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