Commit 9f7df76f authored by mei's avatar mei

Merge branch 'DEV_20150805_001' of http://121.42.32.57/root/xffruit into DEV_20150805_001

parents 3f2023d6 5afca515
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#import "ICRAnswer.h" #import "ICRAnswer.h"
#import "ICRAnswerDetail.h" #import "ICRAnswerDetail.h"
#import "Product.h"
#import "User.h"
#import "Survey.h"
#define ICR_DB_ERROR_PARAMETER @"Parse Error: Bad Parameter(s)" #define ICR_DB_ERROR_PARAMETER @"Parse Error: Bad Parameter(s)"
NSString * const ICRDataBaseErrorDomain = @"ICRDataBaseErrorDomain"; NSString * const ICRDataBaseErrorDomain = @"ICRDataBaseErrorDomain";
...@@ -90,8 +94,7 @@ static NSString *ICRDataBasePath = @""; ...@@ -90,8 +94,7 @@ static NSString *ICRDataBasePath = @"";
[_m_dbQueue inDatabase:^(FMDatabase *db) { [_m_dbQueue inDatabase:^(FMDatabase *db) {
NSArray *tableNameArr = NSArray *tableNameArr =
@[ [ICRPost class], [ICRStore class], [ICRTask class], [ICRAttachment class], [ICRPatrolPlan class], [ICRQuestion class], [ICRStoreResult class], [ICRAnswer class], [ICRAnswerDetail class], [ICRAnnouncement class], @[ [Product class],[User class],[Survey class]];
[ICRPostTask class]];
NSMutableArray *sqlBatch = [NSMutableArray array]; NSMutableArray *sqlBatch = [NSMutableArray array];
NSString *sql = nil; NSString *sql = nil;
......
...@@ -184,20 +184,11 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) { ...@@ -184,20 +184,11 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
failure:(void (^)(id))fail; failure:(void (^)(id))fail;
//获取行情调研单列表 //获取行情调研单列表
- (void)querySurveyWithBillNUmberLinke:(NSString *)billNumberLinke
state:(NSString *)state
titleLike:(NSString *)titleLike
orderFiled:(NSString *)orderFiled
orderDirection:(NSString *)orderDirection
page_number:(NSUInteger)page_number
page_size:(NSUInteger)page_size
success:(void (^)(id))succ
failure:(void (^)(id))fail;
- (void)querySurveyWithBillData:(id)data - (void)querySurveyWithBillData:(id)data
success:(void (^)(id))succ success:(void (^)(id))succ
failure:(void (^)(id))fail; failure:(void (^)(id))fail;
//获取行情调研单反馈列表 //获取行情调研单详情
- (void)getResultsWithSurveyUuid:(NSString *)surveyUuid - (void)getResultWithSurveyUuid:(NSString *)surveyUuid
success:(void (^)(id))succ success:(void (^)(id))succ
failure:(void (^)(id))fail; failure:(void (^)(id))fail;
......
...@@ -69,7 +69,7 @@ typedef NS_ENUM(NSUInteger, ICRHTTPAction) { ...@@ -69,7 +69,7 @@ typedef NS_ENUM(NSUInteger, ICRHTTPAction) {
//行情 //行情
XFFHttp_SurveySave, XFFHttp_SurveySave,
XFFHttp_QuerySurvey, XFFHttp_QuerySurvey,
XFFHttp_GetResults, XFFHttp_GetSurvey,
XFFHttp_GetProduct, XFFHttp_GetProduct,
XFFHttp_GetUser XFFHttp_GetUser
}; };
...@@ -121,7 +121,7 @@ static NSString * const ICRHTTPInterface[] = { ...@@ -121,7 +121,7 @@ static NSString * const ICRHTTPInterface[] = {
//行情调研 //行情调研
[XFFHttp_SurveySave] = @"survey/save_survey", [XFFHttp_SurveySave] = @"survey/save_survey",
[XFFHttp_QuerySurvey] = @"survey/query_survey", [XFFHttp_QuerySurvey] = @"survey/query_survey",
[XFFHttp_GetResults] = @"survey/get_result", [XFFHttp_GetSurvey] = @"survey/get_survey",
[XFFHttp_GetProduct] = @"mdata/product/download", [XFFHttp_GetProduct] = @"mdata/product/download",
[XFFHttp_GetUser] = @"user/download" [XFFHttp_GetUser] = @"user/download"
...@@ -239,7 +239,7 @@ static NSString * const ICRAttachmentTypeValue[] = { ...@@ -239,7 +239,7 @@ static NSString * const ICRAttachmentTypeValue[] = {
{ {
[requestSerializer setValue:user.orgId forHTTPHeaderField:@"enterprise"]; [requestSerializer setValue:user.orgId forHTTPHeaderField:@"enterprise"];
} }
// [requestSerializer setValue:user. forHTTPHeaderField:@"Authorization"]; [requestSerializer setValue:user.authenticode forHTTPHeaderField:@"authorization"];
return requestSerializer; return requestSerializer;
} }
...@@ -391,6 +391,7 @@ acceptTypeJson:(BOOL)bAcceptJson ...@@ -391,6 +391,7 @@ acceptTypeJson:(BOOL)bAcceptJson
userUtil.orgCode = dictResult[ @"enterprise_code" ]; userUtil.orgCode = dictResult[ @"enterprise_code" ];
userUtil.orgName = dictResult[ @"enterprise_name" ]; userUtil.orgName = dictResult[ @"enterprise_name" ];
userUtil.orgId = dictResult[ @"enterprise_uuid" ]; userUtil.orgId = dictResult[ @"enterprise_uuid" ];
userUtil.authenticode = dictResult[@"authenticode"];
[userUtil saveArchive]; [userUtil saveArchive];
if (succ) { if (succ) {
succ( dictResult ); succ( dictResult );
...@@ -1287,12 +1288,14 @@ acceptTypeJson:YES ...@@ -1287,12 +1288,14 @@ acceptTypeJson:YES
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:kICRHTTP_VersionFetch] stringByAppendingFormat:@"/%@",currentVersion]; NSString *urlStr = [[[self class] UrlForPluginHTTPAction:kICRHTTP_VersionFetch] stringByAppendingFormat:@"/%@",currentVersion];
[self GET:urlStr [self GET:urlStr
parameters:nil parameters:nil
needToken:YES needToken:NO
acceptTypeJson:YES acceptTypeJson:YES
success:success success:success
failure:failure]; failure:failure];
} }
//添加行情调研单
- (void)saveSurveyWithAuthenticode:(id)data success:(void (^)(id))succ failure:(void (^)(id))fail - (void)saveSurveyWithAuthenticode:(id)data success:(void (^)(id))succ failure:(void (^)(id))fail
{ {
if (!data) { if (!data) {
...@@ -1328,47 +1331,34 @@ acceptTypeJson:YES ...@@ -1328,47 +1331,34 @@ acceptTypeJson:YES
} }
- (void)querySurveyWithBillNUmberLinke:(NSString *)billNumberLinke //获取行情调研单列表
state:(NSString *)state
titleLike:(NSString *)titleLike
orderFiled:(NSString *)orderFiled
orderDirection:(NSString *)orderDirection
page_number:(NSUInteger)page_number
page_size:(NSUInteger)page_size
success:(void (^)(id))succ
failure:(void (^)(id))fail
{
void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
CLog(@"%@", responseObject);
if (succ) {
succ( responseObject );
}
};
void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
CLog(@"%@", error);
if (fail) {
fail( error );
}
};
ICRUserUtil *userUtil = [ICRUserUtil sharedInstance];
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:XFFHttp_QuerySurvey] stringByAppendingFormat:@"?enterprise=%@&userUuid=%@&billNumberLike=%@&state=%@&titleLike=%@&orderField=%@&orderDirection=%@&page_number=%@&page_size=%@",userUtil.orgId,userUtil.userId,billNumberLinke,state,titleLike,orderFiled,orderDirection,@(page_number),@(page_size)];
NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[self POST:encodeUrlStr
parameters:nil
needToken:NO
acceptTypeJson:YES
success:success
failure:failure];
}
- (void)querySurveyWithBillData:(id)data - (void)querySurveyWithBillData:(id)data
success:(void (^)(id))succ success:(void (^)(id))succ
failure:(void (^)(id))fail{ failure:(void (^)(id))fail{
void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) { void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
CLog(@"%@", responseObject); CLog(@"%@", responseObject);
if (succ) { if (IsDictObject(responseObject)) {
succ( responseObject ); void (^complete)(void) = ^(void){
if (succ) {
[IBTCommon runOnMainThreadWithoutDeadlocking:^{
succ( responseObject );
}];
}
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl storageEntities:responseObject[ @"data" ][ @"records" ]
objectClass:NSClassFromString( @"Survey" )
deleteLocal:YES
handleData:NULL
complete:complete
fail:fail];
}
else {
if (fail) {
fail( nil );
}
} }
}; };
void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) { void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
...@@ -1388,10 +1378,10 @@ acceptTypeJson:YES ...@@ -1388,10 +1378,10 @@ acceptTypeJson:YES
} }
//获取行情调研详情
- (void)getResultsWithSurveyUuid:(NSString *)surveyUuid - (void)getResultWithSurveyUuid:(NSString *)surveyUuid
success:(void (^)(id))succ success:(void (^)(id))succ
failure:(void (^)(id))fail{ failure:(void (^)(id))fail{
if (!surveyUuid) { if (!surveyUuid) {
if (fail) { if (fail) {
fail( [[self class] ErrorWithMsg:ERROR_PARAMETER code:0] ); fail( [[self class] ErrorWithMsg:ERROR_PARAMETER code:0] );
...@@ -1412,14 +1402,15 @@ acceptTypeJson:YES ...@@ -1412,14 +1402,15 @@ acceptTypeJson:YES
} }
}; };
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:XFFHttp_GetResults] stringByAppendingFormat:@"/%@",surveyUuid]; NSString *urlStr = [[[self class] UrlForPluginHTTPAction:XFFHttp_GetSurvey] stringByAppendingFormat:@"/%@",surveyUuid];
NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[self POST:encodeUrlStr
parameters:NULL [self GET:encodeUrlStr
needToken:NO parameters:nil
needToken:NO
acceptTypeJson:YES acceptTypeJson:YES
success:success success:success
failure:failure]; failure:failure];
} }
...@@ -1429,8 +1420,27 @@ acceptTypeJson:YES ...@@ -1429,8 +1420,27 @@ acceptTypeJson:YES
failure:(void (^)(id))fail{ failure:(void (^)(id))fail{
void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) { void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
CLog(@"%@", responseObject); CLog(@"%@", responseObject);
if (succ) { if (IsDictObject(responseObject)) {
succ( responseObject ); void (^complete)(void) = ^(void){
if (succ) {
[IBTCommon runOnMainThreadWithoutDeadlocking:^{
succ( responseObject );
}];
}
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl storageEntities:responseObject[ @"data" ][ @"records" ]
objectClass:NSClassFromString( @"Product" )
deleteLocal:YES
handleData:NULL
complete:complete
fail:fail];
}
else {
if (fail) {
fail( nil );
}
} }
}; };
void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) { void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
...@@ -1457,8 +1467,27 @@ acceptTypeJson:YES ...@@ -1457,8 +1467,27 @@ acceptTypeJson:YES
failure:(void (^)(id))fail{ failure:(void (^)(id))fail{
void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) { void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
CLog(@"%@", responseObject); CLog(@"%@", responseObject);
if (succ) { if (IsDictObject(responseObject)) {
succ( responseObject ); void (^complete)(void) = ^(void){
if (succ) {
[IBTCommon runOnMainThreadWithoutDeadlocking:^{
succ( responseObject );
}];
}
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl storageEntities:responseObject[ @"data" ][ @"records" ]
objectClass:NSClassFromString( @"User" )
deleteLocal:YES
handleData:NULL
complete:complete
fail:fail];
}
else {
if (fail) {
fail( nil );
}
} }
}; };
void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) { void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
......
...@@ -39,4 +39,7 @@ ...@@ -39,4 +39,7 @@
- (BOOL)extensionIsImageType; - (BOOL)extensionIsImageType;
@end @end
\ No newline at end of file
...@@ -81,5 +81,4 @@ ...@@ -81,5 +81,4 @@
return NO; return NO;
} }
@end @end
\ No newline at end of file
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "DataManager.h" #import "DataManager.h"
#import "FMDatabase.h" #import "FMDatabase.h"
#import "Product.h" #import "Product.h"
#import "User.h"
@implementation DataManager @implementation DataManager
{ {
FMDatabase *_database; FMDatabase *_database;
...@@ -57,7 +58,8 @@ ...@@ -57,7 +58,8 @@
} }
- (void)creatTable{ - (void)creatTable{
NSArray *arr = @[@"CREATE TABLE IF NOT EXISTS product(serial integer PRIMARY KEY AUTOINCREMENT,uuid Varchar(1024),code Varchar(1024),secondCode Varchar(1024),name Varchar(1024),qpc Varchar(1024),qpcStr Varchar(1024),measureUnit Varchar(1024),brandName Varchar(1024),manufactory Varchar(1024),isNew Varchar(1024),categoryUuid Varchar(1024),image Varchar(1024),create_time Varchar(1024),create_id Varchar(1024),create_operName Varchar(1024),lastModify_time Varchar(1024),lastModify_id Varchar(1024),lastModify_operName Varchar(1024),enabled Varchar(1024),barcode Varchar(1024),enterprise Varchar(1024),remark Varchar(1024),specification Varchar(1024),version Varchar(1024))", NSArray *arr = @[@"CREATE TABLE IF NOT EXISTS product(serial integer PRIMARY KEY AUTOINCREMENT,uuid Varchar(1024),code Varchar(1024),secondCode Varchar(1024),name Varchar(1024),qpc Varchar(1024),qpcStr Varchar(1024),measureUnit Varchar(1024),brandName Varchar(1024),manufactory Varchar(1024),isNew Varchar(1024),categoryUuid Varchar(1024),image Varchar(1024),create_time Varchar(1024),create_id Varchar(1024),create_operName Varchar(1024),lastModify_time Varchar(1024),lastModify_id Varchar(1024),lastModify_operName Varchar(1024),enabled Varchar(1024),barcode Varchar(1024),enterprise Varchar(1024),remark Varchar(1024),specification Varchar(1024),version Varchar(1024))",
@"CREATE TABLE IF NOT EXISTS user(serial integer PRIMARY KEY AUTOINCREMENT,uuid Varchar(1024),version Varchar(1024),create_time Varchar(1024),create_id Varchar(1024),create_operName Varchar(1024),lastModify_time Varchar(1024),lastModify_id Varchar(1024),lastModify_operName Varchar(1024),company Varchar(1024),login Varchar(1024),password Varchar(1024),mobile Varchar(1024),email Varchar(1024),enabled Varchar(1024),position Varchar(1024),address Varchar(1024),belongOrg Varchar(1024),remark Varchar(1024))",@"CREATE TABLE IF NOT EXISTS fresh(serial integer PRIMARY KEY AUTOINCREMENT,id Varchar(1024),title Varchar(1024),url Varchar(1024),time Varchar(1024),desp Varchar(1024))"]; @"CREATE TABLE IF NOT EXISTS user(serial integer PRIMARY KEY AUTOINCREMENT,uuid Varchar(1024),version Varchar(1024),create_time Varchar(1024),create_id Varchar(1024),create_operName Varchar(1024),lastModify_time Varchar(1024),lastModify_id Varchar(1024),lastModify_operName Varchar(1024),company Varchar(1024),login Varchar(1024),password Varchar(1024),mobile Varchar(1024),email Varchar(1024),enabled Varchar(1024),position Varchar(1024),address Varchar(1024),belongOrg Varchar(1024),remark Varchar(1024))",
@"CREATE TABLE IF NOT EXISTS fresh(serial integer PRIMARY KEY AUTOINCREMENT,id Varchar(1024),title Varchar(1024),url Varchar(1024),time Varchar(1024),desp Varchar(1024))"];
//遍历数组创建表 //遍历数组创建表
for (NSString *sql in arr) { for (NSString *sql in arr) {
BOOL isSeccess = [_database executeUpdate:sql]; BOOL isSeccess = [_database executeUpdate:sql];
...@@ -87,17 +89,19 @@ ...@@ -87,17 +89,19 @@
- (void)insertDataFromUser:(id)model{ - (void)insertDataFromUser:(id)model{
Product *product = (Product *)model; User *user = (User *)model;
NSString *sql = @"insert into product (uuid,code,secondCode,name,qpc,qpcStr,measureUnit,brandName,manufactory,isNew,categoryUuid,image,create_time,create_id,create_operName,lastModify_time,lastModify_id,lastModify_operName,enabled,barcode,enterprise,remark,specification,version) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
NSString *sql = @"insert into user (uuid,version,create_time,create_id,create_operName,lastModify_time,lastModify_id,lastModify_operName,company,login,password,mobile,email,enabled,position,address,belongOrg,remark) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
//?对应的是对象地址类型 //?对应的是对象地址类型
BOOL isSuccess = [_database executeUpdate:sql,product.uuid,product.code,product.secondCode,product.name,product.qpc,product.qpcStr,product.measureUnit,product.brandName,product.manufactory,product.isNew,product.categoryUuid,product.image,product.create_time,product.create_id,product.create_operName,product.lastModify_time,product.lastModify_id,product.lastModify_operName,product.enabled,product.barcode,product.enterprise,product.remark,product.specification,product.version]; BOOL isSuccess = [_database executeUpdate:sql,user.uuid,user.version,user.create_time,user.create_id,user.create_operName,user.lastModify_time,user.lastModify_id,user.lastModify_operName,user.company,user.login,user.password,user.mobile,user.email,user.enabled,user.position,user.address,user.belongOrg,user.remark];
if (!isSuccess) { if (!isSuccess) {
NSLog(@"insert error:%@",[_database lastErrorMessage]); NSLog(@"insert error:%@",[_database lastErrorMessage]);
} }
} }
- (void)deleteDataFromUser{ - (void)deleteDataFromUser{
NSString *deleteSql = @"delete from product"; NSString *deleteSql = @"delete from user";
BOOL isSuccess = [_database executeUpdate:deleteSql]; BOOL isSuccess = [_database executeUpdate:deleteSql];
if (!isSuccess) { if (!isSuccess) {
NSLog(@"delete Error:%@",[_database lastErrorMessage]); NSLog(@"delete Error:%@",[_database lastErrorMessage]);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
+ (NSDate *)convertToDateFrom:(NSString *)dateString; + (NSDate *)convertToDateFrom:(NSString *)dateString;
+ (NSString *)stringFromDate:(NSDate*)aDate; + (NSString *)stringFromDate:(NSDate*)aDate;
+ (NSString*)dictionaryToJson:(id)dic; + (NSString*)dictionaryToJson:(id)dic;
+ (NSString *)checkString:(NSString *)str;
@end @end
...@@ -192,7 +192,11 @@ ...@@ -192,7 +192,11 @@
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
} }
+ (NSString *)checkString:(NSString *)str
{
return (str)?str:@"";
}
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
@property (copy, nonatomic) NSString *registerCode; @property (copy, nonatomic) NSString *registerCode;
@property (copy, nonatomic) NSString *token; @property (copy, nonatomic) NSString *token;
@property (copy, nonatomic) NSNumber *bAutoLogin; @property (copy, nonatomic) NSNumber *bAutoLogin;
@property (copy, nonatomic) NSString *authenticode;
// User Data // User Data
@property (copy, nonatomic) NSString *displayName; @property (copy, nonatomic) NSString *displayName;
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
@property (copy, nonatomic) NSString *currentStoreID; @property (copy, nonatomic) NSString *currentStoreID;
@property (copy, nonatomic) NSString *uniqueID; @property (copy, nonatomic) NSString *uniqueID;
+ (instancetype)sharedInstance; + (instancetype)sharedInstance;
- (BOOL)saveArchive; - (BOOL)saveArchive;
......
...@@ -72,12 +72,12 @@ ...@@ -72,12 +72,12 @@
- (void)setSurvey:(Survey *)survey{ - (void)setSurvey:(Survey *)survey{
self.titleLabel.text = survey.title; self.titleLabel.text = survey.title;
self.billnumberLabel.text = survey.billnumber; self.billnumberLabel.text = survey.billNumber;
self.productnameLabel.text = survey.productname; self.productnameLabel.text = survey.productName;
self.begindateLabel.text = [IBTCommon stringFromDate: survey.begindate]; self.begindateLabel.text = survey.beginDate;
self.enddateLabel.text = [IBTCommon stringFromDate:survey.enddate]; self.enddateLabel.text = survey.endDate;
NSString *stateStr = @""; NSString *stateStr = @"";
if ([survey.state isEqualToString:@"saved"]) { if ([survey.state isEqualToString:@"initial"]) {
[self.stateBtn setBackgroundColor:[UIColor redColor]]; [self.stateBtn setBackgroundColor:[UIColor redColor]];
stateStr = @"未提交"; stateStr = @"未提交";
}else if ([survey.state isEqualToString:@"submitted"]) { }else if ([survey.state isEqualToString:@"submitted"]) {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
@property (nonatomic,strong)NSString *password;//密码 @property (nonatomic,strong)NSString *password;//密码
@property (nonatomic,strong)NSString *mobile;//手机号 @property (nonatomic,strong)NSString *mobile;//手机号
@property (nonatomic,strong)NSString *email;//邮箱 @property (nonatomic,strong)NSString *email;//邮箱
@property (nonatomic,assign)NSInteger *enabled;//是否启用 @property (nonatomic,assign)NSInteger enabled;//是否启用
@property (nonatomic,strong)NSString *position;//职位 @property (nonatomic,strong)NSString *position;//职位
@property (nonatomic,strong)NSString *address;//地址 @property (nonatomic,strong)NSString *address;//地址
@property (nonatomic,strong)NSString *belongOrg;//所属组织 @property (nonatomic,strong)NSString *belongOrg;//所属组织
......
...@@ -9,5 +9,11 @@ ...@@ -9,5 +9,11 @@
#import "User.h" #import "User.h"
@implementation User @implementation User
+ (NSDictionary *)specialKeysAndReplaceKeys {
return @{ @"uID" : [[self class] PrimaryKey], };
}
+ (NSString *)PrimaryKey {
return @"uuid";
}
@end @end
...@@ -12,13 +12,14 @@ ...@@ -12,13 +12,14 @@
#define TableHeight 50 #define TableHeight 50
@interface ChooseProductViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate> @interface ChooseProductViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate>
{ {
UITableView *_tableView;
UITextField *_selectTextFiled; UITextField *_selectTextFiled;
NSMutableArray *_dataArr;
NSMutableArray *_indexArr; NSMutableArray *_indexArr;
NSIndexPath *_currentIndexPath; NSIndexPath *_currentIndexPath;
}@end }
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)UITableView *tableView;
@end
@implementation ChooseProductViewController @implementation ChooseProductViewController
...@@ -28,31 +29,16 @@ ...@@ -28,31 +29,16 @@
[self bulidLayout]; [self bulidLayout];
} }
- (void)initData{ - (void)initData{
_dataArr = [NSMutableArray array]; self.dataArr = [NSMutableArray array];
_indexArr = [NSMutableArray array]; _indexArr = [NSMutableArray array];
//获取商品
[self fetchProductList];
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) { void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
if (data) { __strong __typeof(weakSelf)strongSelf = weakSelf;
NSInteger success = [data[@"success"] integerValue]; [strongSelf fetchProductList];
NSString *message = data[@"message"];
if (success == 1) {
//成功
NSDictionary *dataDict = data[@"data"];
NSArray *records = dataDict[@"records"];
if (records.count > 0) {
for (NSDictionary *recordDict in records) {
Product *product = [[Product alloc]init];
[product setValuesForKeysWithDictionary:recordDict];
[_dataArr addObject:product];
}
//刷新表格
[_tableView reloadData];
}
}else{
[IBTLoadingView showTips:message];
}
}
}; };
void(^fail)(id) = ^(id data) { void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
...@@ -61,6 +47,29 @@ ...@@ -61,6 +47,29 @@
[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)fetchProductList{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@", [Product TableName], @"uuid"];
return [db executeQuery:sql];
};
__weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf.dataArr removeAllObjects];
[strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[strongSelf.tableView reloadData];
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[Product class]
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
}
- (void)bulidLayout - (void)bulidLayout
{ {
self.view.backgroundColor = HexColor(@"f8f8f8"); self.view.backgroundColor = HexColor(@"f8f8f8");
...@@ -84,11 +93,11 @@ ...@@ -84,11 +93,11 @@
_selectTextFiled.rightViewMode = UITextFieldViewModeAlways; _selectTextFiled.rightViewMode = UITextFieldViewModeAlways;
_tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)]; self.tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)];
_tableView.backgroundColor = [UIColor whiteColor]; self.tableView.backgroundColor = [UIColor whiteColor];
_tableView.delegate = self; self.tableView.delegate = self;
_tableView.dataSource = self; self.tableView.dataSource = self;
[self.view addSubview:_tableView]; [self.view addSubview:self.tableView];
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)]; UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)];
...@@ -99,8 +108,8 @@ ...@@ -99,8 +108,8 @@
if(self.isMoreChose){ if(self.isMoreChose){
}else{ }else{
if (_dataArr.count > 0) { if (self.dataArr.count > 0) {
Product *product = _dataArr[_currentIndexPath.row]; Product *product = self.dataArr[_currentIndexPath.row];
self.choseProduct(product); self.choseProduct(product);
} }
} }
...@@ -112,7 +121,7 @@ ...@@ -112,7 +121,7 @@
_selectTextFiled.text = @""; _selectTextFiled.text = @"";
[_indexArr removeAllObjects]; [_indexArr removeAllObjects];
_currentIndexPath = nil; _currentIndexPath = nil;
[_tableView reloadData]; [self.tableView reloadData];
} }
#pragma mark - 协议方法 #pragma mark - 协议方法
...@@ -120,7 +129,7 @@ ...@@ -120,7 +129,7 @@
return 1; return 1;
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _dataArr.count; 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";
...@@ -148,8 +157,8 @@ ...@@ -148,8 +157,8 @@
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
} }
} }
if (_dataArr.count > 0) { if (self.dataArr.count > 0) {
Product *product = _dataArr[indexPath.row]; Product *product = self.dataArr[indexPath.row];
NSString *proStr = [NSString stringWithFormat:@"%@[%@]",product.name,product.code]; NSString *proStr = [NSString stringWithFormat:@"%@[%@]",product.name,product.code];
[cell setTitleStr:proStr]; [cell setTitleStr:proStr];
...@@ -168,7 +177,7 @@ ...@@ -168,7 +177,7 @@
NSString *personStr = @""; NSString *personStr = @"";
for (NSIndexPath *index in _indexArr) { for (NSIndexPath *index in _indexArr) {
Product *product = _dataArr[index.row]; Product *product = self.dataArr[index.row];
personStr = [personStr stringByAppendingFormat:@"%@、",product.name]; personStr = [personStr stringByAppendingFormat:@"%@、",product.name];
} }
_selectTextFiled.text = personStr; _selectTextFiled.text = personStr;
...@@ -180,7 +189,7 @@ ...@@ -180,7 +189,7 @@
_currentIndexPath = indexPath; _currentIndexPath = indexPath;
Product *procuct = _dataArr[indexPath.row]; Product *procuct = self.dataArr[indexPath.row];
_selectTextFiled.text = procuct.name; _selectTextFiled.text = procuct.name;
} }
} }
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
#define TableHeight 50 #define TableHeight 50
@interface ChosePersonViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate> @interface ChosePersonViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate>
{ {
UITableView *_tableView;
UITextField *_selectTextFiled; UITextField *_selectTextFiled;
NSMutableArray *_dataArr;
NSMutableArray *_indexArr;
} }
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *indexArr;
@end @end
@implementation ChosePersonViewController @implementation ChosePersonViewController
...@@ -29,45 +29,51 @@ ...@@ -29,45 +29,51 @@
[self bulidLayout]; [self bulidLayout];
} }
- (void)initData{ - (void)initData{
_dataArr = [NSMutableArray array]; self.dataArr = [NSMutableArray array];
_indexArr = [NSMutableArray array]; self.indexArr = [NSMutableArray array];
[self fetchUserList];
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) { void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
if (data) { __strong __typeof(weakSelf)strongSelf = weakSelf;
NSInteger success = [data[@"success"] integerValue]; [strongSelf fetchUserList];
NSString *message = data[@"message"];
if (success == 1) {
//成功
NSDictionary *dataDict = data[@"data"];
NSArray *records = dataDict[@"records"];
if (records.count > 0) {
for (NSDictionary *recordDict in records) {
User *user = [[User alloc]init];
[user setValuesForKeysWithDictionary:recordDict];
[_dataArr addObject:user];
}
//刷新表格
[_tableView reloadData];
}
}else{
[IBTLoadingView showTips:message];
}
}
}; };
void(^fail)(id) = ^(id data) { void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController 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 -成功
- (void)fetchUserList{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@", [User TableName], @"uuid"];
return [db executeQuery:sql];
};
// for (NSInteger i = 0; i < 10; i++) { __weak typeof(self)weakSelf = self;
// SurveyUser *user = [[SurveyUser alloc]init]; ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
// user.userName = [NSString stringWithFormat:@"张三%ld",(long)i]; __strong __typeof(weakSelf)strongSelf = weakSelf;
// [_dataArr addObject:user]; [strongSelf.dataArr removeAllObjects];
// } [strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[strongSelf.tableView reloadData];
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[User class]
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
} }
#pragma mark - 插入数据
- (void)bulidLayout - (void)bulidLayout
{ {
self.view.backgroundColor = HexColor(@"f8f8f8"); self.view.backgroundColor = HexColor(@"f8f8f8");
...@@ -91,11 +97,11 @@ ...@@ -91,11 +97,11 @@
_selectTextFiled.rightViewMode = UITextFieldViewModeAlways; _selectTextFiled.rightViewMode = UITextFieldViewModeAlways;
_tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)]; self.tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)];
_tableView.backgroundColor = [UIColor whiteColor]; self.tableView.backgroundColor = [UIColor whiteColor];
_tableView.delegate = self; self.tableView.delegate = self;
_tableView.dataSource = self; self.tableView.dataSource = self;
[self.view addSubview:_tableView]; [self.view addSubview:self.tableView];
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)]; UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)];
...@@ -104,8 +110,8 @@ ...@@ -104,8 +110,8 @@
- (void)sureClick{ - (void)sureClick{
NSMutableArray *arr = [[NSMutableArray alloc]init]; NSMutableArray *arr = [[NSMutableArray alloc]init];
for (NSIndexPath *index in _indexArr) { for (NSIndexPath *index in self.indexArr) {
User *user = _dataArr[index.row]; User *user = self.dataArr[index.row];
SurveyUser * survey = [[SurveyUser alloc]init]; SurveyUser * survey = [[SurveyUser alloc]init];
survey.userUuid = user.uuid; survey.userUuid = user.uuid;
survey.userCode = user.login; survey.userCode = user.login;
...@@ -128,8 +134,8 @@ ...@@ -128,8 +134,8 @@
- (void)deletePerson { - (void)deletePerson {
_selectTextFiled.text = @""; _selectTextFiled.text = @"";
[_indexArr removeAllObjects]; [self.indexArr removeAllObjects];
[_tableView reloadData]; [self.tableView reloadData];
} }
#pragma mark - 协议方法 #pragma mark - 协议方法
...@@ -137,7 +143,7 @@ ...@@ -137,7 +143,7 @@
return 1; return 1;
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _dataArr.count; 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";
...@@ -153,8 +159,8 @@ ...@@ -153,8 +159,8 @@
}else{ }else{
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
} }
if (_dataArr.count > 0) { if (self.dataArr.count > 0) {
User *user = _dataArr[indexPath.row]; User *user = self.dataArr[indexPath.row];
[cell setTitleStr:user.name]; [cell setTitleStr:user.name];
} }
...@@ -167,20 +173,24 @@ ...@@ -167,20 +173,24 @@
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];
} }
NSString *personStr = @""; NSString *personStr = @"";
for (NSIndexPath *index in _indexArr) { for (NSIndexPath *index in self.indexArr) {
User *user = _dataArr[index.row]; User *user = self.dataArr[index.row];
personStr = [personStr stringByAppendingFormat:@"%@、",user.name]; if (personStr.length == 0) {
personStr = [personStr stringByAppendingFormat:@"%@",user.name];
}else{
personStr = [personStr stringByAppendingFormat:@"、%@",user.name];
}
} }
_selectTextFiled.text = personStr; _selectTextFiled.text = personStr;
} }
} }
- (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath{ - (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath{
for (NSIndexPath *path in _indexArr) { for (NSIndexPath *path in self.indexArr) {
if (path.row == indexPath.row) { if (path.row == indexPath.row) {
return YES; return YES;
} }
......
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
#import "Survey.h" #import "Survey.h"
@interface SurveyDetailViewController : ICRBaseViewController @interface SurveyDetailViewController : ICRBaseViewController
@property (nonatomic,strong)Survey *survey; @property (nonatomic,strong)Survey *survey;
@property (nonatomic,strong)NSString *surveyUuid;
@end @end
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "SurveyDetailViewController.h" #import "SurveyDetailViewController.h"
#import "ResultDetailViewController.h" #import "ResultDetailViewController.h"
#import "SurveyUser.h"
#define BottomHeight 50 #define BottomHeight 50
#define LeftMargin 20 #define LeftMargin 20
#define LeftWidth 100 #define LeftWidth 100
...@@ -26,6 +27,13 @@ typedef enum : NSUInteger { ...@@ -26,6 +27,13 @@ typedef enum : NSUInteger {
UIView *_surveyView; UIView *_surveyView;
UIView *_bottomView; UIView *_bottomView;
} }
@property (nonatomic,strong)UILabel *billNumberLabel;
@property (nonatomic,strong)UILabel *stateLabel;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UILabel *productLabel;
@property (nonatomic,strong)UILabel *beginDateLabel;
@property (nonatomic,strong)UILabel *endDateLabel;
@property (nonatomic,strong)UILabel *userLabel;
@property (nonatomic,strong)UILabel *noteLabel; @property (nonatomic,strong)UILabel *noteLabel;
@end @end
...@@ -34,8 +42,61 @@ typedef enum : NSUInteger { ...@@ -34,8 +42,61 @@ typedef enum : NSUInteger {
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self bulifLayout]; [self bulifLayout];
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (data) {
NSDictionary *dictData = data[@"data"];
Survey *survey = [[Survey alloc]init];
[survey setValuesForKeysWithDictionary:dictData];
self.survey = survey;
[strongSelf fetchtSurveyDetail];
}else{
[strongSelf fetchtSurveyDetail];
}
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
[IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getResultWithSurveyUuid:self.surveyUuid success:succ failure:fail];
}
- (void)fetchtSurveyDetail{
self.billNumberLabel.text = [IBTCommon checkString:self.survey.billNumber];
if ([self.survey.state isEqualToString:@"initial"]) {
self.stateLabel.textColor = [UIColor redColor];
self.stateLabel.text = @"未提交";
}else if ([self.survey.state isEqualToString:@"submitted"]) {
self.stateLabel.textColor = [UIColor greenColor];
self.stateLabel.text = @"已提交";
}else if ([self.survey.state isEqualToString:@"insurvey"]) {
self.stateLabel.textColor = [UIColor grayColor];
self.stateLabel.text = @"调研中";
}else if ([self.survey.state isEqualToString:@"finished"]) {
self.stateLabel.textColor = [UIColor blackColor];
self.stateLabel.text = @"已完成";
}
NSString *user = @"";
for (NSDictionary *userDict in self.survey.users) {
SurveyUser *surveyUser = [[SurveyUser alloc]init];
[surveyUser setValuesForKeysWithDictionary:userDict];
user = [user stringByAppendingFormat:@"%@、",surveyUser.userName];
}
self.titleLabel.text = [IBTCommon checkString:self.survey.title];
self.productLabel.text = [IBTCommon checkString:self.survey.productName];
self.beginDateLabel.text = [IBTCommon checkString:self.survey.beginDate];
self.endDateLabel.text = [IBTCommon checkString:self.survey.endDate];
self.userLabel.text = [IBTCommon checkString:user];
self.noteLabel.text = [IBTCommon checkString:self.survey.remark];
[self setNoteHeight];
} }
#pragma mark - 视图初始化 #pragma mark - 视图初始化
- (void)bulifLayout{ - (void)bulifLayout{
self.view.backgroundColor = HexColor(@"f8f8f8"); self.view.backgroundColor = HexColor(@"f8f8f8");
...@@ -61,48 +122,85 @@ typedef enum : NSUInteger { ...@@ -61,48 +122,85 @@ typedef enum : NSUInteger {
[_surveyView addSubview:tagLabel]; [_surveyView addSubview:tagLabel];
NSArray *leftArr = @[@"单号:",@"状态:",@"标题:",@"商品:",@"开始日期:",@"截止日期:",@"调研人员:",@"备注:"]; NSArray *leftArr = @[@"单号:",@"状态:",@"标题:",@"商品:",@"开始日期:",@"截止日期:",@"调研人员:",@"备注:"];
NSMutableArray *contentArr = [[NSMutableArray alloc]init];
[contentArr addObject:self.survey.billnumber];
[contentArr addObject:self.survey.state];
[contentArr addObject:self.survey.title];
[contentArr addObject:self.survey.productname];
[contentArr addObject:[IBTCommon stringFromDate:self.survey.begindate]];
[contentArr addObject:[IBTCommon stringFromDate:self.survey.enddate]];
[contentArr addObject:self.survey.productcode];
[contentArr addObject:self.survey.remark];
// NSMutableArray *contentArr = [[NSMutableArray alloc]init];
// [contentArr addObject:[IBTCommon checkString:self.survey.billNumber]];
// [contentArr addObject:[IBTCommon checkString:self.survey.state]];
// [contentArr addObject:[IBTCommon checkString:self.survey.title]];
// [contentArr addObject:[IBTCommon checkString:self.survey.productName]];
// [contentArr addObject:[IBTCommon checkString:self.survey.beginDate]];
// [contentArr addObject:[IBTCommon checkString:self.survey.endDate]];
// [contentArr addObject:[IBTCommon checkString:self.survey.productCode]];
// [contentArr addObject:[IBTCommon checkString:self.survey.remark]];
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) + LeftHeight *i, LeftWidth, LeftHeight)];
leftLabel.text = leftArr[i];
leftLabel.font = FontSize(17); leftLabel.font = FontSize(17);
leftLabel.text = leftArr[i];
[_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) + LeftHeight *i, _surveyView.frame.size.width - LeftMargin - LeftWidth, LeftHeight)];
rightLabel.text = contentArr[i];
rightLabel.font = FontSize(17); rightLabel.font = FontSize(17);
if (i == leftArr.count - 1) {
if (i == 0) {
self.billNumberLabel = rightLabel;
}else if (i == 1) {
// if ([contentArr[i] isEqualToString:@"initial"]) {
// rightLabel.textColor = [UIColor redColor];
// rightLabel.text = @"未提交";
// }else if ([contentArr[i] isEqualToString:@"submitted"]) {
// rightLabel.textColor = [UIColor greenColor];
// rightLabel.text = @"已提交";
// }else if ([contentArr[i] isEqualToString:@"insurvey"]) {
// rightLabel.textColor = [UIColor grayColor];
// rightLabel.text = @"调研中";
// }else if ([contentArr[i] isEqualToString:@"finished"]) {
// rightLabel.textColor = [UIColor blackColor];
// rightLabel.text = @"已完成";
// }
self.stateLabel = rightLabel;
}else if(i == 2){
self.titleLabel = rightLabel;
}else if(i == 3){
self.productLabel = rightLabel;
}else if(i == 4){
self.beginDateLabel = rightLabel;
}else if(i == 5){
self.endDateLabel = rightLabel;
}else if(i == 6){
self.userLabel = rightLabel;
}else if(i == 7){
rightLabel.numberOfLines = 0; rightLabel.numberOfLines = 0;
self.noteLabel = rightLabel; self.noteLabel = rightLabel;
} }
[_surveyView addSubview:rightLabel]; [_surveyView addSubview:rightLabel];
} }
_bottomView= [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_surveyView.frame), ScreenSize.width, 200)]; _bottomView= [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_surveyView.frame), ScreenSize.width, 200)];
_bottomView.backgroundColor = [UIColor whiteColor]; _bottomView.backgroundColor = [UIColor whiteColor];
[_scrollView addSubview:_bottomView]; [_scrollView addSubview:_bottomView];
UILabel *resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin/2, 10, LeftWidth*2, LeftHeight)]; UILabel *resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin/2, 10, LeftWidth*2, LeftHeight)];
resultLabel.text = @"【行情反馈】"; resultLabel.text = @"【行情反馈】";
resultLabel.font = FontSize(17); resultLabel.font = FontSize(17);
resultLabel.textColor = [UIColor blueColor]; resultLabel.textColor = [UIColor blueColor];
[_bottomView addSubview:resultLabel]; [_bottomView addSubview:resultLabel];
UIButton *btn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(CGRectGetWidth(_bottomView.frame) - 100, 10, 100, LeftHeight) target:self sel:@selector(btnClick:) tag:DetailTag image:nil title:@">>查看详情" titleColor:[UIColor blueColor] isCorner:NO corner:0 bgColor:nil]; UIButton *btn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(CGRectGetWidth(_bottomView.frame) - 100, 10, 100, LeftHeight) target:self sel:@selector(btnClick:) tag:DetailTag image:nil title:@">>查看详情" titleColor:[UIColor blueColor] isCorner:NO corner:0 bgColor:nil];
[_bottomView addSubview:btn]; [_bottomView addSubview:btn];
[self setNoteHeight];
} }
- (void)createSurvey{
}
- (void)btnClick:(UIButton *)btn{ - (void)btnClick:(UIButton *)btn{
if (btn.tag == DetailTag) { if (btn.tag == DetailTag) {
ResultDetailViewController *rvc = [ResultDetailViewController new]; ResultDetailViewController *rvc = [ResultDetailViewController new];
......
...@@ -28,8 +28,6 @@ typedef enum : NSUInteger { ...@@ -28,8 +28,6 @@ typedef enum : NSUInteger {
@interface SurveyViewController ()<UITableViewDataSource,UITableViewDelegate,BoltMaskViewDelegate,SortMaskViewDelegate> @interface SurveyViewController ()<UITableViewDataSource,UITableViewDelegate,BoltMaskViewDelegate,SortMaskViewDelegate>
{ {
UITableView *_tableView;
NSMutableArray *_dataArr;
UIView *_maskView; UIView *_maskView;
UIButton *currentBtn; UIButton *currentBtn;
SortMaskView *_sortView; SortMaskView *_sortView;
...@@ -38,6 +36,9 @@ typedef enum : NSUInteger { ...@@ -38,6 +36,9 @@ typedef enum : NSUInteger {
UIButton *_sortBtn; UIButton *_sortBtn;
UIButton *_boltBtn; UIButton *_boltBtn;
} }
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)UITableView *tableView;
@end @end
@implementation SurveyViewController @implementation SurveyViewController
...@@ -50,55 +51,48 @@ typedef enum : NSUInteger { ...@@ -50,55 +51,48 @@ typedef enum : NSUInteger {
} }
- (void)initData{ - (void)initData{
_dataArr = [NSMutableArray array]; self.dataArr = [NSMutableArray array];
//查询 [self fetchtSurveyList];
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) { void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
NSLog(@"%@",data); __strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf fetchtSurveyList];
}; };
void(^fail)(id) = ^(id data) { void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
// [[ICRHTTPController sharedController] querySurveyWithBillNUmberLinke:@"fdsfds" state:@"initial" titleLike:@"fds" orderFiled:@"fdsafds" orderDirection:@"asc" page_number:0 page_size:100 success:succ failure:fail];
ICRUserUtil *userUtil = [ICRUserUtil sharedInstance]; ICRUserUtil *userUtil = [ICRUserUtil sharedInstance];
NSDictionary *dict = @{ NSDictionary *dict = @{
// @"enterprise":@"402881894d3e4cca014d3e4cf7c2002a", @"userUuid":userUtil.userId,
// @"userUuid":userUtil.userId,
// @"billNumberLike":@"150809",
// @"state":@"ee",
// @"titleLike":@"001",
// @"orderField":@"title",
// @"orderDirection":@"asc",
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":@(20)}; @"pageSize":@(20)};
[[ICRHTTPController sharedController] querySurveyWithBillData:dict success:succ failure:fail]; [[ICRHTTPController sharedController] querySurveyWithBillData:dict success:succ failure:fail];
// [[ICRHTTPController sharedController] getResultsWithSurveyUuid:@"111" success:succ failure:fail];
// for (NSInteger i = 0; i < 4; i++) {
// Survey *survey = [[Survey alloc]init];
// survey.title = @"南汇8424西瓜调研情况";
// survey.billnumber = @"150605000001";
// survey.productname = @"南汇842[100213]";
// survey.productcode = @"22222222222";
// survey.remark = @"费卡接口浪格可放大文化大fdsaf缴费卡接口浪费缴费卡上就付款放假快乐撒即可书法家开发商";
// survey.begindate = [IBTCommon convertToDateFrom:@"2015.05.25"];
// survey.enddate = [IBTCommon convertToDateFrom:@"2015.08.06"];
// [_dataArr addObject:survey];
// if (i == 0) {
// survey.state = @"saved";
// }else if (i == 1) {
// survey.state = @"submitted";
// }else if (i == 2) {
// survey.state = @"insurvey";
// }else if (i == 3) {
// survey.state = @"finished";
// }
// }
} }
#pragma mark -成功
- (void)fetchtSurveyList{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@", [Survey TableName], @"uuid"];
return [db executeQuery:sql];
};
__weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf.dataArr removeAllObjects];
[strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[strongSelf.tableView reloadData];
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[Survey class]
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
}
- (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)];
...@@ -111,11 +105,11 @@ typedef enum : NSUInteger { ...@@ -111,11 +105,11 @@ typedef enum : NSUInteger {
[self.view addSubview:_boltBtn]; [self.view addSubview:_boltBtn];
_tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)]; self.tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)];
_tableView.backgroundColor = [UIColor whiteColor]; self.tableView.backgroundColor = [UIColor whiteColor];
_tableView.delegate = self; self.tableView.delegate = self;
_tableView.dataSource = self; self.tableView.dataSource = self;
[self.view addSubview:_tableView]; [self.view addSubview:self.tableView];
_maskView = [[UIView alloc]initWithFrame:CGRectMake(0, TopMargin, ScreenSize.width, ScreenSize.height - 64- TopMargin)]; _maskView = [[UIView alloc]initWithFrame:CGRectMake(0, TopMargin, ScreenSize.width, ScreenSize.height - 64- TopMargin)];
_maskView.backgroundColor = RGBA(0, 0, 0, 0.5); _maskView.backgroundColor = RGBA(0, 0, 0, 0.5);
...@@ -243,7 +237,7 @@ typedef enum : NSUInteger { ...@@ -243,7 +237,7 @@ typedef enum : NSUInteger {
return 1; return 1;
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _dataArr.count; return self.dataArr.count;
} }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"SurveyID"; static NSString *cellID = @"SurveyID";
...@@ -253,8 +247,8 @@ typedef enum : NSUInteger { ...@@ -253,8 +247,8 @@ typedef enum : NSUInteger {
tableView.separatorStyle = UITableViewCellSeparatorStyleNone; tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
} }
if (_dataArr.count > 0) { if (self.dataArr.count > 0) {
Survey *survey = _dataArr[indexPath.row]; Survey *survey = self.dataArr[indexPath.row];
[cell setSurvey:survey]; [cell setSurvey:survey];
} }
...@@ -263,8 +257,10 @@ typedef enum : NSUInteger { ...@@ -263,8 +257,10 @@ typedef enum : NSUInteger {
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
SurveyDetailViewController *svc = [SurveyDetailViewController new]; SurveyDetailViewController *svc = [SurveyDetailViewController new];
if (_dataArr.count > 0) { if (self.dataArr.count > 0) {
svc.survey = _dataArr[indexPath.row]; Survey *survey = self.dataArr[indexPath.row];
svc.survey = survey;
svc.surveyUuid = survey.uuid;
} }
[self PushViewController:svc animated:YES]; [self PushViewController:svc animated:YES];
......
...@@ -10,4 +10,11 @@ ...@@ -10,4 +10,11 @@
@implementation Product @implementation Product
+ (NSDictionary *)specialKeysAndReplaceKeys {
return @{ @"pID" : [[self class] PrimaryKey], };
}
+ (NSString *)PrimaryKey {
return @"uuid";
}
@end @end
...@@ -10,22 +10,24 @@ ...@@ -10,22 +10,24 @@
@interface Survey : IBTModel @interface Survey : IBTModel
@property (nonatomic,strong)NSString *uuid;//唯一标识 @property (nonatomic,strong)NSString *uuid;//唯一标识
@property (nonatomic,strong)NSString *billnumber;//调研单号 @property (nonatomic,strong)NSString *billNumber;//调研单号
@property (nonatomic,strong)NSString *title;//标题 @property (nonatomic,strong)NSString *title;//标题
@property (nonatomic,strong)NSString *productUuid;//商品uuid @property (nonatomic,strong)NSString *productUuid;//商品uuid
@property (nonatomic,strong)NSString *productcode;//商品代码 @property (nonatomic,strong)NSString *enterprise;//商品uuid
@property (nonatomic,strong)NSString *productname;//商品名称 @property (nonatomic,strong)NSString *productCode;//商品代码
@property (nonatomic,strong)NSDate *begindate;//调研开始时间 @property (nonatomic,strong)NSString *productName;//商品名称
@property (nonatomic,strong)NSDate *enddate;//调研结束时间 @property (nonatomic,strong)NSString *beginDate;//调研开始时间
@property (nonatomic,strong)NSString *endDate;//调研结束时间
@property (nonatomic,strong)NSString *remark;//备注 @property (nonatomic,strong)NSString *remark;//备注
@property (nonatomic,strong)NSString *state;//状态saved(未提交),submitted(已提交),insurvey(调研中),finished(已完成) @property (nonatomic,strong)NSString *state;//initial(未提交),submitted(已提交),insurvey(调研中),finished(已完成)
@property (nonatomic,strong)NSDate *create_time;//创建时间 @property (nonatomic,strong)NSString *create_time;//创建时间
@property (nonatomic,strong)NSString *create_id;//创建人代码 @property (nonatomic,strong)NSString *create_id;//创建人代码
@property (nonatomic,strong)NSString *create_operName;//创建人名称 @property (nonatomic,strong)NSString *create_operName;//创建人名称
@property (nonatomic,strong)NSDate *lastModified_time;//最后修改时间 @property (nonatomic,strong)NSString *lastModify_time;//最后修改时间
@property (nonatomic,strong)NSString *lastModified_id;//最后修改人代码
@property (nonatomic,strong)NSString *lastModified_operName;//最后修改人名称
@property (nonatomic,strong)NSString *lastModify_id;//最后修改人代码
@property (nonatomic,strong)NSString *lastModify_operName;//最后修改人名称
@property (nonatomic,strong)NSArray *users;
@property (nonatomic,assign)NSInteger version;
@end @end
...@@ -9,5 +9,11 @@ ...@@ -9,5 +9,11 @@
#import "Survey.h" #import "Survey.h"
@implementation Survey @implementation Survey
+ (NSDictionary *)specialKeysAndReplaceKeys {
return @{ @"sID" : [[self class] PrimaryKey], };
}
+ (NSString *)PrimaryKey {
return @"uuid";
}
@end @end
...@@ -12,4 +12,5 @@ ...@@ -12,4 +12,5 @@
@property (nonatomic,strong)NSString *userUuid;//用户UUid @property (nonatomic,strong)NSString *userUuid;//用户UUid
@property (nonatomic,strong)NSString *userCode;//用户编码 @property (nonatomic,strong)NSString *userCode;//用户编码
@property (nonatomic,strong)NSString *userName;//用户名称 @property (nonatomic,strong)NSString *userName;//用户名称
@property (nonatomic,strong)NSString *uuid;
@end @end
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
if (scrollView == _bottomSV) { if (scrollView == _bottomSV) {
CGFloat index = _bottomSV.contentOffset.x / _bottomSV.frame.size.width; // CGFloat index = _bottomSV.contentOffset.x / _bottomSV.frame.size.width;
} }
} }
......
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