Commit 8938ec94 authored by 陈俊俊's avatar 陈俊俊

发运单

parent e12f0d4c
This diff is collapsed.
...@@ -1721,8 +1721,8 @@ acceptTypeJson:YES ...@@ -1721,8 +1721,8 @@ acceptTypeJson:YES
fail( error ); fail( error );
} }
}; };
NSString *dateStr = [[NSDate date] httpParameterString]; // NSString *dateStr = [[NSDate date] httpParameterString];
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:urlAction] stringByAppendingFormat:@"?startDate=%@&pageNumber=%@&pageSize=%@", dateStr,@(page_number),@(page_size)]; NSString *urlStr = [[[self class] UrlForPluginHTTPAction:urlAction] stringByAppendingFormat:@"?startDate=%@&pageNumber=%@&pageSize=%@", @"2015-05-06",@(page_number),@(page_size)];
NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
if (isPost) { if (isPost) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "MaskCell.h" #import "MaskCell.h"
#import "MJRefresh.h" #import "MJRefresh.h"
typedef void(^ChoseBaseInfo)(NSArray *baseInfos);
@interface ChooseParentViewController : ICRBaseViewController @interface ChooseParentViewController : ICRBaseViewController
...@@ -19,10 +20,15 @@ ...@@ -19,10 +20,15 @@
@property (nonatomic,strong)NSMutableArray *indexArr; @property (nonatomic,strong)NSMutableArray *indexArr;
@property (nonatomic,strong)UITableView *tableView; @property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)UITextField *selectTextFiled; @property (nonatomic,strong)UITextField *selectTextFiled;
@property (nonatomic,strong)NSIndexPath *currentIndexPath;
@property (nonatomic,strong)NSString *tableStr;
@property (nonatomic,assign) BOOL isRefresh; @property (nonatomic,assign) BOOL isRefresh;
@property (nonatomic,copy)ChoseBaseInfo choseBaseInfo;
- (void)endRefreshing; - (void)endRefreshing;
- (void)getBaseDataFromServer; - (void)getBaseDataFromServer;
- (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath; - (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath;
- (void)deleteTextFieldStr; - (void)deleteTextFieldStr;
- (void)fetchDataList:(NSString *)titleStr tableStr:(NSString *)tableStr;
- (void)tableViewRefresh;
@end @end
...@@ -86,6 +86,27 @@ ...@@ -86,6 +86,27 @@
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
return cell; return cell;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
return;
}
if (self.isMoreChose == YES) {
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
if (![self isHaveIndexPath:indexPath]) {
cell.Commitbtn.hidden = NO;
[self.indexArr addObject:indexPath];
}else{
cell.Commitbtn.hidden = YES;
[self.indexArr removeObject:indexPath];
}
}else{
MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:self.currentIndexPath];
currentCell.Commitbtn.hidden = YES;
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO;
self.currentIndexPath = indexPath;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return TableHeight; return TableHeight;
...@@ -93,9 +114,7 @@ ...@@ -93,9 +114,7 @@
- (void)keyboardHidden{ - (void)keyboardHidden{
[self.selectTextFiled resignFirstResponder]; [self.selectTextFiled resignFirstResponder];
} }
- (void)deleteTextFieldStr{
self.selectTextFiled.text = @"";
}
#pragma mark - 结束刷新 #pragma mark - 结束刷新
- (void)endRefreshing{ - (void)endRefreshing{
self.isRefresh = NO; self.isRefresh = NO;
...@@ -110,17 +129,77 @@ ...@@ -110,17 +129,77 @@
} }
return NO; return NO;
} }
- (void)deleteTextFieldStr{
self.selectTextFiled.text = @"";
[self boxValueChanged:nil];
}
#pragma mark - 按钮事件
- (void)boxValueChanged:(NSNotification *)fication{
// NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text];
// [self fetchDataList:tilkeStr];
}
- (void)tableViewRefresh{
self.currentIndexPath = nil;
if (self.indexArr.count > 0) {
[self.indexArr removeAllObjects];
}
[self.tableView reloadData];
}
- (void)fetchDataList:(NSString *)titleStr tableStr:(NSString *)tableStr{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = @"";
if (titleStr.length > 0) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE NAME LIKE '%%%@%%' ORDER BY %@", tableStr,titleStr, @"uuid"];
}else{
sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@", tableStr, @"uuid"];
}
return [db executeQuery:sql];
};
__weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (![GXF_NSUSERFEFTAULTS objectForKey:self.tableView.header.lastUpdatedTimeKey]) {
[GXF_NSUSERFEFTAULTS setObject:[NSDate date] forKey:self.tableView.header.lastUpdatedTimeKey];
[GXF_NSUSERFEFTAULTS synchronize];
[self getBaseDataFromServer];
}else{
[strongSelf.dataArr removeAllObjects];
[strongSelf.dataArr addObject:self.tableView.header.lastUpdatedTime];
[strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[self tableViewRefresh];
}
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:NSClassFromString(tableStr)
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
}
#pragma mark -成功
- (void)sureClick{
if (self.isMoreChose) {
NSMutableArray *arr = [[NSMutableArray alloc]init];
for (NSIndexPath *index in self.indexArr) {
[arr addObject:self.dataArr[index.row]];
}
self.choseBaseInfo(arr);
}else{
NSMutableArray *arr = [[NSMutableArray alloc]init];
if (self.dataArr.count > 0) {
if (self.currentIndexPath) {
[arr addObject:self.dataArr[self.currentIndexPath.row]];
self.choseBaseInfo(arr);
}
}
}
[self PopViewControllerAnimated:YES];
}
#pragma mark -childFunction #pragma mark -childFunction
-(void)getBaseDataFromServer -(void)getBaseDataFromServer
{ {
} }
- (void)sureClick
{
}
- (void)boxValueChanged:(NSNotification *)fication
{
}
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#define XFFruit_ICRNotificationMacro_h #define XFFruit_ICRNotificationMacro_h
#define SetProductTotalPrice @"setProductTotalPrice" #define SetProductTotalPrice @"setProductTotalPrice"
#define KNOTIFICATION_getSelectPurchaseProduct @"KNOTIFICATION_getSelectPurchaseProduct"
#define KNOTIFICATION_changeIsSelectedFunctions @"KNOTIFICATION_changeIsSelectedFunctions" #define KNOTIFICATION_changeIsSelectedFunctions @"KNOTIFICATION_changeIsSelectedFunctions"
......
...@@ -128,12 +128,14 @@ ...@@ -128,12 +128,14 @@
//采购单状态 //采购单状态
#define PURCHASE_STATE_INITIAL @"initial" #define PURCHASE_STATE_INITIAL @"initial" //未提交
#define PURCHASE_STATE_SUBMITTED @"submitted" #define PURCHASE_STATE_SUBMITTED @"submitted"//已提交
#define PURCHASE_STATE_REJECTED @"rejected" #define PURCHASE_STATE_REJECTED @"rejected" //已拒绝
#define PURCHASE_STATE_APPROVED @"approved" #define PURCHASE_STATE_APPROVED @"approved" //已审批
#define PURCHASE_STATE_SHIPPING @"shipping" #define PURCHASE_STATE_SHIPPING @"shipping" //发运中
#define PURCHASE_STATE_FINISHED @"finished" #define PURCHASE_STATE_FINISHED @"finished" //已完成
#define PURCHASE_STATE_ABORTED @"aborted" //已作废
//采购单操作 //采购单操作
#define PURCHASE_ACTION_REJECT @"reject" #define PURCHASE_ACTION_REJECT @"reject"
...@@ -155,4 +157,11 @@ ...@@ -155,4 +157,11 @@
#define GXF_Critical @"critical"//紧急 #define GXF_Critical @"critical"//紧急
#define GXF_Normal @"normal"//普通 #define GXF_Normal @"normal"//普通
#define GXF_BASECLASS_WAREHOUSE @"Warehouse"
#define GXF_BASECLASS_VENDOR @"Vendor"
#define GXF_BASECLASS_PRODUCT @"Product"
#define GXF_BASECLASS_USER @"User"
#endif #endif
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#import "NewPurchaseViewController.h" #import "NewPurchaseViewController.h"
#import "PurchaseViewController.h" #import "PurchaseViewController.h"
#import "NewTransportViewController.h"
@interface BusinessViewController ()<ICRFunctionBaseViewDelegate> @interface BusinessViewController ()<ICRFunctionBaseViewDelegate>
...@@ -171,12 +172,12 @@ ...@@ -171,12 +172,12 @@
break; break;
// case kFunctionTaskManagement://任务管理 case kFunctionNewShipment://任务管理
// { {
// ICRTaskListViewController *tVC = [[ICRTaskListViewController alloc] init]; NewTransportViewController *tVC = [[NewTransportViewController alloc] init];
// [self PushViewController:tVC animated:YES]; [self PushViewController:tVC animated:YES];
// } }
// break; break;
// case kFunctionPatrolPlan://巡店计划 // case kFunctionPatrolPlan://巡店计划
// { // {
// ICRPatrolPlanViewController *pVC = [[ICRPatrolPlanViewController alloc] initWithStore:nil isHomeShow:YES]; // ICRPatrolPlanViewController *pVC = [[ICRPatrolPlanViewController alloc] initWithStore:nil isHomeShow:YES];
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
// //
#import "ChooseParentViewController.h" #import "ChooseParentViewController.h"
typedef void(^ChoseType)(NSString *type);
@interface ChooseTypeViewController : ChooseParentViewController @interface ChooseTypeViewController : ChooseParentViewController
@property (nonatomic,copy)ChoseType choseType;
@end @end
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#define TableHeight 50 #define TableHeight 50
@interface ChooseTypeViewController () @interface ChooseTypeViewController ()
{ {
NSIndexPath *_currentIndexPath;
} }
@end @end
...@@ -23,19 +22,10 @@ ...@@ -23,19 +22,10 @@
self.title = @"类型"; self.title = @"类型";
[self.dataArr addObject:@"紧急"]; [self.dataArr addObject:@"紧急"];
[self.dataArr addObject:@"普通"]; [self.dataArr addObject:@"普通"];
self.selectTextFiled = nil;
self.tableView.frame = CGRectMake(0, 5, ScreenSize.width, ScreenSize.height - 64 - 5);
} }
- (void)createRefresh{} - (void)createRefresh{}
- (void)sureClick{
if (self.dataArr.count > 0) {
if (_currentIndexPath) {
NSString *type = self.dataArr[_currentIndexPath.row];
self.choseType(type);
}
}
[self PopViewControllerAnimated:YES];
}
#pragma mark - 协议方法 #pragma mark - 协议方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...@@ -48,8 +38,8 @@ ...@@ -48,8 +38,8 @@
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
} }
if (_currentIndexPath) { if (self.currentIndexPath) {
if (indexPath.row == _currentIndexPath.row) { if (indexPath.row == self.currentIndexPath.row) {
cell.Commitbtn.hidden = NO; cell.Commitbtn.hidden = NO;
}else{ }else{
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
...@@ -63,17 +53,13 @@ ...@@ -63,17 +53,13 @@
} }
return cell; return cell;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:self.currentIndexPath];
MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath]; currentCell.Commitbtn.hidden = YES;
currentCell.Commitbtn.hidden = YES; MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath]; cell.Commitbtn.hidden = NO;
cell.Commitbtn.hidden = NO; self.currentIndexPath = indexPath;
_currentIndexPath = indexPath;
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
// //
#import "ChooseParentViewController.h" #import "ChooseParentViewController.h"
typedef void(^ChoseVendor)(NSArray *vendor);
@interface ChooseVendorViewController : ChooseParentViewController @interface ChooseVendorViewController : ChooseParentViewController
@property (nonatomic,copy)ChoseVendor choseVendor;
@end @end
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#define TableHeight 50 #define TableHeight 50
@interface ChooseVendorViewController () @interface ChooseVendorViewController ()
{ {
NSIndexPath *_currentIndexPath;
} }
@end @end
...@@ -24,11 +23,9 @@ ...@@ -24,11 +23,9 @@
//记录更新时间 //记录更新时间
self.tableView.header.lastUpdatedTimeKey = ChooseVendorUpdateDate; self.tableView.header.lastUpdatedTimeKey = ChooseVendorUpdateDate;
self.title = @"选择供应商"; self.title = @"选择供应商";
[self fetchVendorList:@""]; [self fetchDataList:@"" tableStr:GXF_BASECLASS_VENDOR];
} }
- (void)getBaseDataFromServer{ - (void)getBaseDataFromServer{
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) { void(^succ)(id) = ^(id data) {
...@@ -36,7 +33,7 @@ ...@@ -36,7 +33,7 @@
if (data) { if (data) {
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf endRefreshing]; [strongSelf endRefreshing];
[strongSelf fetchVendorList:@""]; [strongSelf fetchDataList:@"" tableStr:GXF_BASECLASS_VENDOR];
}else{ }else{
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
} }
...@@ -48,66 +45,6 @@ ...@@ -48,66 +45,6 @@
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getVendorWithPage_number:0 page_size:100 success:succ failure:fail]; [[ICRHTTPController sharedController] getVendorWithPage_number:0 page_size:100 success:succ failure:fail];
} }
#pragma mark -成功
- (void)fetchVendorList:(NSString *)titleStr{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = @"";
if (titleStr.length > 0) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE NAME LIKE '%%%@%%' ORDER BY %@", [Vendor TableName],titleStr, @"uuid"];
}else{
sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@", [Vendor TableName], @"uuid"];
}
return [db executeQuery:sql];
};
__weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (![GXF_NSUSERFEFTAULTS objectForKey:ChooseVendorUpdateDate]) {
[GXF_NSUSERFEFTAULTS setObject:[NSDate date] forKey:ChooseVendorUpdateDate];
[GXF_NSUSERFEFTAULTS synchronize];
[self getBaseDataFromServer];
}else{
[strongSelf.dataArr removeAllObjects];
[strongSelf.dataArr addObject:self.tableView.header.lastUpdatedTime];
[strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[self tableViewRefresh];
}
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[Vendor class]
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
}
- (void)sureClick{
if (self.isMoreChose) {
NSMutableArray *arr = [[NSMutableArray alloc]init];
for (NSIndexPath *index in self.indexArr) {
Vendor *vendor = self.dataArr[index.row];
[arr addObject:vendor];
}
self.choseVendor(arr);
}else{
NSMutableArray *arr = [[NSMutableArray alloc]init];
if (self.dataArr.count > 0) {
Vendor *vendor = self.dataArr[_currentIndexPath.row];
[arr addObject:vendor];
self.choseVendor(arr);
}
}
[self PopViewControllerAnimated:YES];
}
- (void)deleteTextFieldStr {
[super deleteTextFieldStr];
[self boxValueChanged:nil];
}
#pragma mark - 协议方法 #pragma mark - 协议方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"MaskCell"; static NSString *cellID = @"MaskCell";
...@@ -119,14 +56,14 @@ ...@@ -119,14 +56,14 @@
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
} }
if (self.isMoreChose) { if (self.isMoreChose) {
if ([self hasIndexPath:indexPath]) { if ([self isHaveIndexPath:indexPath]) {
cell.Commitbtn.hidden = NO; cell.Commitbtn.hidden = NO;
}else{ }else{
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
} }
}else{ }else{
if (_currentIndexPath) { if (self.currentIndexPath) {
if (indexPath.row == _currentIndexPath.row) { if (indexPath.row == self.currentIndexPath.row) {
cell.Commitbtn.hidden = NO; cell.Commitbtn.hidden = NO;
}else{ }else{
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
...@@ -148,52 +85,10 @@ ...@@ -148,52 +85,10 @@
} }
return cell; return cell;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
return;
}
if (self.isMoreChose == YES) {
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO;
if (![self hasIndexPath:indexPath]) {
[self.indexArr addObject:indexPath];
}
}else{
MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath];
currentCell.Commitbtn.hidden = YES;
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO;
_currentIndexPath = indexPath;
}
}
- (BOOL)hasIndexPath:(NSIndexPath *)indexPath{
for (NSIndexPath *path in self.indexArr) {
if (path.row == indexPath.row) {
return YES;
}
}
return NO;
}
#pragma mark - 按钮事件
- (void)boxValueChanged:(NSNotification *)fication{ - (void)boxValueChanged:(NSNotification *)fication{
NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text]; NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text];
[self fetchVendorList:tilkeStr]; [self fetchDataList:tilkeStr tableStr:GXF_BASECLASS_VENDOR];
}
- (void)tableViewRefresh{
_currentIndexPath = nil;
if (self.indexArr.count > 0) {
[self.indexArr removeAllObjects];
}
[self.tableView reloadData];
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
#import "ChooseParentViewController.h" #import "ChooseParentViewController.h"
#import "Warehouse.h" #import "Warehouse.h"
typedef void(^ChoseWarehouse)(Warehouse *warehouse);
@interface ChooseWarehouseViewController : ChooseParentViewController @interface ChooseWarehouseViewController : ChooseParentViewController
@property (nonatomic,copy)ChoseWarehouse choseWarehouse;
@end @end
...@@ -10,10 +10,7 @@ ...@@ -10,10 +10,7 @@
#define TopMargin 50 #define TopMargin 50
#define TableHeight 50 #define TableHeight 50
@interface ChooseWarehouseViewController () @interface ChooseWarehouseViewController ()
{
NSIndexPath *_currentIndexPath;
}
@end @end
@implementation ChooseWarehouseViewController @implementation ChooseWarehouseViewController
...@@ -23,7 +20,7 @@ ...@@ -23,7 +20,7 @@
//记录更新时间 //记录更新时间
self.tableView.header.lastUpdatedTimeKey = ChooseWarehouseUpdateDate; self.tableView.header.lastUpdatedTimeKey = ChooseWarehouseUpdateDate;
self.title = @"选择仓库"; self.title = @"选择仓库";
[self fetchWarehouseList:@""]; [self fetchDataList:@"" tableStr:GXF_BASECLASS_WAREHOUSE];
} }
- (void)getBaseDataFromServer{ - (void)getBaseDataFromServer{
...@@ -33,7 +30,7 @@ ...@@ -33,7 +30,7 @@
if (data) { if (data) {
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf)strongSelf = weakSelf;
[self endRefreshing]; [self endRefreshing];
[strongSelf fetchWarehouseList:@""]; [strongSelf fetchDataList:@"" tableStr:GXF_BASECLASS_WAREHOUSE];
}else{ }else{
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
} }
...@@ -47,56 +44,6 @@ ...@@ -47,56 +44,6 @@
[[ICRHTTPController sharedController] getWarehouseWithPage_number:0 page_size:100 success:succ failure:fail]; [[ICRHTTPController sharedController] getWarehouseWithPage_number:0 page_size:100 success:succ failure:fail];
} }
#pragma mark -成功
- (void)fetchWarehouseList:(NSString *)titleStr{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = @"";
if (titleStr.length > 0) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE NAME LIKE '%%%@%%' ORDER BY %@", [Warehouse TableName],titleStr, @"uuid"];
}else{
sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@", [Warehouse TableName], @"uuid"];
}
return [db executeQuery:sql];
};
__weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (![GXF_NSUSERFEFTAULTS objectForKey:ChooseWarehouseUpdateDate]) {
[GXF_NSUSERFEFTAULTS setObject:[NSDate date] forKey:ChooseWarehouseUpdateDate];
[GXF_NSUSERFEFTAULTS synchronize];
[self getBaseDataFromServer];
}else{
[strongSelf.dataArr removeAllObjects];
[strongSelf.dataArr addObject:self.tableView.header.lastUpdatedTime];
[strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[self tableViewRefresh];
}
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[Warehouse class]
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
}
- (void)sureClick{
if (self.dataArr.count > 0) {
if (_currentIndexPath) {
Warehouse *warehouse = self.dataArr[_currentIndexPath.row];
self.choseWarehouse(warehouse);
}
}
[self PopViewControllerAnimated:YES];
}
- (void)deleteTextFieldStr {
[super deleteTextFieldStr];
}
#pragma mark - 协议方法 #pragma mark - 协议方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"MaskCell"; static NSString *cellID = @"MaskCell";
...@@ -108,8 +55,8 @@ ...@@ -108,8 +55,8 @@
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
} }
if (_currentIndexPath) { if (self.currentIndexPath) {
if (indexPath.row == _currentIndexPath.row) { if (indexPath.row == self.currentIndexPath.row) {
cell.Commitbtn.hidden = NO; cell.Commitbtn.hidden = NO;
}else{ }else{
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
...@@ -132,29 +79,12 @@ ...@@ -132,29 +79,12 @@
return cell; return cell;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath];
currentCell.Commitbtn.hidden = YES;
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO;
_currentIndexPath = indexPath;
}
#pragma mark - 按钮事件
- (void)boxValueChanged:(NSNotification *)fication{ - (void)boxValueChanged:(NSNotification *)fication{
NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text]; NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text];
[self fetchWarehouseList:tilkeStr]; [self fetchDataList:tilkeStr tableStr:GXF_BASECLASS_WAREHOUSE];
}
- (void)tableViewRefresh{
_currentIndexPath = nil;
if (self.indexArr.count > 0) {
[self.indexArr removeAllObjects];
}
[self.tableView reloadData];
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
......
...@@ -83,7 +83,7 @@ typedef enum : NSUInteger { ...@@ -83,7 +83,7 @@ typedef enum : NSUInteger {
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getPurchaseResultWithPurchaseUuid:@"5a7417014f926eb5014f9ce2988a004d" success:succ failure:fail]; [[ICRHTTPController sharedController] getPurchaseResultWithPurchaseUuid:self.purchaseBill.uuid success:succ failure:fail];
} }
//赋值 //赋值
- (void)prepareDataInCell{ - (void)prepareDataInCell{
...@@ -211,7 +211,7 @@ typedef enum : NSUInteger { ...@@ -211,7 +211,7 @@ typedef enum : NSUInteger {
for (PurchaseBillProduct *billProduct in _pvc.productArr) { for (PurchaseBillProduct *billProduct in _pvc.productArr) {
[billProducts addObject:[billProduct dictForCommit]]; [billProducts addObject:[billProduct dictForCommit]];
} }
self.state = state;
NSDictionary *dict = @{@"uuid":uuidObject, NSDictionary *dict = @{@"uuid":uuidObject,
@"version":versionObject, @"version":versionObject,
@"billnumber":billNumberObject, @"billnumber":billNumberObject,
...@@ -274,6 +274,13 @@ typedef enum : NSUInteger { ...@@ -274,6 +274,13 @@ typedef enum : NSUInteger {
[_purchaseView.otherPriceFiled resignFirstResponder]; [_purchaseView.otherPriceFiled resignFirstResponder];
[_purchaseView.remarkTextView resignFirstResponder]; [_purchaseView.remarkTextView resignFirstResponder];
} }
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
if(self.purchaseBill && [self.state isEqualToString:PURCHASE_STATE_INITIAL]){
[ICRUserUtil sharedInstance].needFresh = YES;
}
}
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
......
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
#import "ICRBaseViewController.h" #import "ICRBaseViewController.h"
@interface ProductBillViewController: ICRBaseViewController @interface ProductBillViewController: ICRBaseViewController
@property (nonatomic,strong)NSMutableArray *productArr; @property (nonatomic,strong)NSMutableArray *productArr;
@property (nonatomic,strong)UITableView *tableView; @property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,assign)CGRect viewFrame; @property (nonatomic,assign)CGRect viewFrame;
@property (nonatomic,assign)BOOL isHiddenEdit; @property (nonatomic,assign)BOOL isHiddenEdit;
@property (nonatomic,strong)NSString *twoTitle;
@end @end
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#import "ProductBillCell.h" #import "ProductBillCell.h"
#import "PurchaseBillProduct.h" #import "PurchaseBillProduct.h"
#define TableHeight 44 #define TableHeight 44
#define ShowHeight 100 #define ShowHeight 110
@interface ProductBillViewController ()<UITableViewDataSource,UITableViewDelegate,FooterCellDelegate> @interface ProductBillViewController ()<UITableViewDataSource,UITableViewDelegate,FooterCellDelegate>
{ {
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
billProduct.price = [NSNumber numberWithFloat:333]; billProduct.price = [NSNumber numberWithFloat:333];
billProduct.baseQty = [NSNumber numberWithFloat:333]; billProduct.baseQty = [NSNumber numberWithFloat:333];
billProduct.basePrice = [NSNumber numberWithFloat:33]; billProduct.basePrice = [NSNumber numberWithFloat:33];
billProduct.total = [NSNumber numberWithFloat:40]; billProduct.total = [NSNumber numberWithFloat:80];
billProduct.remark = @"hshshshsh"; billProduct.remark = @"hshshshsh";
billProduct.qpcStr = @"fdsfdsfdsa"; billProduct.qpcStr = @"fdsfdsfdsa";
[self.productArr addObject:billProduct]; [self.productArr addObject:billProduct];
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
self.tableView.tableHeaderView = headCell; self.tableView.tableHeaderView = headCell;
if (!self.isHiddenEdit) { if (!self.isHiddenEdit) {
FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加商品明细"]; FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加商品明细" isTwo:self.twoTitle];
[self.view addSubview:footCell]; [self.view addSubview:footCell];
footCell.delegate = self; footCell.delegate = self;
self.tableView.tableFooterView = footCell; self.tableView.tableFooterView = footCell;
...@@ -83,7 +83,9 @@ ...@@ -83,7 +83,9 @@
- (void)addClick{ - (void)addClick{
} }
- (void)choosePurchase{
[[NSNotificationCenter defaultCenter] postNotificationName:@"ChoseTransportPurchase" object:nil];
}
#pragma mark - 协议方法 #pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
......
...@@ -89,7 +89,7 @@ typedef enum : NSUInteger { ...@@ -89,7 +89,7 @@ typedef enum : NSUInteger {
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getPurchaseResultWithPurchaseUuid:@"5a7417014f926eb5014f93b18fbc000f" success:succ failure:fail]; [[ICRHTTPController sharedController] getPurchaseResultWithPurchaseUuid:self.bill.uuid success:succ failure:fail];
} }
...@@ -104,13 +104,7 @@ typedef enum : NSUInteger { ...@@ -104,13 +104,7 @@ typedef enum : NSUInteger {
[self createBottomView]; [self createBottomView];
[self createPurchaseView]; [self createPurchaseView];
if ([self.bill.state isEqualToString:@"finished"]) {
_secondBtn.hidden = YES;
_firstBtn.hidden = YES;
CGRect scrollViewFrame = _scrollView.frame;
scrollViewFrame.size.height = ScreenSize.height - 64;
_scrollView.frame = scrollViewFrame;
}
} }
- (void)createBtn{ - (void)createBtn{
...@@ -176,11 +170,15 @@ typedef enum : NSUInteger { ...@@ -176,11 +170,15 @@ typedef enum : NSUInteger {
_secondBtn.tag = CancleTag; _secondBtn.tag = CancleTag;
self.indexStyle = 0; self.indexStyle = 0;
}else{//不显示任何按钮
_firstBtn.hidden = YES;
_secondBtn.hidden = YES;
self.indexStyle = 1;
} }
}else if([self.bill.state isEqualToString:PURCHASE_STATE_ABORTED]){//已作废
_firstBtn.hidden = YES;
_secondBtn.hidden = YES;
self.indexStyle = 1;
CGRect scrollViewFrame = _scrollView.frame;
scrollViewFrame.size.height = ScreenSize.height - 64;
_scrollView.frame = scrollViewFrame;
} }
} }
//改变按钮的位置 //改变按钮的位置
......
...@@ -63,34 +63,34 @@ typedef enum : NSUInteger { ...@@ -63,34 +63,34 @@ typedef enum : NSUInteger {
} }
- (void)initData{ - (void)initData{
self.dataArr = [NSMutableArray array]; self.dataArr = [NSMutableArray array];
for (NSInteger i = 0; i < 6; i++) { // for (NSInteger i = 0; i < 6; i++) {
PurchaseBill *bill = [PurchaseBill new]; // PurchaseBill *bill = [PurchaseBill new];
bill.billNumber = @"150903000013"; // bill.billNumber = @"150903000013";
bill.noticeNumber = @"134594059654"; // bill.noticeNumber = @"134594059654";
bill.create_operName = @"创建人"; // bill.create_operName = @"创建人";
bill.create_time = @"2013-03-04"; // bill.create_time = @"2013-03-04";
bill.vendor_name = @"供应商"; // bill.vendor_name = @"供应商";
bill.total = [NSNumber numberWithFloat:22]; // bill.total = [NSNumber numberWithFloat:22];
bill.charge = [NSNumber numberWithFloat:333]; // bill.charge = [NSNumber numberWithFloat:333];
bill.remark = @"备注"; // bill.remark = @"备注";
bill.lastModify_operName = @"最后修改人"; // bill.lastModify_operName = @"最后修改人";
bill.vendorConfirmTime = @"否"; // bill.vendorConfirmTime = @"否";
//
if (i == 0) { // if (i == 0) {
bill.state = @"initial"; // bill.state = @"initial";
}else if(i == 1){ // }else if(i == 1){
bill.state = @"submitted"; // bill.state = @"submitted";
}else if(i == 2){ // }else if(i == 2){
bill.state = @"rejected"; // bill.state = @"rejected";
}else if(i == 3){ // }else if(i == 3){
bill.state = @"approved"; // bill.state = @"approved";
}else if(i == 4){ // }else if(i == 4){
bill.state = @"shipping"; // bill.state = @"shipping";
}else if(i == 5){ // }else if(i == 5){
bill.state = @"finished"; // bill.state = @"finished";
} // }
[self.dataArr addObject:bill]; // [self.dataArr addObject:bill];
} // }
} }
- (void)getData{ - (void)getData{
[ICRUserUtil sharedInstance].needFresh = NO; [ICRUserUtil sharedInstance].needFresh = NO;
...@@ -154,7 +154,7 @@ typedef enum : NSUInteger { ...@@ -154,7 +154,7 @@ typedef enum : NSUInteger {
NSDictionary *dict = @{ NSDictionary *dict = @{
@"billNumberLike":billObject, @"billNumberLike":billObject,
@"state":stateObject, @"state":stateObject,
@"noticeNumberLike":noticeObject, // @"noticeNumberLike":noticeObject,
@"titleLike":[NSNull null], @"titleLike":[NSNull null],
@"vendorUuid":[NSNull null], @"vendorUuid":[NSNull null],
@"queryOrders":orderArr, @"queryOrders":orderArr,
...@@ -169,9 +169,9 @@ typedef enum : NSUInteger { ...@@ -169,9 +169,9 @@ typedef enum : NSUInteger {
NSString *message = data[@"message"] ; NSString *message = data[@"message"] ;
if (success == 1) { if (success == 1) {
if (_currentPage == 0) { if (_currentPage == 0) {
// if (self.dataArr.count > 0) { if (self.dataArr.count > 0) {
// [self.dataArr removeAllObjects]; [self.dataArr removeAllObjects];
// } }
} }
NSArray *recodesArr = data[ @"data" ][ @"records" ]; NSArray *recodesArr = data[ @"data" ][ @"records" ];
for (NSDictionary *purchaseBillDict in recodesArr) { for (NSDictionary *purchaseBillDict in recodesArr) {
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
@property (nonatomic,strong)NSNumber *basePrice;//基础单价 @property (nonatomic,strong)NSNumber *basePrice;//基础单价
@property (nonatomic,strong)NSNumber *total;// 金额 @property (nonatomic,strong)NSNumber *total;// 金额
@property (nonatomic,strong)NSString *remark;//备注 @property (nonatomic,strong)NSString *remark;//备注
@property (nonatomic,strong)NSNumber *shippedFlag;//发运标志,0 未发运,1已发运
@property (nonatomic,strong)NSNumber *shippedQty;//发运包装数量
@property (nonatomic,strong)NSNumber *shippedBaseQty;//发运基础数量
@end @end
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
@property (nonatomic,strong)UILabel *showBasePriceLabel; @property (nonatomic,strong)UILabel *showBasePriceLabel;
@property (nonatomic,strong)UILabel *showTotalLabel; @property (nonatomic,strong)UILabel *showTotalLabel;
@property (nonatomic,strong)UILabel *showNoteLabel; @property (nonatomic,strong)UILabel *showNoteLabel;
@property (nonatomic,strong)UILabel *showShippedFlag;//发运标志
@property (nonatomic,strong)UILabel *showShippedQty;//发运包装数量
@property (nonatomic,strong)UILabel *showShippedBaseQty;//发运基础数量
@property (nonatomic,assign)BOOL isShowShipping;//是否发运
- (void)setBillProduct:(PurchaseBillProduct *)billProduct row:(NSInteger)row; - (void)setBillProduct:(PurchaseBillProduct *)billProduct row:(NSInteger)row;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define ShowWidth 150 #define ShowWidth 150
#define ShowHeight 20 #define ShowHeight 20
@implementation ProductBillCell @implementation ProductBillCell
...@@ -131,6 +132,7 @@ ...@@ -131,6 +132,7 @@
[self.showView addSubview:self.showPriceLabel]; [self.showView addSubview:self.showPriceLabel];
[self.showView addSubview:self.showBasePriceLabel]; [self.showView addSubview:self.showBasePriceLabel];
[self.showView addSubview:self.showTotalLabel]; [self.showView addSubview:self.showTotalLabel];
[self.showView addSubview:self.showNoteLabel]; [self.showView addSubview:self.showNoteLabel];
[self.contentView addSubview:self.lineLabel]; [self.contentView addSubview:self.lineLabel];
...@@ -148,6 +150,41 @@ ...@@ -148,6 +150,41 @@
self.showBasePriceLabel.text = [NSString stringWithFormat:@"基础单价:%@",billProduct.basePrice]; self.showBasePriceLabel.text = [NSString stringWithFormat:@"基础单价:%@",billProduct.basePrice];
self.showTotalLabel.text = [NSString stringWithFormat:@"总金额:%@",billProduct.total]; self.showTotalLabel.text = [NSString stringWithFormat:@"总金额:%@",billProduct.total];
self.showNoteLabel.text =[NSString stringWithFormat:@"备注:%@",billProduct.remark]; self.showNoteLabel.text =[NSString stringWithFormat:@"备注:%@",billProduct.remark];
[self isShowShippingQty:billProduct];
}
- (void)isShowShippingQty:(PurchaseBillProduct *)billProduct{
if(billProduct.shippedQty){
self.showShippedFlag = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showBasePriceLabel.frame), ShowWidth, ShowHeight))];
self.showShippedFlag.textAlignment = NSTextAlignmentLeft;
self.showShippedFlag.textColor = GXF_PLACEHOLDER_COLOR;
self.showShippedFlag.text = @"是否发运:未";
self.showShippedFlag.font = GXF_THREETEENTH_SIZE;
self.showShippedQty = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showCountLabel.frame), CGRectGetMaxY(self.showBasePriceLabel.frame), ShowWidth, ShowHeight))];
self.showShippedQty.textAlignment = NSTextAlignmentLeft;
self.showShippedQty.textColor = GXF_PLACEHOLDER_COLOR;
self.showShippedQty.text = @"发运包装数量:";
self.showShippedQty.font = GXF_THREETEENTH_SIZE;
self.showShippedBaseQty = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMinX(self.showStandLabel.frame), CGRectGetMaxY(self.showShippedFlag.frame), ShowWidth, ShowHeight))];
self.showShippedBaseQty.textAlignment = NSTextAlignmentLeft;
self.showShippedBaseQty.textColor = GXF_PLACEHOLDER_COLOR;
self.showShippedBaseQty.text = @"发运基础数量:";
self.showShippedBaseQty.font = GXF_THREETEENTH_SIZE;
self.showNoteLabel.frame = CGRectMake(CGRectGetMinX(self.showCountLabel.frame), CGRectGetMaxY(self.showShippedFlag.frame), ShowWidth, ShowHeight);
}
NSMutableAttributedString *attributeStr1 = [IBTCommon setTextViewFontOfString:@"发运状态:" paragraphStyle:0 fontSize:13 color:GXF_CELL_COLOR];
NSString *str = [NSString stringWithFormat:@"%@",[billProduct.shippedFlag integerValue] == 0 ? @"未完成":@"已完成"];
[attributeStr1 appendAttributedString:[IBTCommon setTextViewFontOfString:str paragraphStyle:0 fontSize:13 color:[UIColor redColor]]];
self.showShippedFlag.attributedText = attributeStr1;
self.showShippedBaseQty.text = [NSString stringWithFormat:@"发运包装数量:%@",[billProduct.shippedBaseQty stringValue]];
self.showShippedQty.text = [NSString stringWithFormat:@"发运基础数量:%@",[billProduct.shippedQty stringValue]];
[self.showView addSubview:self.showShippedFlag];
[self.showView addSubview:self.showShippedQty];
[self.showView addSubview:self.showShippedBaseQty];
} }
- (void)awakeFromNib { - (void)awakeFromNib {
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
@interface PurchaseCell : UITableViewCell @interface PurchaseCell : UITableViewCell
@property (nonatomic,strong)UILabel *billNumberLabel;//采购单号 @property (nonatomic,strong)UILabel *billNumberLabel;//采购单号
@property (nonatomic,strong)UILabel *noticeNumberLabel;//采购通知单号 @property (nonatomic,strong)UILabel *noticeNumberLabel;//采购通知单号
@property (nonatomic,strong)UILabel *vendorLabel;//供应商
@property (nonatomic,strong)UILabel *createOperNameLabel;//创建人 @property (nonatomic,strong)UILabel *createOperNameLabel;//创建人
@property (nonatomic,strong)UILabel *createTimeLabel;//创建时间 @property (nonatomic,strong)UILabel *createTimeLabel;//创建时间
@property (nonatomic,strong)UILabel *lineLabel; @property (nonatomic,strong)UILabel *lineLabel;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#import "PurchaseCell.h" #import "PurchaseCell.h"
#define TitleSize 16 #define TitleSize 16
#define ContentSize 14
#define LeftMargin 90 #define LeftMargin 90
#define TopMargin 10 #define TopMargin 10
#define TitleHeight 20 #define TitleHeight 20
...@@ -29,27 +28,31 @@ ...@@ -29,27 +28,31 @@
{ {
self.stateBtn = [UIButton buttonWithType:UIButtonTypeCustom]; self.stateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20); self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
self.stateBtn.titleLabel.font = FontSize(ContentSize); self.stateBtn.titleLabel.font = GXF_FOURTEENTH_SIZE;
[self.stateBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [self.stateBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
self.stateBtn.enabled = NO; self.stateBtn.enabled = NO;
self.billNumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, TopMargin, ScreenSize.width - LeftMargin, TitleHeight))]; self.billNumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, TopMargin, ScreenSize.width - LeftMargin, TitleHeight))];
self.billNumberLabel.textColor = GXF_CONTENT_COLOR; self.billNumberLabel.textColor = GXF_CONTENT_COLOR;
self.billNumberLabel.font = FontSize(TitleSize); self.billNumberLabel.font = GXF_SIXTEENTEH_SIZE;
self.noticeNumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.billNumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight*2))]; self.noticeNumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.billNumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
self.noticeNumberLabel.numberOfLines = 0; self.noticeNumberLabel.numberOfLines = 0;
self.noticeNumberLabel.textColor = GXF_CELL_COLOR; self.noticeNumberLabel.textColor = GXF_CELL_COLOR;
self.noticeNumberLabel.font = FontSize(ContentSize); self.noticeNumberLabel.font = GXF_FOURTEENTH_SIZE;
self.createOperNameLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.noticeNumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))]; self.vendorLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.noticeNumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
self.vendorLabel.textColor = GXF_CELL_COLOR;
self.vendorLabel.font = GXF_FOURTEENTH_SIZE;
self.createOperNameLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.vendorLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
self.createOperNameLabel.textColor = GXF_CELL_COLOR; self.createOperNameLabel.textColor = GXF_CELL_COLOR;
self.createOperNameLabel.font = FontSize(ContentSize); self.createOperNameLabel.font = GXF_FOURTEENTH_SIZE;
self.createTimeLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.createOperNameLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))]; self.createTimeLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.createOperNameLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
self.createTimeLabel.textColor = GXF_CELL_COLOR; self.createTimeLabel.textColor = GXF_CELL_COLOR;
self.createTimeLabel.font = FontSize(ContentSize); self.createTimeLabel.font = GXF_FOURTEENTH_SIZE;
self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin,TableHeight-1, ScreenSize.width - LeftMargin - TopMargin * 2, 1))];; self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin,TableHeight-1, ScreenSize.width - LeftMargin - TopMargin * 2, 1))];;
self.lineLabel.backgroundColor = GXF_LINE_COLOR; self.lineLabel.backgroundColor = GXF_LINE_COLOR;
...@@ -57,6 +60,7 @@ ...@@ -57,6 +60,7 @@
[self.contentView addSubview:self.stateBtn]; [self.contentView addSubview:self.stateBtn];
[self.contentView addSubview:self.billNumberLabel]; [self.contentView addSubview:self.billNumberLabel];
[self.contentView addSubview:self.noticeNumberLabel]; [self.contentView addSubview:self.noticeNumberLabel];
[self.contentView addSubview:self.vendorLabel];
[self.contentView addSubview:self.createOperNameLabel]; [self.contentView addSubview:self.createOperNameLabel];
[self.contentView addSubview:self.createTimeLabel]; [self.contentView addSubview:self.createTimeLabel];
[self.contentView addSubview:self.lineLabel]; [self.contentView addSubview:self.lineLabel];
...@@ -65,7 +69,8 @@ ...@@ -65,7 +69,8 @@
- (void)setPurchaseBill:(PurchaseBill *)purchaseBill{ - (void)setPurchaseBill:(PurchaseBill *)purchaseBill{
self.billNumberLabel.text = [NSString stringWithFormat:@"单号:%@",purchaseBill.billNumber]; self.billNumberLabel.text = [NSString stringWithFormat:@"单号:%@",purchaseBill.billNumber];
self.noticeNumberLabel.text = [NSString stringWithFormat:@"采购通知单:%@",purchaseBill.noticeNumber]; self.noticeNumberLabel.text = [NSString stringWithFormat:@"采购通知单号:%@",purchaseBill.noticeNumber.length > 0 ? purchaseBill.noticeNumber: @"无"];
self.vendorLabel.text = [NSString stringWithFormat:@"供应商:%@[%@]",purchaseBill.vendor_name,purchaseBill.vendor_code] ;
self.createOperNameLabel.text = [NSString stringWithFormat:@"创建人:%@",purchaseBill.create_operName] ; self.createOperNameLabel.text = [NSString stringWithFormat:@"创建人:%@",purchaseBill.create_operName] ;
self.createTimeLabel.text =[NSString stringWithFormat:@"创建时间:%@",purchaseBill.create_time]; self.createTimeLabel.text =[NSString stringWithFormat:@"创建时间:%@",purchaseBill.create_time];
NSString *stateStr = @""; NSString *stateStr = @"";
...@@ -90,6 +95,9 @@ ...@@ -90,6 +95,9 @@
}else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_FINISHED]) { }else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_FINISHED]) {
stateStr = @"已完成"; stateStr = @"已完成";
[self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled]; [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
}else if ([purchaseBill.state isEqualToString:PURCHASE_STATE_ABORTED]) {
stateStr = @"已作废";
[self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
} }
[self.stateBtn setTitle:stateStr forState:UIControlStateNormal]; [self.stateBtn setTitle:stateStr forState:UIControlStateNormal];
} }
......
...@@ -93,16 +93,17 @@ ...@@ -93,16 +93,17 @@
[cell.contentView addSubview:label]; [cell.contentView addSubview:label];
}else if (indexPath.row == _dataArr.count -1){ }else if (indexPath.row == _dataArr.count -1){
self.remarkTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableHeight/2)]; self.remarkTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableHeight)];
self.remarkTextView.backgroundColor = [UIColor redColor];
self.remarkTextView.contentInset = UIEdgeInsetsMake(5, 5, 5, 0); self.remarkTextView.contentInset = UIEdgeInsetsMake(5, 5, 5, 0);
self.remarkTextView.minNumberOfLines = 1; self.remarkTextView.minNumberOfLines = 1;
self.remarkTextView.maxNumberOfLines = 1; self.remarkTextView.maxNumberOfLines = 1;
self.remarkTextView.isScrollable = YES;
self.remarkTextView.font = GXF_FIFTEENTEN_SIZE; self.remarkTextView.font = GXF_FIFTEENTEN_SIZE;
self.remarkTextView.textAlignment = NSTextAlignmentRight; self.remarkTextView.textAlignment = NSTextAlignmentRight;
self.remarkTextView.delegate = self; self.remarkTextView.delegate = self;
self.remarkTextView.returnKeyType = UIReturnKeyDone; self.remarkTextView.returnKeyType = UIReturnKeyDone;
self.remarkTextView.placeholder = @"输入备注内容"; self.remarkTextView.placeholder = @"输入备注内容";
[cell.contentView addSubview:self.remarkTextView]; [cell.contentView addSubview:self.remarkTextView];
}else{ }else{
UILabel *contentLabel = [[UILabel alloc]initWithFrame:(CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableHeight))]; UILabel *contentLabel = [[UILabel alloc]initWithFrame:(CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableHeight))];
...@@ -181,9 +182,8 @@ ...@@ -181,9 +182,8 @@
self.remark = bill.remark; self.remark = bill.remark;
} }
} }
} }
#warning 有点问题
- (void)prepareDataInCell{ - (void)prepareDataInCell{
if (self.total) { if (self.total) {
self.purchasePriceLabel.text = [self.total stringValue]; self.purchasePriceLabel.text = [self.total stringValue];
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row == 2){ if(indexPath.row == 2){
ChooseVendorViewController *cvc = [ChooseVendorViewController new]; ChooseVendorViewController *cvc = [ChooseVendorViewController new];
cvc.choseVendor = ^(NSArray *vendors){ cvc.choseBaseInfo = ^(NSArray *vendors){
if (vendors.count > 0) { if (vendors.count > 0) {
Vendor *vendor = vendors[0]; Vendor *vendor = vendors[0];
self.purchaseSupplierLabel.text = [NSString stringWithFormat:@"%@[%@]",vendor.name,vendor.code]; self.purchaseSupplierLabel.text = [NSString stringWithFormat:@"%@[%@]",vendor.name,vendor.code];
...@@ -207,7 +207,8 @@ ...@@ -207,7 +207,8 @@
[self.delegate pushNextViewController:cvc]; [self.delegate pushNextViewController:cvc];
}else if(indexPath.row == 1){ }else if(indexPath.row == 1){
ChooseTypeViewController *tvc = [[ChooseTypeViewController alloc]init]; ChooseTypeViewController *tvc = [[ChooseTypeViewController alloc]init];
tvc.choseType = ^(NSString *type){ tvc.choseBaseInfo = ^(NSArray *types){
NSString *type = types[0];
self.purchaseTypeLabel.text = type; self.purchaseTypeLabel.text = type;
self.purchaseTypeLabel.textColor = GXF_CONTENT_COLOR; self.purchaseTypeLabel.textColor = GXF_CONTENT_COLOR;
if ([type isEqualToString:@"紧急"]) { if ([type isEqualToString:@"紧急"]) {
...@@ -219,7 +220,8 @@ ...@@ -219,7 +220,8 @@
[self.delegate pushNextViewController:tvc]; [self.delegate pushNextViewController:tvc];
}else if(indexPath.row == 3){ }else if(indexPath.row == 3){
ChooseWarehouseViewController *wvc = [[ChooseWarehouseViewController alloc]init]; ChooseWarehouseViewController *wvc = [[ChooseWarehouseViewController alloc]init];
wvc.choseWarehouse = ^(Warehouse *warehouse){ wvc.choseBaseInfo = ^(NSArray *warehouses){
Warehouse *warehouse = warehouses[0];
self.purchaseStoreLabel.text = [NSString stringWithFormat:@"%@[%@]",warehouse.name,warehouse.code]; self.purchaseStoreLabel.text = [NSString stringWithFormat:@"%@[%@]",warehouse.name,warehouse.code];
self.purchaseStoreLabel.textColor = GXF_CONTENT_COLOR; self.purchaseStoreLabel.textColor = GXF_CONTENT_COLOR;
self.receiveWrh_uuid = warehouse.uuid; self.receiveWrh_uuid = warehouse.uuid;
...@@ -242,9 +244,7 @@ ...@@ -242,9 +244,7 @@
} }
- (void)boxValueChanged:(UITextField *)textFiled{ - (void)boxValueChanged:(UITextField *)textFiled{
if (self.otherPriceFiled.text.length > 0) {
[[NSNotificationCenter defaultCenter] postNotificationName:SetProductTotalPrice object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:SetProductTotalPrice object:nil];
}
} }
......
...@@ -229,7 +229,7 @@ ...@@ -229,7 +229,7 @@
}else if(indexPath.row == 1){ }else if(indexPath.row == 1){
ChosePersonViewController *cvc = [ChosePersonViewController new]; ChosePersonViewController *cvc = [ChosePersonViewController new];
cvc.chosePerson = ^(NSArray *users){ cvc.choseBaseInfo = ^(NSArray *users){
NSString *textStr = @""; NSString *textStr = @"";
if (self.users.count <=0) { if (self.users.count <=0) {
[self.users removeAllObjects]; [self.users removeAllObjects];
......
...@@ -381,7 +381,7 @@ typedef enum : NSUInteger { ...@@ -381,7 +381,7 @@ typedef enum : NSUInteger {
[self startDatePickView]; [self startDatePickView];
}else if(indexPath.row == 4){ }else if(indexPath.row == 4){
ChosePersonViewController *cvc = [ChosePersonViewController new]; ChosePersonViewController *cvc = [ChosePersonViewController new];
cvc.chosePerson = ^(NSArray *users){ cvc.choseBaseInfo = ^(NSArray *users){
NSString *textStr = @""; NSString *textStr = @"";
if (self.users.count <=0) { if (self.users.count <=0) {
[self.users removeAllObjects]; [self.users removeAllObjects];
...@@ -401,7 +401,8 @@ typedef enum : NSUInteger { ...@@ -401,7 +401,8 @@ typedef enum : NSUInteger {
[self PushViewController:cvc animated:YES]; [self PushViewController:cvc animated:YES];
}else if(indexPath.row == 1){ }else if(indexPath.row == 1){
ChooseProductViewController *cvc = [ChooseProductViewController new]; ChooseProductViewController *cvc = [ChooseProductViewController new];
cvc.choseProduct = ^(Product *product){ cvc.choseBaseInfo = ^(NSArray *products){
Product *product = products[0];
_productLabel.text = [NSString stringWithFormat:@"%@[%@]",product.name,product.code]; _productLabel.text = [NSString stringWithFormat:@"%@[%@]",product.name,product.code];
_productLabel.textColor = HexColor(@"444444"); _productLabel.textColor = HexColor(@"444444");
self.productNameStr = product.name; self.productNameStr = product.name;
......
//
// NewTransportViewController.h
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "ICRBaseViewController.h"
#import "Transport.h"
@interface NewTransportViewController : ICRBaseViewController
@property (nonatomic,strong)Transport *transport;
@end
//
// NewTransportViewController.m
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "NewTransportViewController.h"
#import "TopTransportView.h"
#import "BottomTransportView.h"
#import "TransportPurchaseViewController.h"
#import "PurchaseBillProduct.h"
#import "FeeAcountDetail.h"
typedef enum : NSUInteger {
SaveTag = 7000,
CommitTag,
} BtnTag;
#define TopHeight 284
#define BottomHeight 300
#define SpaceHeight 20
#define BottomViewHeight 60
@interface NewTransportViewController ()<TopTransportViewDelegate,UIScrollViewDelegate>
{
UIScrollView *_scrollView;
TopTransportView *_sheetView;
BottomTransportView *_bottomView;
id uuidObject;
id billNumberObject;
NSNumber *versionObject;
}
@end
@implementation NewTransportViewController
- (instancetype)init{
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(choseTransportPurchase) name:@"ChoseTransportPurchase" object:nil];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"新建发运单";
//布局
[self bulidLayout];
uuidObject = [NSNull null];
billNumberObject = [NSNull null];
versionObject = [NSNumber numberWithInteger:0];
// if (self.purchaseBill) {
// [self getDataFromServer];
// }
}
- (void)bulidLayout{
self.view.backgroundColor = XXFBgColor;
_scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,0, ScreenSize.width, ScreenSize.height- 64 - BottomViewHeight )];
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.contentSize = CGSizeMake(ScreenSize.width, TopHeight+ BottomHeight + SpaceHeight*2);
[self.view addSubview:_scrollView];
UIView *footView = [[UIView alloc]initWithFrame:CGRectMake(0, ScreenSize.height - BottomViewHeight - 64, ScreenSize.width, BottomViewHeight)];
UIButton *saveBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(15, 8, (ScreenSize.width - 15*3)/2, 44) target:self sel:@selector(btnClick:) tag:SaveTag image:nil title:@"保存" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_SAVE_COLOR];
[footView addSubview:saveBtn];
UIButton *commitBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(CGRectGetMaxX(saveBtn.frame) + 15, 8, (ScreenSize.width - 15*3)/2, 44) target:self sel:@selector(btnClick:) tag:CommitTag image:nil title:@"提交" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_COMMIT_COLOR];
[footView addSubview:commitBtn];
[self.view addSubview:footView];
_sheetView = [[TopTransportView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, TopHeight)];
_sheetView.delegate = self;
[_scrollView addSubview:_sheetView];
_bottomView = [[BottomTransportView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_sheetView.frame) + 20, ScreenSize.width,BottomHeight)];
_bottomView.backgroundColor = [UIColor whiteColor];
[_scrollView addSubview:_bottomView];
}
- (void)btnClick:(UIButton *)btn{
switch (btn.tag) {
case SaveTag:
{
if ([self checkTransport]) {
[self getDataFromServer:PURCHASE_STATE_INITIAL msg:@"正在保存..."];
}
}
break;
case CommitTag:{
if ([self checkTransport]) {
[self getDataFromServer:PURCHASE_STATE_SUBMITTED msg:@"正在提交..."];
}
}
break;
default:
break;
}
}
- (void)getDataFromServer:(NSString *)state msg:(NSString *)msg{
//保存
void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
if (data) {
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"];
if (success == 1) {
//成功
if ([state isEqualToString:PURCHASE_STATE_INITIAL]) {//保存成功
NSString *uuidS = data[@"data"][@"uuid"];
NSString *billNumberS = data[@"data"][@"billNumber"];
NSNumber *versionN = data[@"data"][@"version"];
uuidObject = uuidS;
billNumberObject = billNumberS;
versionObject = versionN;
[IBTLoadingView showTips:[NSString stringWithFormat:@"当前单据%@已保存成功",billNumberS]];
}else{//提交成功
// PurchaseViewController *svc = [PurchaseViewController new];
// [self PushViewController:svc animated:YES];
}
}else{
[IBTLoadingView showTips:message];
}
}
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
if(self.transport.uuid.length > 0 && uuidObject == [NSNull null]){
uuidObject = self.transport.uuid;
}
if (self.transport.billnumber > 0 && billNumberObject == [NSNull null]) {
billNumberObject = self.transport.billnumber;
}
// if (self.purchaseBill && [versionObject integerValue] == 0) {
// versionObject = self.transport.version;
// }
NSMutableArray *billProducts = [NSMutableArray array];
for (PurchaseBillProduct *billProduct in _bottomView.productVC.productArr) {
[billProducts addObject:[billProduct dictForCommit]];
}
NSMutableArray *costs = [NSMutableArray array];
for (FeeAcountDetail *fee in _bottomView.costVC.costArr) {
[costs addObject:[fee dictForCommit]];
}
// self.state = state;
NSDictionary *dict = @{@"uuid":uuidObject,
// @"version":versionObject,
@"billnumber":billNumberObject,
@"state":state,
@"warehouseUuid":[IBTCommon checkString:_sheetView.warehouseUuid],
@"warehouseCode":[IBTCommon checkString:_sheetView.warehouseCode],
@"warehouseName":[IBTCommon checkString:_sheetView.warehouseName],
@"rwarehouseUuid":[IBTCommon checkString:_sheetView.rwarehouseUuid],
@"rwarehouseCode":[IBTCommon checkString:_sheetView.rwarehouseCode],
@"rwarehouseName":[IBTCommon checkString:_sheetView.rwarehouseName],
@"carnumber":[IBTCommon checkString:_sheetView.carnumber],
@"type":[IBTCommon checkString:_sheetView.type],
@"carphone":[IBTCommon checkString:_sheetView.carphone],
@"note":_sheetView.note,
@"pdtDetails":billProducts,
@"accountDetails":costs};
[IBTLoadingView showProgressLabel:msg];
[[ICRHTTPController sharedController] savePurchaseWithData:dict success:succ failure:fail];
}
- (BOOL)checkTransport{
_sheetView.note = _sheetView.remarkTextView.text;
_sheetView.carnumber = _sheetView.carTextFiled.text;
_sheetView.carphone = _sheetView.phoneTextFiled.text;
if (_sheetView.warehouseName.length == 0 ) {
ShowMessage(@"发货仓库不能为空");
return NO;
}
if (_sheetView.rwarehouseUuid.length == 0 ) {
ShowMessage(@"收货仓库不能为空");
return NO;
}
if (_sheetView.type.length == 0 ) {
ShowMessage(@"运输类型不能为空");
return NO;
}
if (_sheetView.carnumber.length == 0) {
ShowMessage(@"车牌号不能为空");
return NO;
}
if (_sheetView.carphone.length == 0) {
ShowMessage(@"司机电话不能为空");
return NO;
}
if (_bottomView.productVC.productArr.count == 0) {
ShowMessage(@"商品不能为空");
return NO;
}
if (_bottomView.costVC.costArr.count == 0) {
ShowMessage(@"费用不能为空");
return NO;
}
return YES;
}
- (void)choseTransportPurchase{
TransportPurchaseViewController *tpv = [TransportPurchaseViewController new];
tpv.getProchaseProduct = ^(NSArray *products){
[_bottomView refreshProduct:products];
};
[self PushViewController:tpv animated:YES];
}
#pragma mark - TopPurchaseViewDelegate
- (void)pushNextViewController:(id)vc{
[self PushViewController:vc animated:YES];
}
#pragma mark - 协议方法
- (void)hiddenKeyBoard{
[self keyboardHidden];
}
- (void)keyboardHidden{
[_sheetView.phoneTextFiled resignFirstResponder];
[_sheetView.carTextFiled resignFirstResponder];
[_sheetView.remarkTextView resignFirstResponder];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
/*
#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
//
// TransportPurchaseViewController.h
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "ICRBaseViewController.h"
typedef void(^GetPurchaseProduct)(NSArray *products);
@interface TransportPurchaseViewController : ICRBaseViewController
@property (nonatomic,copy)GetPurchaseProduct getProchaseProduct;
@end
//
// TransportPurchaseViewController.m
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "TransportPurchaseViewController.h"
#import "TransportPurchaseCell.h"
#import "QueryOrder.h"
#define TopMargin 50
#define TableHeight 50
@interface TransportPurchaseViewController ()<UITextFieldDelegate,UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)NSMutableArray *indexArr;
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)UITextField *selectTextFiled;
@end
@implementation TransportPurchaseViewController
- (instancetype)init{
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getSelectPurchaseProduct:) name:KNOTIFICATION_getSelectPurchaseProduct object:nil];
}
return self;
}
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"选择采购单";
[self initData];
[self bulidLayout];
[self getData];
}
- (void)initData{
self.dataArr = [NSMutableArray array];
self.indexArr = [NSMutableArray array];
}
- (void)getData{
[ICRUserUtil sharedInstance].needFresh = NO;
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf fetchtPuchaseList:data];
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
[IBTLoadingView showProgressLabel:@"正在加载..."];
ICRUserUtil *userUtil = [ICRUserUtil sharedInstance];
NSMutableArray *orderArr =[NSMutableArray array];
if (orderArr.count == 0) {
QueryOrder *order = [QueryOrder new];
order.field = @"billNumber";
order.direction = @"desc";
[orderArr addObject:[order dictForCommit]];
}
NSDictionary *dict = @{
@"state":@"submitted",
@"queryOrders":orderArr,
@"userUuid":userUtil.userId,
@"pageNumber":@(0),
@"pageSize":@(20)};
[[ICRHTTPController sharedController] queryPurchaseWithData:dict success:succ failure:fail];
}
- (void)fetchtPuchaseList:(id)data{
if (data) {
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ;
if (success == 1) {
NSArray *recodesArr = data[ @"data" ][ @"records" ];
for (NSDictionary *purchaseBillDict in recodesArr) {
PurchaseBill *purchaseBill = [[PurchaseBill alloc]init];
[purchaseBill setValuesForKeysWithDictionary:purchaseBillDict];
[self.dataArr addObject:purchaseBill];
}
[self.tableView reloadData];
}else{
[IBTLoadingView showTips:message];
}
}
else{
[IBTLoadingView showTips:@" 无记录 "];
}
}
#pragma mark - 布局
- (void)bulidLayout
{
self.selectTextFiled = [[UITextField alloc] initWithFrame:CGRectMake(20,5,ScreenSize.width - 40,TopMargin -10)];
self.selectTextFiled.textAlignment = NSTextAlignmentLeft;
self.selectTextFiled.background = [UIImage imageNamed:@"textFiled"];
self.selectTextFiled.delegate = self;
self.selectTextFiled.font = GXF_FIFTEENTEN_SIZE;
[self.view addSubview:self.selectTextFiled];
UIImageView *leftView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 35, 40)];
leftView.image = [UIImage imageNamed:@"search"];
self.selectTextFiled.leftView = leftView;
self.selectTextFiled.leftViewMode = UITextFieldViewModeAlways;
UIButton *rightView = [UIButton buttonWithType:UIButtonTypeCustom];
[rightView setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
rightView.frame = CGRectMake(0, 0, 35, 40);
[rightView addTarget:self action:@selector(deleteTextFieldStr) forControlEvents:UIControlEventTouchUpInside];
self.selectTextFiled.rightView = rightView;
self.selectTextFiled.rightViewMode = UITextFieldViewModeAlways;
self.tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopMargin,ScreenSize.width, ScreenSize.height - 64 - TopMargin)) style:(UITableViewStylePlain)];
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:self.tableView];
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)];
self.navigationItem.rightBarButtonItem = rightItem;
}
- (void)deleteTextFieldStr{
self.selectTextFiled.text = @"";
}
#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"TransPortPurchase";
TransportPurchaseCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[TransportPurchaseCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
if(self.dataArr.count > 0){
PurchaseBill *bill = _dataArr[indexPath.row];
NSMutableArray *arr = [NSMutableArray array];
PurchaseBillProduct *billProduct = [PurchaseBillProduct new];
billProduct.product_name = @"dd";
billProduct.product_uuid = @"402880e64e287fe2014e28895b8a0032";
billProduct.product_code = @"农夫山泉";
billProduct.qpc = [NSNumber numberWithFloat:22];
billProduct.unit = @"筐";
billProduct.qty = [NSNumber numberWithFloat:23];
billProduct.price = [NSNumber numberWithFloat:333];
billProduct.baseQty = [NSNumber numberWithFloat:333];
billProduct.basePrice = [NSNumber numberWithFloat:33];
billProduct.total = [NSNumber numberWithFloat:80];
billProduct.remark = @"hshshshsh";
billProduct.qpcStr = @"fdsfdsfdsa";
[arr addObject:billProduct];
[arr addObject:billProduct];
bill.products = arr;
cell.bill = bill;
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 200;
}
#pragma mark - 按钮确定
- (void)sureClick{
[self PopViewControllerAnimated:YES];
if (self.indexArr.count > 0) {
self.getProchaseProduct(self.indexArr);
}
}
#pragma mark - 得到通知的方法
- (void)getSelectPurchaseProduct:(NSNotification *)fination{
NSDictionary *dict = fination.userInfo;
PurchaseBillProduct *billProduct = dict[@"selectArr"];
NSString *state = dict[@"state"];
if ([state isEqualToString:@"add"]) {
[self.indexArr addObject:billProduct];
}else{
[self.indexArr removeObject:billProduct];
}
}
- (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
//
// FeeAcountDetail.h
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTModel.h"
@interface FeeAcountDetail : IBTModel
@property (nonatomic,strong)NSString *uuid;//唯一标识
@property (nonatomic,strong)NSString *accounttitle;//费用类型
@property (nonatomic,strong)NSString *accounttitlename;//费用类型名称
@property (nonatomic,strong)NSNumber *actualmoney;//应付总金额
@property (nonatomic,strong)NSNumber *paidmoney;//已付总金额
@property (nonatomic,strong)NSNumber *leftmoney;//尾款总金额
@property (nonatomic,strong)NSString *note;//备注
@end
//
// FeeAcountDetail.m
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "FeeAcountDetail.h"
@implementation FeeAcountDetail
@end
//
// Transport.h
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTModel.h"
@interface Transport : IBTModel
@property (nonatomic,strong)NSString *uuid;//唯一标识
@property (nonatomic,strong)NSString *billnumber;//调研单号
@property (nonatomic,strong)NSString *warehouseUuid;//仓库id
@property (nonatomic,strong)NSString *warehouseCode;//仓库代码
@property (nonatomic,strong)NSString *warehouseName;//仓库名称
@property (nonatomic,strong)NSString *rwarehouseUuid;//收货仓库id
@property (nonatomic,strong)NSString *rwarehouseCode;//收货仓库代码
@property (nonatomic,strong)NSString *rwarehouseName;//收货仓库名称
@property (nonatomic,strong)NSString *carnumber;//车牌号
@property (nonatomic,strong)NSString *state;//状态
@property (nonatomic,strong)NSString *type;//类型
@property (nonatomic,strong)NSString *carphone;//司机电话
@property (nonatomic,strong)NSString *note;//备注
@property (nonatomic,strong)NSString *create_time;//创建时间
@property (nonatomic,strong)NSString *create_id;//创建人代码
@property (nonatomic,strong)NSString *create_operName;//create_operName
@property (nonatomic,strong)NSString *lastModified_time;//最后修改时间
@property (nonatomic,strong)NSString *lastModified_id;//最后修改人代码
@property (nonatomic,strong)NSString *lastModified_operName;//最后修改人名称
@end
//
// Transport.m
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "Transport.h"
@implementation Transport
@end
//
// BottomTransportView.h
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ProductBillViewController.h"
#import "CostViewController.h"
@interface BottomTransportView : UIView
@property (nonatomic,strong)ProductBillViewController *productVC;
@property (nonatomic,strong)CostViewController *costVC;
//刷新tableView
- (void)refreshProduct:(NSArray *)productArr;
- (void)refreshCost:(NSArray *)costArr;
@end
//
// BottomTransportView.m
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "BottomTransportView.h"
#define ContentHeight 44
#define BtnWidth 100
#define BeginTag 8000
#define SpaceWidth (ScreenSize.width - 100*2)/3
@interface BottomTransportView ()<UIScrollViewDelegate>
{
UIScrollView *_bottomSV;
UIImageView *_moveImageView;
UIButton *_currentBtn;
UIButton *_addBtn;
}
@end
@implementation BottomTransportView
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
//界面
[self bulidLayout];
}
return self;
}
#pragma mark - 布局
- (void)bulidLayout
{
[self addChildView];
[self createBottomView];
}
- (void)createBottomView{
NSArray *arr = @[@"商品明细",@"费用明细"];
_bottomSV = [[UIScrollView alloc]initWithFrame:CGRectMake(0,ContentHeight + 4, ScreenSize.width, CGRectGetHeight(self.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));
[self 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:GXF_CONTENT_COLOR forState:UIControlStateNormal];
[btn setTitleColor:GXF_SAVE_COLOR forState:UIControlStateDisabled];
btn.titleLabel.font = GXF_SIXTEENTEH_SIZE;
btn.tag = i + BeginTag;
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:btn];
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetWidth(_bottomSV.frame) * i, 0, CGRectGetWidth(_bottomSV.frame), CGRectGetHeight(_bottomSV.frame))];
if (i == 0) {
view.backgroundColor = [UIColor redColor];
self.productVC.viewFrame = view.bounds;
[view addSubview:self.productVC.view];
}else if(i == 1){
self.costVC.viewFrame = view.bounds;
[view addSubview:self.costVC.view];
view.backgroundColor = [UIColor blueColor];
}
[_bottomSV addSubview:view];
}
_moveImageView = [[UIImageView alloc]initWithFrame:CGRectMake(SpaceWidth, ContentHeight, BtnWidth,4)];
_moveImageView.image = [UIImage imageNamed:@"tab_line"];
UILabel *lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0, ContentHeight +1, ScreenSize.width, 1))];
lineLabel.backgroundColor = GXF_LINE_COLOR;
lineLabel.font = GXF_FIFTEENTEN_SIZE;
[self addSubview:lineLabel];
[self addSubview:_moveImageView];
}
- (void)addChildView{
self.productVC = [[ProductBillViewController alloc]init];
self.productVC.twoTitle = @"+选择采购单";
self.costVC = [[CostViewController alloc]init];
}
- (void)btnClick:(UIButton *)btn{
NSInteger index = btn.tag - BeginTag;
_currentBtn.enabled = YES;
btn.enabled = NO;
_currentBtn = btn;
[UIView animateWithDuration:0.5 animations:^{
CGRect moveFrame = _moveImageView.frame;
moveFrame.origin.x = SpaceWidth + (BtnWidth+SpaceWidth) * index;
_moveImageView.frame = moveFrame;
_bottomSV.contentOffset=CGPointMake(index * self.frame.size.width, 0);
}];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
CGFloat offsetX = scrollView.contentOffset.x / self.frame.size.width;
[UIView animateWithDuration:0.5 animations:^{
CGRect moveFrame = _moveImageView.frame;
moveFrame.origin.x = SpaceWidth + (BtnWidth+SpaceWidth) * offsetX;
_moveImageView.frame = moveFrame;
}];
_currentBtn.enabled = YES;
UIButton *btn = (UIButton *) [self viewWithTag:offsetX + BeginTag];
btn.enabled = NO;
_currentBtn = btn;
}
- (void)refreshProduct:(NSArray *)productArr{
if (self.productVC.productArr) {
[self.productVC.productArr addObjectsFromArray:productArr];
[self.productVC.tableView reloadData];
}
}
- (void)refreshCost:(NSArray *)costArr{
}
@end
//
// TopTransportView.h
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "HPGrowingTextView.h"
@protocol TopTransportViewDelegate <NSObject>
- (void)hiddenKeyBoard;
- (void)pushNextViewController:(id)vc;
@end
@interface TopTransportView : UIView
@property (nonatomic,strong)UILabel *rwarehouseLabel; //收货仓库
@property (nonatomic,strong)UILabel *warehouseLabel; //发货仓库
@property (nonatomic,strong)UITextField *carTextFiled; //车辆
@property (nonatomic,strong)UILabel *typeLabel; //运输类型
@property (nonatomic,strong)UITextField *phoneTextFiled; //电话
@property (nonatomic,strong)HPGrowingTextView *remarkTextView;//备注
@property (nonatomic,weak)id <TopTransportViewDelegate>delegate;
@property (nonatomic,strong)NSString *warehouseUuid;
@property (nonatomic,strong)NSString *warehouseCode;
@property (nonatomic,strong)NSString *warehouseName;
@property (nonatomic,strong)NSString *rwarehouseUuid;
@property (nonatomic,strong)NSString *rwarehouseCode;
@property (nonatomic,strong)NSString *rwarehouseName;
@property (nonatomic,strong)NSString *carnumber;
@property (nonatomic,strong)NSString *type;
@property (nonatomic,strong)NSString *carphone;
@property (nonatomic,strong)NSString *note;
@end
//
// TopTransportView.m
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "TopTransportView.h"
#import "SurveyCell.h"
#import "Warehouse.h"
#import "ChooseWarehouseViewController.h"
#import "ChooseTypeViewController.h"
#define LeftMargin 15
#define TopMargin 20
#define LeftWidth 80
#define TableHeight 44
#define SpaceHeight 10
@interface TopTransportView ()<UITableViewDataSource,UITableViewDelegate,HPGrowingTextViewDelegate,UITextFieldDelegate>
{
UITableView *_tableView;
NSMutableArray *_dataArr;
}
@end
@implementation TopTransportView
- (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 ==0 || indexPath.row == 1 || indexPath.row == 2) {
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 == 3 || indexPath.row == 4) {
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-10, TableHeight)];
textField.textAlignment = NSTextAlignmentRight;
textField.textColor = GXF_CONTENT_COLOR;
textField.font = GXF_FIFTEENTEN_SIZE;
textField.returnKeyType = UIReturnKeyDone;
textField.delegate = self;
[cell.contentView addSubview:textField];
if (indexPath.row == 3) {
self.carTextFiled = textField;
self.carTextFiled.placeholder = @"请输入车辆";
}else if(indexPath.row == 4){
textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
textField.returnKeyType = UIReturnKeyDone;
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 = 1;
self.remarkTextView.isScrollable = YES;
self.remarkTextView.font = GXF_FIFTEENTEN_SIZE;
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 = GXF_PLACEHOLDER_COLOR;
contentLabel.font = GXF_FIFTEENTEN_SIZE;
[cell.contentView addSubview:contentLabel];
if (indexPath.row == 0) {
contentLabel.text = @"选择发货仓库";
self.warehouseLabel = contentLabel;
}else if(indexPath.row == 1){
contentLabel.text = @"选择收货仓库";
self.rwarehouseLabel = contentLabel;
}else if(indexPath.row == 2){
contentLabel.text = @"选择类型";
self.typeLabel = contentLabel;
}
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row == 0){
ChooseWarehouseViewController *cvc = [ChooseWarehouseViewController new];
cvc.choseBaseInfo = ^(NSArray *warehouses){
if (warehouses.count > 0) {
Warehouse *warehouse = warehouses[0];
self.warehouseLabel.text = [NSString stringWithFormat:@"%@[%@]",warehouse.name,warehouse.code];
self.warehouseLabel.textColor = GXF_CONTENT_COLOR;
self.warehouseUuid = warehouse.uuid;
self.warehouseCode = warehouse.code;
self.warehouseName = warehouse.name;
}
};
cvc.isMoreChose = NO;
[self.delegate pushNextViewController:cvc];
}else if(indexPath.row == 1){
ChooseWarehouseViewController *tvc = [[ChooseWarehouseViewController alloc]init];
tvc.choseBaseInfo = ^(NSArray *warehouses){
if (warehouses.count > 0) {
Warehouse *warehouse = warehouses[0];
self.rwarehouseLabel.text = [NSString stringWithFormat:@"%@[%@]",warehouse.name,warehouse.code];
self.rwarehouseLabel.textColor = GXF_CONTENT_COLOR;
self.rwarehouseUuid = warehouse.uuid;
self.rwarehouseCode = warehouse.code;
self.rwarehouseName = warehouse.name;
}
};
[self.delegate pushNextViewController:tvc];
}else if(indexPath.row == 2){
ChooseTypeViewController *tvc = [[ChooseTypeViewController alloc]init];
tvc.choseBaseInfo = ^(NSArray *types){
if (types.count > 0) {
NSString *type = types[0];
self.typeLabel.text = [type isEqualToString:GXF_Critical] ? @"紧急":@"普通";
self.typeLabel.textColor = GXF_CONTENT_COLOR;
self.type = type;
}
};
[self.delegate pushNextViewController:tvc];
}
}
- (BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView{
[self.remarkTextView resignFirstResponder];
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[self.delegate hiddenKeyBoard];
return YES;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
//
// TransportPurchaseCell.h
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ProductBillCell.h"
#import "PurchaseBill.h"
@interface TransportPurchaseCell : UITableViewCell<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UILabel *lineLabel;
@property (nonatomic,strong)UILabel *secondLabel;
@property (nonatomic,strong)UITableView *secondTable;
@property (nonatomic,strong)NSMutableArray *secondArr;
@property (nonatomic,strong)PurchaseBill *bill;
@property (nonatomic,strong)NSMutableArray *indexArr;
@property (nonatomic,strong)NSMutableArray *selectArr;
@end
//
// TransportPurchaseCell.m
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "TransportPurchaseCell.h"
#import "PurchaseBillProduct.h"
#import "HeaderCell.h"
@implementation TransportPurchaseCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self bulidLayout];
}
return self;
}
- (void)bulidLayout
{
self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0,0, ScreenSize.width, 1))];;
self.lineLabel.backgroundColor = GXF_LINE_COLOR;
self.titleLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0, 0, ScreenSize.width, 44))];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.textColor = GXF_NAVIGAYION_COLOR;
self.titleLabel.text = @"苹果桃子";
self.titleLabel.font = GXF_SIXTEENTEH_SIZE;
self.secondLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0,44-1, ScreenSize.width, 1))];;
self.secondLabel.backgroundColor = GXF_LINE_COLOR;
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.lineLabel];
[self.contentView addSubview:self.secondLabel];
}
- (void)setBill:(PurchaseBill *)bill{
self.titleLabel.text = [NSString stringWithFormat:@"[采购单:%@]",bill.billNumber];
self.secondArr = [NSMutableArray array];
self.selectArr = [NSMutableArray array];
[self.secondArr addObjectsFromArray:bill.products];
// for (NSDictionary *billDict in bill.products) {
// PurchaseBillProduct *billProcuct = [PurchaseBillProduct new];
// [billProcuct setValuesForKeysWithDictionary:billDict];
// [self.secondArr addObject:billProcuct];
// }
self.secondTable = [[UITableView alloc]initWithFrame:(CGRectMake(0, 44,ScreenSize.width, 200-44)) style:(UITableViewStylePlain)];
self.secondTable.delegate = self;
self.secondTable.dataSource = self;
self.secondTable.bounces = NO;
self.secondTable.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.contentView addSubview:self.secondTable];
NSArray *arr = @[@"商品",@"单价",@"包装数量"];
HeaderCell *headCell = [[HeaderCell alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 38) withArr:arr];
self.secondTable.tableHeaderView = headCell;
//重要
[self.secondTable reloadData];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.secondArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"ProductBillCell";
ProductBillCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[ProductBillCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
cell.editBtn.hidden = YES;
}
PurchaseBillProduct * billProduct = self.secondArr[indexPath.row];
[cell setBillProduct:billProduct row:indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
ProductBillCell *cell = (ProductBillCell *)[tableView cellForRowAtIndexPath:indexPath];
PurchaseBillProduct * billProduct = self.secondArr[indexPath.row];
if (![self isHaveIndexPath:indexPath]) {
cell.editBtn.hidden = NO;
[self.selectArr addObject:indexPath];
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_getSelectPurchaseProduct object:nil userInfo:@{@"selectArr":billProduct,@"state":@"add"}];
}else{
[self.selectArr removeObject:indexPath];
cell.editBtn.hidden = YES;
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_getSelectPurchaseProduct object:nil userInfo:@{@"selectArr":billProduct,@"state":@"remove"}];
}
;
}
- (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath{
for (NSIndexPath *path in self.selectArr) {
if (path.row == indexPath.row) {
return YES;
}
}
return NO;
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// TransportPurductCell.h
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TransportPurductCell : UITableViewCell
@property (nonatomic,strong)UIImageView *smallImageView;
@property (nonatomic,strong)UIButton *editBtn;
@property (nonatomic,strong)UILabel *seqLabel;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UILabel *standLabel;
@property (nonatomic,strong)UILabel *countLabel;
@property (nonatomic,strong)UILabel *baseCountLabel;
@property (nonatomic,strong)UILabel *lineLabel;
@end
//
// TransportPurductCell.m
// XFFruit
//
// Created by 陈俊俊 on 15/9/6.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "TransportPurductCell.h"
#define LeftMargin 13
#define TableHeight 44
#define SmallSize 10
#define SmallWidth 20
#define SpaceMargin 1
#define LeftWidth 40
#define ShowWidth 150
#define ShowHeight 20
@implementation TransportPurductCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self bulidLayout];
}
return self;
}
- (void)bulidLayout
{
CGFloat headWidth = (ScreenSize.width - LeftWidth*2 - SpaceMargin* (4 -1))/4;
self.seqLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, 0, SmallWidth, TableHeight))];
self.seqLabel.textColor = GXF_CONTENT_COLOR;
self.seqLabel.text = @"13";
self.seqLabel.font = GXF_SIXTEENTEH_SIZE;
self.titleLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftWidth, 0, headWidth, TableHeight))];
self.titleLabel.textAlignment = NSTextAlignmentLeft;
self.titleLabel.textColor = GXF_CONTENT_COLOR;
self.titleLabel.text = @"苹果桃子";
self.titleLabel.font = GXF_SIXTEENTEH_SIZE;
self.standLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.titleLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
self.standLabel.textAlignment = NSTextAlignmentLeft;
self.standLabel.textColor = GXF_CONTENT_COLOR;
self.standLabel.text = @"80";
self.standLabel.font = GXF_SIXTEENTEH_SIZE;
self.countLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.standLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
self.countLabel.textAlignment = NSTextAlignmentLeft;
self.countLabel.text = @"200";
self.countLabel.textColor = GXF_CONTENT_COLOR;
self.countLabel.font = GXF_SIXTEENTEH_SIZE;
self.baseCountLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.countLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
self.baseCountLabel.textAlignment = NSTextAlignmentLeft;
self.baseCountLabel.text = @"200";
self.baseCountLabel.textColor = GXF_CONTENT_COLOR;
self.baseCountLabel.font = GXF_SIXTEENTEH_SIZE;
self.editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[self.editBtn setImage:[UIImage imageNamed:@"selected"] forState:UIControlStateNormal];
self.editBtn.frame = CGRectMake(ScreenSize.width - LeftWidth, 0, LeftWidth , TableHeight);
self.editBtn.contentMode = UIViewContentModeScaleAspectFit;
self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin,TableHeight-1, ScreenSize.width - LeftMargin * 2, 1))];;
self.lineLabel.backgroundColor = GXF_LINE_COLOR;
[self.contentView addSubview:self.smallImageView];
[self.contentView addSubview:self.seqLabel];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.standLabel];
[self.contentView addSubview:self.countLabel];
[self.contentView addSubview:self.baseCountLabel];
[self.contentView addSubview:self.editBtn];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
#import "ChooseParentViewController.h" #import "ChooseParentViewController.h"
#import "Product.h" #import "Product.h"
typedef void(^ChoseProduct)(Product *product);
@interface ChooseProductViewController : ChooseParentViewController @interface ChooseProductViewController : ChooseParentViewController
@property (nonatomic,copy)ChoseProduct choseProduct;
@end @end
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#define TableHeight 50 #define TableHeight 50
@interface ChooseProductViewController () @interface ChooseProductViewController ()
{ {
NSIndexPath *_currentIndexPath;
} }
@end @end
...@@ -21,7 +20,7 @@ ...@@ -21,7 +20,7 @@
//记录更新时间 //记录更新时间
self.tableView.header.lastUpdatedTimeKey = ChooseProductUpdateDate; self.tableView.header.lastUpdatedTimeKey = ChooseProductUpdateDate;
self.title = @"选择商品"; self.title = @"选择商品";
[self fetchProductList:@""]; [self fetchDataList:@"" tableStr:GXF_BASECLASS_PRODUCT];
} }
- (void)getBaseDataFromServer{ - (void)getBaseDataFromServer{
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
...@@ -29,7 +28,7 @@ ...@@ -29,7 +28,7 @@
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf endRefreshing]; [strongSelf endRefreshing];
[strongSelf fetchProductList:@""]; [strongSelf fetchDataList:@"" tableStr:GXF_BASECLASS_PRODUCT];
}; };
void(^fail)(id) = ^(id data) { void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
...@@ -38,53 +37,6 @@ ...@@ -38,53 +37,6 @@
[IBTLoadingView showProgressLabel:@"正在加载..."]; [IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getProductWithPage_number:0 page_size:100 success:succ failure:fail]; [[ICRHTTPController sharedController] getProductWithPage_number:0 page_size:100 success:succ failure:fail];
} }
#pragma mark -成功
- (void)fetchProductList:(NSString *)titleStr{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = @"";
if (titleStr.length > 0) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE NAME LIKE '%%%@%%' ORDER BY %@", [Product TableName],titleStr, @"uuid"];
}else{
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;
if (![GXF_NSUSERFEFTAULTS objectForKey:ChooseProductUpdateDate]) {
[GXF_NSUSERFEFTAULTS setObject:[NSDate date] forKey:ChooseProductUpdateDate];
[GXF_NSUSERFEFTAULTS synchronize];
[self getBaseDataFromServer];
}else{
[strongSelf.dataArr removeAllObjects];
[strongSelf.dataArr addObject:self.tableView.header.lastUpdatedTime];
[strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[self tableViewRefresh];
}
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[Product class]
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
}
- (void)sureClick{
if(self.isMoreChose){
}else{
if (self.dataArr.count > 0) {
if (_currentIndexPath) {
Product *product = self.dataArr[_currentIndexPath.row];
self.choseProduct(product);
}
}
}
[self PopViewControllerAnimated:YES];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"MaskCell"; static NSString *cellID = @"MaskCell";
MaskCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; MaskCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
...@@ -101,8 +53,8 @@ ...@@ -101,8 +53,8 @@
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
} }
}else{ }else{
if (_currentIndexPath) { if (self.currentIndexPath) {
if (indexPath.row == _currentIndexPath.row) { if (indexPath.row == self.currentIndexPath.row) {
cell.Commitbtn.hidden = NO; cell.Commitbtn.hidden = NO;
}else{ }else{
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
...@@ -125,40 +77,9 @@ ...@@ -125,40 +77,9 @@
} }
return cell; return cell;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
return;
}
if (self.isMoreChose == YES) {
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO;
if (![self isHaveIndexPath:indexPath]) {
[self.indexArr addObject:indexPath];
}
}else{
MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath];
currentCell.Commitbtn.hidden = YES;
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO;
_currentIndexPath = indexPath;
}
}
#pragma mark - 父类方法
- (void)deleteTextFieldStr {
[super deleteTextFieldStr];
[self boxValueChanged:nil];
}
#pragma mark - 按钮事件
- (void)boxValueChanged:(NSNotification *)fication{ - (void)boxValueChanged:(NSNotification *)fication{
NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text]; NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text];
[self fetchProductList:tilkeStr]; [self fetchDataList:tilkeStr tableStr:GXF_BASECLASS_PRODUCT];
}
- (void)tableViewRefresh{
_currentIndexPath = nil;
[self.tableView reloadData];
} }
......
...@@ -8,10 +8,7 @@ ...@@ -8,10 +8,7 @@
#import "ChooseParentViewController.h" #import "ChooseParentViewController.h"
typedef void(^ChosePerson)(NSArray *user);
@interface ChosePersonViewController : ChooseParentViewController @interface ChosePersonViewController : ChooseParentViewController
@property (nonatomic,copy)ChosePerson chosePerson;
@end @end
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
#import "User.h" #import "User.h"
#define TopMargin 50 #define TopMargin 50
#define TableHeight 50 #define TableHeight 50
@interface ChosePersonViewController (){ @interface ChosePersonViewController ()
NSIndexPath *_currentIndexPath; {
} }
@end @end
@implementation ChosePersonViewController @implementation ChosePersonViewController
...@@ -23,7 +22,7 @@ ...@@ -23,7 +22,7 @@
[super viewDidLoad]; [super viewDidLoad];
self.tableView.header.lastUpdatedTimeKey = ChoosePersonUpdateDate; self.tableView.header.lastUpdatedTimeKey = ChoosePersonUpdateDate;
self.title = @"选择人员"; self.title = @"选择人员";
[self fetchUserList:@""]; [self fetchDataList:@"" tableStr:GXF_BASECLASS_USER];
} }
- (void)getBaseDataFromServer{ - (void)getBaseDataFromServer{
...@@ -32,7 +31,7 @@ ...@@ -32,7 +31,7 @@
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf; __strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf endRefreshing]; [strongSelf endRefreshing];
[strongSelf fetchUserList:@""]; [strongSelf fetchDataList:@"" tableStr:GXF_BASECLASS_USER];
}; };
void(^fail)(id) = ^(id data) { void(^fail)(id) = ^(id data) {
...@@ -43,36 +42,6 @@ ...@@ -43,36 +42,6 @@
[[ICRHTTPController sharedController] getUserWithPage_number:0 page_size:100 success:succ failure:fail]; [[ICRHTTPController sharedController] getUserWithPage_number:0 page_size:100 success:succ failure:fail];
} }
#pragma mark -成功 #pragma mark -成功
- (void)fetchUserList:(NSString *)titleStr{
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = @"";
if (titleStr.length > 0) {
sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE NAME LIKE '%%%@%%' ORDER BY %@", [User TableName],titleStr, @"uuid"];
}else{
sql = [NSString stringWithFormat:@"SELECT * FROM %@ ORDER BY %@", [User TableName], @"uuid"];
}
return [db executeQuery:sql];
};
__weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (![GXF_NSUSERFEFTAULTS objectForKey:ChoosePersonUpdateDate]) {
[GXF_NSUSERFEFTAULTS setObject:[NSDate date] forKey:ChoosePersonUpdateDate];
[GXF_NSUSERFEFTAULTS synchronize];
[self getBaseDataFromServer];
}else{
[strongSelf.dataArr removeAllObjects];
[strongSelf.dataArr addObject:self.tableView.header.lastUpdatedTime];
[strongSelf.dataArr addObjectsFromArray:fetchedObjects];
[self tableViewRefresh];
}
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[User class]
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
}
- (void)sureClick{ - (void)sureClick{
if (self.isMoreChose) { if (self.isMoreChose) {
NSMutableArray *arr = [[NSMutableArray alloc]init]; NSMutableArray *arr = [[NSMutableArray alloc]init];
...@@ -84,18 +53,18 @@ ...@@ -84,18 +53,18 @@
survey.userName = user.name; survey.userName = user.name;
[arr addObject:survey]; [arr addObject:survey];
} }
self.chosePerson(arr); self.choseBaseInfo(arr);
}else{ }else{
NSMutableArray *arr = [[NSMutableArray alloc]init]; NSMutableArray *arr = [[NSMutableArray alloc]init];
if (self.dataArr.count > 0) { if (self.dataArr.count > 0) {
if (_currentIndexPath) { if (self.currentIndexPath) {
User *user = self.dataArr[_currentIndexPath.row]; User *user = self.dataArr[self.currentIndexPath.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;
survey.userName = user.name; survey.userName = user.name;
[arr addObject:survey]; [arr addObject:survey];
self.chosePerson(arr); self.choseBaseInfo(arr);
} }
} }
} }
...@@ -119,8 +88,8 @@ ...@@ -119,8 +88,8 @@
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
} }
}else{ }else{
if (_currentIndexPath) { if (self.currentIndexPath) {
if (indexPath.row == _currentIndexPath.row) { if (indexPath.row == self.currentIndexPath.row) {
cell.Commitbtn.hidden = NO; cell.Commitbtn.hidden = NO;
}else{ }else{
cell.Commitbtn.hidden = YES; cell.Commitbtn.hidden = YES;
...@@ -138,46 +107,12 @@ ...@@ -138,46 +107,12 @@
User *user = self.dataArr[indexPath.row]; User *user = self.dataArr[indexPath.row];
[cell setTitleStr:user.name]; [cell setTitleStr:user.name];
} }
} }
return cell; return cell;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
return;
}
if (self.isMoreChose == YES) {
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
if (![self isHaveIndexPath:indexPath]) {
cell.Commitbtn.hidden = NO;
[self.indexArr addObject:indexPath];
}else{
cell.Commitbtn.hidden = YES;
[self.indexArr removeObject:indexPath];
}
}else{
MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath];
currentCell.Commitbtn.hidden = YES;
MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.Commitbtn.hidden = NO;
_currentIndexPath = indexPath;
}
}
- (void)deleteTextFieldStr{
[super deleteTextFieldStr];
[self boxValueChanged:nil];
}
#pragma mark - 按钮事件
- (void)boxValueChanged:(NSNotification *)fication{ - (void)boxValueChanged:(NSNotification *)fication{
NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text]; NSString *tilkeStr = [IBTCommon trimmingCharacters:self.selectTextFiled.text];
[self fetchUserList:tilkeStr]; [self fetchDataList:tilkeStr tableStr:GXF_BASECLASS_USER];
}
- (void)tableViewRefresh{
_currentIndexPath = nil;
if (self.indexArr.count > 0) {
[self.indexArr removeAllObjects];
}
[self.tableView reloadData];
} }
......
...@@ -394,7 +394,7 @@ typedef enum : NSUInteger { ...@@ -394,7 +394,7 @@ typedef enum : NSUInteger {
[self startDatePickView]; [self startDatePickView];
}else if(indexPath.row == 4){ }else if(indexPath.row == 4){
ChosePersonViewController *cvc = [ChosePersonViewController new]; ChosePersonViewController *cvc = [ChosePersonViewController new];
cvc.chosePerson = ^(NSArray *users){ cvc.choseBaseInfo = ^(NSArray *users){
if(users.count > 0){ if(users.count > 0){
NSString *textStr = @""; NSString *textStr = @"";
if (self.users.count > 0) { if (self.users.count > 0) {
...@@ -417,7 +417,8 @@ typedef enum : NSUInteger { ...@@ -417,7 +417,8 @@ typedef enum : NSUInteger {
}else if(indexPath.row == 1){ }else if(indexPath.row == 1){
ChooseProductViewController *cvc = [ChooseProductViewController new]; ChooseProductViewController *cvc = [ChooseProductViewController new];
cvc.choseProduct = ^(Product *product){ cvc.choseBaseInfo = ^(NSArray *products){
Product *product = products[0];
_productLabel.text = [NSString stringWithFormat:@"%@[%@]",product.name,product.code]; _productLabel.text = [NSString stringWithFormat:@"%@[%@]",product.name,product.code];
_productLabel.textColor = GXF_CONTENT_COLOR; _productLabel.textColor = GXF_CONTENT_COLOR;
self.productNameStr = product.name; self.productNameStr = product.name;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
[self.view addSubview:headCell]; [self.view addSubview:headCell];
self.tableView.tableHeaderView = headCell; self.tableView.tableHeaderView = headCell;
FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加原料明细"]; FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加原料明细" isTwo:@""];
[self.view addSubview:footCell]; [self.view addSubview:footCell];
footCell.delegate = self; footCell.delegate = self;
self.tableView.tableFooterView = footCell; self.tableView.tableFooterView = footCell;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
[self.view addSubview:headCell]; [self.view addSubview:headCell];
self.tableView.tableHeaderView = headCell; self.tableView.tableHeaderView = headCell;
FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加原料明细"]; FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加原料明细" isTwo:@""];
[self.view addSubview:footCell]; [self.view addSubview:footCell];
footCell.delegate = self; footCell.delegate = self;
self.tableView.tableFooterView = footCell; self.tableView.tableFooterView = footCell;
......
...@@ -45,11 +45,11 @@ ...@@ -45,11 +45,11 @@
HeaderCell *headCell = [[HeaderCell alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 38) withArr:arr]; HeaderCell *headCell = [[HeaderCell alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 38) withArr:arr];
[self.view addSubview:headCell]; [self.view addSubview:headCell];
self.tableView.tableHeaderView = headCell; self.tableView.tableHeaderView = headCell;
//
FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加原料明细"]; // FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加原料明细" ];
[self.view addSubview:footCell]; // [self.view addSubview:footCell];
footCell.delegate = self; // footCell.delegate = self;
self.tableView.tableFooterView = footCell; // self.tableView.tableFooterView = footCell;
} }
- (void)addClick{ - (void)addClick{
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
@protocol FooterCellDelegate <NSObject> @protocol FooterCellDelegate <NSObject>
- (void)addClick; - (void)addClick;
- (void)choosePurchase;
@end @end
@interface FooterCell : UIView @interface FooterCell : UIView
- (instancetype)initWithFrame:(CGRect)frame withTitle:(NSString *)title; - (instancetype)initWithFrame:(CGRect)frame withTitle:(NSString *)title isTwo:(NSString *)twoTitle;
@property (nonatomic,strong)id<FooterCellDelegate>delegate; @property (nonatomic,strong)id<FooterCellDelegate>delegate;
@end @end
...@@ -11,14 +11,19 @@ ...@@ -11,14 +11,19 @@
#define LeftMargin 13 #define LeftMargin 13
@interface FooterCell () @interface FooterCell ()
@property (nonatomic,strong)NSString *title; @property (nonatomic,strong)NSString *title;
@property (nonatomic,strong)NSString *twoTitle;
@property (nonatomic,strong)UILabel *lineLabel; @property (nonatomic,strong)UILabel *lineLabel;
@end @end
@implementation FooterCell @implementation FooterCell
- (instancetype)initWithFrame:(CGRect)frame withTitle:(NSString *)title{ - (instancetype)initWithFrame:(CGRect)frame withTitle:(NSString *)title isTwo:(NSString *)twoTitle{
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
self.title = title; self.title = title;
if (twoTitle.length > 0) {
self.twoTitle = twoTitle;
}
[self bulidLayout]; [self bulidLayout];
} }
return self; return self;
...@@ -33,6 +38,18 @@ ...@@ -33,6 +38,18 @@
[addBtn addTarget:self action:@selector(addBtn) forControlEvents:UIControlEventTouchUpInside]; [addBtn addTarget:self action:@selector(addBtn) forControlEvents:UIControlEventTouchUpInside];
addBtn.titleLabel.font = GXF_FIFTEENTEN_SIZE; addBtn.titleLabel.font = GXF_FIFTEENTEN_SIZE;
[self addSubview:addBtn]; [self addSubview:addBtn];
if (self.twoTitle.length > 0) {
addBtn.frame = CGRectMake(0, 0, self.frame.size.width/2, 50);
UIButton *otherBtn = [UIButton buttonWithType:UIButtonTypeCustom];
otherBtn.frame = CGRectMake(self.frame.size.width/2, 0, self.frame.size.width/2, 50);
[otherBtn setTitle:self.twoTitle forState:UIControlStateNormal];
otherBtn.backgroundColor = [UIColor whiteColor];
[otherBtn setTitleColor:GXF_PLACEHOLDER_COLOR forState:UIControlStateNormal];
[otherBtn addTarget:self action:@selector(otherClick) forControlEvents:UIControlEventTouchUpInside];
otherBtn.titleLabel.font = GXF_FIFTEENTEN_SIZE;
[self addSubview:otherBtn];
}
self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, self.frame.size.height-1, ScreenSize.width - LeftMargin * 2, 1))]; self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, self.frame.size.height-1, ScreenSize.width - LeftMargin * 2, 1))];
self.lineLabel.backgroundColor = GXF_LINE_COLOR; self.lineLabel.backgroundColor = GXF_LINE_COLOR;
self.lineLabel.font = GXF_FIFTEENTEN_SIZE; self.lineLabel.font = GXF_FIFTEENTEN_SIZE;
...@@ -44,6 +61,10 @@ ...@@ -44,6 +61,10 @@
[self.delegate addClick]; [self.delegate addClick];
} }
} }
- (void)otherClick{
if ([self.delegate respondsToSelector:@selector(choosePurchase)]) {
[self.delegate choosePurchase];
}
}
@end @end
...@@ -113,7 +113,6 @@ ...@@ -113,7 +113,6 @@
}else if(indexPath.row == 4){ }else if(indexPath.row == 4){
contentLabel.text = @"选择加工工厂"; contentLabel.text = @"选择加工工厂";
self.factoryLabel = contentLabel; self.factoryLabel = contentLabel;
} }
} }
} }
......
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