| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- //
- // NewSalesOutStorageGoodsDetailVC.m
- // IBOSSmini
- //
- // Created by guan hong hou on 2018/4/12.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "NewSalesOutStorageGoodsDetailVC.h"
- #import "NewSalesOutStorageListVC.h"
- @interface NewSalesOutStorageGoodsDetailVC (){
-
- }
- @end
- @implementation NewSalesOutStorageGoodsDetailVC
- #pragma mark 公共函数
- /**
- 视图加载完成函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initUI];
- [self registerKeybordNotification];
-
- }
- /**
- 安全区变化函数
- */
- -(void)viewSafeAreaInsetsDidChange{
- _vTableView.frame=CGRectMake(0,10,self.view.frame.size.width,self.view.safeAreaLayoutGuide.layoutFrame.size.height-10);
- [super viewSafeAreaInsetsDidChange];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-
- }
- #pragma mark 委托函数
- /**
- 单元格cell个数
-
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_goodsList count];
- }
- /**
- tableview的分区数
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- /**
- 高度
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 260;
-
- }
- /**
- 每个单元格cell
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSString *cellIdentifier = @"GoodsDetailListCell";
- NewSalesOutStorageGoodsListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
- if (!cell) {
- cell=[[NewSalesOutStorageGoodsListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
-
- SalesOutStorageSalesSlipGoodsListModel *goodsListModel= [_goodsList objectAtIndex:indexPath.row];
- [cell setNewSalesOutStorageGoodsDetailListModel:goodsListModel];
- cell.goodsDelegate=self;
- cell.index=indexPath.row;
- return cell;
- }
- /**
- 删除商品
- @param position <#position description#>
- */
- -(void)deleteGoods:(NSInteger)position{
-
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"确定要删除吗?" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-
- }];
- UIAlertAction *otherAction = [UIAlertAction actionWithTitle:@"确定"
- style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- [ _goodsList removeObjectAtIndex:position];
- if(_goodsList.count==0){
- ((NewSalesOutStorageListVC*)_salesSlipListVc).lblOutStorageNo.text=@"";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).lblCustomerCode.text=@"";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).lblCustomerName.text=@"";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).lblTelephone.text=@"";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).lblDriver.text=@"请选择运输司机";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).driverId=@"";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).driverName=@"";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).lblDocker.text=@"请选择装卸工人";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).dockerId=@"";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).dockerName=@"";
- ((NewSalesOutStorageListVC*)_salesSlipListVc).lblCustomerAddress.text=@"";
-
- ((NewSalesOutStorageListVC*)_salesSlipListVc).txtRemarks.text=@"";
- }
- [ _vTableView reloadData];
- }];
- UIColor *cancelColor=[UIColor blackColor];
- UIColor *sureColor=[UIColor redColor];
- [cancelAction setValue:cancelColor forKey:@"titleTextColor"];
- [otherAction setValue:sureColor forKey:@"titleTextColor"];
- [alertController addAction:cancelAction];
- [alertController addAction:otherAction];
-
- [self presentViewController:alertController animated:YES completion:nil];
- }
- /**
- 跳转到色号函数
- @param position <#position description#>
- */
- -(void)goColorNumber:(NSInteger)position{
- UpdateColorNumberVC *colorNumberVc=[[UpdateColorNumberVC alloc]init];
- SalesOutStorageSalesSlipGoodsListModel *goodsListModel= [_goodsList objectAtIndex:position];
- colorNumberVc.goodsListModel=goodsListModel;
- colorNumberVc.index=position;
- colorNumberVc.colorNumberDelegate=self;
- [self.nav pushViewController:colorNumberVc animated:YES];
-
- }
- /**
- 色号更新回调函数
- @param position <#position description#>
- @param colorNumber <#colorNumber description#>
- */
- -(void)updateColorNumber:(NSInteger)position colorNumber:(ColorNumberModel *)colorNumber{
- SalesOutStorageSalesSlipGoodsListModel *goodsListModel= [_goodsList objectAtIndex:position];
- goodsListModel.inventoryId=colorNumber.inventoryId;
- goodsListModel.warehouseId=colorNumber.warehouseId;
- goodsListModel.warehouseName=colorNumber.warehouseName;
- goodsListModel.positionNumber=colorNumber.positionNumber;
- goodsListModel.colorNumber=colorNumber.colorNumber;
- [_vTableView reloadData];
- }
- /**
- 隐藏键盘
- @param scrollView <#scrollView description#>
- */
- -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
- {
- [self.view endEditing:YES];
- }
- #pragma mark 私有函数
- /**
- 初始化UI
- */
- -(void)initUI{
- [self.view setBackgroundColor:[UIColor whiteColor]];
- UIView *topSeparatorView = [UIView new];
- topSeparatorView.frame=CGRectMake(0,3, Screen_Width, 10);
- topSeparatorView.backgroundColor = LineBackgroundColor;
- [self.view addSubview:topSeparatorView];
- _vTableView = [[UITableView alloc]
- initWithFrame:CGRectMake(0,
- 10,
- self.view.frame.size.width,
- self.view.frame.size.height-10)];
-
- _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _vTableView.dataSource=self;
- _vTableView.delegate=self;
- [self.view addSubview:_vTableView];
-
-
- }
- /**
- 注册键盘通知
- */
- - (void)registerKeybordNotification {
-
- NSNotificationCenter *notification = [NSNotificationCenter defaultCenter];
-
- [notification removeObserver:self];
-
- [notification addObserver:self
-
- selector:@selector(showKeyboard:)
-
- name:UIKeyboardWillShowNotification
-
- object:nil];
-
- [notification addObserver:self
-
- selector:@selector(hideKeyboard:)
-
- name:UIKeyboardWillHideNotification
-
- object:nil];
-
- #ifdef __IPHONE_5_0
-
- // 5.0以上系统中文键盘高度与4.0系统不一样
-
- float version = [[[UIDevice currentDevice] systemVersion] floatValue];
-
- if (version >= 5.0) {
-
- [notification addObserver:self
-
- selector:@selector(showKeyboard:)
-
- name:UIKeyboardWillChangeFrameNotification
-
- object:nil];
-
- }
-
- #endif
-
- }
- /**
- 弹出键盘
- @param notification <#notification description#>
- */
- - (void)showKeyboard:(NSNotification *)notification {
-
- NSDictionary *userInfo = [notification userInfo];
-
- NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
-
- CGFloat keyboardHeight = CGRectGetHeight([aValue CGRectValue]);
- //50底部保存按钮 40为切换按钮
- CGFloat height = SCREENHEIGHT-rectStatusHeight-rectNavHeight-_vTableView.frame.origin.y - keyboardHeight-40-50;
-
-
- /* 使用动画效果,过度更加平滑 */
-
- [UIView beginAnimations:nil context:nil];
-
- [UIView setAnimationDuration:0.1];
-
-
- CGRect rect = _vTableView.frame;
-
- rect.size.height = height;
-
- _vTableView.frame = rect;
-
-
-
-
- [UIView commitAnimations];
-
- }
- /**
- 隐藏键盘
- @param notification <#notification description#>
- */
- - (void)hideKeyboard:(NSNotification *)notification {
-
- [UIView beginAnimations:nil context:nil];
-
- [UIView setAnimationDuration:0.1];
-
- {
- CGRect rect = _vTableView.frame;
-
- rect.size.height = CGRectGetHeight(self.view.frame)-10;
-
- _vTableView.frame = rect;
-
-
-
- }
-
- [UIView commitAnimations];
-
- }
- @end
|