// // StockingDetailViewController.m // IBOSSmini // // Created by apple on 2017/5/17. // Copyright © 2017年 elongtian. All rights reserved. // #import "StockingDetailViewController.h" @interface StockingDetailViewController (){ UILabel *noValue ; UILabel *onlyCode; UILabel *gradeName ; UILabel *specification ; UILabel *colorNumber; UILabel *wareHouseName; UILabel *positionNumber ; UILabel *goodKindName; UILabel *brandName; UILabel *serialName; UILabel *varietyName; UILabel *quantity ; UILabel *stockingQuantity; UILabel *personName; UILabel *reason ; UILabel *usertime; UILabel *username; UIScrollView *_scrollView; } /** ASIDownManager */ @property (nonatomic,strong) ASIDownManager *downManager; @end @implementation StockingDetailViewController #pragma mark - 公共函数 /** viewDidLoad */ - (void)viewDidLoad { [super viewDidLoad]; [self showTitle:@"库存盘点明细"]; [self loadNavStyle]; [self initUI]; [self reloadData]; } /** 安全区视图发生变化 */ -(void)viewSafeAreaInsetsDidChange{ _scrollView.frame = self.view.safeAreaLayoutGuide.layoutFrame; [super viewSafeAreaInsetsDidChange]; } /** didReceiveMemoryWarning */ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } #pragma mark - 回调函数 /** * 查询正常数据 * * @param sender <#sender description#> */ - (void)onLoadFinish:(ASIDownManager *)sender { NSDictionary *dic =[[NSDictionary alloc] init]; dic = [sender.mWebStr JSONValue]; [self Cancel]; // 服务器返回数据是否正确 if (dic && [dic isKindOfClass:[NSDictionary class]]) { // 服务器返回数据状态值 int iStatus = [[dic objectForKey:@"Status"] intValue]; // 服务器返回数据消息 NSString *message=[dic objectForKey:@"Message"]; // 服务器返回数据状态值正确 if (iStatus == 0) { NSArray * approvArr=[dic objectForKey:@"Result"]; if(approvArr!=nil) { if(approvArr ==nil || approvArr.count==0) { [self showAlertViewText:@"未找到匹配结果"]; } else { for (int i = 0; i < approvArr.count; i++) { NSDictionary *dicValue = approvArr[i]; noValue.text = [dicValue objectForKey:@"CheckNo"]; onlyCode.text = [dicValue objectForKey:@"OnlyCode"]; gradeName.text = [dicValue objectForKey:@"GradeName"]; specification.text = [dicValue objectForKey:@"Specification"]; colorNumber.text = [dicValue objectForKey:@"ColorNumber"]; wareHouseName.text = [dicValue objectForKey:@"WarehouseName"]; positionNumber.text = [dicValue objectForKey:@"PositionNumber"]; goodKindName.text = [dicValue objectForKey:@"KindName"]; brandName.text = [dicValue objectForKey:@"BrandName"]; serialName.text = [dicValue objectForKey:@"SeriesName"]; varietyName.text = [dicValue objectForKey:@"VarietyName"]; quantity.text = [[dicValue objectForKey:@"InventoryQuantity"]stringValue] ; stockingQuantity.text = [[dicValue objectForKey:@"CheckQuantity"]stringValue]; personName.text = [dicValue objectForKey:@"StaffName"]; reason.text = [dicValue objectForKey:@"ShortageReasonName"]; usertime.text = [dicValue objectForKey:@"CreateTime"]; username.text = [dicValue objectForKey:@"UserName"]; } } } } // 服务器返回数据状态值异常 else if(iStatus==ActionResultStatusAuthError ||iStatus==ActionResultStatusNoLogin ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){ [self showReLoginDialog:message]; } else { [self showAlertViewText:message]; } } } /** * 异常数据 * * @param sender sender description */ - (void)onLoadFail:(ASIDownManager *)sender { [self Cancel]; [self showAlertViewText:@"加载失败"]; } #pragma mark - 私有函数 /** 初始化ui */ - (void)initUI { self.view.backgroundColor = LineBackgroundColor; CGFloat heightRow = 30; CGFloat lblx = 10; CGFloat lbly = 3; CGFloat lblwidth = 70; CGFloat lblheight = 25; CGFloat valuex = 80; CGFloat valuey = 3; CGFloat valueheight = 25; _scrollView=[UIScrollView new]; _scrollView.frame=self.view.bounds; [self.view addSubview:_scrollView]; UIView *vTitle = [UIView new]; [_scrollView addSubview:vTitle]; vTitle.backgroundColor = [UIColor whiteColor]; //盘点单号================== UIView *vno = [UIView new]; vno.frame=CGRectMake(0, CGRectGetMaxY(vTitle.frame), Screen_Width, heightRow); [vTitle addSubview:vno]; UILabel *lblno=[UILabel new]; lblno.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblno.text=@"盘点单号:"; lblno.textColor = [UIColor blackColor]; lblno.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vno addSubview:lblno]; noValue = [UILabel new]; noValue.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); noValue.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vno addSubview:noValue]; //唯一编码================== UIView *vonlyCode = [UIView new]; vonlyCode.frame=CGRectMake(0, CGRectGetMaxY(vno.frame), Screen_Width, heightRow); [vTitle addSubview:vonlyCode]; UILabel *lblonlyCode=[UILabel new]; lblonlyCode.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblonlyCode.text=@"唯一编码:"; lblonlyCode.textColor = [UIColor blackColor]; lblonlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vonlyCode addSubview:lblonlyCode]; onlyCode = [UILabel new]; onlyCode.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); onlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vonlyCode addSubview:onlyCode]; //================== UIView *vgradeName = [UIView new]; vgradeName.frame=CGRectMake(0, CGRectGetMaxY(vonlyCode.frame), Screen_Width, heightRow); [vTitle addSubview:vgradeName]; UILabel *lblgradeName=[UILabel new]; lblgradeName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblgradeName.text=@"商品等级:"; lblgradeName.textColor = [UIColor blackColor]; lblgradeName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vgradeName addSubview:lblgradeName]; gradeName = [UILabel new]; gradeName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); gradeName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vgradeName addSubview:gradeName]; //规格================== UIView *vspecification = [UIView new]; vspecification.frame=CGRectMake(0, CGRectGetMaxY(vgradeName.frame), Screen_Width, heightRow); [vTitle addSubview:vspecification]; UILabel *lblspecification=[UILabel new]; lblspecification.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblspecification.text=@"规 格:"; lblspecification.textColor = [UIColor blackColor]; lblspecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vspecification addSubview:lblspecification]; specification = [UILabel new]; specification.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); specification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vspecification addSubview:specification]; //色号================== UIView *vcolorNumber = [UIView new]; vcolorNumber.frame=CGRectMake(0, CGRectGetMaxY(vspecification.frame), Screen_Width, heightRow); [vTitle addSubview:vcolorNumber]; UILabel *lblcolorNumber=[UILabel new]; lblcolorNumber.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblcolorNumber.text=@"色 号:"; lblcolorNumber.textColor = [UIColor blackColor]; lblcolorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vcolorNumber addSubview:lblcolorNumber]; colorNumber = [UILabel new]; colorNumber.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); colorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vcolorNumber addSubview:colorNumber]; //================== UIView *vwareHouseName = [UIView new]; vwareHouseName.frame=CGRectMake(0, CGRectGetMaxY(vcolorNumber.frame), Screen_Width, heightRow); [vTitle addSubview:vwareHouseName]; UILabel *lblwareHouseName=[UILabel new]; lblwareHouseName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblwareHouseName.text=@"库 区:"; lblwareHouseName.textColor = [UIColor blackColor]; lblwareHouseName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vwareHouseName addSubview:lblwareHouseName]; wareHouseName = [UILabel new]; wareHouseName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); wareHouseName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vwareHouseName addSubview:wareHouseName]; //================== UIView *vpositionNumber = [UIView new]; vpositionNumber.frame=CGRectMake(0, CGRectGetMaxY(vwareHouseName.frame), Screen_Width, heightRow); [vTitle addSubview:vpositionNumber]; UILabel *lblpositionNumber=[UILabel new]; lblpositionNumber.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblpositionNumber.text=@"仓 位 号:"; lblpositionNumber.textColor = [UIColor blackColor]; lblpositionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vpositionNumber addSubview:lblpositionNumber]; positionNumber = [UILabel new]; positionNumber.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); positionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vpositionNumber addSubview:positionNumber]; //================== UIView *vgoodKindName = [UIView new]; vgoodKindName.frame=CGRectMake(0, CGRectGetMaxY(vpositionNumber.frame), Screen_Width, heightRow); [vTitle addSubview:vgoodKindName]; UILabel *lblgoodKindName=[UILabel new]; lblgoodKindName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblgoodKindName.text=@"商品种类:"; lblgoodKindName.textColor = [UIColor blackColor]; lblgoodKindName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vgoodKindName addSubview:lblgoodKindName]; goodKindName = [UILabel new]; goodKindName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); goodKindName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vgoodKindName addSubview:goodKindName]; // 品牌================== UIView *vbrandName = [UIView new]; vbrandName.frame=CGRectMake(0, CGRectGetMaxY(vgoodKindName.frame), Screen_Width, heightRow); [vTitle addSubview:vbrandName]; UILabel *lblbrandName=[UILabel new]; lblbrandName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblbrandName.text=@"商品品牌:"; lblbrandName.textColor = [UIColor blackColor]; lblbrandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vbrandName addSubview:lblbrandName]; brandName = [UILabel new]; brandName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); brandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vbrandName addSubview:brandName]; // 系列================== UIView *vserialName = [UIView new]; vserialName.frame=CGRectMake(0, CGRectGetMaxY(vbrandName.frame), Screen_Width, heightRow); [vTitle addSubview:vserialName]; UILabel *lblserialName=[UILabel new]; lblserialName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblserialName.text=@"商品系列:"; lblserialName.textColor = [UIColor blackColor]; lblserialName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vserialName addSubview:lblserialName]; serialName = [UILabel new]; serialName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); serialName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vserialName addSubview:serialName]; // ================== UIView *vvarietyName = [UIView new]; vvarietyName.frame=CGRectMake(0, CGRectGetMaxY(vserialName.frame), Screen_Width, heightRow); [vTitle addSubview:vvarietyName]; UILabel *lblvarietyName=[UILabel new]; lblvarietyName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblvarietyName.text=@"商品品类:"; lblvarietyName.textColor = [UIColor blackColor]; lblvarietyName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vvarietyName addSubview:lblvarietyName]; varietyName = [UILabel new]; varietyName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); varietyName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vvarietyName addSubview:varietyName]; //================== UIView *vQuantity = [UIView new]; vQuantity.frame=CGRectMake(0, CGRectGetMaxY(vvarietyName.frame), Screen_Width, heightRow); [vTitle addSubview:vQuantity]; UILabel *lblQuantity=[UILabel new]; lblQuantity.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblQuantity.text=@"库存数量:"; lblQuantity.textColor = [UIColor blackColor]; lblQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vQuantity addSubview:lblQuantity]; quantity = [UILabel new]; quantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); quantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vQuantity addSubview:quantity]; //================== UIView *vstockingQuantity = [UIView new]; vstockingQuantity.frame=CGRectMake(0, CGRectGetMaxY(vQuantity.frame), Screen_Width, heightRow); [vTitle addSubview:vstockingQuantity]; UILabel *lblstockingQuantity=[UILabel new]; lblstockingQuantity.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblstockingQuantity.text=@"盘点数量:"; lblstockingQuantity.textColor = [UIColor blackColor]; lblstockingQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vstockingQuantity addSubview:lblstockingQuantity]; stockingQuantity = [UILabel new]; stockingQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); stockingQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vstockingQuantity addSubview:stockingQuantity]; //================== UIView *vpersonName = [UIView new]; vpersonName.frame=CGRectMake(0, CGRectGetMaxY(vstockingQuantity.frame), Screen_Width, heightRow); [vTitle addSubview:vpersonName]; UILabel *lblpersonName=[UILabel new]; lblpersonName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblpersonName.text=@"责 任 人:"; lblpersonName.textColor = [UIColor blackColor]; lblpersonName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vpersonName addSubview:lblpersonName]; personName = [UILabel new]; personName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); personName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vpersonName addSubview:personName]; //================== UIView *vreason = [UIView new]; vreason.frame=CGRectMake(0, CGRectGetMaxY(vpersonName.frame), Screen_Width, heightRow); [vTitle addSubview:vreason]; UILabel *lblreason=[UILabel new]; lblreason.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblreason.text=@"盘亏原因:"; lblreason.textColor = [UIColor blackColor]; lblreason.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vreason addSubview:lblreason]; reason = [UILabel new]; reason.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); reason.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vreason addSubview:reason]; //================== UIView *vusertime = [UIView new]; vusertime.frame=CGRectMake(0, CGRectGetMaxY(vreason.frame), Screen_Width, heightRow); [vTitle addSubview:vusertime]; UILabel *lblusertime=[UILabel new]; lblusertime.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblusertime.text=@"盘点时间:"; lblusertime.textColor = [UIColor blackColor]; lblusertime.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vusertime addSubview:lblusertime]; usertime = [UILabel new]; usertime.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); usertime.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vusertime addSubview:usertime]; //================== UIView *vusername = [UIView new]; vusername.frame=CGRectMake(0, CGRectGetMaxY(vusertime.frame), Screen_Width, heightRow); [vTitle addSubview:vusername]; UILabel *lblusername=[UILabel new]; lblusername.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblusername.text=@"盘 点 人:"; lblusername.textColor = [UIColor blackColor]; lblusername.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vusername addSubview:lblusername]; username = [UILabel new]; username.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); username.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vusername addSubview:username]; vTitle.frame=CGRectMake(10, 10, Screen_Width-20, CGRectGetMaxY(vusername.frame) ); vTitle.layer.cornerRadius = CornerRadius; _scrollView.contentSize = CGSizeMake(self.view.frame.size.width, CGRectGetMaxY(vTitle.frame)+rectStatusHeight+rectNavHeight); } /** 加载数据 */ -(void)reloadData { [self startLoading]; NSString *urlStr = ServerURL; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetInventoryCheckDataIphone" 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:_stockingID forKey:@"DetailID"]; _downManager = [[ASIDownManager alloc] init]; _downManager.delegate = self; _downManager.OnImageDown = @selector(onLoadFinish:); _downManager.OnImageFail = @selector(onLoadFail:); [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } /** * 隐藏进度条 */ - (void)Cancel { [self stopLoading]; } /** 导航栏 */ - (void)loadNavStyle { //返回 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; } /** 返回 */ - (void)GoBack { [self.navigationController popViewControllerAnimated:YES]; } @end