Skip to content

Commit

Permalink
新增商品
Browse files Browse the repository at this point in the history
  • Loading branch information
woaomo committed Sep 14, 2015
1 parent 2969e14 commit 2fc42fe
Show file tree
Hide file tree
Showing 13 changed files with 1,086 additions and 30 deletions.
18 changes: 18 additions & 0 deletions YHB_Prj/YHB_Prj.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
AB8844171B913D6300FA526D /* UITableView+DelegateBlocks.m in Sources */ = {isa = PBXBuildFile; fileRef = AB8844141B913D6300FA526D /* UITableView+DelegateBlocks.m */; };
AB88441B1B913DBB00FA526D /* ChooseLocaViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB88441A1B913DBB00FA526D /* ChooseLocaViewController.m */; };
AB88441E1B914D0F00FA526D /* CLTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = AB88441D1B914D0F00FA526D /* CLTableViewCell.m */; };
AB97F8B31BA65AB6000A0F3E /* SPNewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB97F8B21BA65AB6000A0F3E /* SPNewViewController.m */; };
AB97F8B61BA66BF2000A0F3E /* SPKCViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB97F8B51BA66BF2000A0F3E /* SPKCViewController.m */; };
AB97F8B91BA66CEB000A0F3E /* SPKCTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = AB97F8B81BA66CEB000A0F3E /* SPKCTableViewCell.m */; };
AB9F43E91B92E45900914C85 /* SettingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB9F43E81B92E45900914C85 /* SettingViewController.m */; };
AB9F43EC1B92E58400914C85 /* SetTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = AB9F43EB1B92E58400914C85 /* SetTableViewCell.m */; };
ABAACA071B95B5EC00305080 /* SupplierManage.m in Sources */ = {isa = PBXBuildFile; fileRef = ABAACA061B95B5EC00305080 /* SupplierManage.m */; };
Expand Down Expand Up @@ -424,6 +427,12 @@
AB88441A1B913DBB00FA526D /* ChooseLocaViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChooseLocaViewController.m; sourceTree = "<group>"; };
AB88441C1B914D0F00FA526D /* CLTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLTableViewCell.h; sourceTree = "<group>"; };
AB88441D1B914D0F00FA526D /* CLTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLTableViewCell.m; sourceTree = "<group>"; };
AB97F8B11BA65AB6000A0F3E /* SPNewViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPNewViewController.h; sourceTree = "<group>"; };
AB97F8B21BA65AB6000A0F3E /* SPNewViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPNewViewController.m; sourceTree = "<group>"; };
AB97F8B41BA66BF2000A0F3E /* SPKCViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPKCViewController.h; sourceTree = "<group>"; };
AB97F8B51BA66BF2000A0F3E /* SPKCViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPKCViewController.m; sourceTree = "<group>"; };
AB97F8B71BA66CEB000A0F3E /* SPKCTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPKCTableViewCell.h; sourceTree = "<group>"; };
AB97F8B81BA66CEB000A0F3E /* SPKCTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPKCTableViewCell.m; sourceTree = "<group>"; };
AB9F43E71B92E45900914C85 /* SettingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingViewController.h; sourceTree = "<group>"; };
AB9F43E81B92E45900914C85 /* SettingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingViewController.m; sourceTree = "<group>"; };
AB9F43EA1B92E58400914C85 /* SetTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetTableViewCell.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1202,6 +1211,12 @@
children = (
ABFAB0EA1BA1C0DE009D8654 /* SPEditViewController.h */,
ABFAB0EB1BA1C0DE009D8654 /* SPEditViewController.m */,
AB97F8B11BA65AB6000A0F3E /* SPNewViewController.h */,
AB97F8B21BA65AB6000A0F3E /* SPNewViewController.m */,
AB97F8B41BA66BF2000A0F3E /* SPKCViewController.h */,
AB97F8B51BA66BF2000A0F3E /* SPKCViewController.m */,
AB97F8B71BA66CEB000A0F3E /* SPKCTableViewCell.h */,
AB97F8B81BA66CEB000A0F3E /* SPKCTableViewCell.m */,
ABFAB0ED1BA29CF9009D8654 /* SPManager.h */,
ABFAB0EE1BA29CF9009D8654 /* SPManager.m */,
ABDDB36F1BA2CF4000DCD659 /* JHLSViewController.h */,
Expand Down Expand Up @@ -2113,6 +2128,7 @@
FF2A6C761A0F3B7B001607AC /* UIImage+MultiFormat.m in Sources */,
5B54BA201B922210002098A4 /* DJCheckCartViewController.m in Sources */,
AB40EABC1B8BFA0100DE5ED7 /* ClerkTableViewCell.m in Sources */,
AB97F8B91BA66CEB000A0F3E /* SPKCTableViewCell.m in Sources */,
FF2A6C6F1A0F3B7B001607AC /* SDWebImageDecoder.m in Sources */,
FFF391981B846F58007DC652 /* AFSecurityPolicy.m in Sources */,
5B54BA481B9348FD002098A4 /* DJProductCheckViewManager.m in Sources */,
Expand Down Expand Up @@ -2239,6 +2255,7 @@
AB8844171B913D6300FA526D /* UITableView+DelegateBlocks.m in Sources */,
5B1F7FA31B90B62900763059 /* DJProductCheckListDetailVC.m in Sources */,
FF5C86FB1B81B72400F79EC1 /* MASLayoutConstraint.m in Sources */,
AB97F8B31BA65AB6000A0F3E /* SPNewViewController.m in Sources */,
FF2A6C721A0F3B7B001607AC /* SDWebImageManager.m in Sources */,
FF2A6C891A0F3B8A001607AC /* UIScrollView+SVPullToRefresh.m in Sources */,
FFD26CEA1B8C1B3B0003F491 /* KCYJViewController.m in Sources */,
Expand All @@ -2258,6 +2275,7 @@
AB25793F1B8F02010015039A /* IQToolbar.m in Sources */,
AB40EAB51B8BF97500DE5ED7 /* ClerkViewController.m in Sources */,
FF5CC7041B93EE5300F55713 /* SXViewController.m in Sources */,
AB97F8B61BA66BF2000A0F3E /* SPKCViewController.m in Sources */,
FF2A6C081A0F39EC001607AC /* ViewInteraction.m in Sources */,
FF2A6C6D1A0F3B7B001607AC /* SDImageCache.m in Sources */,
);
Expand Down
10 changes: 10 additions & 0 deletions YHB_Prj/YHB_Prj/ThirdParty/AFNetworking/NetManager/NetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,15 @@
succ:(SUCCESSBLOCK)success
failure:(FAILUREBLOCK)failure;

+ (void)uploadImgArry:(NSArray*)aImgArry
parameters:(NSDictionary*)aParam
apiName:(NSString *)aApidName
uploadUrl:(NSString*)aUrl
uploadimgName:(NSString*)aImgname
progressBlock:(PROGRESSBLOCK)block
succ:(SUCCESSBLOCK)success
failure:(FAILUREBLOCK)failure;


+ (void)cancelOperation:(id)aOperationKey;
@end
44 changes: 44 additions & 0 deletions YHB_Prj/YHB_Prj/ThirdParty/AFNetworking/NetManager/NetManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,48 @@ + (void)uploadImg:(UIImage*)aImg
success(Dict);
}];
}

+ (void)uploadImgArry:(NSArray*)aImgArry
parameters:(NSDictionary*)aParam
apiName:(NSString *)aApidName
uploadUrl:(NSString*)aUrl
uploadimgName:(NSString*)aImgname
progressBlock:(PROGRESSBLOCK)block
succ:(SUCCESSBLOCK)success
failure:(FAILUREBLOCK)failure
{
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

NSString *param = nil;
NSMutableDictionary *dict = nil;
manager.requestSerializer.timeoutInterval = 30;

param = [[NetManager shareInstance] basePostDict:aParam apiName:aApidName];
dict = [NSMutableDictionary dictionaryWithDictionary:aParam];
[dict setValue:param forKey:@"S3CAPI"];
[manager.requestSerializer setValue:param forHTTPHeaderField:@"S3CAPI"];
[NetManager setRequestHeadValue:manager];
if([kBaseUrl compare:@"https://api.chinascrm.com/sapi4app.html"] == 0)
{
manager.securityPolicy.allowInvalidCertificates = YES;
}

[manager POST:kBaseUrl parameters:dict constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
NSString *fileName = @"temp_image.jpg";
for(int i=0; i<aImgArry.count; i++)
{
fileName = [NSString stringWithFormat:@"temp_image%d.jpg",i];
NSData *imageData = UIImageJPEGRepresentation([aImgArry objectAtIndex:i], 1);
[formData appendPartWithFileData:imageData name:@"pic" fileName:fileName mimeType:@"application/octet-stream"];
}
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *Dict = [operation.responseString objectFromJSONString];
success(Dict);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSDictionary *Dict = [operation.responseString objectFromJSONString];
success(Dict);
}];
}


@end
121 changes: 94 additions & 27 deletions YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPEditViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ - (void)touchfl
{
[self.view endEditing:YES];
void(^selectBlock)(SPGLCategoryMode *) = ^(SPGLCategoryMode *aMode){
[_btnfl setTitle:aMode.strCateName forState:UIControlStateNormal];
[self.btnfl setTitle:aMode.strCateName forState:UIControlStateNormal];
_cid = aMode.strId;
};
[self pushXIBName:@"ShangpinguanliVC" animated:YES selector:@"setSelectBlock:" param:selectBlock,nil];
Expand Down Expand Up @@ -222,36 +222,44 @@ - (void)touchView
- (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];
}];
if (dict)
{
[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";
else _myMode.strIsScore = @"0";

NSDictionary *dict = [self dictFromMode];

return dict;
if ([self isAllOK])
{
_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";
else _myMode.strIsScore = @"0";

NSDictionary *dict = [self dictFromMode];

return dict;
}
else return nil;
}

- (NSDictionary *)dictFromMode
Expand Down Expand Up @@ -279,6 +287,65 @@ - (NSDictionary *)dictFromMode
return [dict copy];
}

- (BOOL)isAllOK
{
if (![self isAllNum1:self.textfieldtm.text] || ![self isNotEmpty:self.textfieldpm.text])
{
[SVProgressHUD showErrorWithStatus:@"请输入正确条码" cover:YES offsetY:kMainScreenHeight/2.0];
return NO;
}
else if(![self isNotEmpty:self.textfieldpm.text])
{
[SVProgressHUD showErrorWithStatus:@"请输入商品名" cover:YES offsetY:kMainScreenHeight/2.0];
return NO;
}
else if(![self isPureFloat:self.textfieldjj.text])
{
[SVProgressHUD showErrorWithStatus:@"请输入正确进价" cover:YES offsetY:kMainScreenHeight/2.0];
return NO;
}
else if(![self isPureFloat:self.textfieldsj.text])
{
[SVProgressHUD showErrorWithStatus:@"请输入正确售价" cover:YES offsetY:kMainScreenHeight/2.0];
return NO;
}
return YES;
}

- (BOOL)isNotEmpty:(NSString *)str
{
BOOL aBool;
if (!str) {
aBool=false;
} else {
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSString *trimedString = [str stringByTrimmingCharactersInSet:set];
if ([trimedString length] == 0) {
aBool=false;
} else {
aBool=true;
}
}
return aBool;
}

- (BOOL)isAllNum1:(NSString *)string{
unichar c;
for (int i=0; i<string.length; i++) {
c=[string characterAtIndex:i];
if (!isdigit(c) && c!=',') {
return NO;
}
}
return YES;
}

- (BOOL)isPureFloat:(NSString*)string{
NSScanner* scan = [NSScanner scannerWithString:string];
float val;
return[scan scanFloat:&val] && [scan isAtEnd];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (actionSheet==self.sheetzk)
Expand Down
16 changes: 16 additions & 0 deletions YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPKCTableViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// SPKCTableViewCell.h
// YHB_Prj
//
// Created by Johnny's on 15/9/14.
// Copyright (c) 2015年 striveliu. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface SPKCTableViewCell : UITableViewCell
@property(nonatomic,strong) UITextField *countTf;
+ (CGFloat)heightForCell;
- (void)setCell:(NSString *)aStr;
- (instancetype)init;
@end
66 changes: 66 additions & 0 deletions YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPKCTableViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// SPKCTableViewCell.m
// YHB_Prj
//
// Created by Johnny's on 15/9/14.
// Copyright (c) 2015年 striveliu. All rights reserved.
//

#import "SPKCTableViewCell.h"

@interface SPKCTableViewCell()

@property(nonatomic,strong) UILabel *mendianLabel;
@end

@implementation SPKCTableViewCell

- (void)awakeFromNib {
// Initialization code
}

+(CGFloat)heightForCell
{
return 50;
}

- (instancetype)init
{
if (self = [super init])
{
[self createView];
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
return self;
}

- (void)createView
{
_mendianLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kMainScreenWidth, 25)];
_mendianLabel.font = kFont12;
_mendianLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:_mendianLabel];

_countTf = [[UITextField alloc] initWithFrame:CGRectMake(20, _mendianLabel.bottom, kMainScreenWidth-40, 25)];
_countTf.font = kFont12;
_countTf.placeholder = @"0";
_countTf.keyboardType = UIKeyboardTypeNumberPad;
[self addSubview:_countTf];

// UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 49.3, kMainScreenWidth, 0.5)];
// lineView.backgroundColor = [UIColor blackColor];
// [self addSubview:lineView];
}

- (void)setCell:(NSString *)aStr
{
_mendianLabel.text = aStr;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

@end
15 changes: 15 additions & 0 deletions YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/SPKCViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// SPKCViewController.h
// YHB_Prj
//
// Created by Johnny's on 15/9/14.
// Copyright (c) 2015年 striveliu. All rights reserved.
//

#import "BaseViewController.h"

@interface SPKCViewController : BaseViewController

- (instancetype)initWithBlock:(void(^)(int))aBlock;

@end
Loading

0 comments on commit 2fc42fe

Please sign in to comment.