|
|
@@ -44,6 +44,213 @@
|
|
|
[self getFormDataFromSever];
|
|
|
}
|
|
|
|
|
|
+#pragma mark --- 保存单据【保养维护特有】
|
|
|
+-(void)saveFormAction
|
|
|
+{
|
|
|
+ [MBProgressHUD showMessage:@"" toView:self.view];
|
|
|
+
|
|
|
+ [self.view endEditing:YES];
|
|
|
+
|
|
|
+ //拼接主表上传的数据
|
|
|
+ NSMutableDictionary *formParam = [NSMutableDictionary new];
|
|
|
+ //拼接多明细表单上传的数据
|
|
|
+ NSMutableArray *dataArr = [NSMutableArray new];
|
|
|
+
|
|
|
+ for (UITableView *tableView in self.dView.tableViewArr) {
|
|
|
+ [tableView endEditing:YES];
|
|
|
+
|
|
|
+ id obj = tableView.dataArray[0];
|
|
|
+ if ([obj isKindOfClass:[FormModel class]]) {
|
|
|
+ for (int i = 0; i<_listArr.count; i++) {
|
|
|
+ FormModel *model = _listArr[i];
|
|
|
+ for (int j = 0; j < model.showItems.count; j++) {
|
|
|
+ DetailFormModel *detailModel = model.showItems[j];
|
|
|
+ /*判断必填项*/
|
|
|
+ if ([detailModel.fd_allowblank isEqualToString:@"F"] || [detailModel.fd_allowblank isEqualToString:@"necessaryField"]) {
|
|
|
+ if (detailModel.fd_value.length == 0) {
|
|
|
+ [JOShowMessageFromNavi showDropViewWithMessage:@"必填项不能为空!" ToNavi:self.navigationController withColor:nil];
|
|
|
+ [MBProgressHUD hideHUDForView:self.view];
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ [formParam addEntriesFromDictionary:@{detailModel.fd_field:FORMAT(@"%@",detailModel.fd_value != nil ? detailModel.fd_value:@"")}];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ [formParam addEntriesFromDictionary:@{detailModel.fd_field:FORMAT(@"%@",detailModel.fd_value != nil ? detailModel.fd_value:@"")}];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int j = 0; j < model.hideItems.count; j++) {
|
|
|
+ DetailFormModel *detailModel = model.hideItems[j];
|
|
|
+ [formParam addEntriesFromDictionary:@{detailModel.fd_field:FORMAT(@"%@",detailModel.fd_value != nil ? detailModel.fd_value:@"")}];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ NSMutableArray *gridDataArr = [NSMutableArray new];
|
|
|
+ NSString *dgCaller = @"";
|
|
|
+ for (int i = 0; i < tableView.dataArray.count; i++) {
|
|
|
+ NSMutableDictionary *gridDataDic = [NSMutableDictionary new];
|
|
|
+ MoreGridModel *model = tableView.dataArray[i];
|
|
|
+ /*特殊处理:配件用料,当类型选择为辅材且数量大于0时,必须要输入新设备/仓库名称和编号*/
|
|
|
+ NSString *typeStr = @"",*codeStr = @"",*newDevice = @"",*shuLiang = @"";
|
|
|
+ for (int j = 0; j < model.showItems.count; j++) {
|
|
|
+ DetailgridModel *detailModel = model.showItems[j];
|
|
|
+ if ([detailModel.dg_value isEqualToString:@"PROD"] || [detailModel.dg_value isEqualToString:@"辅材"]) {
|
|
|
+ typeStr = @"PROD";
|
|
|
+ }
|
|
|
+ if ([detailModel.dg_field isEqualToString:@"dd_ordercode"]) {
|
|
|
+ codeStr = detailModel.dg_value;
|
|
|
+ }
|
|
|
+ if ([detailModel.dg_field isEqualToString:@"dd_othcode"]) {
|
|
|
+ newDevice = detailModel.dg_value;
|
|
|
+ }
|
|
|
+ if ([detailModel.dg_field isEqualToString:@"dd_qty"]) {
|
|
|
+ shuLiang = detailModel.dg_value;
|
|
|
+ }
|
|
|
+ /*判断必填项*/
|
|
|
+ if ([detailModel.dg_logictype isEqualToString:@"F"] || [detailModel.dg_logictype isEqualToString:@"necessaryField"]) {
|
|
|
+ if (detailModel.dg_value.length == 0) {
|
|
|
+ [JOShowMessageFromNavi showDropViewWithMessage:@"明细必填项不能为空!" ToNavi:self.navigationController withColor:nil];
|
|
|
+ [MBProgressHUD hideHUDForView:self.view];
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ [gridDataDic addEntriesFromDictionary:@{detailModel.dg_field:FORMAT(@"%@",detailModel.dg_value != nil ? detailModel.dg_value:@"")}];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ [gridDataDic addEntriesFromDictionary:@{detailModel.dg_field:FORMAT(@"%@",detailModel.dg_value != nil ? detailModel.dg_value:@"")}];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*特殊处理:配件用料,当类型选择为辅材且数量大于0时,必须要输入新设备/仓库名称和编号*/
|
|
|
+ if ([typeStr isEqualToString:@"PROD"] && [shuLiang intValue] > 0) {
|
|
|
+ if (newDevice.length == 0 || codeStr.length == 0) {
|
|
|
+ [JOShowMessageFromNavi showDropViewWithMessage:FORMAT(@"明细%d的编号和新设备/仓库名称不能为空",i+1) ToNavi:self.navigationController withColor:nil];
|
|
|
+ [MBProgressHUD hideHUDForView:self.view];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int j = 0; j < model.hideItems.count; j++) {
|
|
|
+ DetailgridModel *detailModel = model.hideItems[j];
|
|
|
+ [gridDataDic addEntriesFromDictionary:@{detailModel.dg_field:FORMAT(@"%@",detailModel.dg_value != nil ? detailModel.dg_value:@"")}];
|
|
|
+ }
|
|
|
+ [gridDataArr addObject:gridDataDic];
|
|
|
+ dgCaller = model.dgcaller;
|
|
|
+ }
|
|
|
+ NSDictionary *dgDic = @{
|
|
|
+ @"dgcaller":dgCaller,
|
|
|
+ @"dgData":gridDataArr,
|
|
|
+ };
|
|
|
+ if (multidetailgrid) {
|
|
|
+ [dataArr addObject:dgDic];
|
|
|
+ }else
|
|
|
+ dataArr = gridDataArr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //主表
|
|
|
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:formParam options:NSJSONWritingPrettyPrinted error:nil];
|
|
|
+ NSString *formStr=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
|
+
|
|
|
+ //多明细表
|
|
|
+ NSData *gridData = [NSJSONSerialization dataWithJSONObject:dataArr options:NSJSONWritingPrettyPrinted error:nil];
|
|
|
+ NSString *gridStr = [[NSString alloc] initWithData:gridData encoding:NSUTF8StringEncoding];
|
|
|
+ if (dataArr.count == 0) {
|
|
|
+ gridStr = @"";
|
|
|
+ }
|
|
|
+
|
|
|
+ SLog(@"主表合并的东西:%@",formParam);
|
|
|
+ SLog(@"多明细表合并的东西:%@",dataArr);
|
|
|
+
|
|
|
+ NSString *url = [NSString stringWithFormat:@"%@mobile/device/saveOrUpdateDeviceChange.action",g_id];
|
|
|
+
|
|
|
+ NSDictionary *dic = @{
|
|
|
+ @"caller":_caller,
|
|
|
+ @"formStore":formStr,
|
|
|
+ @"gridStore":multidetailgrid ? @"":gridStr,
|
|
|
+ @"othergridStore":multidetailgrid ? gridStr:@"",
|
|
|
+ @"master":g_master,
|
|
|
+ @"sessionUser":g_sessionUser,
|
|
|
+ @"sessionId":g_sessionId,
|
|
|
+ @"id":self.idStr ? self.idStr : @"0"
|
|
|
+ };
|
|
|
+
|
|
|
+ SLog(@"aaaaaaaa:%@ --- url:%@",dic,url);
|
|
|
+
|
|
|
+ url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
+
|
|
|
+ UASNetworkManager *manager = [UASNetworkManager shareManager];
|
|
|
+
|
|
|
+ [manager request:url method:POST parameters:dic progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
|
|
|
+ [MBProgressHUD hideHUDForView:self.view];
|
|
|
+
|
|
|
+ SLog(@"chenggong---:%@",responseObject);
|
|
|
+
|
|
|
+ NSString *specialStr = responseObject[@"exceptionInfo"];
|
|
|
+ //异常
|
|
|
+ if (specialStr.length != 0) {
|
|
|
+
|
|
|
+ [JOShowMessageFromNavi showDropViewWithMessage:specialStr ToNavi:self.navigationController withColor:nil];
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ [_listArr removeAllObjects];
|
|
|
+ [self.gridData removeAllObjects];
|
|
|
+ [self.dView removeFromSuperview];
|
|
|
+ [uploadBtn setTitle:Localized(@"UU_custom_submit") forState:UIControlStateNormal];
|
|
|
+ [uploadBtn removeTarget:self action:@selector(acceptRepairAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [uploadBtn addTarget:self action:@selector(uploadFormAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+
|
|
|
+ //单据配置时标识状态码字段
|
|
|
+ _cModel = [[ConfigModel alloc]initWithDic:responseObject[@"config"]];
|
|
|
+
|
|
|
+ NSMutableArray *formAllDataArr = [NSMutableArray new];
|
|
|
+ NSMutableArray *gridAllDataArr = [NSMutableArray new];
|
|
|
+
|
|
|
+ for (id obj in responseObject[@"data"][@"formdetail"]) {
|
|
|
+
|
|
|
+ [formAllDataArr addObject:obj];
|
|
|
+ }
|
|
|
+
|
|
|
+ formAllDataArr = [NSDictionary changeType:formAllDataArr];
|
|
|
+
|
|
|
+ multidetailgrid = [responseObject[@"data"][@"multidetailgrid"] boolValue];
|
|
|
+ if (multidetailgrid) {
|
|
|
+ for (id obj in responseObject[@"data"][@"othergridetail"]) {
|
|
|
+ [gridAllDataArr addObject:obj];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ NSMutableArray *arr = [NSMutableArray new];
|
|
|
+ for (id obj in responseObject[@"data"][@"gridetail"]) {
|
|
|
+ [arr addObject:obj];
|
|
|
+ }
|
|
|
+ if (arr.count != 0) {
|
|
|
+ NSDictionary *dic = @{
|
|
|
+ @"dgtitle":@"从属明细表",
|
|
|
+ @"dgcaller":@"",
|
|
|
+ @"detailgrid":arr,
|
|
|
+ };
|
|
|
+ [gridAllDataArr addObject:dic];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ gridAllDataArr = [NSDictionary changeType:gridAllDataArr];
|
|
|
+
|
|
|
+ if (formAllDataArr.count != 0) {
|
|
|
+ [self handlerDataFromDowload:formAllDataArr andGridData:gridAllDataArr];
|
|
|
+ }
|
|
|
+
|
|
|
+ self.idStr = [NSString stringWithFormat:@"%@",responseObject[@"id"]];
|
|
|
+
|
|
|
+ } failure:^(NSURLSessionDataTask *task, NSError *error) {
|
|
|
+ [MBProgressHUD hideHUDForView:self.view];
|
|
|
+
|
|
|
+ SLog(@"错误的原因:%@",error);
|
|
|
+ ErrorInfomation;
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark --- 提交上传操作
|
|
|
-(void)uploadFormAction
|
|
|
{
|
|
|
@@ -1148,7 +1355,7 @@
|
|
|
[uploadBtn addTarget:self action:@selector(uploadFormAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
[self.view addSubview:uploadBtn];
|
|
|
[uploadBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.equalTo(self.view).offset(20);
|
|
|
+ make.width.mas_equalTo(self_width-40);
|
|
|
make.right.equalTo(self.view).offset(-20);
|
|
|
make.bottom.equalTo(self.view).offset(-5);
|
|
|
make.height.mas_equalTo(40);
|
|
|
@@ -1158,6 +1365,30 @@
|
|
|
_date.delegate = self;
|
|
|
_date.didSelect = @selector(onDateDO);
|
|
|
_date.didClear = @selector(onDateClear);
|
|
|
+
|
|
|
+ //养护管理增加保存按钮
|
|
|
+ if ([self.caller isEqualToString:@"DeviceChange!Maintain"]) {
|
|
|
+ UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ saveBtn.layer.masksToBounds = YES;
|
|
|
+ saveBtn.layer.cornerRadius = 5;
|
|
|
+ [saveBtn setBackgroundColor:HexColor(@"#33A2EE") forState:UIControlStateNormal];
|
|
|
+ [saveBtn setBackgroundColor:HexColor(@"#8EB2CD") forState:UIControlStateDisabled];
|
|
|
+ [saveBtn setBackgroundColor:HexColor(@"#2D84C0") forState:UIControlStateHighlighted];
|
|
|
+ [saveBtn setTitle:Localized(@"UU_custom_save") forState:UIControlStateNormal];
|
|
|
+ saveBtn.userInteractionEnabled = YES;
|
|
|
+ [saveBtn addTarget:self action:@selector(saveFormAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:saveBtn];
|
|
|
+ [saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(self.view).offset(20);
|
|
|
+ make.width.mas_equalTo(self_width/2-40);
|
|
|
+ make.bottom.equalTo(self.view).offset(-5);
|
|
|
+ make.height.mas_equalTo(40);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [uploadBtn mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.mas_equalTo(self_width/2-40);
|
|
|
+ }];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#pragma mark --- 维修单接单
|