Commit ff0b3ea6 authored by 陈俊俊's avatar 陈俊俊

选择采购单刷新

parent 372eed79
......@@ -120,6 +120,7 @@
#define ChooseWarehouseUpdateDate @"chooseWarehouseUpdateDate"
#define PurchaseUpdateDate @"purchaseUpdateDate"
#define TransportUpdateDate @"TransportUpdateDate"
#define PurchaseNoticeUpdateDate @"purchaseNoticeUpdateDate"
//行情调研状态
......
......@@ -81,43 +81,25 @@ typedef enum : NSUInteger {
NSMutableArray *orderArr =[NSMutableArray array];
if (self.orderDirection.length > 0 && ![self.orderDirection isEqualToString:@"none"]) {
QueryOrder *order = [QueryOrder new];
order.field = @"lastModified";
order.field = @"created";
order.direction = self.orderDirection;
[orderArr addObject:[order dictForCommit]];
}
id billObject = [NSNull null];
if (self.billLike.length > 0) {
billObject = self.billLike;
if (self.orderDirection.length > 0 && ![self.orderDirection isEqualToString:@"none"]) {
QueryOrder *order = [QueryOrder new];
order.field = @"billNumber";
order.direction = self.orderDirection;
[orderArr addObject:[order dictForCommit]];
}
}
id stateObject = [NSNull null];
if (self.state.length > 0 && ![self.state isEqualToString:@"none"]) {
stateObject = self.state;
if (self.orderDirection.length > 0 && ![self.orderDirection isEqualToString:@"none"]) {
QueryOrder *order = [QueryOrder new];
order.field = @"state";
order.direction = self.orderDirection;
[orderArr addObject:[order dictForCommit]];
}
}
id titleObject = [NSNull null];
if (self.titleLike.length > 0) {
titleObject = self.titleLike;
if (self.orderDirection.length > 0 && ![self.orderDirection isEqualToString:@"none"]) {
QueryOrder *order = [QueryOrder new];
order.field = @"titleLike";
order.direction = self.orderDirection;
[orderArr addObject:[order dictForCommit]];
}
}
if (orderArr.count == 0) {
QueryOrder *order = [QueryOrder new];
order.field = @"billNumber";
order.field = @"created";
order.direction = @"desc";
[orderArr addObject:[order dictForCommit]];
......@@ -176,7 +158,7 @@ typedef enum : NSUInteger {
_currentPage = 0;
[self getData];
}];
self.tableView.header.lastUpdatedTimeKey = PurchaseUpdateDate;
self.tableView.header.lastUpdatedTimeKey = PurchaseNoticeUpdateDate;
self.tableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
if (_isLoadMore) {
......
......@@ -34,22 +34,6 @@
if (!self.transportProductArr) {
self.transportProductArr = [NSMutableArray array];
}
// TransportPdtDetail *pdtDetail = [TransportPdtDetail new];
//
// pdtDetail.productName = @"dd";
// pdtDetail.productUuid = @"402880e64e287fe2014e28895b8a0032";
// pdtDetail.productCode = @"农夫山泉";
// pdtDetail.qpc = [NSNumber numberWithFloat:22];
// pdtDetail.unit = @"筐";
// pdtDetail.qty = [NSNumber numberWithFloat:23];
// pdtDetail.price = [NSNumber numberWithFloat:333];
// pdtDetail.baseQty = [NSNumber numberWithFloat:333];
// pdtDetail.total = [NSNumber numberWithFloat:80];
// pdtDetail.note = @"hshshshsh";
// pdtDetail.qpcStr = @"fdsfdsfdsa";
//
//
// [self.transportProductArr addObject:pdtDetail];
}
- (void)setViewFrame:(CGRect)viewFrame{
......
......@@ -10,9 +10,15 @@
#import "TransportPurchaseCell.h"
#import "QueryOrder.h"
#import "TransportPdtDetail.h"
#import "MJRefresh.h"
#define TopMargin 50
#define TableHeight 50
@interface TransportPurchaseViewController ()<UITextFieldDelegate,UITableViewDataSource,UITableViewDelegate>
{
BOOL _isRefresh;
BOOL _isLoadMore;
NSInteger _currentPage;
}
@property (nonatomic,strong)NSMutableArray *indexArr;
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)UITableView *tableView;
......@@ -24,12 +30,11 @@
- (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 {
......@@ -37,6 +42,7 @@
self.title = @"选择采购单";
[self initData];
[self bulidLayout];
[self createRefresh];
[self getData];
}
- (void)initData{
......@@ -59,7 +65,6 @@
ICRUserUtil *userUtil = [ICRUserUtil sharedInstance];
NSMutableArray *orderArr =[NSMutableArray array];
if (orderArr.count == 0) {
QueryOrder *order = [QueryOrder new];
order.field = @"billNumber";
......@@ -71,7 +76,8 @@
@"state":@"submitted",
@"queryOrders":orderArr,
@"userUuid":userUtil.userId,
@"pageNumber":@(0),
@"fetchParts":@"products",
@"pageNumber":@(_currentPage),
@"pageSize":@(20)};
[[ICRHTTPController sharedController] queryPurchaseWithData:dict success:succ failure:fail];
}
......@@ -80,13 +86,29 @@
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ;
if (success == 1) {
if (_currentPage == 0) {
if (self.dataArr.count > 0) {
[self.dataArr removeAllObjects];
}
}
NSArray *recodesArr = data[ @"data" ][ @"records" ];
for (NSDictionary *purchaseBillDict in recodesArr) {
PurchaseBill *purchaseBill = [[PurchaseBill alloc]init];
[purchaseBill setValuesForKeysWithDictionary:purchaseBillDict];
purchaseBill.products = [self coverTransportDetProduct:purchaseBillDict[@"products"]];
[self.dataArr addObject:purchaseBill];
}
NSDictionary *pageDict = data[ @"data" ][ @"paging" ];
NSInteger pageCount = [pageDict[@"pageCount"] integerValue];
[self.tableView reloadData];
[self endRefreshing];
if (pageCount <= _currentPage) {
[self.tableView.footer noticeNoMoreData];
}
if (_currentPage == 0 && self.dataArr.count > 0) {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
}else{
[IBTLoadingView showTips:message];
}
......@@ -96,6 +118,22 @@
[IBTLoadingView showTips:@" 无记录 "];
}
}
- (NSMutableArray *)coverTransportDetProduct:(NSArray *)arr{
NSMutableArray *transArr = [NSMutableArray array];
for (NSDictionary *arrDict in arr) {
TransportPdtDetail *detail = [TransportPdtDetail new];
[detail setValuesForKeysWithDictionary:arrDict];
detail.productUuid = arrDict[@"product_uuid"];
detail.productCode = arrDict[@"product_code"];
detail.productName = arrDict[@"product_name"];
detail.price = arrDict[@"basePrice"];
detail.note = arrDict[@"remark"];
[transArr addObject:detail];
}
return transArr;
}
#pragma mark - 布局
- (void)bulidLayout
{
......@@ -130,7 +168,33 @@
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(sureClick)];
self.navigationItem.rightBarButtonItem = rightItem;
}
- (void)createRefresh{
self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
if (_isRefresh) {
return ;
}
_isRefresh = YES;
_currentPage = 0;
[self getData];
}];
self.tableView.header.lastUpdatedTimeKey = TransportUpdateDate;
self.tableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
if (_isLoadMore) {
return ;
}
_isLoadMore = YES;
_currentPage ++;
[self getData];
} ];
}
#pragma mark - 结束刷新
- (void)endRefreshing{
_isLoadMore = NO;
_isRefresh = NO;
[self.tableView.header endRefreshing];
[self.tableView.footer endRefreshing];
}
- (void)deleteTextFieldStr{
self.selectTextFiled.text = @"";
}
......@@ -146,55 +210,25 @@
TransportPurchaseCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[TransportPurchaseCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
if(self.dataArr.count > 0){
PurchaseBill *bill = _dataArr[indexPath.row];
NSMutableArray *arr = [NSMutableArray array];
TransportPdtDetail *billProduct = [TransportPdtDetail new];
billProduct.productName = @"dd";
billProduct.productUuid = @"402880e64e287fe2014e28895b8a0032";
billProduct.productCode = @"农夫山泉";
billProduct.qpc = [NSNumber numberWithFloat:22];
billProduct.unit = @"筐";
billProduct.qty = [NSNumber numberWithFloat:23];
billProduct.price = [NSNumber numberWithFloat:333];
billProduct.baseQty = [NSNumber numberWithFloat:333];
billProduct.total = [NSNumber numberWithFloat:80];
billProduct.note = @"hshshshsh";
billProduct.qpcStr = @"fdsfdsfdsa";
billProduct.purchasebillnumber = bill.billNumber;
[arr addObject:billProduct];
[arr addObject:billProduct];
bill.products = arr;
[cell setPurchaseBill:bill selectArr:self.indexArr];
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 210;
return 180;
}
#pragma mark - 按钮确定
- (void)sureClick{
[self PopViewControllerAnimated:YES];
if (self.indexArr.count > 0) {
NSLog(@"%@",self.indexArr);
self.getProchaseProduct(self.indexArr);
}
}
#pragma mark - 得到通知的方法
- (void)getSelectPurchaseProduct:(NSNotification *)fination{
NSDictionary *dict = fination.userInfo;
TransportPdtDetail *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.
......
......@@ -8,6 +8,7 @@
#import <UIKit/UIKit.h>
#import "PurchaseBill.h"
@interface TransportPurchaseCell : UITableViewCell<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UILabel *lineLabel;
......@@ -23,4 +24,5 @@
- (void)setPurchaseBill:(PurchaseBill *)bill selectArr:(NSMutableArray *)selectArr;
@end
......@@ -29,7 +29,7 @@
{
self.contentView.backgroundColor = XXFBgColor;
UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 200)];
UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 170)];
bgView.backgroundColor = [UIColor whiteColor];
[self.contentView addSubview:bgView];
......@@ -38,19 +38,15 @@
self.titleLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0, 0, ScreenSize.width, 44))];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.text = @"苹果桃子";
self.titleLabel.font = GXF_SEVENTEENTH_SIZE;
self.secondLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0,44-1, ScreenSize.width, 1))];;
self.secondLabel.backgroundColor = GXF_LINE_COLOR;
self.threeLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0,200-1, ScreenSize.width, 1))];;
self.threeLabel.backgroundColor = GXF_LINE_COLOR;
[bgView addSubview:self.titleLabel];
[bgView addSubview:self.lineLabel];
[bgView addSubview:self.secondLabel];
[bgView addSubview:self.threeLabel];
}
......@@ -59,13 +55,7 @@
self.secondArr = [NSMutableArray array];
self.selectArr = selectArr;
[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-45)) style:(UITableViewStylePlain)];
self.secondTable = [[UITableView alloc]initWithFrame:(CGRectMake(0, 44,ScreenSize.width, 170-45)) style:(UITableViewStylePlain)];
self.secondTable.delegate = self;
self.secondTable.dataSource = self;
......@@ -99,72 +89,57 @@
}
TransportPdtDetail * billProduct = self.secondArr[indexPath.row];
[cell setPdtDetail:billProduct row:indexPath.row];
if ([self isHaveIndexPath:indexPath]) {
if ([self isHaveIndexPath:billProduct]) {
cell.editBtn.hidden = NO;
// 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.lineLabel.y = ShowHeight + TableHeight -1;
// cell.showView.height = ShowHeight;
// cell.backgroundColor = XXFBgColor;
}else{
cell.editBtn.hidden = YES;
// 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.lineLabel.y = TableHeight -1;
// cell.showView.height = 0;
// cell.backgroundColor = [UIColor whiteColor];
}
//
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if ([self isHaveIndexPath:indexPath]) {
return ShowHeight + TableHeight;
}
// TransportPdtDetail * billProduct = self.secondArr[indexPath.row];
// if ([self isHaveIndexPath:billProduct]) {
// return ShowHeight + TableHeight;
// }
return TableHeight;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
// TransportPurductCell *cell = (TransportPurductCell *)[tableView cellForRowAtIndexPath:indexPath];
// TransportPdtDetail * billProduct = self.secondArr[indexPath.row];
// CGRect Linefrmame = cell.lineLabel.frame;
// CGRect showfrmame = cell.showView.frame;
// if (![self isHaveIndexPath:indexPath]) {
// cell.editBtn.hidden = NO;
TransportPurductCell *cell = (TransportPurductCell *)[tableView cellForRowAtIndexPath:indexPath];
TransportPdtDetail * billProduct = self.secondArr[indexPath.row];
if (![self isHaveIndexPath:billProduct]) {
cell.editBtn.hidden = NO;
// cell.smallImageView.image = [UIImage imageNamed:@"arrowdown"];
// Linefrmame.origin.y = ShowHeight + TableHeight - 1;
// showfrmame.size.height = ShowHeight;
// cell.lineLabel.y = ShowHeight + TableHeight -1;
// cell.showView.height = ShowHeight;
// cell.backgroundColor = [UIColor whiteColor];
// [self.selectArr addObject:billProduct];
[self.selectArr addObject:billProduct];
// [[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_getSelectPurchaseProduct object:nil userInfo:@{@"selectArr":billProduct,@"state":@"add"}];
// }else{
// [self.selectArr removeObject:billProduct];
// cell.editBtn.hidden = YES;
}else{
[self.selectArr removeObject:billProduct];
cell.editBtn.hidden = YES;
// cell.smallImageView.image = [UIImage imageNamed:@"arrowright"];
// Linefrmame.origin.y = TableHeight -1;
// showfrmame.size.height = 0;
// cell.lineLabel.y = TableHeight -1;
// cell.showView.height = 0;
// cell.backgroundColor = [UIColor whiteColor];
// [[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_getSelectPurchaseProduct object:nil userInfo:@{@"selectArr":billProduct,@"state":@"remove"}];
// }
//
// cell.lineLabel.frame = Linefrmame;
// cell.showView.frame = showfrmame;
// [self.secondTable reloadData];
}
[self.secondTable reloadData];
}
- (BOOL)isHaveIndexPath:(NSIndexPath *)indexPath{
for (NSIndexPath *path in self.selectArr) {
if (path.row == indexPath.row) {
- (BOOL)isHaveIndexPath:(TransportPdtDetail *)billProduct{
for (TransportPdtDetail *detail in self.selectArr) {
if (detail.uuid == billProduct.uuid) {
return YES;
}
}
......
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