| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- //
- // NewOtherOutStorageGoodsDetailVC.m
- // IBOSSmini
- //
- // Created by guan hong hou on 2018/4/28.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "NewOtherOutStorageGoodsDetailVC.h"
- @interface NewOtherOutStorageGoodsDetailVC ()
- @end
- @implementation NewOtherOutStorageGoodsDetailVC
- #pragma mark 公共函数
- /**
- 视图加载完成函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self initUI];
- [self initSlideSlip];
- _dataList=[[NSMutableArray alloc]init];
- [self registerKeybordNotification];
- }
- /**
- 安全区变化函数
- */
- -(void)viewSafeAreaInsetsDidChange{
- _vTableView.frame=CGRectMake(0, CGRectGetMaxY(_topSeparatorView.frame),self.view.frame.size.width,self.view.safeAreaLayoutGuide.layoutFrame.size.height-CGRectGetMaxY(_topSeparatorView.frame));
-
- [super viewSafeAreaInsetsDidChange];
- }
- /**
- 内存警告函数
- */
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-
- }
- #pragma mark 委托函数
- -(void)showSelectedGoods:(NSMutableArray*)checkedGoodsList{
-
- [_dataList addObjectsFromArray:checkedGoodsList];
-
- _vTableView.dataSource=self;
- _vTableView.delegate=self;
- [_vTableView reloadData];
-
- }
- -(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) {
- [ _dataList removeObjectAtIndex:position];
- [ _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];
- }
- #pragma mark - 委托回调函数
- #pragma mark - tableView回调
- /**
- 单元格cell个数
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_dataList 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 242;
-
- }
- /**
- 点击单元格事件
- @param tableView tableView description
- @param indexPath indexPath description
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- self.hidesBottomBarWhenPushed=YES;
- OtherOutStorageInventoryDetailVC *detailVc=[[OtherOutStorageInventoryDetailVC alloc] init];
- InventoryModel *otherOutStorageDetailModel= [_dataList objectAtIndex:indexPath.row];
- detailVc.goodsDetailModel= otherOutStorageDetailModel;
- [self.nav pushViewController:detailVc animated:YES];
-
- }
- /**
- 扫描回调函数
- @param code <#code description#>
- */
- -(void)reloadDataWithOnlyCode:(NSString *)code
- {
- _onlyCode=code;
- if((_goodsCode==nil||[_goodsCode isEqualToString:@""])&&(_onlyCode==nil||[_onlyCode isEqualToString:@""])){
- [self showAlertViewText:@"商品编码或唯一编码至少输入一个"];
- return;
- }
- NewOtherOutStorageGoodsSearchVC *goodsSearchVc=[[NewOtherOutStorageGoodsSearchVC alloc]init];
-
- goodsSearchVc.onlyCode=_onlyCode;
- _isfilterQuantityEqZero=YES;
- goodsSearchVc.goodsDetailList=_dataList;
- goodsSearchVc.isfilterQuantityEqZero=_isfilterQuantityEqZero;
- goodsSearchVc.goodsDelegate=self;
- [self.nav pushViewController:goodsSearchVc animated:YES];
-
- }
- /**
- 隐藏键盘
-
- @param scrollView <#scrollView description#>
- */
- -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
- {
- [self.view endEditing:YES];
- }
- /**
- 每个单元格cell
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"OtherOutStorageGoodsListCell";
- NewOtherOutStorageGoodsListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
- if (!cell) {
- cell=[[NewOtherOutStorageGoodsListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
-
- InventoryModel *goodsListModel= [_dataList objectAtIndex:indexPath.row];
- cell.outStorageDelegate = self;
- cell.index=indexPath.row;
- [cell setOtherOutStorageGoodsListModel:goodsListModel];
-
- return cell;
- }
- /**
- 刷新tableview
- */
- -(void)refreshTable{
- [_vTableView reloadData];
- }
- #pragma mark 私有函数
- /**
- 抽屉初始化
- */
- - (void)initSlideSlip{
- // 抽屉对象
- __weak typeof(self) weakself=self;
- self.filterController = [[SideSlipFilterController alloc]
- initWithSponsor:self
- resetBlock:^(NSArray *dataList) {
- for (SideSlipModel *model in dataList) {
-
- model.selectedItemList = nil;
- model.customDict = nil;
- }
- } commitBlock:^(NSArray *dataList) {
- [self.view endEditing:YES];
- // 查询条件
- SideSlipModel *serviceRegionModel = dataList[0];
- InventorySearchModel *m = [serviceRegionModel.customDict objectForKey:OTHER_OUT_STORAGE_SEARCH_RANGE_MODEL];
- _goodsCode = m.goodsCode;
- _goodsName=m.goodsName;
- _onlyCode=m.onlyCode;
- _brandId=m.brandId;
- _warehouseId=m.warehouseId;
- _isfilterQuantityEqZero=m.isfilterQuantityEqZero;
- if((_goodsCode==nil||[_goodsCode isEqualToString:@""])&&(_onlyCode==nil||[_onlyCode isEqualToString:@""])){
- [self showAlertViewText:@"商品编码或唯一编码至少输入一个"];
- return;
- }
- NewOtherOutStorageGoodsSearchVC *goodsSearchVc=[[NewOtherOutStorageGoodsSearchVC alloc]init];
- goodsSearchVc.goodsCode=_goodsCode;
- goodsSearchVc.goodsName=_goodsName;
- goodsSearchVc.onlyCode=_onlyCode;
- goodsSearchVc.warehouseId=_warehouseId;
- goodsSearchVc.goodsDetailList=_dataList; goodsSearchVc.isfilterQuantityEqZero=_isfilterQuantityEqZero;
- goodsSearchVc.brandId=_brandId;
- goodsSearchVc.goodsDelegate=self;
- [self.nav pushViewController:goodsSearchVc animated:YES];
-
- [weakself.filterController dismiss];
-
-
-
- }];
- _filterController.animationDuration = AnimationDuration;
- _filterController.hasHeadView = YES;
- _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
- _filterController.dataList = [self packageDataList];
- }
- /**
- 打开抽屉
- */
- -(void)dataSearch{
- [_filterController showPagerView:self.nav];
- }
- /**
- 注册键盘通知
- */
- - (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)-CGRectGetMaxY(_topSeparatorView.frame);
-
- _vTableView.frame = rect;
-
- }
-
- [UIView commitAnimations];
-
- }
- /**
- 抽屉 数据源
- @return <#return value description#>
- */
- - (NSArray *)packageDataList {
- NSMutableArray *dataArray = [NSMutableArray array];
- SideSlipModel *model = [[SideSlipModel alloc] init];
- model.containerCellClass = @"NewOtherOutStorageGoodsDetailSearchCell";
- model.regionTitle = @"查询条件";
-
- [dataArray addObject:model];
- return [dataArray mutableCopy];
- }
- /**
- 扫描点击事件
- */
- -(void)btnScanCilck{
- ScanViewController *scanVc=[[ScanViewController alloc]init];
- scanVc.rootVC=self;
- [self.nav pushViewController:scanVc animated:YES];
- }
- /**
- 初始化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];
-
- CGFloat height = 40;
- _searchView = [[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(topSeparatorView.frame), Screen_Width, 50)];
- _searchView.backgroundColor = [UIColor whiteColor];
- UIButton *btnSearch = [UIButton buttonWithType:UIButtonTypeCustom];
- btnSearch.frame = CGRectMake(5, 5, Screen_Width-45, height);
- btnSearch.layer.cornerRadius = 6.0f;
- [btnSearch setTitle:@"搜索" forState:UIControlStateNormal];
- [btnSearch setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- btnSearch.titleLabel.textAlignment = NSTextAlignmentCenter;
- btnSearch.titleLabel.font = [UIFont systemFontOfSize:LabelAndTextFontOfSize];
- btnSearch.backgroundColor = LineBackgroundColor;
- [btnSearch addTarget:self action:@selector(dataSearch) forControlEvents:UIControlEventTouchUpInside];
- [_searchView addSubview:btnSearch];
-
- UIButton *scan=[UIButton buttonWithType:UIButtonTypeCustom];
- scan.frame=CGRectMake(_searchView.frame.size.width-35,8,35,35);
- scan.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
- [scan setImage:[UIImage imageNamed:@"scan"] forState:UIControlStateNormal];
- [_searchView addSubview:scan];
- [scan addTarget:self action:@selector(btnScanCilck) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:_searchView];
-
- _topSeparatorView = [UIView new];
- _topSeparatorView.frame=CGRectMake(0, CGRectGetMaxY(_searchView.frame), Screen_Width, 10);
- _topSeparatorView.backgroundColor = LineBackgroundColor;
- [self.view addSubview:_topSeparatorView];
-
-
- _vTableView = [[UITableView alloc]
- initWithFrame:CGRectMake(0,
- CGRectGetMaxY(_topSeparatorView.frame),
- self.view.frame.size.width,
- Screen_Height-CGRectGetMaxY(_topSeparatorView.frame))];
- _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _vTableView.dataSource=self;
- _vTableView.delegate=self;
- [self.view addSubview:_vTableView];
-
-
- }
- @end
|