| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- //
- // 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
|