Commit 70eb0a29 authored by Javen's avatar Javen

『新建采购单』底部增加费用明细 Sandy

parent 816d96de
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
0460F6741BA8B7A3004A073D /* NotuceRecordCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0460F6731BA8B7A3004A073D /* NotuceRecordCell.m */; }; 0460F6741BA8B7A3004A073D /* NotuceRecordCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0460F6731BA8B7A3004A073D /* NotuceRecordCell.m */; };
0460F6771BA8BA30004A073D /* NoticeRecord.m in Sources */ = {isa = PBXBuildFile; fileRef = 0460F6761BA8BA30004A073D /* NoticeRecord.m */; }; 0460F6771BA8BA30004A073D /* NoticeRecord.m in Sources */ = {isa = PBXBuildFile; fileRef = 0460F6761BA8BA30004A073D /* NoticeRecord.m */; };
047C7E431BA9DF1800051DE7 /* NoticeDetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C7E421BA9DF1800051DE7 /* NoticeDetailCell.m */; }; 047C7E431BA9DF1800051DE7 /* NoticeDetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C7E421BA9DF1800051DE7 /* NoticeDetailCell.m */; };
049957E51C8C1CFD003388D3 /* BottomPurchaseView.m in Sources */ = {isa = PBXBuildFile; fileRef = 049957E41C8C1CFD003388D3 /* BottomPurchaseView.m */; };
049957E81C8C2AFD003388D3 /* PurchaseProductViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 049957E71C8C2AFD003388D3 /* PurchaseProductViewController.m */; };
04B4A3871B9CAAD700D88D68 /* ShopDetail.m in Sources */ = {isa = PBXBuildFile; fileRef = 04B4A3861B9CAAD700D88D68 /* ShopDetail.m */; }; 04B4A3871B9CAAD700D88D68 /* ShopDetail.m in Sources */ = {isa = PBXBuildFile; fileRef = 04B4A3861B9CAAD700D88D68 /* ShopDetail.m */; };
04E721E31BA755FD008F9158 /* ProductUnit.m in Sources */ = {isa = PBXBuildFile; fileRef = 04E721E21BA755FD008F9158 /* ProductUnit.m */; }; 04E721E31BA755FD008F9158 /* ProductUnit.m in Sources */ = {isa = PBXBuildFile; fileRef = 04E721E21BA755FD008F9158 /* ProductUnit.m */; };
04F6E70A1B9B08A500550849 /* PurchaseNoticeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F6E7091B9B08A500550849 /* PurchaseNoticeViewController.m */; }; 04F6E70A1B9B08A500550849 /* PurchaseNoticeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F6E7091B9B08A500550849 /* PurchaseNoticeViewController.m */; };
...@@ -531,6 +533,10 @@ ...@@ -531,6 +533,10 @@
0460F6761BA8BA30004A073D /* NoticeRecord.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NoticeRecord.m; sourceTree = "<group>"; }; 0460F6761BA8BA30004A073D /* NoticeRecord.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NoticeRecord.m; sourceTree = "<group>"; };
047C7E411BA9DF1800051DE7 /* NoticeDetailCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoticeDetailCell.h; sourceTree = "<group>"; }; 047C7E411BA9DF1800051DE7 /* NoticeDetailCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoticeDetailCell.h; sourceTree = "<group>"; };
047C7E421BA9DF1800051DE7 /* NoticeDetailCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NoticeDetailCell.m; sourceTree = "<group>"; }; 047C7E421BA9DF1800051DE7 /* NoticeDetailCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NoticeDetailCell.m; sourceTree = "<group>"; };
049957E31C8C1CFD003388D3 /* BottomPurchaseView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BottomPurchaseView.h; sourceTree = "<group>"; };
049957E41C8C1CFD003388D3 /* BottomPurchaseView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BottomPurchaseView.m; sourceTree = "<group>"; };
049957E61C8C2AFD003388D3 /* PurchaseProductViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurchaseProductViewController.h; sourceTree = "<group>"; };
049957E71C8C2AFD003388D3 /* PurchaseProductViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PurchaseProductViewController.m; sourceTree = "<group>"; };
04B4A3851B9CAAD700D88D68 /* ShopDetail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShopDetail.h; sourceTree = "<group>"; }; 04B4A3851B9CAAD700D88D68 /* ShopDetail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShopDetail.h; sourceTree = "<group>"; };
04B4A3861B9CAAD700D88D68 /* ShopDetail.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShopDetail.m; sourceTree = "<group>"; }; 04B4A3861B9CAAD700D88D68 /* ShopDetail.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShopDetail.m; sourceTree = "<group>"; };
04E721E11BA755FD008F9158 /* ProductUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProductUnit.h; sourceTree = "<group>"; }; 04E721E11BA755FD008F9158 /* ProductUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProductUnit.h; sourceTree = "<group>"; };
...@@ -1677,6 +1683,8 @@ ...@@ -1677,6 +1683,8 @@
7281A0A81B8974120052B1AC /* Controllers */ = { 7281A0A81B8974120052B1AC /* Controllers */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
049957E61C8C2AFD003388D3 /* PurchaseProductViewController.h */,
049957E71C8C2AFD003388D3 /* PurchaseProductViewController.m */,
7281A0A91B8974120052B1AC /* NewPurchaseViewController.h */, 7281A0A91B8974120052B1AC /* NewPurchaseViewController.h */,
7281A0AA1B8974120052B1AC /* NewPurchaseViewController.m */, 7281A0AA1B8974120052B1AC /* NewPurchaseViewController.m */,
7281A0AB1B8974120052B1AC /* ProductBillViewController.h */, 7281A0AB1B8974120052B1AC /* ProductBillViewController.h */,
...@@ -1717,6 +1725,8 @@ ...@@ -1717,6 +1725,8 @@
7281A0BB1B897EAB0052B1AC /* PurchaseCell.m */, 7281A0BB1B897EAB0052B1AC /* PurchaseCell.m */,
FE4678B41B8D986900B5EDA3 /* PurchaseBoltView.h */, FE4678B41B8D986900B5EDA3 /* PurchaseBoltView.h */,
FE4678B51B8D986900B5EDA3 /* PurchaseBoltView.m */, FE4678B51B8D986900B5EDA3 /* PurchaseBoltView.m */,
049957E31C8C1CFD003388D3 /* BottomPurchaseView.h */,
049957E41C8C1CFD003388D3 /* BottomPurchaseView.m */,
); );
path = Views; path = Views;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -3163,12 +3173,14 @@ ...@@ -3163,12 +3173,14 @@
C15918801AC4362D0013B391 /* UIApplication+CheckFirstRun.m in Sources */, C15918801AC4362D0013B391 /* UIApplication+CheckFirstRun.m in Sources */,
72A814001BCD3B0A003631F3 /* NewReceiveViewController.m in Sources */, 72A814001BCD3B0A003631F3 /* NewReceiveViewController.m in Sources */,
0460F6711BA8B3FC004A073D /* FollowUpRecordViewController.m in Sources */, 0460F6711BA8B3FC004A073D /* FollowUpRecordViewController.m in Sources */,
049957E51C8C1CFD003388D3 /* BottomPurchaseView.m in Sources */,
C1F696091AB870B400F9F5DD /* main.m in Sources */, C1F696091AB870B400F9F5DD /* main.m in Sources */,
30D9D8811AD3AC5A0086EEE7 /* ICRHelpAndFeedBackViewController.m in Sources */, 30D9D8811AD3AC5A0086EEE7 /* ICRHelpAndFeedBackViewController.m in Sources */,
35CF33871B956CF7001211EF /* GXFBottomView.m in Sources */, 35CF33871B956CF7001211EF /* GXFBottomView.m in Sources */,
C14E3F7F1ADA336F0093325D /* ICRTaskProcessViewController.m in Sources */, C14E3F7F1ADA336F0093325D /* ICRTaskProcessViewController.m in Sources */,
72A814151BCF990B003631F3 /* ReceiveProductViewController.m in Sources */, 72A814151BCF990B003631F3 /* ReceiveProductViewController.m in Sources */,
C1E91C471AD77842007B00D4 /* ICRTask.m in Sources */, C1E91C471AD77842007B00D4 /* ICRTask.m in Sources */,
049957E81C8C2AFD003388D3 /* PurchaseProductViewController.m in Sources */,
C1D0171B1AD8F0D600CD9CB8 /* IBTSegmentContainer.m in Sources */, C1D0171B1AD8F0D600CD9CB8 /* IBTSegmentContainer.m in Sources */,
C10C90991AE56E8700B911CD /* JTOptionCell.m in Sources */, C10C90991AE56E8700B911CD /* JTOptionCell.m in Sources */,
72805D081BB8F22B009E1F82 /* BottomTransferView.m in Sources */, 72805D081BB8F22B009E1F82 /* BottomTransferView.m in Sources */,
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#import "PurchaseBillProduct.h" #import "PurchaseBillProduct.h"
#import "GXFPopView.h" #import "GXFPopView.h"
#import "NoticeProduct.h" #import "NoticeProduct.h"
#import "BottomPurchaseView.h"
#import "NewCostViewController.h"
#define TopHeight 328 #define TopHeight 328
#define BottomHeight 300 #define BottomHeight 300
#define SpaceHeight 20 #define SpaceHeight 20
...@@ -31,6 +33,7 @@ typedef enum : NSUInteger { ...@@ -31,6 +33,7 @@ typedef enum : NSUInteger {
TopPurchaseView *_purchaseView; TopPurchaseView *_purchaseView;
UIView *_bottomView; UIView *_bottomView;
ProductBillViewController *_pvc ; ProductBillViewController *_pvc ;
BottomPurchaseView *_aBottomView;
id uuidObject; id uuidObject;
id billNumberObject; id billNumberObject;
NSNumber *versionObject; NSNumber *versionObject;
...@@ -52,6 +55,7 @@ typedef enum : NSUInteger { ...@@ -52,6 +55,7 @@ typedef enum : NSUInteger {
//监听值的改变 //监听值的改变
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setProductTotalPrice:) name:SetProductTotalPrice object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setProductTotalPrice:) name:SetProductTotalPrice object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addPurchaseProduct:) name:KNOTIFICATION_AddPurchaseProduct object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addPurchaseProduct:) name:KNOTIFICATION_AddPurchaseProduct object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addTransportCost:) name:KNOTIFICATION_AddTransportCost object:nil];
} }
return self; return self;
} }
...@@ -72,7 +76,7 @@ typedef enum : NSUInteger { ...@@ -72,7 +76,7 @@ typedef enum : NSUInteger {
_purchaseView.noticeNumber = self.purchaseNotice.billnumber; _purchaseView.noticeNumber = self.purchaseNotice.billnumber;
//转换 //转换
NSMutableArray *arr = [self coverPurchaseBillProduct:self.purchaseNotice.products]; NSMutableArray *arr = [self coverPurchaseBillProduct:self.purchaseNotice.products];
_pvc.productArr = arr; _aBottomView.productVC.productArr = arr;
} }
} }
- (void)getDataFromServer{ - (void)getDataFromServer{
...@@ -114,10 +118,38 @@ typedef enum : NSUInteger { ...@@ -114,10 +118,38 @@ typedef enum : NSUInteger {
[billProduct setValuesForKeysWithDictionary:productDict]; [billProduct setValuesForKeysWithDictionary:productDict];
[arr addObject:billProduct]; [arr addObject:billProduct];
} }
_pvc.productArr = arr; _aBottomView.productVC.productArr = arr;
[_pvc.tableView reloadData]; [_aBottomView.productVC.tableView reloadData];
} }
- (void)addTransportCost:(NSNotification *)fination{
NewCostViewController *nvc = [NewCostViewController new];
NSIndexPath *indexPath = [[fination userInfo] objectForKey:@"indexPath"];
FeeAcountDetail *fee = [[fination userInfo] objectForKey:@"feeAccountDetail"];
if (indexPath) {
nvc.navTitle = @"编辑费用";
nvc.indexPath = indexPath;
nvc.accountDetail = fee;
}else{
nvc.navTitle = @"添加费用";
}
nvc.getTransportCost = ^(FeeAcountDetail *fee,NSIndexPath *indexPath){
if (fee) {
[_aBottomView refreshCost:fee indexPath:indexPath];
}
};
nvc.deleteTransportCost = ^(FeeAcountDetail *fee,NSIndexPath *indexPath){
if (fee) {
[_aBottomView refreshDelCost:fee indexPath:indexPath];
}
};
[self PushViewController:nvc animated:YES];
}
#pragma mark - 布局 #pragma mark - 布局
- (void)bulidLayout - (void)bulidLayout
{ {
...@@ -142,13 +174,16 @@ typedef enum : NSUInteger { ...@@ -142,13 +174,16 @@ typedef enum : NSUInteger {
_purchaseView.delegate = self; _purchaseView.delegate = self;
[_scrollView addSubview:_purchaseView]; [_scrollView addSubview:_purchaseView];
_bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_purchaseView.frame) + 20, ScreenSize.width,BottomHeight)]; // _bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_purchaseView.frame) + 20, ScreenSize.width,BottomHeight)];
_bottomView.backgroundColor = [UIColor whiteColor]; // _bottomView.backgroundColor = [UIColor whiteColor];
[_scrollView addSubview:_bottomView]; // [_scrollView addSubview:_bottomView];
//
_pvc = [[ProductBillViewController alloc]init]; // _pvc = [[ProductBillViewController alloc]init];
_pvc.viewFrame = _bottomView.bounds; // _pvc.viewFrame = _bottomView.bounds;
[_bottomView addSubview:_pvc.view]; // [_bottomView addSubview:_pvc.view];
_aBottomView = [[BottomPurchaseView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_purchaseView.frame) + 20, ScreenSize.width,BottomHeight) withHidden:NO];
_aBottomView.backgroundColor = [UIColor whiteColor];
[_scrollView addSubview:_aBottomView];
} }
...@@ -156,7 +191,7 @@ typedef enum : NSUInteger { ...@@ -156,7 +191,7 @@ typedef enum : NSUInteger {
//计算总金额 //计算总金额
//其他费用 + 商品总金额 //其他费用 + 商品总金额
float otherPrice = [_purchaseView.otherPriceFiled.text floatValue]; float otherPrice = [_purchaseView.otherPriceFiled.text floatValue];
NSMutableArray *purchaseProduct = _pvc.productArr; NSMutableArray *purchaseProduct = _aBottomView.productVC.productArr;
float totalPrice = 0; float totalPrice = 0;
for (PurchaseBillProduct *billProduct in purchaseProduct) { for (PurchaseBillProduct *billProduct in purchaseProduct) {
totalPrice += [billProduct.total floatValue]; totalPrice += [billProduct.total floatValue];
...@@ -177,12 +212,12 @@ typedef enum : NSUInteger { ...@@ -177,12 +212,12 @@ typedef enum : NSUInteger {
shopDetail.IsXiuGai=YES; shopDetail.IsXiuGai=YES;
svc.choseShopDetail = ^(ShopDetail *Detail){ svc.choseShopDetail = ^(ShopDetail *Detail){
if (Detail.IsDeleted) { if (Detail.IsDeleted) {
[_pvc.productArr removeObjectAtIndex:indexTag]; [_aBottomView.productVC.productArr removeObjectAtIndex:indexTag];
}else{ }else{
PurchaseBillProduct *billProduct = [self coverPurchaseProduct:Detail]; PurchaseBillProduct *billProduct = [self coverPurchaseProduct:Detail];
[_pvc.productArr replaceObjectAtIndex:indexTag withObject:billProduct]; [_aBottomView.productVC.productArr replaceObjectAtIndex:indexTag withObject:billProduct];
} }
[_pvc.tableView reloadData]; [_aBottomView.productVC.tableView reloadData];
[[NSNotificationCenter defaultCenter] postNotificationName:SetProductTotalPrice object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:SetProductTotalPrice object:nil];
}; };
svc.shopDetail=shopDetail; svc.shopDetail=shopDetail;
...@@ -191,8 +226,8 @@ typedef enum : NSUInteger { ...@@ -191,8 +226,8 @@ typedef enum : NSUInteger {
svc.navTitle = @"添加商品"; svc.navTitle = @"添加商品";
svc.choseShopDetail = ^(ShopDetail *shopDetail){ svc.choseShopDetail = ^(ShopDetail *shopDetail){
PurchaseBillProduct *billProduct = [self coverPurchaseProduct:shopDetail]; PurchaseBillProduct *billProduct = [self coverPurchaseProduct:shopDetail];
[_pvc.productArr addObject:billProduct]; [_aBottomView.productVC.productArr addObject:billProduct];
[_pvc.tableView reloadData]; [_aBottomView.productVC.tableView reloadData];
[[NSNotificationCenter defaultCenter] postNotificationName:SetProductTotalPrice object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:SetProductTotalPrice object:nil];
}; };
} }
...@@ -276,7 +311,7 @@ typedef enum : NSUInteger { ...@@ -276,7 +311,7 @@ typedef enum : NSUInteger {
} }
} }
NSMutableArray *billProducts = [NSMutableArray array]; NSMutableArray *billProducts = [NSMutableArray array];
for (PurchaseBillProduct *billProduct in _pvc.productArr) { [billProducts addObject:[billProduct dictForCommit]]; for (PurchaseBillProduct *billProduct in _aBottomView.productVC.productArr) { [billProducts addObject:[billProduct dictForCommit]];
} }
self.state = state; self.state = state;
NSDictionary *dict = @{@"uuid":uuidObject, NSDictionary *dict = @{@"uuid":uuidObject,
...@@ -314,7 +349,7 @@ typedef enum : NSUInteger { ...@@ -314,7 +349,7 @@ typedef enum : NSUInteger {
ShowMessage(@"收货仓库不能为空"); ShowMessage(@"收货仓库不能为空");
return NO; return NO;
} }
if (_pvc.productArr.count == 0) { if (_aBottomView.productVC.productArr.count == 0) {
ShowMessage(@"采购商品不能为空"); ShowMessage(@"采购商品不能为空");
return NO; return NO;
} }
...@@ -322,7 +357,7 @@ typedef enum : NSUInteger { ...@@ -322,7 +357,7 @@ typedef enum : NSUInteger {
ShowMessage(@"金额不能为空"); ShowMessage(@"金额不能为空");
return NO; return NO;
} }
for (PurchaseBillProduct *billProduct in _pvc.productArr) { for (PurchaseBillProduct *billProduct in _aBottomView.productVC.productArr) {
if ([billProduct.qty floatValue] <= 0 || [billProduct.baseQty floatValue] <= 0) { if ([billProduct.qty floatValue] <= 0 || [billProduct.baseQty floatValue] <= 0) {
ShowMessage(@"有数量等于0的商品明细,请编辑后保存"); ShowMessage(@"有数量等于0的商品明细,请编辑后保存");
return NO; return NO;
......
//
// PurchaseProductViewController.h
// XFFruit
//
// Created by Mac on 16/3/6.
// Copyright © 2016年 Xummer. All rights reserved.
//
#import "ICRBaseViewController.h"
@interface PurchaseProductViewController : ICRBaseViewController
@property (nonatomic,strong)NSMutableArray *transportProductArr;
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,assign)CGRect viewFrame;
@property (nonatomic,assign)BOOL isHiddenEdit;
@property (nonatomic,strong)NSString *twoTitle;
@end
//
// PurchaseProductViewController.m
// XFFruit
//
// Created by Mac on 16/3/6.
// Copyright © 2016年 Xummer. All rights reserved.
//
#import "PurchaseProductViewController.h"
#import "FooterCell.h"
#import "HeaderCell.h"
#import "TransportPurductCell.h"
#import "TransportPdtDetail.h"
#import "GXFPopView.h"
#define TableHeight 44
#define ShowHeight 130
@interface PurchaseProductViewController ()
<UITableViewDataSource,UITableViewDelegate,FooterCellDelegate,HeaderCellDelegate,GXFPopViewDelegate>
{
CGRect _tableFrame;
NSMutableArray *_selectRowArr;//记录当前选中的cell
}
@property (nonatomic,strong)GXFPopView *popView;
@end
@implementation PurchaseProductViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = XXFBgColor;
[self initData];
[self createView];
}
- (void)initData{
_selectRowArr = [[NSMutableArray alloc]init];
if (!self.transportProductArr) {
self.transportProductArr = [NSMutableArray array];
}
}
- (void)setViewFrame:(CGRect)viewFrame{
_tableFrame = viewFrame;
}
- (void)createView{
self.tableView = [[UITableView alloc]initWithFrame:_tableFrame style:(UITableViewStylePlain)];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:self.tableView];
NSArray *arr = @[@"商品",@"单价",@"包装数量",@"已转运数"];
HeaderCell *headCell = [[HeaderCell alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 38) withArr:arr withHiddenEdit:self.isHiddenEdit];
[self.view addSubview:headCell];
headCell.delegate = self;
self.tableView.tableHeaderView = headCell;
// if (!self.isHiddenEdit) {
// FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加商品明细" isTwo:self.twoTitle];
// [self.view addSubview:footCell];
// footCell.delegate = self;
// self.tableView.tableFooterView = footCell;
// }
}
#pragma mark - headCellDelegate
- (void)addClickList{
if (!self.popView) {
// NSArray *arr = @[@"添加商品明细",@"选择采购单"];
// NSArray *arr = @[@"选择采购单"];
//
// self.popView = [[GXFPopView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, ScreenSize.height) withArr:arr];
// self.popView.delegate = self;
// [AppWindow addSubview:self.popView];
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_AddPurchaseProduct object:nil];
}
}
#pragma mark - popViewdelegate
- (void)selectRowTitle:(NSString *)str{
if (self.popView) {
[self.popView removeFromSuperview];
self.popView= nil;
}
if ([str isEqualToString:@"添加商品明细"]) {
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_AddPurchaseProduct object:nil];
}else if([str isEqualToString:@"选择采购单"]){
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_ChoseTransportPurchase object:nil];
}
}
- (void)clearFromSuper{
if (self.popView) {
[self.popView removeFromSuperview];
self.popView = nil;
}
}
#pragma mark - footerDelegate
- (void)addClick{
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_AddPurchaseProduct object:nil];
}
- (void)editClick:(UIButton *)btn{
TransportPdtDetail *pdDetail = self.transportProductArr[btn.tag];
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_AddPurchaseProduct object:nil userInfo:@{@"transportPdtDetail":pdDetail,@"indexTag":@(btn.tag)}];
}
- (void)choosePurchase{
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_ChoseTransportPurchase object:nil];
}
#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.transportProductArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"TransportPurductCell";
TransportPurductCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[TransportPurductCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID withImageName:@"edit"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (self.isHiddenEdit) {
cell.editBtn.hidden = YES;
}
}
if ([self isHaveIndexPath:indexPath]) {
cell.smallImageView.image = [UIImage imageNamed:@"arrowdown"];
CGRect Linefrmame = cell.lineLabel.frame;
Linefrmame.origin.y = ShowHeight + TableHeight -1;
cell.lineLabel.frame = Linefrmame;
CGRect showfrmame = cell.showView.frame;
showfrmame.size.height = ShowHeight;
cell.showView.frame = showfrmame;
cell.backgroundColor = XXFBgColor;
}else{
cell.smallImageView.image = [UIImage imageNamed:@"arrowright"];
CGRect Linefrmame = cell.lineLabel.frame;
Linefrmame.origin.y = TableHeight-1;
cell.lineLabel.frame = Linefrmame;
CGRect showfrmame = cell.showView.frame;
showfrmame.size.height = 0;
cell.showView.frame = showfrmame;
cell.backgroundColor = [UIColor whiteColor];
}
cell.editBtn.tag = indexPath.row;
[cell.editBtn addTarget:self action:@selector(editClick:) forControlEvents:UIControlEventTouchUpInside];
if (self.transportProductArr.count > 0) {
TransportPdtDetail *billP = self.transportProductArr[indexPath.row];
[cell setPdtDetail:billP row:indexPath.row];
}
return cell;
}
- (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath{
for (NSIndexPath *path in _selectRowArr) {
if (path.row == indexPath.row) {
return YES;
}
}
return NO;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
TransportPurductCell *cell = (TransportPurductCell *)[tableView cellForRowAtIndexPath:indexPath];
CGRect Linefrmame = cell.lineLabel.frame;
CGRect showfrmame = cell.showView.frame;
if (Linefrmame.origin.y == TableHeight - 1) {
cell.smallImageView.image = [UIImage imageNamed:@"arrowdown"];
Linefrmame.origin.y = ShowHeight + TableHeight - 1;
showfrmame.size.height = ShowHeight;
cell.backgroundColor = [UIColor whiteColor];
[_selectRowArr addObject:indexPath];
}else{
cell.smallImageView.image = [UIImage imageNamed:@"arrowright"];
Linefrmame.origin.y = TableHeight -1;
showfrmame.size.height = 0;
cell.backgroundColor = [UIColor whiteColor];
[_selectRowArr removeObject:indexPath];
}
cell.lineLabel.frame = Linefrmame;
cell.showView.frame = showfrmame;
[self.tableView reloadData];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if ([self isHaveIndexPath:indexPath]) {
return ShowHeight + TableHeight;
}
return TableHeight;
}
- (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
//
// BottomPurchaseView.h
// XFFruit
//
// Created by Mac on 16/3/6.
// Copyright © 2016年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "PurchaseProductViewController.h"
#import "CostViewController.h"
#import "FeeAcountDetail.h"
#import "TransportPdtDetail.h"
#import "ProductBillViewController.h"
@interface BottomPurchaseView : UIView
- (instancetype)initWithFrame:(CGRect)frame withHidden:(BOOL)isHidden;
@property (nonatomic,strong)ProductBillViewController *productVC;
@property (nonatomic,strong)CostViewController *costVC;
@property (nonatomic,assign)BOOL isHiddenEdit;
//添加或者编辑费用
- (void)refreshCost:(FeeAcountDetail *)fee indexPath:(NSIndexPath *)indexPath;
//删除费用
- (void)refreshDelCost:(FeeAcountDetail *)fee indexPath:(NSIndexPath *)indexPath;
//刷新费用
- (void)refreshCost:(NSArray *)costArr;
//刷新商品
- (void)refreshTranProduct:(NSArray *)tranProductArr;
#warning - 临时
- (void)reProduct:(NSArray *)tranProductArr;
//删除商品
- (void)refreshDelProduct:(TransportPdtDetail *)fee tag:(NSInteger)indexTag;
//添加
- (void)refreshProduct:(TransportPdtDetail *)transportPdtDetail;
- (void)refreshEditProduct:(TransportPdtDetail *)transportPdtDetail tag:(NSInteger)indexTag;
@end
//
// BottomPurchaseView.m
// XFFruit
//
// Created by Mac on 16/3/6.
// Copyright © 2016年 Xummer. All rights reserved.
//
#import "BottomPurchaseView.h"
#import "TransportPdtDetail.h"
#import "FeeAcountDetail.h"
#define ContentHeight 44
#define BtnWidth 100
#define BeginTag 8000
#define SpaceWidth (ScreenSize.width - 100*2)/3
@interface BottomPurchaseView ()<UIScrollViewDelegate>
{
UIScrollView *_bottomSV;
UIImageView *_moveImageView;
UIButton *_currentBtn;
UIButton *_addBtn;
}
@end
@implementation BottomPurchaseView
- (instancetype)initWithFrame:(CGRect)frame withHidden:(BOOL)isHidden{
self = [super initWithFrame:frame];
if (self) {
self.isHiddenEdit = isHidden;
//界面
[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.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;
self.productVC.isHiddenEdit = self.isHiddenEdit;
[view addSubview:self.productVC.view];
}else if(i == 1){
self.costVC.viewFrame = view.bounds;
self.costVC.isHiddenEdit = self.isHiddenEdit;
[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:(TransportPdtDetail *)transportPdtDetail
{
if (self.productVC.productArr) {
[self.productVC.productArr addObject:transportPdtDetail];
[self.productVC.tableView reloadData];
}
}
//添加编辑
- (void)refreshCost:(FeeAcountDetail *)fee indexPath:(NSIndexPath *)indexPath{
if (indexPath) {
[self.costVC.costArr replaceObjectAtIndex:indexPath.row withObject:fee];
// NSArray *indexArray=[NSArray arrayWithObject:indexPath];
// [self.costVC.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationAutomatic];
[self.costVC.tableView reloadData];
}else{
if (self.costVC.costArr) {
[self.costVC.costArr addObject:fee];
[self.costVC.tableView reloadData];
}
}
}
//删除
- (void)refreshDelCost:(FeeAcountDetail *)fee indexPath:(NSIndexPath *)indexPath{
if (indexPath) {
[self.costVC.costArr removeObjectAtIndex:indexPath.row];
[self.costVC.tableView reloadData];
}
}
//刷新
- (void)refreshCost:(NSArray *)costArr{
NSMutableArray *feeArr = [NSMutableArray array];
for (NSDictionary *billDict in costArr) {
FeeAcountDetail *billProbuct = [FeeAcountDetail new];
[billProbuct setValuesForKeysWithDictionary:billDict];
[feeArr addObject:billProbuct];
}
self.costVC.costArr = feeArr;
[self.costVC.tableView reloadData];
}
- (void)refreshTranProduct:(NSArray *)tranProductArr{
NSMutableArray *productArr = [NSMutableArray array];
for (NSDictionary *billDict in tranProductArr) {
TransportPdtDetail *billProbuct = [TransportPdtDetail new];
[billProbuct setValuesForKeysWithDictionary:billDict];
[productArr addObject:billProbuct];
}
self.productVC.productArr = productArr;
[self.productVC.tableView reloadData];
}
- (void)reProduct:(NSArray *)tranProductArr{
[self.productVC.productArr addObjectsFromArray:tranProductArr];
[self.productVC.tableView reloadData];
}
- (void)refreshDelProduct:(TransportPdtDetail *)fee tag:(NSInteger)indexTag{
if (fee) {
[self.productVC.productArr removeObjectAtIndex:indexTag];
[self.productVC.tableView reloadData];
}
}
- (void)refreshEditProduct:(TransportPdtDetail *)transportPdtDetail tag:(NSInteger)indexTag{
[self.productVC.productArr replaceObjectAtIndex:indexTag withObject:transportPdtDetail];
[self.productVC.tableView reloadData];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment