Commit b4c8d8c3 authored by 陈俊俊's avatar 陈俊俊

行情调研完善

parent 48d5df9b
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
72C8034C1B7B72DB00990363 /* AddWorkSheetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C8034B1B7B72DB00990363 /* AddWorkSheetViewController.m */; }; 72C8034C1B7B72DB00990363 /* AddWorkSheetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C8034B1B7B72DB00990363 /* AddWorkSheetViewController.m */; };
72C8034F1B7B735300990363 /* TopSheetView.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C8034E1B7B735300990363 /* TopSheetView.m */; }; 72C8034F1B7B735300990363 /* TopSheetView.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C8034E1B7B735300990363 /* TopSheetView.m */; };
72C803521B7B897B00990363 /* DataManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C803511B7B897B00990363 /* DataManager.m */; }; 72C803521B7B897B00990363 /* DataManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C803511B7B897B00990363 /* DataManager.m */; };
72EDD86E1B96E11700964115 /* ChooseParentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EDD86D1B96E11700964115 /* ChooseParentViewController.m */; };
72F56CB21B76EC200077F0C9 /* SurveyUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F56CB11B76EC200077F0C9 /* SurveyUser.m */; }; 72F56CB21B76EC200077F0C9 /* SurveyUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F56CB11B76EC200077F0C9 /* SurveyUser.m */; };
871F9F047CDDAC523E4358DC /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86D33EC280C440156ED1B976 /* libPods.a */; }; 871F9F047CDDAC523E4358DC /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86D33EC280C440156ED1B976 /* libPods.a */; };
C10214CD1AD8FE200024637E /* ICRStoreDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C10214CC1AD8FE200024637E /* ICRStoreDetailViewController.m */; }; C10214CD1AD8FE200024637E /* ICRStoreDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C10214CC1AD8FE200024637E /* ICRStoreDetailViewController.m */; };
...@@ -522,6 +523,8 @@ ...@@ -522,6 +523,8 @@
72C8034E1B7B735300990363 /* TopSheetView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopSheetView.m; sourceTree = "<group>"; }; 72C8034E1B7B735300990363 /* TopSheetView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopSheetView.m; sourceTree = "<group>"; };
72C803501B7B897B00990363 /* DataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataManager.h; sourceTree = "<group>"; }; 72C803501B7B897B00990363 /* DataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataManager.h; sourceTree = "<group>"; };
72C803511B7B897B00990363 /* DataManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataManager.m; sourceTree = "<group>"; }; 72C803511B7B897B00990363 /* DataManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataManager.m; sourceTree = "<group>"; };
72EDD86C1B96E11700964115 /* ChooseParentViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChooseParentViewController.h; sourceTree = "<group>"; };
72EDD86D1B96E11700964115 /* ChooseParentViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChooseParentViewController.m; sourceTree = "<group>"; };
72F56CB01B76EC200077F0C9 /* SurveyUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurveyUser.h; sourceTree = "<group>"; }; 72F56CB01B76EC200077F0C9 /* SurveyUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurveyUser.h; sourceTree = "<group>"; };
72F56CB11B76EC200077F0C9 /* SurveyUser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SurveyUser.m; sourceTree = "<group>"; }; 72F56CB11B76EC200077F0C9 /* SurveyUser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SurveyUser.m; sourceTree = "<group>"; };
7DDFB1D460448C3B45118195 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; }; 7DDFB1D460448C3B45118195 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
...@@ -1489,6 +1492,8 @@ ...@@ -1489,6 +1492,8 @@
children = ( children = (
C142D2C31AC3A16C000109A7 /* ICRBaseViewController.h */, C142D2C31AC3A16C000109A7 /* ICRBaseViewController.h */,
C142D2C41AC3A16C000109A7 /* ICRBaseViewController.m */, C142D2C41AC3A16C000109A7 /* ICRBaseViewController.m */,
72EDD86C1B96E11700964115 /* ChooseParentViewController.h */,
72EDD86D1B96E11700964115 /* ChooseParentViewController.m */,
); );
path = BaseViewController; path = BaseViewController;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2373,6 +2378,7 @@ ...@@ -2373,6 +2378,7 @@
351CFF5E1B90633700F30866 /* GXFNoticeFunctionTableViewCell.m in Sources */, 351CFF5E1B90633700F30866 /* GXFNoticeFunctionTableViewCell.m in Sources */,
FE2FCC881B7492C500BBC6FB /* ResultDetailViewController.m in Sources */, FE2FCC881B7492C500BBC6FB /* ResultDetailViewController.m in Sources */,
7281A0B41B8974120052B1AC /* ProductViewController.m in Sources */, 7281A0B41B8974120052B1AC /* ProductViewController.m in Sources */,
72EDD86E1B96E11700964115 /* ChooseParentViewController.m in Sources */,
C159183D1AC062460013B391 /* IBTTableViewCellInfo.m in Sources */, C159183D1AC062460013B391 /* IBTTableViewCellInfo.m in Sources */,
C1FE504E1AE024FA00C18080 /* RIButtonItem.m in Sources */, C1FE504E1AE024FA00C18080 /* RIButtonItem.m in Sources */,
C18AEA9A1AD2749200A1DB7B /* ICRStoreListViewController.m in Sources */, C18AEA9A1AD2749200A1DB7B /* ICRStoreListViewController.m in Sources */,
......
//
// ChooseParentViewController.h
// XFFruit
//
// Created by 陈俊俊 on 15/9/2.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "ICRBaseViewController.h"
#import "MaskCell.h"
#import "MJRefresh.h"
#define TopMargin 50
#define TableHeight 50
@interface ChooseParentViewController : ICRBaseViewController
@property (nonatomic,assign) BOOL isMoreChose;//是否是多选
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)NSMutableArray *indexArr;
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)UITextField *selectTextFiled;
@property (nonatomic,assign) BOOL isRefresh;
- (void)endRefreshing;
- (void)getBaseDataFromLocal;
- (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath;
@end
//
// ChooseParentViewController.m
// XFFruit
//
// Created by 陈俊俊 on 15/9/2.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "ChooseParentViewController.h"
@interface ChooseParentViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate>
@end
@implementation ChooseParentViewController
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boxValueChanged:) name:UITextFieldTextDidChangeNotification object:nil];
[self initData];
[self bulidLayout];
[self createRefresh];
}
- (void)initData{
self.dataArr = [NSMutableArray array];
self.indexArr = [NSMutableArray array];
}
#pragma mark - 布局
- (void)bulidLayout
{
self.selectTextFiled = [[UITextField alloc] initWithFrame:CGRectMake(20,5,ScreenSize.width - 40,TopMargin -10)];
self.selectTextFiled.textAlignment = NSTextAlignmentLeft;
self.selectTextFiled.background = [UIImage imageNamed:@"textFiled"];
self.selectTextFiled.delegate = self;
self.selectTextFiled.font = GXF_FIFTEENTEN_SIZE;
[self.view addSubview:self.selectTextFiled];
UIImageView *leftView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 35, 40)];
leftView.image = [UIImage imageNamed:@"search"];
self.selectTextFiled.leftView = leftView;
self.selectTextFiled.leftViewMode = UITextFieldViewModeAlways;
UIButton *rightView = [UIButton buttonWithType:UIButtonTypeCustom];
[rightView setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
rightView.frame = CGRectMake(0, 0, 35, 40);
[rightView addTarget:self action:@selector(deletePerson) forControlEvents:UIControlEventTouchUpInside];
self.selectTextFiled.rightView = rightView;
self.selectTextFiled.rightViewMode = UITextFieldViewModeAlways;
self.tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)];
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.view addSubview:self.tableView];
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)];
self.navigationItem.rightBarButtonItem = rightItem;
}
- (void)createRefresh{
self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
if (self.isRefresh) {
return ;
}
self.isRefresh = YES;
[self getBaseDataFromLocal];
}];
}
#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"cellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return TableHeight;
}
- (void)keyboardHidden{
[self.selectTextFiled resignFirstResponder];
}
- (void)deletePerson {
self.selectTextFiled.text = @"";
}
#pragma mark - 结束刷新
- (void)endRefreshing{
self.isRefresh = NO;
[self.tableView.header endRefreshing];
}
- (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath{
for (NSIndexPath *path in self.indexArr) {
if (path.row == indexPath.row) {
return YES;
}
}
return NO;
}
#pragma mark -childFunction
-(void)getBaseDataFromLocal
{
}
- (void)sureClick
{
}
- (void)boxValueChanged:(NSNotification *)fication
{
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
...@@ -38,4 +38,5 @@ ...@@ -38,4 +38,5 @@
+ (NSString *)checkString:(NSString *)str; + (NSString *)checkString:(NSString *)str;
+ (NSMutableAttributedString *)setTextViewFontOfString:(NSString *)string paragraphStyle:(NSInteger)lineHeight fontSize:(float)size color:(UIColor *)color; + (NSMutableAttributedString *)setTextViewFontOfString:(NSString *)string paragraphStyle:(NSInteger)lineHeight fontSize:(float)size color:(UIColor *)color;
+ (NSString *)trimmingCharacters:(NSString *)str; + (NSString *)trimmingCharacters:(NSString *)str;
+ (int)compareDate:(NSString*)oneDate withDate:(NSString*)twoDate;
@end @end
...@@ -210,6 +210,26 @@ ...@@ -210,6 +210,26 @@
NSString *newStr = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; NSString *newStr = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
return newStr; return newStr;
} }
+ (int)compareDate:(NSString*)oneDate withDate:(NSString*)twoDate{
int ci;
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *dt1 = [[NSDate alloc] init];
NSDate *dt2 = [[NSDate alloc] init];
dt1 = [df dateFromString:oneDate];
dt2 = [df dateFromString:twoDate];
NSComparisonResult result = [dt1 compare:dt2];
switch (result)
{
//date02比date01大
case NSOrderedAscending: ci=1; break;
//date02比date01小
case NSOrderedDescending: ci=-1; break;
//date02=date01
case NSOrderedSame: ci=0; break;
default: NSLog(@"erorr dates %@, %@", dt2, dt1); break;
}
return ci;
}
@end @end
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
#define IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) #define IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define FontSize(num) [UIFont systemFontOfSize:num] #define FontSize(num) [UIFont systemFontOfSize:num]
#define AppWindow [[UIApplication sharedApplication].delegate window] #define AppWindow [[UIApplication sharedApplication].delegate window]
#define GXF_NSUSERFEFTAULTS [NSUserDefaults standardUserDefaults]
#define GXF_NAVIGAYION_COLOR HexColor(@"7ebf74") #define GXF_NAVIGAYION_COLOR HexColor(@"7ebf74")
#define GXF_SAVE_COLOR HexColor(@"50bd62") #define GXF_SAVE_COLOR HexColor(@"50bd62")
...@@ -110,9 +110,9 @@ ...@@ -110,9 +110,9 @@
#define GXF_SEVENTEENTH_SIZE FontSize(17) #define GXF_SEVENTEENTH_SIZE FontSize(17)
//refreshUpdateDate //refreshUpdateDate
#define SurveyUpdateDate @"surveyUpdateDate" #define SurveyUpdateDate @"surveyUpdateDate"
#define ChooseProductUpdateDate @"chooseProductUpdateDate" #define ChooseProductUpdateDate @"chooseProductUpdateDate"
#define ChoosePersonUpdateDate @"choosePersonUpdateDate"
//行情调研状态 //行情调研状态
//initial(未提交),submitted(已提交),insurvey(调研中),finished(已完成) //initial(未提交),submitted(已提交),insurvey(调研中),finished(已完成)
#define SURVEY_STATE_INITIAL @"initial" #define SURVEY_STATE_INITIAL @"initial"
...@@ -130,6 +130,8 @@ ...@@ -130,6 +130,8 @@
#define PURCHASE_STATE_FINISHED @"finished" #define PURCHASE_STATE_FINISHED @"finished"
#define ShowMessage(msg) [[[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil] show]
#endif #endif
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
case kFunctionNewSurvey://新建行情 case kFunctionNewSurvey://新建行情
{ {
NewSurveyViewController *svc = [[NewSurveyViewController alloc] init]; NewSurveyViewController *svc = [[NewSurveyViewController alloc] init];
svc.title = [IBTCommon localizableString:@"AddSurvey"]; svc.navTitle = [IBTCommon localizableString:@"AddSurvey"];
[self PushViewController:svc animated:YES]; [self PushViewController:svc animated:YES];
} }
break; break;
...@@ -136,7 +136,6 @@ ...@@ -136,7 +136,6 @@
{ {
SurveyViewController *svc = [[SurveyViewController alloc] init]; SurveyViewController *svc = [[SurveyViewController alloc] init];
svc.title = [IBTCommon localizableString:@"Survey"]; svc.title = [IBTCommon localizableString:@"Survey"];
svc.navigationItem.hidesBackButton = YES;
[self PushViewController:svc animated:YES]; [self PushViewController:svc animated:YES];
} }
break; break;
......
...@@ -6,12 +6,11 @@ ...@@ -6,12 +6,11 @@
// Copyright (c) 2015年 Xummer. All rights reserved. // Copyright (c) 2015年 Xummer. All rights reserved.
// //
#import "ICRBaseViewController.h" #import "ChooseParentViewController.h"
#import "Product.h" #import "Product.h"
typedef void(^ChoseProduct)(Product *product); typedef void(^ChoseProduct)(Product *product);
@interface ChooseProductViewController : ICRBaseViewController @interface ChooseProductViewController : ChooseParentViewController
@property (nonatomic,assign) BOOL isMoreChose;//是否是多选
@property (nonatomic,copy)ChoseProduct choseProduct; @property (nonatomic,copy)ChoseProduct choseProduct;
@end @end
...@@ -7,54 +7,21 @@ ...@@ -7,54 +7,21 @@
// //
#import "ChooseProductViewController.h" #import "ChooseProductViewController.h"
#import "MaskCell.h"
#import "MJRefresh.h"
@interface ChooseProductViewController ()
#define TopMargin 50
#define TableHeight 50
@interface ChooseProductViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate>
{ {
UITextField *_selectTextFiled;
NSMutableArray *_indexArr;
NSIndexPath *_currentIndexPath; NSIndexPath *_currentIndexPath;
BOOL _isRefresh;
} }
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)UITableView *tableView;
@end @end
@implementation ChooseProductViewController @implementation ChooseProductViewController
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boxValueChanged:) name:UITextFieldTextDidChangeNotification object:nil]; //记录更新时间
self.title = @"选择商品"; self.tableView.header.lastUpdatedTimeKey = ChooseProductUpdateDate;
[self initData]; self.title = @"选择商品";
[self bulidLayout];
//刷新
[self createRefresh];
}
- (void)initData{
self.dataArr = [NSMutableArray array];
_indexArr = [NSMutableArray array];
[self fetchProductList:@""]; [self fetchProductList:@""];
} }
- (void)createRefresh{
self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
if (_isRefresh) {
return ;
}
_isRefresh = YES;
[self getBaseDataFromLocal];
}];
self.tableView.header.lastUpdatedTimeKey = ChooseProductUpdateDate;
}
- (void)getBaseDataFromLocal{ - (void)getBaseDataFromLocal{
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) { void(^succ)(id) = ^(id data) {
...@@ -70,11 +37,6 @@ ...@@ -70,11 +37,6 @@
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getProductWithPage_number:0 page_size:100 success:succ failure:fail]; [[ICRHTTPController sharedController] getProductWithPage_number:0 page_size:100 success:succ failure:fail];
} }
#pragma mark - 结束刷新
- (void)endRefreshing{
_isRefresh = NO;
[self.tableView.header endRefreshing];
}
#pragma mark -成功 #pragma mark -成功
- (void)fetchProductList:(NSString *)titleStr{ - (void)fetchProductList:(NSString *)titleStr{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
...@@ -90,15 +52,15 @@ ...@@ -90,15 +52,15 @@
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) { ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf)strongSelf = weakSelf;
if (!fetchedObjects) { if (![GXF_NSUSERFEFTAULTS objectForKey:ChooseProductUpdateDate]) {
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:self.tableView.header.lastUpdatedTimeKey]; [GXF_NSUSERFEFTAULTS setObject:[NSDate date] forKey:ChooseProductUpdateDate];
[[NSUserDefaults standardUserDefaults] synchronize]; [GXF_NSUSERFEFTAULTS synchronize];
[self getData]; [self getBaseDataFromLocal];
}else{ }else{
[strongSelf.dataArr removeAllObjects]; [strongSelf.dataArr removeAllObjects];
[strongSelf.dataArr addObject:self.tableView.header.lastUpdatedTime]; [strongSelf.dataArr addObject:self.tableView.header.lastUpdatedTime];
[strongSelf.dataArr addObjectsFromArray:fetchedObjects]; [strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[self deletePerson]; [self tableViewRefresh];
} }
}; };
...@@ -108,40 +70,6 @@ ...@@ -108,40 +70,6 @@
fetchResultsBlock:fetchResultsBlk]; fetchResultsBlock:fetchResultsBlk];
} }
- (void)bulidLayout
{
_selectTextFiled = [[UITextField alloc] initWithFrame:CGRectMake(20,5,ScreenSize.width - 40,TopMargin -10)];
_selectTextFiled.textAlignment = NSTextAlignmentLeft;
_selectTextFiled.background = [UIImage imageNamed:@"textFiled"];
_selectTextFiled.delegate = self;
_selectTextFiled.returnKeyType = UIReturnKeyDone;
_selectTextFiled.font = GXF_FIFTEENTEN_SIZE;
[_selectTextFiled addTarget:self action:@selector(boxValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:_selectTextFiled];
UIImageView *leftView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 35, 40)];
leftView.image = [UIImage imageNamed:@"search"];
_selectTextFiled.leftView = leftView;
_selectTextFiled.leftViewMode = UITextFieldViewModeAlways;
UIButton *rightView = [UIButton buttonWithType:UIButtonTypeCustom];
[rightView setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
rightView.frame = CGRectMake(0, 0, 35, 40);
[rightView addTarget:self action:@selector(deletePerson) forControlEvents:UIControlEventTouchUpInside];
_selectTextFiled.rightView = rightView;
_selectTextFiled.rightViewMode = UITextFieldViewModeAlways;
self.tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)];
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.view addSubview:self.tableView];
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)];
self.navigationItem.rightBarButtonItem = rightItem;
}
- (void)sureClick{ - (void)sureClick{
if(self.isMoreChose){ if(self.isMoreChose){
...@@ -156,19 +84,6 @@ ...@@ -156,19 +84,6 @@
} }
[self PopViewControllerAnimated:YES]; [self PopViewControllerAnimated:YES];
} }
- (void)deletePerson {
_selectTextFiled.text = @"";
}
#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"MaskCell"; static NSString *cellID = @"MaskCell";
MaskCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; MaskCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
...@@ -219,7 +134,7 @@ ...@@ -219,7 +134,7 @@
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath]; MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO; cell.Commitbtn.hidden = NO;
if (![self isHaveIndexPath:indexPath]) { if (![self isHaveIndexPath:indexPath]) {
[_indexArr addObject:indexPath]; [self.indexArr addObject:indexPath];
} }
}else{ }else{
MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath]; MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath];
...@@ -230,33 +145,14 @@ ...@@ -230,33 +145,14 @@
} }
} }
- (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath{
for (NSIndexPath *path in _indexArr) {
if (path.row == indexPath.row) {
return YES;
}
}
return NO;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return TableHeight;
}
#pragma mark - 按钮事件 #pragma mark - 按钮事件
- (void)boxValueChanged:(NSNotification *)fication{ - (void)boxValueChanged:(NSNotification *)fication{
NSString *tilkeStr = [IBTCommon trimmingCharacters:_selectTextFiled.text]; NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text];
[self fetchProductList:tilkeStr]; [self fetchProductList:tilkeStr];
[self tableViewRefresh];
} }
- (void)tableViewRefresh{ - (void)tableViewRefresh{
[self.tableView reloadData];
_currentIndexPath = nil; _currentIndexPath = nil;
} [self.tableView reloadData];
#pragma mark - hideKeyBoard
- (void)keyboardHidden{
[_selectTextFiled resignFirstResponder];
} }
......
...@@ -6,13 +6,12 @@ ...@@ -6,13 +6,12 @@
// Copyright (c) 2015年 Xummer. All rights reserved. // Copyright (c) 2015年 Xummer. All rights reserved.
// //
#import "ICRBaseViewController.h" #import "ChooseParentViewController.h"
typedef void(^ChosePerson)(NSArray *user); typedef void(^ChosePerson)(NSArray *user);
@interface ChosePersonViewController : ICRBaseViewController @interface ChosePersonViewController : ChooseParentViewController
@property (nonatomic,assign) BOOL isMoreChose;//是否是多选
@property (nonatomic,copy)ChosePerson chosePerson; @property (nonatomic,copy)ChosePerson chosePerson;
@end @end
...@@ -7,40 +7,31 @@ ...@@ -7,40 +7,31 @@
// //
#import "ChosePersonViewController.h" #import "ChosePersonViewController.h"
#import "MaskCell.h"
#import "SurveyUser.h" #import "SurveyUser.h"
#import "User.h" #import "User.h"
#define TopMargin 50
#define TableHeight 50
@interface ChosePersonViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate>
{
UITextField *_selectTextFiled;
NSIndexPath *_currentIndexPath;
@interface ChosePersonViewController (){
NSIndexPath *_currentIndexPath;
} }
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *indexArr;
@end @end
@implementation ChosePersonViewController @implementation ChosePersonViewController
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self initData]; self.tableView.header.lastUpdatedTimeKey = ChoosePersonUpdateDate;
[self bulidLayout]; self.title = @"选择人员";
[self fetchUserList:@""];
} }
- (void)initData{
self.dataArr = [NSMutableArray array];
self.indexArr = [NSMutableArray array];
[self fetchUserList];
- (void)getBaseDataFromLocal{
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) { void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf fetchUserList]; [strongSelf endRefreshing];
[strongSelf fetchUserList:@""];
}; };
void(^fail)(id) = ^(id data) { void(^fail)(id) = ^(id data) {
...@@ -50,65 +41,37 @@ ...@@ -50,65 +41,37 @@
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getUserWithPage_number:0 page_size:100 success:succ failure:fail]; [[ICRHTTPController sharedController] getUserWithPage_number:0 page_size:100 success:succ failure:fail];
} }
#pragma mark -成功 #pragma mark -成功
- (void)fetchUserList{ - (void)fetchUserList:(NSString *)titleStr{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) { ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@", [User TableName], @"uuid"]; NSString * sql = @"";
if (titleStr.length > 0) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE NAME LIKE '%%%@%%' ORDER BY %@", [User TableName],titleStr, @"uuid"];
}else{
sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@", [User TableName], @"uuid"];
}
return [db executeQuery:sql]; return [db executeQuery:sql];
}; };
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) { ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf.dataArr removeAllObjects]; if (![GXF_NSUSERFEFTAULTS objectForKey:ChoosePersonUpdateDate]) {
[strongSelf.dataArr addObjectsFromArray:fetchedObjects]; [GXF_NSUSERFEFTAULTS setObject:[NSDate date] forKey:ChoosePersonUpdateDate];
[strongSelf.tableView reloadData]; [GXF_NSUSERFEFTAULTS synchronize];
[self getBaseDataFromLocal];
}else{
[strongSelf.dataArr removeAllObjects];
[strongSelf.dataArr addObject:self.tableView.header.lastUpdatedTime];
[strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[self tableViewRefresh];
}
}; };
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController]; ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[User class] [dbCtrl runFetchForClass:[User class]
fetchBlock:fetchBlk fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk]; fetchResultsBlock:fetchResultsBlk];
} }
#pragma mark - 插入数据
- (void)bulidLayout
{
_selectTextFiled = [[UITextField alloc] initWithFrame:CGRectMake(20,5,ScreenSize.width - 40,TopMargin -10)];
_selectTextFiled.textAlignment = NSTextAlignmentLeft;
_selectTextFiled.background = [UIImage imageNamed:@"textFiled"];
_selectTextFiled.delegate = self;
_selectTextFiled.font = GXF_FIFTEENTEN_SIZE;
[self.view addSubview:_selectTextFiled];
UIImageView *leftView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 35, 40)];
leftView.image = [UIImage imageNamed:@"search"];
_selectTextFiled.leftView = leftView;
_selectTextFiled.leftViewMode = UITextFieldViewModeAlways;
UIButton *rightView = [UIButton buttonWithType:UIButtonTypeCustom];
[rightView setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
rightView.frame = CGRectMake(0, 0, 35, 40);
[rightView addTarget:self action:@selector(deletePerson) forControlEvents:UIControlEventTouchUpInside];
_selectTextFiled.rightView = rightView;
_selectTextFiled.rightViewMode = UITextFieldViewModeAlways;
self.tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)];
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.view addSubview:self.tableView];
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)];
self.navigationItem.rightBarButtonItem = rightItem;
}
- (void)sureClick{ - (void)sureClick{
if (self.isMoreChose) { if (self.isMoreChose) {
NSMutableArray *arr = [[NSMutableArray alloc]init]; NSMutableArray *arr = [[NSMutableArray alloc]init];
...@@ -138,25 +101,7 @@ ...@@ -138,25 +101,7 @@
[self PopViewControllerAnimated:YES]; [self PopViewControllerAnimated:YES];
} }
- (void)deletePerson {
if (self.isMoreChose) {
[self.indexArr removeAllObjects];
}else{
_currentIndexPath = nil;
}
_selectTextFiled.text = @"";
[self.tableView reloadData];
}
#pragma mark - 协议方法 #pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"MaskCell"; static NSString *cellID = @"MaskCell";
MaskCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; MaskCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
...@@ -184,58 +129,51 @@ ...@@ -184,58 +129,51 @@
} }
} }
if (self.dataArr.count > 0) { if (self.dataArr.count > 0) {
User *user = self.dataArr[indexPath.row]; if (indexPath.row == 0) {
[cell setTitleStr:user.name]; NSString *dateStr = [self.dataArr[indexPath.row] httpParameterString];
cell.titleLabel.textColor = GXF_CONTENT_COLOR;
[cell setTitleStr:[NSString stringWithFormat:@"上次更新时间:%@",dateStr]];
}else{
User *user = self.dataArr[indexPath.row];
[cell setTitleStr:user.name];
}
} }
return cell; return cell;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
return;
}
if (self.isMoreChose == YES) { if (self.isMoreChose == YES) {
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath]; MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO;
if (![self isHaveIndexPath:indexPath]) { if (![self isHaveIndexPath:indexPath]) {
cell.Commitbtn.hidden = NO;
[self.indexArr addObject:indexPath]; [self.indexArr addObject:indexPath];
}else{
cell.Commitbtn.hidden = YES;
[self.indexArr removeObject:indexPath];
} }
NSString *personStr = @"";
for (NSIndexPath *index in self.indexArr) {
User *user = self.dataArr[index.row];
if (personStr.length == 0) {
personStr = [personStr stringByAppendingFormat:@"%@",user.name];
}else{
personStr = [personStr stringByAppendingFormat:@"、%@",user.name];
}
}
_selectTextFiled.text = personStr;
}else{ }else{
MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath]; MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath];
currentCell.Commitbtn.hidden = YES; currentCell.Commitbtn.hidden = YES;
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath]; MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO; cell.Commitbtn.hidden = NO;
_currentIndexPath = indexPath; _currentIndexPath = indexPath;
User *user = self.dataArr[indexPath.row];
_selectTextFiled.text = user.name;
} }
} }
- (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath{ #pragma mark - 按钮事件
for (NSIndexPath *path in self.indexArr) { - (void)boxValueChanged:(NSNotification *)fication{
if (path.row == indexPath.row) { NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text];
return YES; [self fetchUserList:tilkeStr];
}
}
return NO;
} }
- (void)tableViewRefresh{
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ _currentIndexPath = nil;
return TableHeight; if (self.indexArr.count > 0) {
[self.indexArr removeAllObjects];
}
[self.tableView reloadData];
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#import "Product.h" #import "Product.h"
#define LeftMargin 15 #define LeftMargin 15
#define BtnHeight 44 #define BtnHeight 44
#define TableHeight 46 #define TableRowHeight 46
#define CornerRadius 5 #define CornerRadius 5
#define BtnSize 19 #define BtnSize 19
#define TotalHeight 432 #define TotalHeight 432
...@@ -66,8 +66,41 @@ typedef enum : NSUInteger { ...@@ -66,8 +66,41 @@ typedef enum : NSUInteger {
[super viewDidLoad]; [super viewDidLoad];
self.title = self.navTitle; self.title = self.navTitle;
[self initData]; [self initData];
[self createTableView]; [self createTableView];
if (self.survey) {
[self getDataFromServer];
}
} }
- (void)getDataFromServer{
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (data) {
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ;
if (success == 1) {
NSDictionary *dictData = data[@"data"];
Survey *survey = [[Survey alloc]init];
[survey setValuesForKeysWithDictionary:dictData];
strongSelf.survey = survey;
[strongSelf preferDataInPersonLabel];
}else{
[IBTLoadingView showTips:message];
}
}
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
[IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getResultWithSurveyUuid:self.survey.uuid success:succ failure:fail];
}
- (void)initData{ - (void)initData{
_dataArr = [NSMutableArray array]; _dataArr = [NSMutableArray array];
...@@ -131,11 +164,31 @@ typedef enum : NSUInteger { ...@@ -131,11 +164,31 @@ typedef enum : NSUInteger {
- (BOOL)checkSurvey{ - (BOOL)checkSurvey{
self.titleStr = _titleField.text; self.titleStr = _titleField.text;
self.remarkStr = _noteTextView.text; self.remarkStr = _noteTextView.text;
if (self.titleStr.length == 0 || self.productUuidStr.length == 0 || self.productNameStr.length == 0|| self.productCodeStr.length == 0 || self.users.count <=0 || self.beginDateStr.length == 0 || self.endDateStr.length == 0) { if (self.titleStr.length == 0 ) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"信息不完整" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; ShowMessage(@"调研标题不能为空");
[alert show]; return NO;
}
if (self.productUuidStr.length == 0 || self.productNameStr.length == 0|| self.productCodeStr.length == 0 ) {
ShowMessage(@"调研商品不能为空");
return NO;
}
if (self.beginDateStr.length == 0) {
ShowMessage(@"调研开始日期不能为空");
return NO;
}
if (self.endDateStr.length == 0) {
ShowMessage(@"调研结束日期不能为空");
return NO;
}
if (self.users.count <=0) {
ShowMessage(@"调研人员不能为空");
return NO; return NO;
} }
if ([IBTCommon compareDate:self.beginDateStr withDate:self.endDateStr] < 0) {
ShowMessage(@"开始日期不能小于结束日期");
return NO;
}
return YES; return YES;
} }
...@@ -223,7 +276,7 @@ typedef enum : NSUInteger { ...@@ -223,7 +276,7 @@ typedef enum : NSUInteger {
- (void)createViewInCell:(SurveyCell *)cell indexPath:(NSIndexPath *)indexPath{ - (void)createViewInCell:(SurveyCell *)cell indexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) { if (indexPath.row == 0) {
_titleField = [[UITextField alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableHeight)]; _titleField = [[UITextField alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableRowHeight)];
_titleField.textAlignment = NSTextAlignmentRight; _titleField.textAlignment = NSTextAlignmentRight;
_titleField.textColor = GXF_CONTENT_COLOR; _titleField.textColor = GXF_CONTENT_COLOR;
_titleField.placeholder = @"输入调研标题"; _titleField.placeholder = @"输入调研标题";
...@@ -231,12 +284,8 @@ typedef enum : NSUInteger { ...@@ -231,12 +284,8 @@ typedef enum : NSUInteger {
_titleField.returnKeyType = UIReturnKeyDone; _titleField.returnKeyType = UIReturnKeyDone;
_titleField.delegate = self; _titleField.delegate = self;
[cell.contentView addSubview:_titleField]; [cell.contentView addSubview:_titleField];
if (self.survey) {
_titleField.text = [IBTCommon checkString:self.survey.title];
self.titleStr = [IBTCommon checkString:self.survey.title];
}
}else if (indexPath.row == _dataArr.count -1){ }else if (indexPath.row == _dataArr.count -1){
_noteTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableHeight)]; _noteTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableRowHeight)];
_noteTextView.contentInset = UIEdgeInsetsMake(5, 5, 5, 0); _noteTextView.contentInset = UIEdgeInsetsMake(5, 5, 5, 0);
_noteTextView.minNumberOfLines = 1; _noteTextView.minNumberOfLines = 1;
_noteTextView.maxNumberOfLines = 4; _noteTextView.maxNumberOfLines = 4;
...@@ -246,15 +295,12 @@ typedef enum : NSUInteger { ...@@ -246,15 +295,12 @@ typedef enum : NSUInteger {
_noteTextView.returnKeyType = UIReturnKeyDone; _noteTextView.returnKeyType = UIReturnKeyDone;
_noteTextView.placeholder = @"输入备注内容"; _noteTextView.placeholder = @"输入备注内容";
[cell.contentView addSubview:_noteTextView]; [cell.contentView addSubview:_noteTextView];
if (self.survey) {
_noteTextView.text = [IBTCommon checkString:self.survey.remark];
self.remarkStr = [IBTCommon checkString:self.survey.remark];
}
CGRect lineFrame = cell.lineLabel.frame; CGRect lineFrame = cell.lineLabel.frame;
lineFrame.origin.y = TableHeight*2-1; lineFrame.origin.y = TableRowHeight*2-1;
cell.lineLabel.frame = lineFrame; cell.lineLabel.frame = lineFrame;
}else{ }else{
UILabel *contentLabel = [[UILabel alloc]initWithFrame:(CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableHeight))]; UILabel *contentLabel = [[UILabel alloc]initWithFrame:(CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableRowHeight))];
contentLabel.textAlignment= NSTextAlignmentRight; contentLabel.textAlignment= NSTextAlignmentRight;
contentLabel.textColor = GXF_PLACEHOLDER_COLOR; contentLabel.textColor = GXF_PLACEHOLDER_COLOR;
contentLabel.font = GXF_FIFTEENTEN_SIZE; contentLabel.font = GXF_FIFTEENTEN_SIZE;
...@@ -262,56 +308,59 @@ typedef enum : NSUInteger { ...@@ -262,56 +308,59 @@ typedef enum : NSUInteger {
if (indexPath.row == 1) { if (indexPath.row == 1) {
contentLabel.text = @"选择商品"; contentLabel.text = @"选择商品";
_productLabel = contentLabel; _productLabel = contentLabel;
[self preferDataInProductLabel];
}else if(indexPath.row == 2){ }else if(indexPath.row == 2){
contentLabel.text = @"选择日期"; contentLabel.text = @"选择日期";
_startDateLabel = contentLabel; _startDateLabel = contentLabel;
if (self.survey) {
if (self.survey.beginDate.length > 9) {
_startDateLabel.text = [[IBTCommon checkString:self.survey.beginDate]substringToIndex:10];
}
_startDateLabel.textColor = GXF_CONTENT_COLOR;
self.beginDateStr =[IBTCommon checkString:self.survey.beginDate];
}
}else if(indexPath.row == 3){ }else if(indexPath.row == 3){
contentLabel.text = @"选择日期"; contentLabel.text = @"选择日期";
_endDateLabel = contentLabel; _endDateLabel = contentLabel;
if (self.survey) {
if (self.survey.endDate.length > 9) {
_endDateLabel.text = [[IBTCommon checkString:self.survey.endDate]substringToIndex:10];
}
_endDateLabel.textColor = GXF_CONTENT_COLOR;
self.endDateStr = [IBTCommon checkString:self.survey.endDate];
}
}else if(indexPath.row == 4){ }else if(indexPath.row == 4){
contentLabel.text = @"选择调研人员"; contentLabel.text = @"选择调研人员";
_personLabel = contentLabel; _personLabel = contentLabel;
[self preferDataInPersonLabel];
} }
} }
} }
- (void)preferDataInPersonLabel{ - (void)preferDataInPersonLabel{
if (self.survey) {
_titleField.text = [IBTCommon checkString:self.survey.title];
self.titleStr = [IBTCommon checkString:self.survey.title];
}
if (self.survey) {
if (self.survey.endDate.length > 9) {
_endDateLabel.text = [[IBTCommon checkString:self.survey.endDate]substringToIndex:10];
}
_endDateLabel.textColor = GXF_CONTENT_COLOR;
self.endDateStr = [IBTCommon checkString:self.survey.endDate];
}
if (self.survey) { if (self.survey) {
if (self.survey.users.count > 0) { if (self.survey.users.count > 0) {
NSString *personStr = @""; NSString *personStr = @"";
for (SurveyUser * surveyUser in self.survey.users) { for (NSDictionary * userDict in self.survey.users) {
SurveyUser *surveyUser = [[SurveyUser alloc]init];
[surveyUser setValuesForKeysWithDictionary:userDict];
if (personStr.length == 0) { if (personStr.length == 0) {
personStr = [personStr stringByAppendingFormat:@"%@",surveyUser.userName]; personStr = [personStr stringByAppendingFormat:@"%@",surveyUser.userName];
}else { }else{
personStr = [personStr stringByAppendingFormat:@"、%@",surveyUser.userName]; personStr = [personStr stringByAppendingFormat:@"、%@",surveyUser.userName];
} }
} }
_personLabel.text = personStr; _personLabel.text = personStr;
_personLabel.textColor = GXF_CONTENT_COLOR; _personLabel.textColor = GXF_CONTENT_COLOR;
} }
if (self.users > 0) { if (self.users > 0) {
[self.users addObjectsFromArray:self.survey.users]; [self.users addObjectsFromArray:self.survey.users];
} }
} }
} if (self.survey) {
- (void)preferDataInProductLabel{ if (self.survey.beginDate.length > 9) {
_startDateLabel.text = [[IBTCommon checkString:self.survey.beginDate]substringToIndex:10];
}
_startDateLabel.textColor = GXF_CONTENT_COLOR;
self.beginDateStr =[IBTCommon checkString:self.survey.beginDate];
}
if (self.survey) { if (self.survey) {
_productLabel.text = [NSString stringWithFormat:@"%@[%@]",[IBTCommon checkString:self.survey.productName],[IBTCommon checkString:self.survey.productCode]]; _productLabel.text = [NSString stringWithFormat:@"%@[%@]",[IBTCommon checkString:self.survey.productName],[IBTCommon checkString:self.survey.productCode]];
_productLabel.textColor = GXF_CONTENT_COLOR; _productLabel.textColor = GXF_CONTENT_COLOR;
...@@ -319,13 +368,19 @@ typedef enum : NSUInteger { ...@@ -319,13 +368,19 @@ typedef enum : NSUInteger {
self.productNameStr = [IBTCommon checkString:self.survey.productName]; self.productNameStr = [IBTCommon checkString:self.survey.productName];
self.productUuidStr = [IBTCommon checkString:self.survey.productUuid]; self.productUuidStr = [IBTCommon checkString:self.survey.productUuid];
} }
if (self.survey) {
_noteTextView.text = [IBTCommon checkString:self.survey.remark];
self.remarkStr = [IBTCommon checkString:self.survey.remark];
}
} }
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 5){ if (indexPath.row == 5){
return TableHeight*2; return TableRowHeight*2;
}else{ }else{
return TableHeight; return TableRowHeight;
} }
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
#define BottomHeight 50 #define BottomHeight 50
#define LeftMargin 20 #define LeftMargin 20
#define LeftWidth 100 #define LeftWidth 100
#define LeftHeight 30 #define LeftHeight 20
#define TopMargin 15 #define TopMargin 15
#define ContentMargin 10
typedef enum : NSUInteger { typedef enum : NSUInteger {
DetailTag = 6000, DetailTag = 6000,
...@@ -37,6 +37,8 @@ typedef enum : NSUInteger { ...@@ -37,6 +37,8 @@ typedef enum : NSUInteger {
@property (nonatomic,strong)UILabel *endDateLabel; @property (nonatomic,strong)UILabel *endDateLabel;
@property (nonatomic,strong)UILabel *userLabel; @property (nonatomic,strong)UILabel *userLabel;
@property (nonatomic,strong)UILabel *noteLabel; @property (nonatomic,strong)UILabel *noteLabel;
@property (nonatomic,strong)UILabel *lefeNoteLabel;
@end @end
@implementation SurveyDetailViewController @implementation SurveyDetailViewController
...@@ -149,11 +151,11 @@ typedef enum : NSUInteger { ...@@ -149,11 +151,11 @@ typedef enum : NSUInteger {
UIButton *endBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, ScreenSize.width - LeftMargin*2, 40) target:self sel:@selector(btnClick:) tag:EndTag image:nil title:@"结束" titleColor:[UIColor whiteColor] isCorner:YES corner:8 bgColor:GXF_COMMIT_COLOR]; UIButton *endBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, ScreenSize.width - LeftMargin*2, 40) target:self sel:@selector(btnClick:) tag:EndTag image:nil title:@"结束" titleColor:[UIColor whiteColor] isCorner:YES corner:8 bgColor:GXF_COMMIT_COLOR];
[self.view addSubview:endBtn]; [self.view addSubview:endBtn];
_surveyView= [[UIView alloc]initWithFrame:CGRectMake(0, TopMargin, ScreenSize.width, LeftHeight*9+LeftMargin/2)]; _surveyView= [[UIView alloc]initWithFrame:CGRectMake(0, TopMargin, ScreenSize.width, LeftHeight * 9+ ContentMargin * 10)];
_surveyView.backgroundColor = [UIColor whiteColor]; _surveyView.backgroundColor = [UIColor whiteColor];
[_scrollView addSubview:_surveyView]; [_scrollView addSubview:_surveyView];
UILabel *tagLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin/2, 10, LeftWidth*2, LeftHeight)]; UILabel *tagLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin/2, ContentMargin, LeftWidth*2, LeftHeight)];
tagLabel.text = @"【调研内容】"; tagLabel.text = @"【调研内容】";
tagLabel.font = GXF_SEVENTEENTH_SIZE; tagLabel.font = GXF_SEVENTEENTH_SIZE;
tagLabel.textColor = HexColor(@"7ebf74"); tagLabel.textColor = HexColor(@"7ebf74");
...@@ -161,13 +163,13 @@ typedef enum : NSUInteger { ...@@ -161,13 +163,13 @@ typedef enum : NSUInteger {
NSArray *leftArr = @[@"单号:",@"状态:",@"标题:",@"商品:",@"开始日期:",@"截止日期:",@"调研人员:",@"备注:"]; NSArray *leftArr = @[@"单号:",@"状态:",@"标题:",@"商品:",@"开始日期:",@"截止日期:",@"调研人员:",@"备注:"];
for (NSInteger i = 0 ; i < leftArr.count; i++) { for (NSInteger i = 0 ; i < leftArr.count; i++) {
UILabel *leftLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin, CGRectGetMaxY(tagLabel.frame) + LeftHeight *i, LeftWidth, LeftHeight)]; UILabel *leftLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin, CGRectGetMaxY(tagLabel.frame) + ContentMargin+ (LeftHeight + ContentMargin) *i, LeftWidth, LeftHeight)];
leftLabel.font = GXF_SEVENTEENTH_SIZE; leftLabel.font = GXF_SEVENTEENTH_SIZE;
leftLabel.text = leftArr[i]; leftLabel.text = leftArr[i];
leftLabel.textColor = GXF_DETAIL_COLOR; leftLabel.textColor = GXF_DETAIL_COLOR;
[_surveyView addSubview:leftLabel]; [_surveyView addSubview:leftLabel];
UILabel *rightLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(leftLabel.frame), CGRectGetMaxY(tagLabel.frame) + LeftHeight *i, _surveyView.frame.size.width - LeftMargin - LeftWidth, LeftHeight)]; UILabel *rightLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(leftLabel.frame), CGRectGetMaxY(tagLabel.frame) + ContentMargin+ (LeftHeight + ContentMargin) *i, _surveyView.frame.size.width - LeftMargin - LeftWidth, LeftHeight)];
rightLabel.font = GXF_SEVENTEENTH_SIZE; rightLabel.font = GXF_SEVENTEENTH_SIZE;
rightLabel.textColor = GXF_DETAIL_COLOR; rightLabel.textColor = GXF_DETAIL_COLOR;
if (i == 0) { if (i == 0) {
...@@ -183,10 +185,12 @@ typedef enum : NSUInteger { ...@@ -183,10 +185,12 @@ typedef enum : NSUInteger {
}else if(i == 5){ }else if(i == 5){
self.endDateLabel = rightLabel; self.endDateLabel = rightLabel;
}else if(i == 6){ }else if(i == 6){
rightLabel.numberOfLines = 0;
self.userLabel = rightLabel; self.userLabel = rightLabel;
}else if(i == 7){ }else if(i == 7){
rightLabel.numberOfLines = 0; rightLabel.numberOfLines = 0;
self.noteLabel = rightLabel; self.noteLabel = rightLabel;
self.lefeNoteLabel = leftLabel;
} }
[_surveyView addSubview:rightLabel]; [_surveyView addSubview:rightLabel];
} }
...@@ -261,13 +265,24 @@ typedef enum : NSUInteger { ...@@ -261,13 +265,24 @@ typedef enum : NSUInteger {
- (void)setNoteHeight - (void)setNoteHeight
{ {
CGFloat height = [self.noteLabel calculateHeight]; CGFloat personHeight = [self.userLabel calculateHeight];
CGRect personFrame = self.userLabel.frame;
personFrame.size.height = personHeight;
self.userLabel.frame = personFrame;
CGFloat noteHeight = [self.noteLabel calculateHeight];
CGRect noteFrame = self.noteLabel.frame; CGRect noteFrame = self.noteLabel.frame;
noteFrame.size.height = height; noteFrame.size.height = noteHeight;
noteFrame.origin.y = CGRectGetMaxY(self.userLabel.frame)+ ContentMargin;
self.noteLabel.frame = noteFrame; self.noteLabel.frame = noteFrame;
CGFloat totalHeight = height + LeftHeight*9; CGRect leftNoteFrame = self.lefeNoteLabel.frame;
leftNoteFrame.origin.y = CGRectGetMaxY(self.userLabel.frame)+ ContentMargin;
self.lefeNoteLabel.frame = leftNoteFrame;
CGFloat totalHeight = noteHeight + (LeftHeight * 7+ ContentMargin*10) + personHeight;
CGRect surveyFrame = _surveyView.frame; CGRect surveyFrame = _surveyView.frame;
surveyFrame.size.height = totalHeight; surveyFrame.size.height = totalHeight;
_surveyView.frame = surveyFrame; _surveyView.frame = surveyFrame;
......
...@@ -195,6 +195,9 @@ typedef enum : NSUInteger { ...@@ -195,6 +195,9 @@ typedef enum : NSUInteger {
if (pageCount <= _currentPage) { if (pageCount <= _currentPage) {
[self.tableView.footer noticeNoMoreData]; [self.tableView.footer noticeNoMoreData];
} }
if (_currentPage == 0 && self.dataArr.count > 0) {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
}else{ }else{
[IBTLoadingView showTips:message]; [IBTLoadingView showTips:message];
} }
...@@ -206,7 +209,8 @@ typedef enum : NSUInteger { ...@@ -206,7 +209,8 @@ typedef enum : NSUInteger {
- (void)createTableView - (void)createTableView
{ {
_sureBtn = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)]; _sureBtn = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)];
self.navigationItem.rightBarButtonItem = _sureBtn;
_sortBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, 10, BtnWidth, BtnHeight) target:self sel:@selector(sortClick:) tag:SortTag image:@"black_arrow_down_with_text" title:nil titleColor:GXF_DETAIL_COLOR isCorner:NO corner:0 bgColor:nil]; _sortBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, 10, BtnWidth, BtnHeight) target:self sel:@selector(sortClick:) tag:SortTag image:@"black_arrow_down_with_text" title:nil titleColor:GXF_DETAIL_COLOR isCorner:NO corner:0 bgColor:nil];
_sortBtn.titleLabel.font = FontSize(BtnSize); _sortBtn.titleLabel.font = FontSize(BtnSize);
[self.view addSubview:_sortBtn]; [self.view addSubview:_sortBtn];
...@@ -247,20 +251,21 @@ typedef enum : NSUInteger { ...@@ -247,20 +251,21 @@ typedef enum : NSUInteger {
#pragma mark - 确定 #pragma mark - 确定
- (void)sureClick{ - (void)sureClick{
[_boltView.titleFiled resignFirstResponder]; if (self.state.length > 0 || self.billNumberLike.length > 0 || self.titleLike.length > 0 ||self.orderDirection.length > 0) {
[_boltView.billFiled resignFirstResponder]; [_boltView.titleFiled resignFirstResponder];
[_boltView.billFiled resignFirstResponder];
_currentPage = 0;
//请求
[self getData]; //请求
//还原数据 [self getData];
if (_sortView) { //还原数据
[self hiddenSortMaskView:YES]; if (_sortView) {
} [self hiddenSortMaskView:YES];
if (_boltView) { }
[self hiddenBoltMaskView:YES]; if (_boltView) {
[self hiddenBoltMaskView:YES];
}
} }
self.navigationItem.rightBarButtonItem = nil;
} }
#pragma mark -按钮事件 #pragma mark -按钮事件
...@@ -275,7 +280,6 @@ typedef enum : NSUInteger { ...@@ -275,7 +280,6 @@ typedef enum : NSUInteger {
[btn setImage:[UIImage imageNamed:@"black_arrow_down_with_text"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"black_arrow_down_with_text"] forState:UIControlStateNormal];
[self hiddenSortMaskView:YES]; [self hiddenSortMaskView:YES];
currentBtn = nil; currentBtn = nil;
self.navigationItem.rightBarButtonItem = nil;
}else{ }else{
[btn setImage:[UIImage imageNamed:@"select_arrow_up_text"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"select_arrow_up_text"] forState:UIControlStateNormal];
if (_sortView == nil) { if (_sortView == nil) {
...@@ -289,7 +293,6 @@ typedef enum : NSUInteger { ...@@ -289,7 +293,6 @@ typedef enum : NSUInteger {
_sortView.frame = sortFrame; _sortView.frame = sortFrame;
}]; }];
} }
self.navigationItem.rightBarButtonItem = _sureBtn;
currentBtn = btn; currentBtn = btn;
} }
}else if(btn.tag == BoltTag){ }else if(btn.tag == BoltTag){
...@@ -300,7 +303,6 @@ typedef enum : NSUInteger { ...@@ -300,7 +303,6 @@ typedef enum : NSUInteger {
[btn setImage:[UIImage imageNamed:@"black_filter_with_text"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"black_filter_with_text"] forState:UIControlStateNormal];
[self hiddenBoltMaskView:YES]; [self hiddenBoltMaskView:YES];
currentBtn = nil; currentBtn = nil;
self.navigationItem.rightBarButtonItem = nil;
}else{ }else{
[btn setImage:[UIImage imageNamed:@"selected-filter_with_text"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"selected-filter_with_text"] forState:UIControlStateNormal];
...@@ -316,7 +318,6 @@ typedef enum : NSUInteger { ...@@ -316,7 +318,6 @@ typedef enum : NSUInteger {
_boltView.frame = sortFrame; _boltView.frame = sortFrame;
}]; }];
currentBtn = btn; currentBtn = btn;
self.navigationItem.rightBarButtonItem = _sureBtn;
} }
} }
......
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