Commit 3b6e7db6 authored by mei's avatar mei

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

parents 8d02e4a0 d7dbc1f7
This diff is collapsed.
......@@ -193,6 +193,9 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
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
success:(void (^)(id))succ
......
......@@ -239,7 +239,7 @@ static NSString * const ICRAttachmentTypeValue[] = {
{
[requestSerializer setValue:user.orgId forHTTPHeaderField:@"enterprise"];
}
// [requestSerializer setValue:user.authorization forHTTPHeaderField:@"Authorization"];
// [requestSerializer setValue:user. forHTTPHeaderField:@"Authorization"];
return requestSerializer;
}
......@@ -1317,7 +1317,7 @@ acceptTypeJson:YES
NSDictionary *dict = data;
NSString *currentTime = [[NSDate date] httpParameterString];
ICRUserUtil *userUtil = [ICRUserUtil sharedInstance];
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:XFFHttp_SurveySave] stringByAppendingFormat:@"?time=%@&operator.id=%@&operator.operName=%@&enterprise=%@",currentTime,userUtil.userCode,userUtil.displayName,userUtil.orgId];
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:XFFHttp_SurveySave] stringByAppendingFormat:@"?time=%@&operId=%@&operName=%@",currentTime,userUtil.userCode,userUtil.displayName];
NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[self POST:encodeUrlStr
parameters:dict
......@@ -1361,6 +1361,34 @@ acceptTypeJson:YES
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) {
CLog(@"%@", error);
if (fail) {
fail( error );
}
};
NSDictionary *dict = data;
NSString *urlStr = [[self class] UrlForPluginHTTPAction:XFFHttp_QuerySurvey];
[self POST:urlStr
parameters:dict
needToken:NO
acceptTypeJson:YES
success:success
failure:failure];
}
- (void)getResultsWithSurveyUuid:(NSString *)surveyUuid
success:(void (^)(id))succ
failure:(void (^)(id))fail{
......@@ -1439,8 +1467,8 @@ acceptTypeJson:YES
fail( error );
}
};
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:XFFHttp_GetUser] stringByAppendingFormat:@"?start_date=%@&page_number=%@&page_size=%@", [[NSDate date] httpParameterString],@(page_number),@(page_size)];
NSString *dateStr = @"2015-01-01";
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:XFFHttp_GetUser] stringByAppendingFormat:@"?start_date=%@&page_number=%@&page_size=%@", dateStr,@(page_number),@(page_size)];
NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[self POST:encodeUrlStr
parameters:NULL
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "arrorw.png"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "select_arrow_up_text.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "select_arrow_up_text@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "tab_line.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "tab_line@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
//
// DataManager.h
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface DataManager : NSObject
//非标准单例
+ (DataManager *)sharedDatabaseManager;
- (void)createDB;
- (void)insertDataFromModel:(id)model;
- (void)deleteDataFromProduct;
- (void)insertDataFromUser:(id)model;
- (void)deleteDataFromUser;
@end
//
// DataManager.m
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "DataManager.h"
#import "FMDatabase.h"
#import "Product.h"
@implementation DataManager
{
FMDatabase *_database;
}
//非标准单例
+ (DataManager *)sharedDatabaseManager{
static DataManager *manager = nil;
@synchronized(self){
if (manager == nil) {
manager = [[self alloc] init];
}
}
return manager;
}
- (void)createDB
{
//先获取app.db在沙盒中的路径
NSString *path = [self getFullDatabasePathFromFileName:@"XFFruit.db"];
//创建数据库对象
_database = [[FMDatabase alloc] initWithPath:path];
//打开数据库
if ([_database open]) {//第一次打开如果没有那么就创建并打开 如果有直接打开
//打开成功 那么就创建表
[self creatTable];
}else{
NSLog(@"open database:%@",[_database lastErrorMessage]);
}
}
#pragma mark - 获取数据库文件的全路径
- (NSString *)getFullDatabasePathFromFileName:(NSString *)name{
//获取沙盒路径
NSString *path = NSHomeDirectory();
NSString *docPath = [path stringByAppendingPathComponent:@"Documents"];
//要判断Documents存在不存在
NSFileManager *fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:docPath]) {//存在
//返回文件在Documents 目录下得路径
return [docPath stringByAppendingFormat:@"/%@",name];
}else{
NSLog(@"Documents不存在");
//不存在可以自己创建一个Documents目录
return nil;
}
}
- (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))"];
//遍历数组创建表
for (NSString *sql in arr) {
BOOL isSeccess = [_database executeUpdate:sql];
if (!isSeccess) {
NSLog(@"create table failed%@",[_database lastErrorMessage]);
}
}
}
- (void)insertDataFromModel:(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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
//?对应的是对象地址类型
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];
if (!isSuccess) {
NSLog(@"insert error:%@",[_database lastErrorMessage]);
}
}
- (void)deleteDataFromProduct{
NSString *deleteSql = @"delete from product";
BOOL isSuccess = [_database executeUpdate:deleteSql];
if (!isSuccess) {
NSLog(@"delete Error:%@",[_database lastErrorMessage]);
}
}
- (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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
//?对应的是对象地址类型
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];
if (!isSuccess) {
NSLog(@"insert error:%@",[_database lastErrorMessage]);
}
}
- (void)deleteDataFromUser{
NSString *deleteSql = @"delete from product";
BOOL isSuccess = [_database executeUpdate:deleteSql];
if (!isSuccess) {
NSLog(@"delete Error:%@",[_database lastErrorMessage]);
}
}
@end
......@@ -145,7 +145,7 @@
for (UIViewController *vCtrl in controllers) {
// Normal图片命名 Tab+|subname|+Icon+@2x.png
iconImgName = [NSString stringWithFormat:@"Tab%@Icon", vCtrl.title];
iconImgName = [NSString stringWithFormat:@"Tab%@Icon", vCtrl.title];
UITabBarItem *tabBarItem =
[UITabBarItem itemWithTitle:[IBTCommon localizableString:vCtrl.title]
......
......@@ -24,7 +24,7 @@
#import "NewSurveyViewController.h"
#import "SurveyViewController.h"
#import "AddWorkSheetViewController.h"
@interface ICRHomeViewController ()
<
......@@ -143,9 +143,11 @@
break;
case kFunctionMyShop:
{
ICRStoreListViewController *sVC = [[ICRStoreListViewController alloc] initWithBHaveToChooseOne:NO];
sVC.title = [IBTCommon localizableString:@"MyStore"];
sVC.m_delegate = self;
// ICRStoreListViewController *sVC = [[ICRStoreListViewController alloc] initWithBHaveToChooseOne:NO];
// sVC.title = [IBTCommon localizableString:@"MyStore"];
// sVC.m_delegate = self;
// [self PushViewController:sVC animated:YES];
AddWorkSheetViewController *sVC = [[AddWorkSheetViewController alloc] init];
[self PushViewController:sVC animated:YES];
}
break;
......
//
// User.h
// XFFruit
//
// Created by n22 on 15/8/13.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTModel.h"
@interface User : IBTModel
@property (nonatomic,strong)NSString *uuid;//唯一标识
@property (nonatomic,strong)NSString *version;//版本号
@property (nonatomic,strong)NSDate *create_time;//创建时间
@property (nonatomic,strong)NSString *create_id;//创建人代码
@property (nonatomic,strong)NSString *create_operName;//创建人名称
@property (nonatomic,strong)NSDate *lastModify_time;//最后修改时间
@property (nonatomic,strong)NSString *lastModify_id;//最后修改人代码
@property (nonatomic,strong)NSString *lastModify_operName;//最后修改人名称
@property (nonatomic,strong)NSArray *company;//所属公司
@property (nonatomic,strong)NSString *login;//用户名
@property (nonatomic,strong)NSString *name;//用户名
@property (nonatomic,strong)NSString *password;//密码
@property (nonatomic,strong)NSString *mobile;//手机号
@property (nonatomic,strong)NSString *email;//邮箱
@property (nonatomic,assign)NSInteger *enabled;//是否启用
@property (nonatomic,strong)NSString *position;//职位
@property (nonatomic,strong)NSString *address;//地址
@property (nonatomic,strong)NSString *belongOrg;//所属组织
@property (nonatomic,strong)NSString *remark;//备注
@end
//
// User.m
// XFFruit
//
// Created by n22 on 15/8/13.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "User.h"
@implementation User
@end
......@@ -9,7 +9,7 @@
#import "ChosePersonViewController.h"
#import "MaskCell.h"
#import "SurveyUser.h"
#import "SurveyUser.h"
#import "User.h"
#define TopMargin 50
#define TableHeight 50
@interface ChosePersonViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate>
......@@ -43,7 +43,7 @@
NSArray *records = dataDict[@"records"];
if (records.count > 0) {
for (NSDictionary *recordDict in records) {
SurveyUser *user = [[SurveyUser alloc]init];
User *user = [[User alloc]init];
[user setValuesForKeysWithDictionary:recordDict];
[_dataArr addObject:user];
}
......@@ -105,10 +105,23 @@
- (void)sureClick{
NSMutableArray *arr = [[NSMutableArray alloc]init];
for (NSIndexPath *index in _indexArr) {
SurveyUser *user = _dataArr[index.row];
User *user = _dataArr[index.row];
SurveyUser * survey = [[SurveyUser alloc]init];
survey.userUuid = user.uuid;
survey.userCode = user.login;
survey.userName = user.name;
[arr addObject:survey];
}
if (arr.count == 0) {
SurveyUser *user = [[SurveyUser alloc]init];
user.userUuid = @"5a7417014e4c2928014e4dea21fb002f";
user.userName = @"栗阳";
user.userCode = @"admin";
[arr addObject:user];
self.chosePerson(arr);
}else{
self.chosePerson(arr);
}
self.chosePerson(arr);
[self PopViewControllerAnimated:YES];
}
......@@ -141,8 +154,8 @@
cell.Commitbtn.hidden = YES;
}
if (_dataArr.count > 0) {
SurveyUser *user = _dataArr[indexPath.row];
[cell setTitleStr:user.userName];
User *user = _dataArr[indexPath.row];
[cell setTitleStr:user.name];
}
return cell;
......@@ -159,8 +172,8 @@
NSString *personStr = @"";
for (NSIndexPath *index in _indexArr) {
SurveyUser *user = _dataArr[index.row];
personStr = [personStr stringByAppendingFormat:@"%@、",user.userName];
User *user = _dataArr[index.row];
personStr = [personStr stringByAppendingFormat:@"%@、",user.name];
}
_selectTextFiled.text = personStr;
}
......
......@@ -103,13 +103,15 @@ typedef enum : NSUInteger {
case SaveTag:
{
if ([self checkSurvey]) {
[self saveSurvey];
[self saveSurvey:@"initial" message:@"正在保存..."];
}
}
break;
case CommitTag:
{
if ([self checkSurvey]) {
[self saveSurvey:@"submitted" message:@"正在提交..."];
}
}
break;
default:
......@@ -129,7 +131,7 @@ typedef enum : NSUInteger {
#pragma mark - 保存
- (void)saveSurvey
- (void)saveSurvey:(NSString *)state message:(NSString *)msg
{
//保存
void(^succ)(id) = ^(id data) {
......@@ -139,6 +141,8 @@ typedef enum : NSUInteger {
NSString *message = data[@"message"];
if (success == 1) {
//成功
[IBTLoadingView showTips:@"操作成功"];
}else{
[IBTLoadingView showTips:message];
}
......@@ -148,9 +152,17 @@ typedef enum : NSUInteger {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
NSDictionary *dict = @{@"uuid":@"",@"billnumber":@"",@"title":self.surveyTitle,@"productUuid":self.productUuid,@"productCode":self.productCode,@"productName":self.productName,@"beginDate":self.beginDate,@"endDate":self.endDate,@"remark":self.remark,@"users":self.users};
[IBTLoadingView showProgressLabel:@"正在保存..."];
NSDictionary *dict = @{@"billnumber":@"",
@"title":self.surveyTitle,
@"state":state,
@"productUuid":self.productUuid,
@"productCode":self.productCode,
@"productName":self.productName,
@"beginDate":self.beginDate,
@"endDate":self.endDate,
@"remark":self.remark,
@"users":self.users};
[IBTLoadingView showProgressLabel:msg];
[[ICRHTTPController sharedController] saveSurveyWithAuthenticode:dict success:succ failure:fail];
}
......
......@@ -52,7 +52,7 @@ typedef enum : NSUInteger {
- (void)initData{
_dataArr = [NSMutableArray array];
//保存
//查询
void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
NSLog(@"%@",data);
......@@ -61,9 +61,22 @@ typedef enum : NSUInteger {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
[IBTLoadingView showProgressLabel:@"正在保存..."];
[[ICRHTTPController sharedController] querySurveyWithBillNUmberLinke:@"fdsfds" state:@"initial" titleLike:@"fds" orderFiled:@"fdsafds" orderDirection:@"asc" page_number:1 page_size:10 success:succ failure:fail];
[[ICRHTTPController sharedController] getResultsWithSurveyUuid:@"111" success:succ failure:fail];
[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",
@"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];
......@@ -123,6 +136,7 @@ typedef enum : NSUInteger {
#pragma mark -按钮事件
- (void)sortClick:(UIButton *)btn{
_maskView.backgroundColor = RGBA(0, 0, 0, 0.5);
_maskView.hidden = NO;
if (btn.tag == SortTag) {
if(_boltView){
......@@ -134,7 +148,7 @@ typedef enum : NSUInteger {
currentBtn = nil;
self.navigationItem.rightBarButtonItem = nil;
}else{
[btn setImage:[UIImage imageNamed:@"select_arrow_up"] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:@"select_arrow_up_text"] forState:UIControlStateNormal];
if (_sortView == nil) {
_sortView = [[SortMaskView alloc]initWithFrame:CGRectMake(0, -105, ScreenSize.width, 105)];
_sortView.dataArr = [[NSMutableArray alloc]initWithObjects:@"默认排序",@"默认排序",@"默认排序" ,nil];
......@@ -190,6 +204,7 @@ typedef enum : NSUInteger {
CGRect sortFrame = _sortView.frame;
sortFrame.origin.y = -105;
_sortView.frame = sortFrame;
_maskView.backgroundColor = RGBA(0, 0, 0, 0);
}completion:^(BOOL finished) {
[_sortView removeFromSuperview];
_sortView = nil;
......@@ -207,6 +222,7 @@ typedef enum : NSUInteger {
CGRect sortFrame = _boltView.frame;
sortFrame.origin.y = -105;
_boltView.frame = sortFrame;
_maskView.backgroundColor = RGBA(0, 0, 0, 0);
}completion:^(BOOL finished) {
[_boltView removeFromSuperview];
_boltView = nil;
......
......@@ -10,7 +10,29 @@
@interface Product : IBTModel
@property (nonatomic,strong)NSString *uuid;//商品uuid
@property (nonatomic,strong)NSString *code;//商品代码
@property (nonatomic,strong)NSString *code;//代码
@property (nonatomic,strong)NSString *secondCode;//第二代码
@property (nonatomic,strong)NSString *name;//名称
@property (nonatomic,strong)NSString *qpc;//默认规格
@property (nonatomic,strong)NSString *qpcStr;//默认规格说明
@property (nonatomic,strong)NSString *measureUnit;//默认规格单位
@property (nonatomic,strong)NSString *brandName;//品牌名称
@property (nonatomic,strong)NSString *name;//品牌名称
@property (nonatomic,strong)NSString *manufactory;//生产厂商
@property (nonatomic,strong)NSString *isNew;//是否新品
@property (nonatomic,strong)NSString *categoryUuid;//所属商品类别
@property (nonatomic,strong)NSString *image;//图片相对路径
@property (nonatomic,strong)NSDate *create_time;//创建时间
@property (nonatomic,strong)NSString *create_id;//创建人代码
@property (nonatomic,strong)NSString *create_operName;//创建人名称
@property (nonatomic,strong)NSDate *lastModify_time;//最后修改时间
@property (nonatomic,strong)NSString *lastModify_id;//最后修改人代码
@property (nonatomic,strong)NSString *lastModify_operName;//最后修改人名称
@property (nonatomic,assign)NSInteger enabled;//是否启用
@property (nonatomic,strong)NSString *barcode;
@property (nonatomic,strong)NSString *enterprise;
@property (nonatomic,strong)NSString *remark;
@property (nonatomic,strong)NSString *specification;
@property (nonatomic,strong)NSString *version;
@end
//
// AddWorkSheetViewController.h
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
// 新建加工单
#import "ICRBaseViewController.h"
@interface AddWorkSheetViewController : ICRBaseViewController
@end
//
// AddWorkSheetViewController.m
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "AddWorkSheetViewController.h"
#import "TopSheetView.h"
#define TopHeight 284
#define BottomHeight 300
#define SpaceHeight 20
#define ContentHeight 44
#define BeginTag 7000
#define SpaceWidth 20
#define BtnWidth (ScreenSize.width - 20*4)/3
@interface AddWorkSheetViewController ()<TopSheetViewDelegate,UIScrollViewDelegate>
{
UIScrollView *_scrollView;
TopSheetView *_sheetView;
UIView *_bottomView;
UIScrollView *_bottomSV;
UIImageView *_moveImageView;
}
@end
@implementation AddWorkSheetViewController
- (void)viewDidLoad {
[super viewDidLoad];
//布局
[self bulidLayout];
}
- (void)bulidLayout{
self.view.backgroundColor = XXFBgColor;
_scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,0, ScreenSize.width, ScreenSize.height- 64)];
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.contentSize = CGSizeMake(ScreenSize.width, TopHeight+ BottomHeight + SpaceHeight*2);
[self.view addSubview:_scrollView];
_sheetView = [[TopSheetView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, TopHeight)];
_sheetView.delegate = self;
[_scrollView addSubview:_sheetView];
_bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_sheetView.frame) + 20, ScreenSize.width,BottomHeight)];
_bottomView.backgroundColor = [UIColor whiteColor];
[_scrollView addSubview:_bottomView];
[self createBottomView];
}
- (void)createBottomView{
NSArray *arr = @[@"原料明细",@"成品明细",@"费用明细"];
_bottomSV = [[UIScrollView alloc]initWithFrame:CGRectMake(0,ContentHeight + 4, ScreenSize.width, CGRectGetHeight(_bottomView.frame) - ContentHeight-2 )];
_bottomSV.showsHorizontalScrollIndicator = NO;
_bottomSV.showsVerticalScrollIndicator = NO;
_bottomSV.pagingEnabled = YES;
_bottomSV.delegate = self;
_bottomSV.backgroundColor = [UIColor yellowColor];
_bottomSV.contentSize = CGSizeMake(ScreenSize.width * arr.count, CGRectGetHeight(_bottomSV.frame));
[_bottomView addSubview:_bottomSV];
for (NSInteger i = 0; i < arr.count; i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
[btn setTitle:arr[i] forState:UIControlStateNormal];
btn.frame = CGRectMake(SpaceWidth + (BtnWidth+SpaceWidth) * i, 0, BtnWidth, ContentHeight);
[btn setTitleColor:HexColor(@"444444") forState:UIControlStateNormal];
btn.titleLabel.font = FontSize(16);
btn.tag = i + BeginTag;
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
[_bottomView addSubview:btn];
UIView *image = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetWidth(_bottomSV.frame) * i, 0, CGRectGetWidth(_bottomSV.frame), CGRectGetHeight(_bottomSV.frame))];
if (i == 0) {
image.backgroundColor = [UIColor redColor];
}else if(i == 1){
image.backgroundColor = [UIColor blackColor];
}else if(i == 2){
image.backgroundColor = [UIColor blueColor];
}
[_bottomSV addSubview:image];
}
_moveImageView = [[UIImageView alloc]initWithFrame:CGRectMake(SpaceWidth, ContentHeight, BtnWidth,4)];
_moveImageView.image = [UIImage imageNamed:@"tab_line"];
[_bottomView addSubview:_moveImageView];
}
- (void)btnClick:(UIButton *)btn{
NSInteger index = btn.tag - BeginTag;
[UIView animateWithDuration:0.5 animations:^{
CGRect moveFrame = _moveImageView.frame;
moveFrame.origin.x = SpaceWidth + (BtnWidth+SpaceWidth) * index;
_moveImageView.frame = moveFrame;
}];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
if (scrollView == _bottomSV) {
CGFloat index = _bottomSV.contentOffset.x / _bottomSV.frame.size.width;
}
}
#pragma mark - 协议方法
- (void)hiddenKeyBoard{
[self keyboardHidden];
}
- (void)keyboardHidden{
[_sheetView.titleTextFiled resignFirstResponder];
[_sheetView.peopleTextFiled resignFirstResponder];
[_sheetView.peopleTextFiled resignFirstResponder];
[_sheetView.phoneTextFiled resignFirstResponder];
[_sheetView.remarkTextView resignFirstResponder];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
//
// TopSheetView.h
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "HPGrowingTextView.h"
@protocol TopSheetViewDelegate <NSObject>
- (void)hiddenKeyBoard;
@end
@interface TopSheetView : UIView
@property (nonatomic,strong)UITextField *titleTextFiled;//标题
@property (nonatomic,strong)NSString *supplier;//供应商
@property (nonatomic,strong)UITextField *peopleTextFiled;//联系人
@property (nonatomic,strong)UITextField *phoneTextFiled;//电话
@property (nonatomic,strong)NSString *factory;//标题
@property (nonatomic,strong)HPGrowingTextView *remarkTextView;//标题
@property (nonatomic,strong)UIButton *factoryBtn;
@property (nonatomic,strong)UIButton *supplierBtn;
@property (nonatomic,strong)UILabel *factoryLabel;
@property (nonatomic,strong)UILabel *supplierLabel;
@property (nonatomic,weak)id <TopSheetViewDelegate>delegate;
@end
//
// TopSheetView.m
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "TopSheetView.h"
#import "SurveyCell.h"
#define LeftMargin 15
#define TopMargin 20
#define LeftWidth 80
#define TableHeight 44
#define SpaceHeight 10
#define TitleSize 16
@interface TopSheetView ()<UITableViewDataSource,UITableViewDelegate,HPGrowingTextViewDelegate,UITextFieldDelegate>
{
UITableView *_tableView;
NSMutableArray *_dataArr;
}
@end
@implementation TopSheetView
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
//界面
[self bulidLayout];
}
return self;
}
#pragma mark - 布局
- (void)bulidLayout
{
self.backgroundColor = XXFBgColor;
_dataArr = [NSMutableArray array];
NSArray *arr = @[@"标题:",@"供应商:",@"联系人:",@"联系电话:",@"加工工厂:",@"备注:"];
[_dataArr addObjectsFromArray:arr];
_tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,self.frame.size.width, self.frame.size.height - TopMargin)) style:(UITableViewStylePlain)];
_tableView.backgroundColor = [UIColor whiteColor];
_tableView.bounces = NO;
_tableView.delegate = self;
_tableView.dataSource = self;
[self addSubview:_tableView];
}
#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"cellID";
SurveyCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[SurveyCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (indexPath.row ==1 || indexPath.row == 4) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
[self createViewInCell:cell indexPath:indexPath];
}
[cell setTitleStr:_dataArr[indexPath.row]];
return cell;
}
- (void)createViewInCell:(SurveyCell *)cell indexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0 || indexPath.row == 2 || indexPath.row == 3) {
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-10, TableHeight)];
textField.textAlignment = NSTextAlignmentRight;
textField.textColor = HexColor(@"444444");
textField.font = FontSize(15);
textField.returnKeyType = UIReturnKeyDone;
textField.delegate = self;
[cell.contentView addSubview:textField];
if (indexPath.row == 0) {
self.titleTextFiled = textField;
self.titleTextFiled.placeholder = @"请输入标题";
}else if(indexPath.row == 2){
self.peopleTextFiled = textField;
self.peopleTextFiled.placeholder = @"请输入联系人";
}else if(indexPath.row == 3){
self.phoneTextFiled = textField;
self.phoneTextFiled.placeholder = @"请输入联系人手机";
}
}else if (indexPath.row == _dataArr.count -1){
self.remarkTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-10, TableHeight)];
self.remarkTextView.contentInset = UIEdgeInsetsMake(5, 5, 5, 0);
self.remarkTextView.minNumberOfLines = 1;
self.remarkTextView.maxNumberOfLines = 2;
self.remarkTextView.font = FontSize(15);
self.remarkTextView.textAlignment = NSTextAlignmentRight;
self.remarkTextView.delegate = self;
self.remarkTextView.returnKeyType = UIReturnKeyDone;
self.remarkTextView.placeholder = @"输入备注内容";
[cell.contentView addSubview:self.remarkTextView];
}else{
UILabel *contentLabel = [[UILabel alloc]initWithFrame:(CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-10, TableHeight))];
contentLabel.textAlignment= NSTextAlignmentRight;
contentLabel.textColor = HexColor(@"bbbbbb");
contentLabel.font = FontSize(TitleSize);
[cell.contentView addSubview:contentLabel];
if (indexPath.row == 1) {
contentLabel.text = @"选择供应商";
self.supplierLabel = contentLabel;
}else if(indexPath.row == 4){
contentLabel.text = @"选择加工工厂";
self.factoryLabel = contentLabel;
}
}
}
- (BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView{
[self.remarkTextView resignFirstResponder];
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[self.delegate hiddenKeyBoard];
return YES;
}
@end
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