Commit d169f1ef authored by Sandy's avatar Sandy

改造转运单

parent 9f218ce9
......@@ -19,5 +19,6 @@
#define IsDictObject(Object) [(Object) isKindOfClass:[NSDictionary class]]
#define IsErrorObject(Object) ![(Object) isKindOfClass:[NSError class]]
#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self
#endif
......@@ -48,7 +48,7 @@ typedef enum : NSUInteger {
UILabel *_packageCountLabel; //包装数量
UILabel *_baseCountLabel; //基础数量
UILabel *_counterNum;//柜台
}
@property (nonatomic,strong)NSString *productCodeStr;//商品代码
@property (nonatomic,strong)NSString *productNameStr;//商品名字
......@@ -94,7 +94,7 @@ typedef enum : NSUInteger {
}
-(void)setupSubviews
{
{
_tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, 0,ScreenSize.width, ScreenSize.height - 64 - LeftMargin)) style:(UITableViewStylePlain)];
_tableView.backgroundColor = [UIColor whiteColor];
_tableView.bounces = NO;
......@@ -104,8 +104,11 @@ typedef enum : NSUInteger {
UIView *footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 50)];
if (self.intertype == ShopDetailInterTypeTransport) {
// UIButton *saveBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, 10, (ScreenSize.width - LeftMargin*2), BtnHeight) target:self sel:@selector(btnClick:) tag:SaveTag image:nil title:@"删除" titleColor: [UIColor whiteColor] isCorner:YES corner:CornerRadius bgColor:GXF_SAVE_COLOR];
// [footView addSubview:saveBtn];
}else if(self.intertype == ShopDetailInterTypeTranfer){
UIButton *saveBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, 10, (ScreenSize.width - LeftMargin*2), BtnHeight) target:self sel:@selector(btnClick:) tag:SaveTag image:nil title:@"删除" titleColor: [UIColor whiteColor] isCorner:YES corner:CornerRadius bgColor:GXF_SAVE_COLOR];
[footView addSubview:saveBtn];
}else{
UIButton *saveBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, 10, (ScreenSize.width - LeftMargin*3)/2, BtnHeight) target:self sel:@selector(btnClick:) tag:SaveTag image:nil title:@"删除" titleColor: [UIColor whiteColor] isCorner:YES corner:CornerRadius bgColor:GXF_SAVE_COLOR];
......@@ -115,7 +118,7 @@ typedef enum : NSUInteger {
[footView addSubview:commitBtn];
}
_tableView.tableFooterView = footView;
_tableView.tableFooterView = footView;
[self.view addSubview:_tableView];
}
......@@ -144,15 +147,15 @@ typedef enum : NSUInteger {
//基础数量
foundationQuantity.text=self.shopDetail.foundationQuantity;
//基础单价
// if ([self.shopDetail.foundationUnitPrice floatValue] > 0) {
foundationUnitPrice.text= [self.shopDetail.foundationUnitPrice stringValue];
// }
// if ([self.shopDetail.foundationUnitPrice floatValue] > 0) {
foundationUnitPrice.text= [self.shopDetail.foundationUnitPrice stringValue];
// }
self.basePrice = self.shopDetail.foundationUnitPrice;
//包装单价
// if ([self.shopDetail.packageUnitPrice floatValue] > 0) {
packageUnitPrice.text=[self.shopDetail.packageUnitPrice stringValue];
// }
// if ([self.shopDetail.packageUnitPrice floatValue] > 0) {
packageUnitPrice.text=[self.shopDetail.packageUnitPrice stringValue];
// }
self.packPrice = self.shopDetail.packageUnitPrice;
//总金额
if ([self.shopDetail.totalMoney floatValue] <= 0) {
......@@ -242,7 +245,7 @@ typedef enum : NSUInteger {
}
complete();
complete();
} failure:^(id fail) {
[hud hide:YES];
......@@ -268,7 +271,7 @@ typedef enum : NSUInteger {
{
[self clearShopDetail];
}
}
}
......@@ -299,7 +302,7 @@ typedef enum : NSUInteger {
self.shopDetail.packageSpecification = packageSpecification.text;
self.shopDetail.packageQpcStr = [NSString stringWithFormat:@"1*%@",packageSpecification.text];
self.shopDetail.packageQpcUnit = self.productMeasureUnit;
self.shopDetail.packageUnit = self.packageUintStr;
self.shopDetail.packageQuantity = packageQuantity.text;
self.shopDetail.packageUnitPrice = self.packPrice;
......@@ -342,10 +345,10 @@ typedef enum : NSUInteger {
ShowMessage(@"商品数量不能为0");
return NO;
}
// if ([packageUnitPrice.text floatValue] <=0 || [foundationUnitPrice.text floatValue] <= 0 || [totalMoney.text floatValue]<= 0) {
// ShowMessage(@"商品价格不能0");
// return NO;
// }
// if ([packageUnitPrice.text floatValue] <=0 || [foundationUnitPrice.text floatValue] <= 0 || [totalMoney.text floatValue]<= 0) {
// ShowMessage(@"商品价格不能0");
// return NO;
// }
return YES;
}
#pragma mark - 协议方法
......@@ -372,7 +375,7 @@ typedef enum : NSUInteger {
}
[cell setTitleStr:_dataArr[indexPath.row]];
if (self.intertype == ShopDetailInterTypeTransport){
if (self.intertype == ShopDetailInterTypeTransport || self.intertype == ShopDetailInterTypeTranfer){
cell.userInteractionEnabled = NO;
}
return cell;
......@@ -457,7 +460,7 @@ typedef enum : NSUInteger {
[textField addTarget:self action:@selector(textChange:) forControlEvents:UIControlEventAllEditingEvents];
textField.placeholder = @"输入包装单价";
packageUnitPrice=textField; //包装单价
}else if ([title isEqualToString:@"总金额"]) {
label.text = @"元";
[textField addTarget:self action:@selector(textChange:) forControlEvents:UIControlEventAllEditingEvents];
......@@ -477,7 +480,7 @@ typedef enum : NSUInteger {
[self setviewsData];
[self setviewsData];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
......@@ -547,9 +550,9 @@ typedef enum : NSUInteger {
}
NSMutableString * futureString = [NSMutableString stringWithString:textField.text];
// kLOG(@"%@", futureString);
// kLOG(@"%@", futureString);
[futureString insertString:string atIndex:range.location];
// kLOG(@"----%@", futureString);
// kLOG(@"----%@", futureString);
NSInteger flag = 0;
NSInteger pointNum = 0;//用于标记小数点的数量,只能有一个小数点
const NSInteger limited = 2;//限制小数点后面的位数
......@@ -558,7 +561,7 @@ typedef enum : NSUInteger {
if ([futureString characterAtIndex:i] == '.') {
pointNum++;
// kLOG(@"----->>>%ld",pointNum);
// kLOG(@"----->>>%ld",pointNum);
if (pointNum == 2) {
return NO;
......@@ -625,15 +628,15 @@ typedef enum : NSUInteger {
- (void)setPacktAndTotalPrice{
if (self.basePrice && foundationUnitPrice.text.length > 0) {
if (foundationQuantity.text.length > 0) {
// float basePrice = [self.basePrice floatValue] * 100;
// int intBasePrice = (int)basePrice;
// int foundationQtt = [foundationQuantity.text intValue];
// double price = (intBasePrice * foundationQtt * 1.0);
// double totalPrice = price / 100;
// float basePrice = [self.basePrice floatValue] * 100;
// int intBasePrice = (int)basePrice;
// int foundationQtt = [foundationQuantity.text intValue];
// double price = (intBasePrice * foundationQtt * 1.0);
// double totalPrice = price / 100;
// NSDecimalNumber *basePrice = [NSDecimalNumber decimalNumberWithDecimal:[self.basePrice decimalValue]];
// NSDecimalNumber *foundationQty = [NSDecimalNumber decimalNumberWithString:foundationQuantity.text];
// NSDecimalNumber *multiplyResult = [basePrice decimalNumberByMultiplyingBy:foundationQty];
// NSDecimalNumber *basePrice = [NSDecimalNumber decimalNumberWithDecimal:[self.basePrice decimalValue]];
// NSDecimalNumber *foundationQty = [NSDecimalNumber decimalNumberWithString:foundationQuantity.text];
// NSDecimalNumber *multiplyResult = [basePrice decimalNumberByMultiplyingBy:foundationQty];
NSDecimalNumber *multiplyResult = [CalculateHelper calculateNum1:self.basePrice num2:foundationQuantity.text type:CalculateTypeMul roundingType:NSRoundBankers cutLenth:2];
totalMoney.text = [multiplyResult stringValue];
self.totalPrice = multiplyResult;
......@@ -651,19 +654,19 @@ typedef enum : NSUInteger {
- (void)setUnitAndTotalPrice{
if (self.packPrice&&packageUnitPrice.text.length > 0) {
if (packageQuantity.text.length > 0) {
// float pakePrice = [self.packPrice floatValue] * 100;
// int intPakePrice = (int)pakePrice;
// int pakageQty = [packageQuantity.text intValue];
//
// double price = (intPakePrice * pakageQty * 1.0);
// double totalPrice = price / 100;
// float totalPrice = pakePrice * 100 * pakageQty / 100;
// float pakePrice = [self.packPrice floatValue] * 100;
// int intPakePrice = (int)pakePrice;
// int pakageQty = [packageQuantity.text intValue];
//
// double price = (intPakePrice * pakageQty * 1.0);
// double totalPrice = price / 100;
// float totalPrice = pakePrice * 100 * pakageQty / 100;
NSDecimalNumber *totalPrice = [CalculateHelper calculateNum1:self.packPrice num2:packageQuantity.text type:CalculateTypeMul roundingType:NSRoundBankers cutLenth:2];
totalMoney.text = [totalPrice stringValue];
self.totalPrice = totalPrice;
if (foundationQuantity.text.length > 0 && [foundationQuantity.text integerValue] > 0) {
NSDecimalNumber *packagePrice = [CalculateHelper calculateNum1:totalPrice num2:foundationQuantity.text type:CalculateTypeDiv roundingType:NSRoundBankers cutLenth:2];
// float packagePrice = totalPrice / [foundationQuantity.text floatValue];
// float packagePrice = totalPrice / [foundationQuantity.text floatValue];
foundationUnitPrice.text = packagePrice.stringValue;
self.basePrice = packagePrice; }
}
......@@ -674,14 +677,14 @@ typedef enum : NSUInteger {
if (totalMoney.text.length > 0) {
if (packageQuantity.text.length > 0 && [packageQuantity.text floatValue] > 0) {
// float packagePrice = [self.totalPrice floatValue] / [packageQuantity.text floatValue];
// float packagePrice = [self.totalPrice floatValue] / [packageQuantity.text floatValue];
NSDecimalNumber *packagePrice = [CalculateHelper calculateNum1:self.totalPrice num2:packageQuantity.text type:CalculateTypeDiv roundingType:NSRoundBankers cutLenth:2];
packageUnitPrice.text = packagePrice.stringValue;
self.packPrice = packagePrice;
}
if (foundationQuantity.text.length > 0 && [foundationQuantity.text floatValue] > 0) {
// float packagePrice = [self.totalPrice floatValue] / [foundationQuantity.text floatValue];
// float packagePrice = [self.totalPrice floatValue] / [foundationQuantity.text floatValue];
NSDecimalNumber *packagePrice = [CalculateHelper calculateNum1:self.totalPrice num2:foundationQuantity.text type:CalculateTypeDiv roundingType:NSRoundBankers cutLenth:2];
foundationUnitPrice.text = packagePrice.stringValue;
self.basePrice = packagePrice;
......
......@@ -18,6 +18,7 @@
#import "TransportPdtDetail.h"
#import "ChooseTransportViewController.h"
#import "ChooseTransferViewController.h"
#import "ProductStockModel.h"
typedef enum : NSUInteger {
SaveTag = 7000,
CommitTag,
......@@ -37,6 +38,12 @@ typedef enum : NSUInteger {
NSNumber *versionObject;
}
@property (nonatomic,strong)NSString *state;
/**
* 缓存的选择的采购单数据
*/
@property (strong, nonatomic) NSMutableDictionary *dicProduct;
@property (assign, nonatomic) NSInteger purchaseAddStockCheckNumber;
@end
@implementation NewTransferViewController
......@@ -59,6 +66,7 @@ typedef enum : NSUInteger {
[super viewDidLoad];
//布局
[self bulidLayout];
self.purchaseAddStockCheckNumber = 0;
uuidObject = [NSNull null];
billNumberObject = [NSNull null];
versionObject = [NSNumber numberWithInteger:0];
......@@ -101,6 +109,18 @@ typedef enum : NSUInteger {
_sheetView.transfer = self.transfer;
[_bottomView refreshCost:self.transfer.accountDetails];
[_bottomView refreshTranProduct:self.transfer.pdtDetails];
//清空缓存,重新
[self.dicProduct removeAllObjects];
for (TransferPdtDetail *pdtDetail in _bottomView.productVC.transferProductArr) {
NSMutableArray *arrProduct = [self.dicProduct objectForKey:pdtDetail.sourcebillnumber];
if (!arrProduct) {
arrProduct = [NSMutableArray array];
[self.dicProduct setObject:arrProduct forKey:pdtDetail.sourcebillnumber];
}
[arrProduct addObject:pdtDetail];
}
}
- (void)bulidLayout{
......@@ -141,9 +161,17 @@ typedef enum : NSUInteger {
break;
case CommitTag:{
if ([self checkTransfer]) {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请确认提交" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
alertView.delegate = self;
[alertView show];
NSArray *array = self.dicProduct.allKeys;
WS(weakSelf);
//判断数量问题
[IBTLoadingView showProgressLabel:@""];
[self stockValidWithDic:self.dicProduct billNumbers:array complete:^{
[IBTLoadingView hideHUDWithText:@""];
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请确认提交" delegate:weakSelf cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
alertView.delegate = weakSelf;
[alertView show];
}];
}
}
break;
......@@ -229,6 +257,59 @@ typedef enum : NSUInteger {
}
}
/**
* 查库存接口
*
* @param dic 存放已选择单据
* @param billNumbers 单号
* @param complete 回调
*/
- (void)stockValidWithDic:(NSMutableDictionary *)dic billNumbers:(NSArray *)billNumbers complete:(void (^)(void))complete {
//如果billNumbers数量为0,说明没有去选择
NSString *billNum = billNumbers[self.purchaseAddStockCheckNumber];
NSMutableArray *arrProducts = [dic objectForKey:billNum];
WS(weakSelf);
[HTTP purchaseStockWithPurchaseUuid:billNum success:^(id succ) {
if (![succ[@"data"] isKindOfClass:[NSArray class]]) {
[IBTLoadingView hideHUDWithText:@""];
NSString *msg = [NSString stringWithFormat:@"该批次<%@>在总部系统的库存不足!", billNum];
ShowMessage(msg);
return ;
}
for (NSDictionary *dict in succ[@"data"]) {
ProductStockModel *model = [ProductStockModel new];
[model setValuesForKeysWithDictionary:dict];
for (TransportPdtDetail *detail in arrProducts) {
if ([detail.productCode isEqualToString:model.productCode]) {
if (detail.baseQty.floatValue > model.qty.floatValue) {
CLog(@"库存不足");
[IBTLoadingView hideHUDWithText:@""];
self.purchaseAddStockCheckNumber = 0;
NSString *msg = [NSString stringWithFormat:@"该批次<%@>的商品%@在总部系统的库存不足!", billNum, detail.productName];
ShowMessage(msg);
return ;
}
}
}
}
self.purchaseAddStockCheckNumber += 1;
if (self.purchaseAddStockCheckNumber == billNumbers.count) {
self.purchaseAddStockCheckNumber = 0;
complete();
}else{
[weakSelf stockValidWithDic:dic billNumbers:billNumbers complete:complete];
}
} failure:^(id fail) {
[IBTLoadingView hideHUDWithText:@""];
self.purchaseAddStockCheckNumber = 0;
}];
}
- (BOOL)checkTransfer{
......@@ -294,6 +375,8 @@ typedef enum : NSUInteger {
[_bottomView reProduct:arr];
}
};
tpv.dicProduct = self.dicProduct;
[self PushViewController:tpv animated:YES];
}
#pragma mark - 通知选择发运单
......@@ -370,6 +453,7 @@ typedef enum : NSUInteger {
NSInteger indexTag = [[[fication userInfo] objectForKey:@"indexTag"] integerValue];
ShopDetaileViewController *svc = [[ShopDetaileViewController alloc] init];
svc.intertype = ShopDetailInterTypeTranfer;
if (billProduct) {
svc.navTitle = @"编辑商品";
ShopDetail *shopDetail=[self coverShopDetail:billProduct];
......@@ -378,6 +462,17 @@ typedef enum : NSUInteger {
TransferPdtDetail *tdetail = [self coverTransportPdtDetail:Detail];
if (Detail.IsDeleted) {
[_bottomView refreshDelProduct:tdetail tag:indexTag];
//清空缓存,重新
[self.dicProduct removeAllObjects];
for (TransferPdtDetail *pdtDetail in _bottomView.productVC.transferProductArr) {
NSMutableArray *arrProduct = [self.dicProduct objectForKey:pdtDetail.sourcebillnumber];
if (!arrProduct) {
arrProduct = [NSMutableArray array];
[self.dicProduct setObject:arrProduct forKey:pdtDetail.sourcebillnumber];
}
[arrProduct addObject:pdtDetail];
}
}else{
[_bottomView refreshEditProduct:tdetail tag:indexTag];
}
......@@ -527,6 +622,13 @@ typedef enum : NSUInteger {
}
}
- (NSMutableDictionary *)dicProduct {
if (!_dicProduct) {
_dicProduct = [NSMutableDictionary dictionary];
}
return _dicProduct;
}
/*
#pragma mark - Navigation
......
......@@ -202,7 +202,7 @@ typedef enum : NSUInteger {
NSArray *array = self.dicProduct.allKeys;
__weak NewTransportViewController *weakSelf = self;
WS(weakSelf);
//判断数量问题
[IBTLoadingView showProgressLabel:@""];
[self stockValidWithDic:self.dicProduct billNumbers:array complete:^{
......@@ -220,6 +220,13 @@ typedef enum : NSUInteger {
}
}
/**
* 查库存接口
*
* @param dic 存放已选择单据
* @param billNumbers 单号
* @param complete 回调
*/
- (void)stockValidWithDic:(NSMutableDictionary *)dic billNumbers:(NSArray *)billNumbers complete:(void (^)(void))complete {
//如果billNumbers数量为0,说明没有去选择
......
......@@ -86,7 +86,7 @@ NSInteger purchaseStockCheckNumber = 0;
}
NSDictionary *dict;
if (self.isTransportIn) {
// if (self.isTransportIn) {
dict = @{
@"state":PURCHASE_STATE_RECEIVED,
@"queryOrders":orderArr,
......@@ -96,17 +96,17 @@ NSInteger purchaseStockCheckNumber = 0;
@"isProductCenter":@(1),
@"pageNumber":@(_currentPage),
@"pageSize":@(20)};
}else{
dict = @{
@"state":[NSNull null],
@"stateNotIn":@[PURCHASE_STATE_ABORTED,PURCHASE_STATE_REJECTED],
@"queryOrders":orderArr,
@"userUuid":userUtil.userId,
@"billNumberProductLike":billNumberObject,
@"fetchParts":@"products",
@"pageNumber":@(_currentPage),
@"pageSize":@(20)};
}
// }else{
// dict = @{
// @"state":[NSNull null],
// @"stateNotIn":@[PURCHASE_STATE_ABORTED,PURCHASE_STATE_REJECTED],
// @"queryOrders":orderArr,
// @"userUuid":userUtil.userId,
// @"billNumberProductLike":billNumberObject,
// @"fetchParts":@"products",
// @"pageNumber":@(_currentPage),
// @"pageSize":@(20)};
// }
[[ICRHTTPController sharedController] queryPurchaseWithData:dict success:succ failure:fail];
}
- (void)fetchtPuchaseList:(id)data{
......
......@@ -22,6 +22,8 @@
@property (nonatomic,strong)NSMutableArray *indexArr;
@property (nonatomic,strong)NSMutableArray *selectArr;
/** 是否发运单进入 */
@property (assign, nonatomic) BOOL isPurchaseIn;
- (void)setPurchaseBill:(PurchaseBill *)bill selectArr:(NSMutableArray *)selectArr;
- (void)setTransPort:(Transport *)bill selectArr:(NSMutableArray *)selectArr;
......
......@@ -162,18 +162,21 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
// TransportPurductCell *cell = (TransportPurductCell *)[tableView cellForRowAtIndexPath:indexPath];
// TransportPdtDetail * billProduct = self.secondArr[indexPath.row];
// if (![self isHaveIndexPath:billProduct]) {
// cell.editBtn.hidden = NO;
// [self.selectArr addObject:billProduct];
//
// }else{
// [self.selectArr removeObject:billProduct];
// cell.editBtn.hidden = YES;
// }
// self.headCell.checkBox.isSelected = self.selectArr.count == self.secondArr.count;
// [self.secondTable reloadData];
if (!self.isPurchaseIn) {
TransportPurductCell *cell = (TransportPurductCell *)[tableView cellForRowAtIndexPath:indexPath];
TransportPdtDetail * billProduct = self.secondArr[indexPath.row];
if (![self isHaveIndexPath:billProduct]) {
cell.editBtn.hidden = NO;
[self.selectArr addObject:billProduct];
}else{
[self.selectArr removeObject:billProduct];
cell.editBtn.hidden = YES;
}
self.headCell.checkBox.isSelected = self.selectArr.count == self.secondArr.count;
[self.secondTable reloadData];
}
}
- (BOOL)isHaveIndexPath:(TransportPdtDetail *)billProduct{
for (TransportPdtDetail *detail in self.selectArr) {
......
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