From 2969e140332e1a7b0f712655643b20db4a827119 Mon Sep 17 00:00:00 2001 From: woaomo <609429505@qq.com> Date: Sun, 13 Sep 2015 15:37:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BF=AE=E6=94=B9=E5=95=86?= =?UTF-8?q?=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YHB_Prj/Yudanchaxun/YDCXViewController.m | 37 +++++++++++++ .../EditSPVC/SPEditViewController.m | 54 +++++++++++++++---- .../shangpinguanli/EditSPVC/SPManager.m | 5 +- .../EditSPVC/YPDMViewController.h | 2 +- .../EditSPVC/YPDMViewController.m | 8 ++- .../shangpinguanli/SPGLProductDetail.m | 5 +- 6 files changed, 95 insertions(+), 16 deletions(-) diff --git a/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXViewController.m b/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXViewController.m index 3325b89..d5744e3 100644 --- a/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXViewController.m +++ b/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXViewController.m @@ -12,6 +12,7 @@ #import "DJYDCXRows.h" #import "YDCXDetailViewController.h" #import "JCCXSXViewController.h" +#import "SVPullToRefresh.h" static const CGFloat topBtnHeight = 44; static const CGFloat bottomViewHeight = 44; @@ -52,6 +53,8 @@ - (void)viewDidLoad { _tableviewYudan.separatorStyle = UITableViewCellSeparatorStyleNone; [self.view addSubview:_tableviewYudan]; + [self addTableViewTrag]; + [self createBottomView]; _arrNo = [NSMutableArray arrayWithCapacity:0]; @@ -62,6 +65,40 @@ - (void)viewDidLoad { [self.btnNo sendActionsForControlEvents:UIControlEventTouchUpInside]; } +#pragma mark 增加上拉下拉 +- (void)addTableViewTrag +{ + __weak YDCXViewController *weakself = self; +// [weakself.myTableView addPullToRefreshWithActionHandler:^{ +// [_manager getSaleHisByProductIdApp:productId finishBlock:^(NSArray *resultArr) { +// if (resultArr && resultArr.count>0) +// { +// _arrData = [resultArr mutableCopy]; +// [_myTableView reloadData]; +// } +// else [SVProgressHUD showErrorWithStatus:@"无数据" cover:YES offsetY:kMainScreenHeight/2.0]; +// [weakself.myTableView.pullToRefreshView stopAnimating]; +// } isRefresh:YES]; +// }]; + + + [weakself.tableviewYudan addInfiniteScrollingWithActionHandler:^{ + if (_currentArray.count%20==0 && _currentArray.count!=0) + { + [_manage appGetVipCerditListArr:_currentStatus isRefresh:NO finishBlock:^(NSArray *resultArr) { + if (resultArr && resultArr.count>0) + { + [_currentArray addObjectsFromArray:resultArr]; + [_tableviewYudan reloadData]; + } + else [SVProgressHUD showErrorWithStatus:@"无数据" cover:YES offsetY:kMainScreenHeight/2.0]; + [weakself.tableviewYudan.infiniteScrollingView stopAnimating]; + }]; + } + else [weakself.tableviewYudan.infiniteScrollingView stopAnimating]; + }]; +} + #pragma mark Btn相关 - (void)createTopView { diff --git a/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPEditViewController.m b/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPEditViewController.m index 6919343..bd19800 100644 --- a/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPEditViewController.m +++ b/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPEditViewController.m @@ -28,8 +28,8 @@ typedef NS_ENUM(NSInteger, FieldType) { @interface SPEditViewController () { - NSString *cid; - NSString *supid; + NSString *_cid; + NSString *_supid; } @property(nonatomic,strong) SPGLProductMode *myMode; @@ -57,6 +57,8 @@ @interface SPEditViewController () @property(nonatomic,strong) UIActionSheet *sheetjf; @property(nonatomic,strong) SPManager *manager; + +@property(nonatomic,strong) UITapGestureRecognizer *tapGR; @end @implementation SPEditViewController @@ -66,6 +68,8 @@ - (instancetype)initWithMode:(SPGLProductMode *)aMode if (self=[super init]) { _myMode = aMode; + if (aMode.strCid) _cid = aMode.strCid; + if (aMode.strSupid) _supid = aMode.strSupid; } return self; } @@ -77,6 +81,9 @@ - (void)viewDidLoad { [self createScrollView]; + _tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchView)]; + [_bgScrollView addGestureRecognizer:_tapGR]; + CGFloat btnWidth = 200; _btnOK = [[UIButton alloc] initWithFrame:CGRectMake(kMainScreenWidth/2.0-btnWidth/2.0, kMainScreenHeight-64-50+10, btnWidth, 30)]; _btnOK.backgroundColor = KColor; @@ -100,7 +107,8 @@ - (void)createScrollView _titleArray = @[@"条码:",@"品名:",@"分类:",@"库存:",@"进价:",@"售价:",@"单位:",@"供货商:",@"折扣活动:",@"积分商品:"]; NSString *isAct = [_myMode.strActEnable intValue]==1?@"参加":@"不参加"; NSString *isScore = [_myMode.strIsScore intValue]==1?@"是":@"否"; - _contentArray = @[_myMode.strProductCode,_myMode.strProductName,_myMode.strClsName,_myMode.strStockQty,_myMode.strBuyingPrice,_myMode.strSalePrice,_myMode.strSaleUnit,_myMode.strSupName,isAct,isScore]; + NSString *supName = _myMode.strSupName?_myMode.strSupName:@""; + _contentArray = @[_myMode.strProductCode,_myMode.strProductName,_myMode.strClsName,_myMode.strStockQty,_myMode.strBuyingPrice,_myMode.strSalePrice,_myMode.strSaleUnit,supName,isAct,isScore]; CGFloat endHeight = 0; for (int i=0; i<_titleArray.count; i++) @@ -124,7 +132,7 @@ - (void)createScrollView textField.tag = 100+i; [_bgScrollView addSubview:textField]; textField.text = _contentArray[i]; - if (i==FieldTypejj || i==FieldTypesj) textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; + if (i==FieldTypejj || i==FieldTypesj || i==FieldTypetm) textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; if (i==FieldTypekc) textField.enabled = NO; if (i==FieldTypekc) textField.textColor = [UIColor lightGrayColor]; } @@ -170,42 +178,57 @@ - (void)createScrollView #pragma mark touchBtn - (void)touchfl { + [self.view endEditing:YES]; void(^selectBlock)(SPGLCategoryMode *) = ^(SPGLCategoryMode *aMode){ [_btnfl setTitle:aMode.strCateName forState:UIControlStateNormal]; - cid = aMode.strId; + _cid = aMode.strId; }; [self pushXIBName:@"ShangpinguanliVC" animated:YES selector:@"setSelectBlock:" param:selectBlock,nil]; } - (void)touchgy { + [self.view endEditing:YES]; SupplierViewController *vc = [[SupplierViewController alloc] initWithSelectBlock:^(SupplierMode *mode) { [self.btngy setTitle:mode.strSupName forState:UIControlStateNormal]; - supid = mode.strid; + _supid = mode.strid; }]; [self.navigationController pushViewController:vc animated:YES]; } - (void)touchzk { + [self.view endEditing:YES]; [self.sheetzk showInView:self.view]; } - (void)touchjf { + [self.view endEditing:YES]; [self.sheetjf showInView:self.view]; } - (void)touchtm { + [self.view endEditing:YES]; MLOG(@"%s", __func__); } +- (void)touchView +{ + [self.view endEditing:YES]; +} + - (void)touchOK { NSDictionary *dict = [self getDict]; [self.manager saveOrUpdateDict:dict finishBlock:^(NSString *resultCode) { - + if ([resultCode isEqualToString:@"1"]) + { + [SVProgressHUD showSuccessWithStatus:@"修改成功" cover:YES offsetY:kMainScreenHeight/2.0]; + [self.navigationController popViewControllerAnimated:YES]; + } + else [SVProgressHUD showErrorWithStatus:@"修改失败" cover:YES offsetY:kMainScreenHeight/2.0]; }]; } @@ -213,10 +236,14 @@ - (NSDictionary *)getDict { _myMode.strProductCode = self.textfieldtm.text; _myMode.strProductName = self.textfieldpm.text; + if (_cid) _myMode.strCid = _cid; + if (_supid) _myMode.strSupid = _supid; _myMode.strClsName = self.btnfl.titleLabel.text; _myMode.strBuyingPrice = self.textfieldjj.text; _myMode.strSalePrice = self.textfieldsj.text; _myMode.strSaleUnit = self.textfielddw.text; + if (!self.btngy.titleLabel.text) _myMode.strSupName = @""; + else _myMode.strSupName = self.btngy.titleLabel.text; if ([self.btnzk.titleLabel.text isEqualToString:@"参加"]) _myMode.strActEnable = @"1"; else _myMode.strActEnable = @"0"; if ([self.btnjf.titleLabel.text isEqualToString:@"是"]) _myMode.strIsScore = @"1"; @@ -231,11 +258,15 @@ - (NSDictionary *)dictFromMode { NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:0]; [dict setValue:@1 forKey:@"operateType"]; - if (cid) [dict setObject:cid forKey:@"cid"]; - if (supid) + if (_cid) + { + [dict setObject:_cid forKey:@"cid"]; + [dict setObject:_myMode.strClsName forKey:@"cls_name"]; + } + if (_supid) { - [dict setObject:supid forKey:@"sup_id"]; - [dict setObject:self.btngy.titleLabel.text forKey:@"sup_name"]; + [dict setObject:_supid forKey:@"sup_id"]; + [dict setObject:_myMode.strSupName forKey:@"sup_name"]; } [dict setObject:_myMode.strId forKey:@"id"]; [dict setObject:_myMode.strProductName forKey:@"product_name"]; @@ -243,6 +274,7 @@ - (NSDictionary *)dictFromMode [dict setObject:_myMode.strBuyingPrice forKey:@"buying_price"]; [dict setObject:_myMode.strSalePrice forKey:@"sale_price"]; [dict setObject:_myMode.strIsScore forKey:@"is_score"]; + [dict setObject:_myMode.strSaleUnit forKey:@"sale_unit"]; [dict setObject:_myMode.strActEnable forKey:@"act_enabled"]; return [dict copy]; } diff --git a/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPManager.m b/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPManager.m index 5e8d883..86ae6b8 100644 --- a/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPManager.m +++ b/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPManager.m @@ -17,8 +17,9 @@ - (void)saveOrUpdateDict:(NSDictionary *)aDict finishBlock:(void (^)(NSString *) { [NetManager requestWith:aDict apiName:@"saveOrUpdateProduct" method:@"post" succ:^(NSDictionary *successDict) { MLOG(@"%@", successDict); - NSString *code = successDict[@"RErrorInfo"]; - MLOG(@"%@", code); + NSString *msg = successDict[@"msg"]; + if ([msg isEqualToString:@"success"]) FBlock(@"1"); + else FBlock(nil); } failure:^(NSDictionary *failDict, NSError *error) { FBlock(nil); }]; diff --git a/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/YPDMViewController.h b/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/YPDMViewController.h index 92a04b2..f8600a7 100644 --- a/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/YPDMViewController.h +++ b/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/YPDMViewController.h @@ -10,6 +10,6 @@ @class SPGLProductMode; @interface YPDMViewController : BaseViewController -- (instancetype)initWithProductMode:(SPGLProductMode *)aMode ; +- (instancetype)initWithProductMode:(SPGLProductMode *)aMode changeBlock:(void(^)(SPGLProductMode *))aChangeBlcok; @end diff --git a/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/YPDMViewController.m b/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/YPDMViewController.m index ecdf060..c31ed57 100644 --- a/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/YPDMViewController.m +++ b/YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/YPDMViewController.m @@ -19,15 +19,19 @@ @interface YPDMViewController () @property(nonatomic,strong) UIButton *btnSao; @property(nonatomic,strong) UIButton *btnJia; @property(nonatomic,strong) NSMutableArray *dataArr; + +@property(nonatomic,strong) void(^ changeBlock)(SPGLProductMode *); + @end @implementation YPDMViewController -- (instancetype)initWithProductMode:(SPGLProductMode *)aMode +- (instancetype)initWithProductMode:(SPGLProductMode *)aMode changeBlock:(void (^)(SPGLProductMode *))aChangeBlcok { if (self=[super init]) { _productMode = aMode; + _changeBlock = aChangeBlcok; } return self; } @@ -50,6 +54,8 @@ - (void)touchOk NSString *msg = successDict[@"msg"]; if ([msg isEqualToString:@"success"]) { [SVProgressHUD showSuccessWithStatus:@"修改成功" cover:YES offsetY:kMainScreenHeight/2.0]; + _productMode.strProductCode = mutableStr; + _changeBlock(_productMode); [self.navigationController popViewControllerAnimated:YES]; } else [SVProgressHUD showErrorWithStatus:@"修改失败" cover:YES offsetY:kMainScreenHeight/2.0]; diff --git a/YHB_Prj/YHB_Prj/shangpinguanli/SPGLProductDetail.m b/YHB_Prj/YHB_Prj/shangpinguanli/SPGLProductDetail.m index 9e216f7..4b074d3 100644 --- a/YHB_Prj/YHB_Prj/shangpinguanli/SPGLProductDetail.m +++ b/YHB_Prj/YHB_Prj/shangpinguanli/SPGLProductDetail.m @@ -96,7 +96,10 @@ - (void)touchShangchuan - (void)touchYPDM { - YPDMViewController *vc = [[YPDMViewController alloc] initWithProductMode:_productMode]; + YPDMViewController *vc = [[YPDMViewController alloc] initWithProductMode:_productMode changeBlock:^(SPGLProductMode *aMode) { + _productMode = aMode; + self.chanpinmaLabel.text = self.productMode.strProductCode; + }]; [self.navigationController pushViewController:vc animated:YES]; }