Commit 5afca515 authored by n22's avatar n22

详情接口

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