| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578 |
- //
- // NewOtherInStorageGoodsDetailVC.m
- // IBOSSmini
- //
- // Created by guan hong hou on 2018/4/24.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "NewOtherInStorageGoodsDetailVC.h"
- @interface NewOtherInStorageGoodsDetailVC ()
- @end
- @implementation NewOtherInStorageGoodsDetailVC
- #pragma mark 公共函数
- /**
- 视图加载完成函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initUI];
- _dataList=[[NSMutableArray alloc]init];
- [self initSlideSlip];
- [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 委托函数
- /**
- 扫描回调函数
- @param code <#code description#>
- */
- -(void)reloadDataWithOnlyCode:(NSString *)code
- {
- _onlyCode=code;
- if((_goodsCode==nil||[_goodsCode isEqualToString:@""])&&(_onlyCode==nil||[_onlyCode isEqualToString:@""])){
- [self showAlertViewText:@"商品编码或唯一编码至少输入一个"];
- return;
- }
- NewOtherInStorageGoodsSearchVC *goodsSearchVc=[[NewOtherInStorageGoodsSearchVC alloc]init];
- goodsSearchVc.onlyCode=_onlyCode;
- goodsSearchVc.goodsDetailList=_dataList;
- goodsSearchVc.goodsDelegate=self;
- [self.nav pushViewController:goodsSearchVc animated:YES];
-
- }
- /**
- 单元格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 287;
-
- }
- /**
- 隐藏键盘
- @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 = @"OtherInStorageGoodsListCell";
- OtherInStorageGoodsListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
- if (!cell) {
- cell=[[OtherInStorageGoodsListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
-
- _goodsListModel= [_dataList objectAtIndex:indexPath.row];
- cell.inStorageDelegate = self;
- cell.index=indexPath.row;
- [cell setOtherInStorageGoodsModel:_goodsListModel];
-
- return cell;
- }
- /**
- 刷新tableview
- */
- -(void)refreshTable{
- [_vTableView reloadData];
- }
- /**
- 点击单元格事件
- @param tableView tableView description
- @param indexPath indexPath description
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [self.view endEditing:YES];
- self.hidesBottomBarWhenPushed=YES;
- OtherInStorageGoodsDetailVC *detailVc=[[OtherInStorageGoodsDetailVC alloc] init];
- OtherInStorageGoodsSearchListModel *salesInStorageDetailModel= [_dataList objectAtIndex:indexPath.row];
- detailVc.goodsDetailModel= salesInStorageDetailModel;
- [self.nav pushViewController:detailVc animated:YES];
-
- }
- /**
- 显示选中的商品列表
- @param checkedGoodsList <#checkedGoodsList description#>
- */
- -(void)showSelectedGoods:(NSMutableArray*)checkedGoodsList{
-
- [_dataList addObjectsFromArray:checkedGoodsList];
- _vTableView.dataSource=self;
- _vTableView.delegate=self;
- [_vTableView reloadData];
-
- }
- /**
- 库区回调函数
- @param model <#model description#>
- @param value <#value description#>
- */
- - (void) baseIDAndNameDoneDatas: (BaseIDAndNameModel *)model BaseIDAndName:(baseIdAndName) value{
- if(value==baseIdAndNameWare){
- _goodsListModel= [_dataList objectAtIndex:_position];
- _goodsListModel.warehouseId=model.warehouseId;
- _goodsListModel.warehouseName=model.name;
- _goodsListModel.warehouseCode=model.id;
- _goodsListModel.positionNumberName=@"";
- _goodsListModel.positionNumberId=@"";
- [_vTableView reloadData];
- _positionNumberList= [self filterPositionNumber: _goodsListModel.warehouseId positionNumberArray:_otherInStorageVc.positionNumberList];
- }
- }
- /**
- 产品等级和仓位号回调函数
- @param model <#model description#>
- @param cr <#cr description#>
- */
- - (void)customerReportTextDoneDatas:(CustomerReportTextInfoModel *)model CustomerReport:(CustomerReport)cr
- {
- if (model==nil) {
- return;
- }
-
- if(cr==ReportGrade){
- _goodsListModel= [_dataList objectAtIndex:_position];
- _goodsListModel.gradeId=model.idCode;
- _goodsListModel.gradeName=model.name;
-
- }
-
- if(cr==ReportPositionNumber){
- _goodsListModel= [_dataList objectAtIndex:_position];
- _goodsListModel.positionNumberId=model.idCode;
- _goodsListModel.positionNumberName=model.name;
- }
- [_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) {
- // 查询条件
- SideSlipModel *serviceRegionModel = dataList[0];
- OtherInStorageGoodsSearchModel *m = [serviceRegionModel.customDict objectForKey:In_STORAGE_SEARCH_RANGE_MODEL];
- _goodsCode = m.goodsCode;
- _goodsName=m.goodsName;
- _onlyCode=m.onlyCode;
- _brandId=m.brandId;
- _kindId=m.kindId;
- _kindCode=m.kindCode;
- _varietyId=m.varietyId;
- if((_goodsCode==nil||[_goodsCode isEqualToString:@""])&&(_onlyCode==nil||[_onlyCode isEqualToString:@""])){
- [self showAlertViewText:@"商品编码或唯一编码至少输入一个"];
- return;
- }
- NewOtherInStorageGoodsSearchVC *goodsSearchVc=[[NewOtherInStorageGoodsSearchVC alloc]init];
- goodsSearchVc.goodsCode=_goodsCode;
- goodsSearchVc.goodsName=_goodsName;
- goodsSearchVc.onlyCode=_onlyCode;
- goodsSearchVc.kindId=_kindId;
- goodsSearchVc.kindCode=_kindCode;
- goodsSearchVc.brandId=_brandId;
- goodsSearchVc.goodsDetailList=_dataList;
- goodsSearchVc.varietyId=_varietyId;
- 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];
- }
- /**
- 抽屉数据源
- @return <#return value description#>
- */
- - (NSArray *)packageDataList {
- NSMutableArray *dataArray = [NSMutableArray array];
- SideSlipModel *model = [[SideSlipModel alloc] init];
- model.containerCellClass = @"SalesInStorageGoodsSearchCell";
- model.regionTitle = @"查询条件";
-
- [dataArray addObject:model];
- return [dataArray mutableCopy];
- }
- /**
- 初始化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];
- [self.view addSubview:_searchView];
-
- 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];
-
- _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,
- self.view.frame.size.height-CGRectGetMaxY(_topSeparatorView.frame))];
-
- _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _vTableView.dataSource=self;
- _vTableView.delegate=self;
- [self.view addSubview:_vTableView];
-
-
- }
- /**
- 扫描点击事件
- */
- -(void)btnScanCilck{
- ScanViewController *scanVc=[[ScanViewController alloc]init];
- scanVc.rootVC=self;
- [self.nav pushViewController:scanVc animated:YES];
- }
- /**
- 跳转到产品等级页面
- @param pos <#pos description#>
- */
- -(void)goGrade:(NSInteger)pos{
- _position=pos;
- [self.view endEditing:YES];
- CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
- tc.delegate=self;
- tc.dataSourceCode=@"T_MST_Goods_Grade";
- tc.showDialogViewTag=ReportGrade;
- [self.nav pushViewController:tc animated:YES];
- }
- /**
- 跳转到库区页面
- @param pos <#pos description#>
- */
- -(void)goWareHouse:(NSInteger)pos{
- _position=pos;
- [self.view endEditing:YES];
- WareSearchViewController *tc=[[WareSearchViewController alloc ]init];
- tc.bDelegate = self;
- tc.jsonArr=_otherInStorageVc.warehouseList;
- tc.showDialogViewTag = baseIdAndNameWare;
- [self.nav pushViewController:tc animated:YES];
- }
- /**
- 跳转到仓位号页面
- @param pos <#pos description#>
- */
- -(void)goPositionNumber:(NSInteger)pos{
- _position=pos;
- [self.view endEditing:YES];
- _goodsListModel= [_dataList objectAtIndex:_position];
- NSString *warehouseId= _goodsListModel.warehouseId;
- if(warehouseId==nil||[warehouseId isEqualToString:@""]){
- [self showAlertViewText:@"请选择库区"];
- return;
- }
- if([warehouseId isEqualToString:@"0"]){
- [self showAlertViewText:@"请选择库区"];
- return;
- }
-
- if(_positionNumberList==nil||_positionNumberList.count==0){
- [self showAlertViewText:@"仓位号数据源不能为空"];
- return;
- }
-
- CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
- tc.delegate=self;
- tc.jsonArr=_positionNumberList;
- tc.showDialogViewTag=ReportPositionNumber;
- [self.nav pushViewController:tc animated:YES];
- }
- /**
- 过滤仓位号
- @param warehouseId <#warehouseId description#>
- @param positionNumberArray <#positionNumberArray description#>
- @return <#return value description#>
- */
- -(NSMutableArray*) filterPositionNumber:(NSString*)warehouseId positionNumberArray:(NSArray*)positionNumberArray{
- NSMutableArray *positionNumberFilterArray=[[NSMutableArray alloc]init];
- for(int i=0;i<positionNumberArray.count;i++){
- NSDictionary *dic=positionNumberArray[i];
- NSInteger warehouseIdValue= [[dic objectForKey:@"WarehouseID"]integerValue];
- if([warehouseId integerValue]==warehouseIdValue){
- [ positionNumberFilterArray addObject:dic];
- }
- }
- return positionNumberFilterArray;
- }
- /**
- 打开抽屉
- */
- -(void)dataSearch{
- [_filterController showPagerView:self.nav];
- }
- /**
- 删除商品
- @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) {
- [ _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];
- }
- /**
- 注册键盘通知
- */
- - (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];
-
- }
- @end
|