Skip to content

Commit

Permalink
完善修改商品
Browse files Browse the repository at this point in the history
  • Loading branch information
woaomo committed Sep 13, 2015
1 parent 54ed09d commit 2969e14
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 16 deletions.
37 changes: 37 additions & 0 deletions YHB_Prj/YHB_Prj/Yudanchaxun/YDCXViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,6 +53,8 @@ - (void)viewDidLoad {
_tableviewYudan.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:_tableviewYudan];

[self addTableViewTrag];

[self createBottomView];

_arrNo = [NSMutableArray arrayWithCapacity:0];
Expand All @@ -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
{
Expand Down
54 changes: 43 additions & 11 deletions YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPEditViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ typedef NS_ENUM(NSInteger, FieldType) {

@interface SPEditViewController ()<UIScrollViewDelegate, UIActionSheetDelegate>
{
NSString *cid;
NSString *supid;
NSString *_cid;
NSString *_supid;
}

@property(nonatomic,strong) SPGLProductMode *myMode;
Expand Down Expand Up @@ -57,6 +57,8 @@ @interface SPEditViewController ()<UIScrollViewDelegate, UIActionSheetDelegate>
@property(nonatomic,strong) UIActionSheet *sheetjf;

@property(nonatomic,strong) SPManager *manager;

@property(nonatomic,strong) UITapGestureRecognizer *tapGR;
@end

@implementation SPEditViewController
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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++)
Expand All @@ -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];
}
Expand Down Expand Up @@ -170,53 +178,72 @@ - (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];
}];
}

- (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";
Expand All @@ -231,18 +258,23 @@ - (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"];
[dict setObject:_myMode.strProductCode forKey:@"product_code"];
[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];
}
Expand Down
5 changes: 3 additions & 2 deletions YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
@class SPGLProductMode;
@interface YPDMViewController : BaseViewController

- (instancetype)initWithProductMode:(SPGLProductMode *)aMode ;
- (instancetype)initWithProductMode:(SPGLProductMode *)aMode changeBlock:(void(^)(SPGLProductMode *))aChangeBlcok;

@end
8 changes: 7 additions & 1 deletion YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/YPDMViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ @interface YPDMViewController ()<UITableViewDataSource,UITableViewDelegate>
@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;
}
Expand All @@ -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];
Expand Down
5 changes: 4 additions & 1 deletion YHB_Prj/YHB_Prj/shangpinguanli/SPGLProductDetail.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down

0 comments on commit 2969e14

Please sign in to comment.