| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- //
- // NewOtherInStorageHomeVC.m
- // IBOSSmini
- //
- // Created by guan hong hou on 2018/4/24.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "NewOtherInStorageHomeVC.h"
- @interface NewOtherInStorageHomeVC (){
- NewOtherInStorageVC *otherInStorageVc;
- NewOtherInStorageGoodsDetailVC *otherInStorageGoodsDetailVc;
- }
- @end
- @implementation NewOtherInStorageHomeVC
- #pragma mark 公共函数
- /**
- 视图加载完成函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self loadNavStyle];
- [self initUI];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-
- }
- #pragma mark 委托函数
- /**
- 加载总数数据成功回调
-
- @param sender <#sender description#>
- */
- - (void)onSaveDataLoadFinish:(ASIDownManager *)sender {
- NSDictionary *dic = [sender.mWebStr JSONValue];
- [self stopLoading];
- // 服务器返回数据是否正确
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- // 服务器返回数据状态值
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- // 服务器返回数据消息
- NSString *message=[dic objectForKey:@"Message"];
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
-
- __weak typeof (self)weakself = self;
- //初始化->
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示"
- message:@"保存成功!" preferredStyle:
- UIAlertControllerStyleAlert ];
- // addAction->
- [alert addAction:[UIAlertAction actionWithTitle:@"确定"
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *action)
- {
-
- [weakself.navigationController popViewControllerAnimated:YES];
- //关闭当前页面 刷新一览主界面
- if([self.refreshDelegate respondsToSelector:@selector(refreshData)]){
- [self.refreshDelegate refreshData];
- }
-
-
-
- }]];
- //展示->
- [self presentViewController:alert animated:YES completion:nil];
- }
-
- else if(iStatus==ActionResultStatusAuthError
- ||iStatus==ActionResultStatusNoLogin
- ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
-
- [self showReLoginDialog:message];
- }
- else{
- [self showAlertViewText:message];
- }
-
- }
- }
- /**
- 加载总数数据失败回调
-
- @param sender <#sender description#>
- */
- - (void)onSaveDataLoadFail:(ASIDownManager *)sender {
- [self stopLoading];
- [self showAlertViewText:@"加载失败"];
- }
- #pragma mark 私有函数
- /**
- 导航按钮样式
- */
- -(void)loadNavStyle
- {
-
- self.navigationItem.title=@"新建其他入库";
- //返回
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
- forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0, 15, 18);
-
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- }
- /**
- 初始化UI
- */
- -(void)initUI{
-
- [self.view setBackgroundColor:[UIColor whiteColor]];
- self.page = [[PageSwitchView alloc] init];
- [self.view addSubview:self.page];
- otherInStorageVc = [[NewOtherInStorageVC alloc] init];
- otherInStorageVc.listNavVc=self.navigationController;
-
- otherInStorageGoodsDetailVc = [[NewOtherInStorageGoodsDetailVC alloc] init];
- otherInStorageGoodsDetailVc.nav=self.navigationController;
- otherInStorageGoodsDetailVc.otherInStorageVc=otherInStorageVc;
- NSMutableArray *arr=[[NSMutableArray alloc]init];
-
- PageSwitchModel *model = [[PageSwitchModel alloc] init];
- model.title = @"其它入库";
- model.controller = otherInStorageVc;
- [arr addObject:model];
- model = [[PageSwitchModel alloc] init];
- model.title = @"商品明细";
- model.controller = otherInStorageGoodsDetailVc;
- [arr addObject:model];
-
- self.page.datas = arr;
- UIView *bottomView= [UIView new];
- [self.view addSubview:bottomView];
- bottomView.translatesAutoresizingMaskIntoConstraints=NO;
- UIView *bottomSeparatorView = [UIView new];
- bottomSeparatorView.frame=CGRectMake(0, 0, Screen_Width, 1);
- bottomSeparatorView.backgroundColor = LineBackgroundColor;
- [bottomView addSubview:bottomSeparatorView];
- //提交结算
- _btnSave=[UIButton buttonWithType:UIButtonTypeCustom];
- [_btnSave setTitle:@"保存" forState:UIControlStateNormal];
- [_btnSave setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- _btnSave.frame=CGRectMake(20,7, Screen_Width-40,40);
- [_btnSave setBackgroundColor:[UIColor colorWithRed:189.0/255.0 green:0 blue:7.0/255.0 alpha:1]];
- [_btnSave addTarget:self action:@selector(saveInStorage) forControlEvents:UIControlEventTouchUpInside];
- [bottomView addSubview:_btnSave];
- [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_page]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_page)]];
-
- [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[bottomView]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(bottomView)]];
- NSArray *arr1 = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_page][bottomView(55)]-marg-|" options:0 metrics:@{@"marg":@(SCREENHEIGHT >= 812 ? 34 : 0)} views:NSDictionaryOfVariableBindings(_page,bottomView)];
-
- [self.view addConstraints:arr1];
- }
- /**
- 返回函数
- */
- - (void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- /**
- 保存函数
- */
- -(void)saveInStorage{
- if(otherInStorageGoodsDetailVc.dataList==nil||otherInStorageGoodsDetailVc.dataList.count==0){
- [self showAlertViewText:@"商品明细不能为空"];
- return;
- }
-
- [otherInStorageGoodsDetailVc.view endEditing:YES];
- [otherInStorageVc.view endEditing:YES];
- if(otherInStorageVc.lblCustomerCode.text!=nil&&otherInStorageVc.lblCustomerCode.text.length>0){
- if([otherInStorageVc.lblCustomerCode.text isEqualToString:@"请选择客户编码"]){
- otherInStorageVc.customerCode=@"";
- }
- }
- for(OtherInStorageGoodsSearchListModel *goodsListModel in otherInStorageGoodsDetailVc.dataList){
-
- if(goodsListModel.enterQuantity==nil||[goodsListModel.enterQuantity isEqualToString:@""]){
- [self showAlertViewText:@"入库数量不能为空"];
- return;
- }
-
- if(goodsListModel.enterPrice==nil||[goodsListModel.enterPrice isEqualToString:@""]){
- [self showAlertViewText:@"入库价格不能为空"];
- return;
- }
-
-
- if(goodsListModel.code==nil||[goodsListModel.code isEqualToString:@""]){
- [self showAlertViewText:@"商品编码不能为空"];
- return;
- }
-
-
- if(goodsListModel.onlyCode==nil||[goodsListModel.onlyCode isEqualToString:@""]){
- [self showAlertViewText:@"唯一编码不能为空"];
- return;
- }
-
- if(goodsListModel.gradeName==nil||[goodsListModel.gradeName isEqualToString:@""]){
- [self showAlertViewText:@"等级不能为空"];
- return;
- }
-
- if(goodsListModel.warehouseName==nil||[goodsListModel.warehouseName isEqualToString:@""]){
- [self showAlertViewText:@"库区不能为空"];
- return;
- }
-
- if(goodsListModel.positionNumberId==nil||[goodsListModel.positionNumberId isEqualToString:@""]){
- [self showAlertViewText:@"仓位号不能为空"];
- return;
- }
-
-
- if([goodsListModel.enterQuantity doubleValue]<=0){
- [self showAlertViewText:@"入库数量必须大于零"];
- return;
- }
-
- if ([goodsListModel.enterQuantity doubleValue] >MAXIMUM_QUANTITY) {
- NSString *quantityHint=[NSString stringWithFormat:@"入库数量超过最大值%f",MAXIMUM_QUANTITY];
- [self showAlertViewText:quantityHint];
- return;
- }
- if([goodsListModel.enterPrice doubleValue]>MAXIMUM_PRICE){
- NSString *priceHint=[NSString stringWithFormat:@"入库价格超过最大值%f",MAXIMUM_PRICE];
- [self showAlertViewText:priceHint];
- return;
- }
- }
-
- otherInStorageVc.remarks=otherInStorageVc.txtRemarks.text;
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"SaveEnterDataIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:@"1" forKey:@"IDevicesType"];
- [dict setObject:@"1" forKey:@"EnterType"];
- [dict setObject:otherInStorageVc.dockerId==nil?@"":otherInStorageVc.dockerId forKey:@"Docker"];
- [dict setObject:otherInStorageVc.driverId==nil?@"":otherInStorageVc.driverId forKey:@"Driver"];
- [dict setObject: otherInStorageVc.remarks==nil?@"": otherInStorageVc.remarks forKey:@"Remarks"];
- [dict setObject: otherInStorageVc.customerId==nil?@"": otherInStorageVc.customerId forKey:@"CustomerID"];
- [dict setObject: otherInStorageVc.customerCode==nil?@"": otherInStorageVc.customerCode forKey:@"CustomerCode"];
- [dict setObject: otherInStorageVc.customerName==nil?@"": otherInStorageVc.customerName forKey:@"CustomerName"];
- [dict setObject: otherInStorageVc.telephone==nil?@"": otherInStorageVc.telephone forKey:@"Telephone"];
- [dict setObject: otherInStorageVc.address==nil?@"": otherInStorageVc.address forKey:@"Address"];
- [dict setObject: otherInStorageVc.contacts==nil?@"": otherInStorageVc.contacts forKey:@"Contacts"];
- [dict setObject: otherInStorageVc.staffId==nil?@"": otherInStorageVc.staffId forKey:@"StaffID"];
- [dict setObject: otherInStorageVc.organizationId==nil?@"": otherInStorageVc.organizationId forKey:@"BusinessOrganizationID"];
- [dict setObject: otherInStorageVc.organizationCode==nil?@"": otherInStorageVc.organizationCode forKey:@"OrganizationCode"];
-
- [dict setObject: otherInStorageVc.organizationName==nil?@"": otherInStorageVc.organizationName forKey:@"OrganizationName"];
-
- [dict setObject: otherInStorageVc.supplierId==nil?@"": otherInStorageVc.supplierId forKey:@"SupplierID"];
-
- NSMutableArray *goodsListArray=[[NSMutableArray alloc]init];
-
- if(otherInStorageGoodsDetailVc.dataList!=nil&&otherInStorageGoodsDetailVc.dataList.count>0){
-
- for(OtherInStorageGoodsSearchListModel *goodsListModel in otherInStorageGoodsDetailVc.dataList){
- NSDictionary *dic=[NSDictionary new];
- dic=@{@"InventoryID":goodsListModel.inventoryId,@"CodeID":goodsListModel.codeId,@"Code":goodsListModel.code,@"PositionNumber":goodsListModel.positionNumberName==nil?@"":goodsListModel.positionNumberName,@"EnterQuantity":goodsListModel.enterQuantity,@"EnterPrice":goodsListModel.enterPrice,@"OnlyCode":goodsListModel.onlyCode,@"Specification":goodsListModel.specification==nil?@"":goodsListModel.specification,@"ColorNumber":goodsListModel.colorNumber==nil?@"":goodsListModel.colorNumber,@"BrandID":goodsListModel.brandId==nil?@"":goodsListModel.brandId,@"BrandName":goodsListModel.brandName==nil?@"":goodsListModel.brandName,@"GradeID":goodsListModel.gradeId==nil?@"":goodsListModel.gradeId,@"GradeName":goodsListModel.gradeName==nil?@"":goodsListModel.gradeName,@"KindID":goodsListModel.kindId==nil?@"":goodsListModel.kindId,@"KindName":goodsListModel.kindName==nil?@"":goodsListModel.kindName,@"VarietyID":goodsListModel.varietyId==nil?@"":goodsListModel.varietyId,@"VarietyName":goodsListModel.varietyName==nil?@"":goodsListModel.varietyName,@"SeriesID":goodsListModel.seriesId==nil?@"":goodsListModel.seriesId,@"SeriesName":goodsListModel.seriesName==nil?@"":goodsListModel.seriesName,@"UnitID":goodsListModel.unitId==nil?@"":goodsListModel.unitId,@"UnitName":goodsListModel.unitName==nil?@"":goodsListModel.unitName,@"Package":goodsListModel.package==nil?@"":goodsListModel.package,@"Weight":goodsListModel.weight==nil?@"":goodsListModel.weight,@"Specification":goodsListModel.specification==nil?@"":goodsListModel.specification,@"Volume":goodsListModel.volume==nil?@"":goodsListModel.volume,@"Acreage":goodsListModel.acreage==nil?@"":goodsListModel.acreage,@"WarehouseID":goodsListModel.warehouseId==nil?@"":goodsListModel.warehouseId,@"WarehouseName":goodsListModel.warehouseName==nil?@"":goodsListModel.warehouseName,@"SourceDetailID":@"",@"Remarks":@""};
- [goodsListArray addObject:dic];
- }
-
- SBJsonWriter *write = [[SBJsonWriter alloc] init];
- NSString *value = [write stringWithObject:goodsListArray];
- [dict setObject:value forKeyedSubscript:@"DetailData"];
- }
- [self startLoading];
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.OnImageDown = @selector(onSaveDataLoadFinish:);
- _downManager.OnImageFail = @selector(onSaveDataLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
-
- }
- @end
|