Commit 404500c5 authored by freecui's avatar freecui

加工单接口bug修改

parent cad79801
......@@ -290,6 +290,7 @@
}
- (NSString *)httpParameterString {
NSString *str = [self stringWithFormatter:@"%Y-%m-%d %H:%M:%S"];
return [self stringWithFormatter:@"%Y-%m-%d %H:%M:%S"];
}
- (NSString *)coverStringFromString {
......
......@@ -20,6 +20,7 @@
// Fuctions
- (NSDictionary *)dictForCommit;
- (NSMutableDictionary *)mutableDictDateToStringForCommit;//把属性为日期类型的转化为string
- (NSDictionary *)dictForLocalSave;
- (void)praseFromJsonDict:(NSDictionary *)dict;
- (void)praseFromLocalDict:(NSDictionary *)dict;
......
......@@ -418,6 +418,48 @@
return mDict;
}
- (NSMutableDictionary *)mutableDictDateToStringForCommit {
unsigned int count;
objc_property_t *properties = class_copyPropertyList([self class], &count);
if (count == 0) {
free(properties);
return nil;
}
NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
NSDictionary *dictSpKeyDict = [[self class] specialKeysAndReplaceKeys];
NSArray *arrSpecialKeys = [dictSpKeyDict allKeys];
NSArray *arrCustomKeys = [[self class] customAcitonKeys];
NSArray *arrLocalKeys = [[self class] localKeys];
for (unsigned int i = 0; i < count; i++) {
objc_property_t property = properties[i];
NSString *key = [NSString stringWithUTF8String:property_getName(property)];
id value = [self valueForKey:key];
if ([value isKindOfClass:[NSDate class]]) {
value = [value httpParameterString];
}
if (value) {
if ([arrCustomKeys containsObject:key] ||
[arrLocalKeys containsObject:key]) {
continue;
} else if ([arrSpecialKeys containsObject:key]) {
[mDict addEntriesFromDictionary:@{dictSpKeyDict[key]: value}];
} else {
[mDict addEntriesFromDictionary:@{key: value}];
}
}
}
free(properties);
return mDict;
}
- (NSDictionary *)dictForLocalSave {
unsigned int count;
objc_property_t *properties = class_copyPropertyList([self class], &count);
......
......@@ -58,8 +58,8 @@ typedef NS_ENUM(NSInteger, cellRow) {
@property (nonatomic, assign) BOOL d_isProduct;
@property (nonatomic, strong) NSArray *d_meteilHeaderArr;
@property (nonatomic, strong) NSArray *d_productHeaderArr;
@property (nonatomic, strong) NSMutableArray *d_meteilArr;
@property (nonatomic, strong) NSMutableArray *d_productArr;
//@property (nonatomic, strong) NSMutableArray *d_meteilArr;
//@property (nonatomic, strong) NSMutableArray *d_productArr;
@property (nonatomic, assign) NSInteger d_editOrDelete;
......@@ -86,29 +86,29 @@ typedef NS_ENUM(NSInteger, cellRow) {
}
- (void)addNewMaterail: (NSNotification *)aNotification {
GXFProcessMaterial *material = aNotification.object;
if (_d_meteilArr) {
[_d_meteilArr addObject:material];
if (_d_materialMuArr) {
[_d_materialMuArr addObject:material];
[self p_refreshData];
}
}
- (void)addNewProduct: (NSNotification *)aNotification {
GXFProcessProduct *product = aNotification.object;
if (_d_productArr) {
[_d_productArr addObject:product];
if (_d_productMuArr) {
[_d_productMuArr addObject:product];
[self p_refreshData];
}
}
- (void)editProduct: (NSNotification *)aNotification {
GXFProcessProduct *product = aNotification.object;
if (_d_productArr) {
[_d_productArr replaceObjectAtIndex:_d_editOrDelete withObject:product];//待做:优化为刷新这一条
if (_d_productMuArr) {
[_d_productMuArr replaceObjectAtIndex:_d_editOrDelete withObject:product];//待做:优化为刷新这一条
[self p_refreshData];
}
}
- (void)deleteProduct: (NSNotification *)aNotification {
GXFProcessProduct *product = aNotification.object;
if (_d_productArr) {
[_d_productArr removeObject:product];////待做:优化为刷新这一条
if (_d_productMuArr) {
[_d_productMuArr removeObject:product];////待做:优化为刷新这一条
[self p_refreshData];
}
}
......@@ -184,31 +184,31 @@ typedef NS_ENUM(NSInteger, cellRow) {
_selectRowArr = [[NSMutableArray alloc]init];
self.d_processBill = [[GXFProcessBill alloc]init];
if (!self.d_meteilArr) {
self.d_meteilArr = [NSMutableArray array];
if (!self.d_materialMuArr) {
self.d_materialMuArr = [NSMutableArray array];
}
GXFProcessMaterial *processM = [[GXFProcessMaterial alloc]init];
processM.uuid = @"00";
processM.productName = @"Material";
processM.productUuid = @"01";
processM.baseQty = @(10);
processM.instockDate = [NSDate date];
[self.d_meteilArr addObject:processM];
[self.d_meteilArr addObject:processM];
// GXFProcessMaterial *processM = [[GXFProcessMaterial alloc]init];
// processM.uuid = @"00";
// processM.productName = @"Material";
// processM.productUuid = @"01";
// processM.baseQty = @(10);
// processM.instockDate = [NSDate date];
// [self.d_materialMuArr addObject:processM];
// [self.d_materialMuArr addObject:processM];
if (!self.d_productArr) {
self.d_productArr = [NSMutableArray array];
if (!self.d_productMuArr) {
self.d_productMuArr = [NSMutableArray array];
}
GXFProcessProduct *processP = [[GXFProcessProduct alloc]init];
processP.uuid = @"11";
processP.productName = @"product";
processP.productUuid = @"12";
processP.baseQty = @(10);
processP.outstockDate = [NSDate date];
[self.d_productArr addObject:processP];
NSDictionary *dict = [processP dictForCommit];
// GXFProcessProduct *processP = [[GXFProcessProduct alloc]init];
// processP.uuid = @"11";
// processP.productName = @"product";
// processP.productUuid = @"12";
// processP.baseQty = @(10);
// processP.outstockDate = [NSDate date];
// [self.d_productMuArr addObject:processP];
}
- (void)initSubViews {
self.view.backgroundColor = XXFBgColor;
......@@ -231,9 +231,9 @@ typedef NS_ENUM(NSInteger, cellRow) {
return _d_arrLeftTableV.count;
} else {
if (_d_isProduct) {
return 2 + _d_productArr.count;
return 2 + _d_productMuArr.count;
}
return 2 + _d_meteilArr.count;
return 2 + _d_materialMuArr.count;
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
......@@ -394,10 +394,10 @@ typedef NS_ENUM(NSInteger, cellRow) {
if (cell == nil) {
if (_d_isProduct) {
GXFProcessProduct *processP = (GXFProcessProduct *)_d_productArr[indexPath.row - 2];
GXFProcessProduct *processP = (GXFProcessProduct *)_d_productMuArr[indexPath.row - 2];
cell = [[GXFProcessProductTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID processProduct:processP];
} else {
GXFProcessMaterial *pm = (GXFProcessMaterial *)_d_meteilArr[indexPath.row - 2];
GXFProcessMaterial *pm = (GXFProcessMaterial *)_d_materialMuArr[indexPath.row - 2];
cell = [[GXFProcessMaterialTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID processMaterial:pm];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
......@@ -527,7 +527,7 @@ typedef NS_ENUM(NSInteger, cellRow) {
- (void)editClick: (UIButton *)btn{
if (_d_isProduct) {
self.d_editOrDelete = btn.tag - 2;
GXFProcessProduct *product = _d_productArr[btn.tag - 2];
GXFProcessProduct *product = _d_productMuArr[btn.tag - 2];
GXFPopNewProductViewController *productVC = [[GXFPopNewProductViewController alloc]initWithProcessProduct:product isEdit: YES];
[self PushViewController:productVC animated:NO];
} else {
......@@ -558,19 +558,23 @@ typedef NS_ENUM(NSInteger, cellRow) {
#pragma GXFBottomViewDelegate
- (void)bottomViewleftButtonClicked:(UIButton *)leftBtn {
}
- (void)bottomViewRightButtonClicked:(UIButton *)rightBtn {
CLog(@"ffff");
//[IBTCommon checkString:_d_processBill.title]
if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.title]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"标题不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
return;
}
if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.vendor_name]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"请选择供应商" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
return;
}
// if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.title]) {
// UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"标题不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
// [alert show];
// return;
// }
// if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.vendor_name]) {
// UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"请选择供应商" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
// [alert show];
// return;
// }
if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.warehouse_name]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"请选择加工工厂" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
......@@ -580,29 +584,29 @@ typedef NS_ENUM(NSInteger, cellRow) {
//保存
void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
// if (data) {
// NSInteger success = [data[@"success"] integerValue];
// NSString *message = data[@"message"];
// if (success == 1) {
// //成功
// if ([state isEqualToString:@"initial"]) {//保存成功
// [IBTLoadingView showTips:@"操作成功"];
// }else{//提交成功
// SurveyViewController *svc = [SurveyViewController new];
// [self PushViewController:svc animated:YES];
// }
// }else{
// [IBTLoadingView showTips:message];
// }
// }
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
//保存
void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
// if (data) {
// NSInteger success = [data[@"success"] integerValue];
// NSString *message = data[@"message"];
// if (success == 1) {
// //成功
// if ([state isEqualToString:@"initial"]) {//保存成功
// [IBTLoadingView showTips:@"操作成功"];
// }else{//提交成功
// SurveyViewController *svc = [SurveyViewController new];
// [self PushViewController:svc animated:YES];
// }
// }else{
// [IBTLoadingView showTips:message];
// }
// }
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
// if(self.survey.uuid.length > 0 && uuidObject == [NSNull null]){
// uuidObject = self.survey.uuid;
......@@ -614,42 +618,43 @@ typedef NS_ENUM(NSInteger, cellRow) {
// version = self.survey.version;
// }
// NSDictionary *material = @{@"uuid":@"",@"productUuid":@"",@"productCode":@"",@"productName":@"",@"instockDate":@"",@"place":@"",@"quality":@"",@"baseQty":@"",@"basePrice":@"",@"total":@"",@"remark":@"",};
// NSDictionary *product = @{@"uuid":@"",@"productUuid":@"",@"productCode":@"",@"productName":@"",@"instockDate":@"",@"place":@"",@"quality":@"",@"baseQty":@"",@"basePrice":@"",@"total":@"",@"remark":@"",};
NSMutableArray *productMuArr = [NSMutableArray array];
for (int count = 0; count < _d_productArr.count; count ++) {
GXFProcessProduct *product = (GXFProcessProduct *)_d_productArr[count];
[productMuArr addObject:[product dictForCommit]];
for (int count = 0; count < _d_productMuArr.count; count ++) {
GXFProcessProduct *product = (GXFProcessProduct *)_d_productMuArr[count];
NSMutableDictionary *dic = [product mutableDictDateToStringForCommit];
// NSDictionary *materialdict = @{@"uuid":@"11",@"productUuid":@"402880e64e287fe2014e28895b8a0032",@"productCode":@"农夫山泉",@"productName":@"dd",@"outstockDate":@"2015-09-05 13:36:16 +0000",@"unit":@"",@"qpc":@"kk",@"qpcStr":@"ll",@"quality":@"9",@"baseQty":@"8",@"remark":@""};
[productMuArr addObject:dic];//productdict];
}
NSMutableArray *materialMuArr = [NSMutableArray array];
for (int count = 0; count < _d_productArr.count; count ++) {
for (int count = 0; count < _d_materialMuArr.count; count ++) {
GXFProcessMaterial *material = (GXFProcessMaterial *)_d_materialMuArr[count];
[materialMuArr addObject:[material dictForCommit]];
NSMutableDictionary *dic = [material mutableDictDateToStringForCommit];
// NSDictionary *productdict = @{@"uuid":@"",@"productUuid":@"402880e64e287fe2014e28895b8a0032",@"productCode":@"农夫山泉",@"productName":@"dd",@"outstockDate":@"2015-09-05 13:36:16 +0000",@"place":@"",@"quality":@"",@"baseQty":@"1",@"basePrice":@"2",@"total":@"2",@"remark":@""};
[materialMuArr addObject:dic];//materialdict];
}
NSDictionary *dict = @{@"uuid":@"",
@"version":@(0),
@"billnumber":@"",
@"title":@"title",//[IBTCommon checkString:self.titleStr],
@"vendor_uuid":_d_processBill.vendor_uuid,
@"vendor_code":_d_processBill.vendor_code,
@"vendor_name":_d_processBill.vendor_name,
@"warehouse_uuid":_d_processBill.warehouse_uuid,
@"warehouse_code":_d_processBill.warehouse_code,
@"warehouse_name":_d_processBill.warehouse_name,
@"contact":[IBTCommon checkString: _d_processBill.contact],
@"contactPhone":[IBTCommon checkString:_d_processBill.contact],
@"total":_d_processBill.total,
@"remark":[IBTCommon checkString:_d_processBill.remark],
@"materials":materialMuArr,
@"products":productMuArr};
//[IBTLoadingView showProgressLabel:msg];
[[ICRHTTPController sharedController] saveSurveyWithAuthenticode:dict success:succ failure:fail];
}
- (void)bottomViewRightButtonClicked:(UIButton *)rightBtn {
NSDictionary *dict = @{@"uuid":@"",
@"version":@(0),
@"billnumber":@"",
@"title":@"title",//[IBTCommon checkString:self.titleStr],
@"vendor_uuid": @"000",//_d_processBill.vendor_uuid,
@"vendor_code": @"111",//_d_processBill.vendor_code,
@"vendor_name": @"ff",//_d_processBill.vendor_name,
@"warehouse_uuid":_d_processBill.warehouse_uuid,
@"warehouse_code":_d_processBill.warehouse_code,
@"warehouse_name":_d_processBill.warehouse_name,
@"contact":[IBTCommon checkString: _d_processBill.contact],
@"contactPhone":[IBTCommon checkString:_d_processBill.contactPhone],
@"total":_d_processBill.total,
@"remark":[IBTCommon checkString:_d_processBill.remark],
@"materials":materialMuArr,
@"products":productMuArr};
//[IBTLoadingView showProgressLabel:msg];
[[ICRHTTPController sharedController] saveSurveyWithAuthenticode:dict success:succ failure:fail];
}
......
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