SalesOrderOptionCombinationDetailVC.m 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. //
  2. // SalesOrderOptionCombinationDetailVC.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/9/14.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "SalesOrderOptionCombinationDetailVC.h"
  9. @interface SalesOrderOptionCombinationDetailVC ()
  10. @end
  11. @implementation SalesOrderOptionCombinationDetailVC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. self.view.backgroundColor = [UIColor whiteColor];
  15. [self initUI];
  16. }
  17. /**
  18. 安全区视图发生变化
  19. */
  20. -(void)viewSafeAreaInsetsDidChange{
  21. _vTableView.frame = CGRectMake(0,0,Screen_Width, self.view.superview.frame.size.height-50);
  22. [super viewSafeAreaInsetsDidChange];
  23. }
  24. -(void)initUI
  25. {
  26. _vTableView = [[UITableView alloc]
  27. initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height-rectNavHeight-rectStatusHeight - 100)];
  28. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  29. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  30. _vTableView.backgroundColor = [UIColor whiteColor];
  31. _vTableView.delegate = self;
  32. _vTableView.dataSource=self;
  33. [self.view addSubview:_vTableView];
  34. }
  35. -(void)loadData:(NSMutableArray*)combinationGoodsList promotionGoodsList:(NSMutableArray*)promotionGoodsList
  36. {
  37. _promotionGoodsDetailList=promotionGoodsList;
  38. if(combinationGoodsList!=nil&&combinationGoodsList.count>0)
  39. {
  40. _combinationGoodsDetailList=combinationGoodsList;
  41. [_vTableView reloadData];
  42. }
  43. }
  44. -(void)btnGoodsCombinationCheckPressed:(OptionCombinationDetailCell*)cell
  45. {
  46. NSInteger pos= cell.position;
  47. InventoryListModel *goodsModel= [_combinationGoodsDetailList objectAtIndex:pos];
  48. goodsModel.isCheckedStatus=!goodsModel.isCheckedStatus;
  49. if( goodsModel.isCheckedStatus)
  50. {
  51. for(int i=0;i<_combinationGoodsDetailList.count;i++)
  52. {
  53. InventoryListModel *goodsDetailModel=[_combinationGoodsDetailList objectAtIndex:i];
  54. if(pos==i)
  55. {
  56. [goodsDetailModel setIsCheckedStatus:YES];
  57. }
  58. else{
  59. [goodsDetailModel setIsCheckedStatus:NO];
  60. }
  61. }
  62. [_vTableView reloadData];
  63. InventoryListModel *currentPromotionGoods;
  64. int currentPosition=0;
  65. if(_promotionGoodsDetailList!=nil&&_promotionGoodsDetailList.count>0)
  66. {
  67. for(int i=0;i<_promotionGoodsDetailList.count;i++)
  68. {
  69. InventoryListModel *promotionGoodsModel=[_promotionGoodsDetailList objectAtIndex:i];
  70. if (promotionGoodsModel.isChecked) {
  71. currentPromotionGoods=promotionGoodsModel;
  72. currentPosition=i;
  73. break;
  74. }
  75. }
  76. }
  77. if(currentPromotionGoods!=nil)
  78. {
  79. [currentPromotionGoods setPromotionGoodsId:goodsModel.promotionGoodsId];
  80. [currentPromotionGoods setPromotionDetailId:goodsModel.promotionDetailId];
  81. [currentPromotionGoods setCombinationId:goodsModel.combinationId];
  82. [currentPromotionGoods setCodeId:goodsModel.codeId];
  83. [currentPromotionGoods setCode:goodsModel.code];
  84. [currentPromotionGoods setGoodsName:goodsModel.goodsName];
  85. [currentPromotionGoods setGoodsCateName:goodsModel.goodsCateName];
  86. [currentPromotionGoods setOnlyCode:goodsModel.onlyCode];
  87. [currentPromotionGoods setSpecification:goodsModel.specification];
  88. [currentPromotionGoods setBrandId:goodsModel.brandId];
  89. [currentPromotionGoods setBrandName:goodsModel.brandName];
  90. [currentPromotionGoods setGradeId:goodsModel.gradeId];
  91. [currentPromotionGoods setGradeName:goodsModel.gradeName];
  92. [currentPromotionGoods setKindId:goodsModel.kindId];
  93. [currentPromotionGoods setKindName:goodsModel.kindName];
  94. [currentPromotionGoods setSeriesId:goodsModel.seriesId];
  95. [currentPromotionGoods setSeriesName:goodsModel.seriesName];
  96. [currentPromotionGoods setVarietyId:goodsModel.varietyId];
  97. [currentPromotionGoods setVarietyName:goodsModel.varietyName];
  98. [currentPromotionGoods setUnitId:goodsModel.unitId];
  99. [currentPromotionGoods setUnitName:goodsModel.unitName];
  100. [currentPromotionGoods setWarehouseId:goodsModel.warehouseId];
  101. [currentPromotionGoods setWareHouseName:goodsModel.wareHouseName];
  102. [currentPromotionGoods setPositionNumber:goodsModel.positionNumber];
  103. [currentPromotionGoods setSalesPrice:goodsModel.salesPrice];
  104. [currentPromotionGoods setGiftFlag:goodsModel.giftFlag];
  105. [currentPromotionGoods setColorNumber:goodsModel.colorNumber];
  106. [currentPromotionGoods setAcreage:goodsModel.acreage];
  107. [currentPromotionGoods setWeight:goodsModel.weight];
  108. [currentPromotionGoods setVolume:goodsModel.volume];
  109. [currentPromotionGoods setDecimalPlaces:goodsModel.decimalPlaces];
  110. [currentPromotionGoods setCirculateType:goodsModel.circulateType];
  111. [currentPromotionGoods setPackage:goodsModel.package];
  112. [currentPromotionGoods setMarkedPrice:goodsModel.markedPrice];
  113. [currentPromotionGoods setInventoryQuantity:goodsModel.inventoryQuantity];
  114. [currentPromotionGoods setCanSaleQuantity:goodsModel.canSaleQuantity];
  115. [currentPromotionGoods setAcreageFlag:goodsModel.acreageFlag];
  116. [currentPromotionGoods setInventoryId:goodsModel.inventoryId];
  117. [currentPromotionGoods setGoodsQuantityHide:goodsModel.goodsQuantityHide];
  118. [currentPromotionGoods setMinimumPurchaseQuantity:goodsModel.minimumPurchaseQuantity];
  119. NSString *combinationQuantity=goodsModel.combinationQuantity;
  120. NSString *goodsNumberHide=goodsModel.goodsQuantityHide;
  121. NSString *decimalPlaces=goodsModel.decimalPlaces;
  122. if([combinationQuantity doubleValue]>0)
  123. {
  124. double salesQuantity=[combinationQuantity doubleValue]*[goodsNumberHide doubleValue];
  125. NSString *decimalPlacesStr=[NSString stringWithFormat:@"%@%@%@",@"%.",decimalPlaces,@"f"];
  126. NSString *salesQuantityStr=[NSString stringWithFormat:decimalPlacesStr,salesQuantity];
  127. [currentPromotionGoods setSalesQuantity:salesQuantityStr];
  128. }
  129. [_promotionGoodsDetailList replaceObjectAtIndex:currentPosition withObject:currentPromotionGoods];
  130. __weak typeof(self) weakself=self;
  131. if ([weakself.goodsDelegate respondsToSelector:@selector(refreshPromotionGoodsData:)]){
  132. [weakself.goodsDelegate refreshPromotionGoodsData:_promotionGoodsDetailList];
  133. }
  134. }
  135. }
  136. }
  137. /**
  138. 高度
  139. @return <#return value description#>
  140. */
  141. - (NSMutableDictionary *)heights{
  142. if (_heights == nil){
  143. _heights = [NSMutableDictionary dictionary];
  144. }
  145. return _heights;
  146. }
  147. /**
  148. 单元格cell个数
  149. @param tableView <#tableView description#>
  150. @param section <#section description#>
  151. @return <#return value description#>
  152. */
  153. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  154. {
  155. return [_combinationGoodsDetailList count];
  156. }
  157. /**
  158. <#Description#>
  159. @param tableView <#tableView description#>
  160. @return <#return value description#>
  161. */
  162. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  163. return 1;
  164. }
  165. /**
  166. 高度
  167. @param tableView <#tableView description#>
  168. @param indexPath <#indexPath description#>
  169. @return <#return value description#>
  170. */
  171. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  172. return [self.heights[@(indexPath.row)] floatValue];
  173. }
  174. /**
  175. 预防高度
  176. @param tableView <#tableView description#>
  177. @param indexPath <#indexPath description#>
  178. @return <#return value description#>
  179. */
  180. -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  181. return 280;
  182. }
  183. /**
  184. 每个单元格cell
  185. @param tableView <#tableView description#>
  186. @param indexPath <#indexPath description#>
  187. @return <#return value description#>
  188. */
  189. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  190. {
  191. static NSString *CellIdentifier = @"CombinationGoodsDetailListCell";
  192. OptionCombinationDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
  193. if (!cell) {
  194. cell=[[OptionCombinationDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  195. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  196. }
  197. else
  198. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  199. {
  200. while ([cell.contentView.subviews lastObject] != nil) {
  201. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  202. }
  203. }
  204. InventoryListModel *combinationGoodsModel= [_combinationGoodsDetailList objectAtIndex:indexPath.row];
  205. cell.delegate=self;
  206. cell.position=indexPath.row;
  207. [cell setCombinationGoodsDetailCell:combinationGoodsModel];
  208. BOOL checked = combinationGoodsModel.isCheckedStatus;
  209. [cell setCheckBackground:checked];
  210. self.heights[@(indexPath.row)] = @(cell.height);
  211. return cell;
  212. }
  213. @end