// // SalesOrderOptionCombinationDetailVC.m // IBOSS // // Created by 关宏厚 on 2020/9/14. // Copyright © 2020 elongtian. All rights reserved. // #import "SalesOrderOptionCombinationDetailVC.h" @interface SalesOrderOptionCombinationDetailVC () @end @implementation SalesOrderOptionCombinationDetailVC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; [self initUI]; } /** 安全区视图发生变化 */ -(void)viewSafeAreaInsetsDidChange{ _vTableView.frame = CGRectMake(0,0,Screen_Width, self.view.superview.frame.size.height-50); [super viewSafeAreaInsetsDidChange]; } -(void)initUI { _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height-rectNavHeight-rectStatusHeight - 100)]; _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone; _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight; _vTableView.backgroundColor = [UIColor whiteColor]; _vTableView.delegate = self; _vTableView.dataSource=self; [self.view addSubview:_vTableView]; } -(void)loadData:(NSMutableArray*)combinationGoodsList promotionGoodsList:(NSMutableArray*)promotionGoodsList { _promotionGoodsDetailList=promotionGoodsList; if(combinationGoodsList!=nil&&combinationGoodsList.count>0) { _combinationGoodsDetailList=combinationGoodsList; [_vTableView reloadData]; } } -(void)btnGoodsCombinationCheckPressed:(OptionCombinationDetailCell*)cell { NSInteger pos= cell.position; InventoryListModel *goodsModel= [_combinationGoodsDetailList objectAtIndex:pos]; goodsModel.isCheckedStatus=!goodsModel.isCheckedStatus; if( goodsModel.isCheckedStatus) { for(int i=0;i<_combinationGoodsDetailList.count;i++) { InventoryListModel *goodsDetailModel=[_combinationGoodsDetailList objectAtIndex:i]; if(pos==i) { [goodsDetailModel setIsCheckedStatus:YES]; } else{ [goodsDetailModel setIsCheckedStatus:NO]; } } [_vTableView reloadData]; InventoryListModel *currentPromotionGoods; int currentPosition=0; if(_promotionGoodsDetailList!=nil&&_promotionGoodsDetailList.count>0) { for(int i=0;i<_promotionGoodsDetailList.count;i++) { InventoryListModel *promotionGoodsModel=[_promotionGoodsDetailList objectAtIndex:i]; if (promotionGoodsModel.isChecked) { currentPromotionGoods=promotionGoodsModel; currentPosition=i; break; } } } if(currentPromotionGoods!=nil) { [currentPromotionGoods setPromotionGoodsId:goodsModel.promotionGoodsId]; [currentPromotionGoods setPromotionDetailId:goodsModel.promotionDetailId]; [currentPromotionGoods setCombinationId:goodsModel.combinationId]; [currentPromotionGoods setCodeId:goodsModel.codeId]; [currentPromotionGoods setCode:goodsModel.code]; [currentPromotionGoods setGoodsName:goodsModel.goodsName]; [currentPromotionGoods setGoodsCateName:goodsModel.goodsCateName]; [currentPromotionGoods setOnlyCode:goodsModel.onlyCode]; [currentPromotionGoods setSpecification:goodsModel.specification]; [currentPromotionGoods setBrandId:goodsModel.brandId]; [currentPromotionGoods setBrandName:goodsModel.brandName]; [currentPromotionGoods setGradeId:goodsModel.gradeId]; [currentPromotionGoods setGradeName:goodsModel.gradeName]; [currentPromotionGoods setKindId:goodsModel.kindId]; [currentPromotionGoods setKindName:goodsModel.kindName]; [currentPromotionGoods setSeriesId:goodsModel.seriesId]; [currentPromotionGoods setSeriesName:goodsModel.seriesName]; [currentPromotionGoods setVarietyId:goodsModel.varietyId]; [currentPromotionGoods setVarietyName:goodsModel.varietyName]; [currentPromotionGoods setUnitId:goodsModel.unitId]; [currentPromotionGoods setUnitName:goodsModel.unitName]; [currentPromotionGoods setWarehouseId:goodsModel.warehouseId]; [currentPromotionGoods setWareHouseName:goodsModel.wareHouseName]; [currentPromotionGoods setPositionNumber:goodsModel.positionNumber]; [currentPromotionGoods setSalesPrice:goodsModel.salesPrice]; [currentPromotionGoods setGiftFlag:goodsModel.giftFlag]; [currentPromotionGoods setColorNumber:goodsModel.colorNumber]; [currentPromotionGoods setAcreage:goodsModel.acreage]; [currentPromotionGoods setWeight:goodsModel.weight]; [currentPromotionGoods setVolume:goodsModel.volume]; [currentPromotionGoods setDecimalPlaces:goodsModel.decimalPlaces]; [currentPromotionGoods setCirculateType:goodsModel.circulateType]; [currentPromotionGoods setPackage:goodsModel.package]; [currentPromotionGoods setMarkedPrice:goodsModel.markedPrice]; [currentPromotionGoods setInventoryQuantity:goodsModel.inventoryQuantity]; [currentPromotionGoods setCanSaleQuantity:goodsModel.canSaleQuantity]; [currentPromotionGoods setAcreageFlag:goodsModel.acreageFlag]; [currentPromotionGoods setInventoryId:goodsModel.inventoryId]; [currentPromotionGoods setGoodsQuantityHide:goodsModel.goodsQuantityHide]; [currentPromotionGoods setMinimumPurchaseQuantity:goodsModel.minimumPurchaseQuantity]; NSString *combinationQuantity=goodsModel.combinationQuantity; NSString *goodsNumberHide=goodsModel.goodsQuantityHide; NSString *decimalPlaces=goodsModel.decimalPlaces; if([combinationQuantity doubleValue]>0) { double salesQuantity=[combinationQuantity doubleValue]*[goodsNumberHide doubleValue]; NSString *decimalPlacesStr=[NSString stringWithFormat:@"%@%@%@",@"%.",decimalPlaces,@"f"]; NSString *salesQuantityStr=[NSString stringWithFormat:decimalPlacesStr,salesQuantity]; [currentPromotionGoods setSalesQuantity:salesQuantityStr]; } [_promotionGoodsDetailList replaceObjectAtIndex:currentPosition withObject:currentPromotionGoods]; __weak typeof(self) weakself=self; if ([weakself.goodsDelegate respondsToSelector:@selector(refreshPromotionGoodsData:)]){ [weakself.goodsDelegate refreshPromotionGoodsData:_promotionGoodsDetailList]; } } } } /** 高度 @return <#return value description#> */ - (NSMutableDictionary *)heights{ if (_heights == nil){ _heights = [NSMutableDictionary dictionary]; } return _heights; } /** 单元格cell个数 @param tableView <#tableView description#> @param section <#section description#> @return <#return value description#> */ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [_combinationGoodsDetailList count]; } /** <#Description#> @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 [self.heights[@(indexPath.row)] floatValue]; } /** 预防高度 @param tableView <#tableView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 280; } /** 每个单元格cell @param tableView <#tableView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"CombinationGoodsDetailListCell"; OptionCombinationDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ]; if (!cell) { cell=[[OptionCombinationDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.selectionStyle=UITableViewCellSelectionStyleNone; } else //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免 { while ([cell.contentView.subviews lastObject] != nil) { [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview]; } } InventoryListModel *combinationGoodsModel= [_combinationGoodsDetailList objectAtIndex:indexPath.row]; cell.delegate=self; cell.position=indexPath.row; [cell setCombinationGoodsDetailCell:combinationGoodsModel]; BOOL checked = combinationGoodsModel.isCheckedStatus; [cell setCheckBackground:checked]; self.heights[@(indexPath.row)] = @(cell.height); return cell; } @end