SalesOrderOptionCombinationPromotionDetailHomeVC.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. //
  2. // SalesOrderOptionCombinationPromotionDetailHomeVC.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/9/14.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "SalesOrderOptionCombinationPromotionDetailHomeVC.h"
  9. @interface SalesOrderOptionCombinationPromotionDetailHomeVC ()<UIScrollViewDelegate>
  10. {
  11. SalesOrderOptionCombinationPromotionDetailVC *promotionDetailVC;
  12. SalesOrderOptionCombinationDetailVC *combinationDetailVC;
  13. // 滑动线
  14. UILabel *_sliderLabel;
  15. // 滚动条
  16. UIScrollView *_mainScrollView;
  17. // 基本信息按钮
  18. UIButton *_promotionDetailBtn;
  19. // 业绩信息按钮
  20. UIButton *_combinationDetailBtn;
  21. // 保存
  22. UIButton *_btnSave;
  23. }
  24. @end
  25. // 5个导航菜单
  26. static int navcount = 2;
  27. @implementation SalesOrderOptionCombinationPromotionDetailHomeVC
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. _orderGoodsDetailList=[[NSMutableArray alloc]init];
  31. _combinationGoodsDetailList=[[NSMutableArray alloc]init];
  32. [self initUI];
  33. [self setMainSrollView];
  34. //设置默认
  35. [self sliderWithTag:self.currentIndex+1];
  36. }
  37. /**
  38. 安全区视图发生变化
  39. */
  40. -(void)viewSafeAreaInsetsDidChange{
  41. self.view.backgroundColor = [UIColor whiteColor];
  42. _mainScrollView.frame = CGRectMake(0, 40, Screen_Width,self.view.safeAreaLayoutGuide.layoutFrame.size.height-50);
  43. for (NSInteger i = 0; i < _mainScrollView.subviews.count; i++) {
  44. _mainScrollView.subviews[i].frame = CGRectMake(Screen_Width * i, 0, Screen_Width,CGRectGetHeight(_mainScrollView.frame));
  45. }
  46. [self.promotionDetailVC viewSafeAreaInsetsDidChange];
  47. [self.combinationDetailVC viewSafeAreaInsetsDidChange];
  48. UIImage *pic = [UIImage imageNamed:@"bt_datasave"];
  49. CGFloat h =40;
  50. _btnSave.frame=CGRectMake(0, self.view.safeAreaLayoutGuide.layoutFrame.size.height- h - 5 , Screen_Width,h) ;
  51. [super viewSafeAreaInsetsDidChange];
  52. }
  53. -(void)initUI
  54. {
  55. UIView *navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 40)];
  56. [self.view setBackgroundColor:[UIColor whiteColor]];
  57. _promotionDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  58. [_promotionDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  59. [_promotionDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  60. _promotionDetailBtn.frame = CGRectMake(2, 0, Screen_Width/navcount, navView.frame.size.height);
  61. _promotionDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
  62. [_promotionDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
  63. [_promotionDetailBtn setTitle:@"促销明细" forState:UIControlStateNormal];
  64. _promotionDetailBtn.tag = 1;
  65. _promotionDetailBtn.selected = YES;
  66. [navView addSubview:_promotionDetailBtn];
  67. // 组合明细
  68. _combinationDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  69. _combinationDetailBtn.frame = CGRectMake(_promotionDetailBtn.frame.origin.x+_promotionDetailBtn.frame.size.width, _promotionDetailBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
  70. [_combinationDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  71. [_combinationDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  72. _combinationDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
  73. [_combinationDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
  74. [_combinationDetailBtn setTitle:@"组合明细" forState:UIControlStateNormal];
  75. _combinationDetailBtn.tag = 2;
  76. [navView addSubview:_combinationDetailBtn];
  77. // 选中后的红线
  78. _sliderLabel = [[UILabel alloc]initWithFrame:CGRectMake(_promotionDetailBtn.frame.origin.x, 40-2, Screen_Width/navcount, 2)];
  79. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(((Screen_Width/navcount)-75)/2, 0, 75, 2)];
  80. line.backgroundColor = [UIColor redColor];
  81. [_sliderLabel addSubview:line];
  82. [navView addSubview:_sliderLabel];
  83. [self.view addSubview:navView];
  84. self.navigationItem.title =@"自选组合促销明细";
  85. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  86. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  87. [button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
  88. button.frame = CGRectMake(0, 0,45,22);
  89. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
  90. [self loadGoodsDetail];
  91. }
  92. -(void)loadGoodsDetail
  93. {
  94. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  95. [dict setObject:@"GetPromotionDetailData" forKey:@"Action"];
  96. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  97. [dict setObject:kkUserCode forKey:@"UserCode"];
  98. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  99. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  100. [dict setObject:_code forKeyedSubscript:@"Code"];
  101. [dict setObject:_brandId forKeyedSubscript:@"BrandID"];
  102. [dict setObject:_kindCode forKeyedSubscript:@"KindCode"];
  103. [dict setObject:_warehouseId forKeyedSubscript:@"WarehouseID"];
  104. [dict setObject:_varietyId forKeyedSubscript:@"VarietyID"];
  105. [dict setObject:_seriesId forKeyedSubscript:@"SeriesID"];
  106. [dict setObject:_specification forKeyedSubscript:@"Specification"];
  107. [dict setObject:_onlyCode forKeyedSubscript:@"OnlyCode"];
  108. [dict setObject:_colorNumber forKeyedSubscript:@"ColorNumber"];
  109. [dict setObject:_gradeIds forKeyedSubscript:@"GradeIDs"];
  110. [dict setObject:_promotionTypeId forKeyedSubscript:@"PromotionsType"];
  111. [dict setObject:_promotionDetailName forKeyedSubscript:@"PromotionDetailName"];
  112. [dict setObject:_promotionName forKeyedSubscript:@"PromotionName"];
  113. [dict setObject:_organizationCode forKeyedSubscript:@"OrganizationCode"];
  114. [dict setObject:_promotionOrderModel.detailId forKeyedSubscript:@"DetailID"];
  115. _downManager = [[ASIDownManager alloc] init];
  116. [self startLoading];
  117. _downManager.delegate = self;
  118. _downManager.onRequestSuccess = @selector(onPromotionOrderDetailLoadFinish:);
  119. _downManager.onRequestFail = @selector(onPromotionOrderDetailLoadFail:);
  120. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  121. }
  122. -(void)onPromotionOrderDetailLoadFinish:(ASIDownManager *)sender {
  123. NSDictionary *dic = [sender.mWebStr JSONValue];
  124. [self stopLoading];
  125. // 服务器返回数据是否正确
  126. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  127. // 服务器返回数据状态值
  128. int iStatus = [[dic objectForKey:@"Status"] intValue];
  129. int iNewCount = 0;
  130. // 服务器返回数据消息
  131. NSString *message=[dic objectForKey:@"Message"];
  132. // 服务器返回数据状态值正确
  133. if (iStatus == 0)
  134. {
  135. NSDictionary *resultDic=[dic objectForKey:@"Result"];
  136. NSArray *promotionArray= [resultDic objectForKey:@"Table"];
  137. NSArray *combinationArray= [resultDic objectForKey:@"Table1"];
  138. if(promotionArray!=nil&&promotionArray.count>0)
  139. {
  140. for(int i=0;i<promotionArray.count;i++)
  141. {
  142. NSDictionary *dic=[promotionArray objectAtIndex:i];
  143. InventoryListModel *model = [InventoryListModel new];
  144. int promotionGoodsIdValue= [[dic objectForKey:@"PromotionGoodsID"]intValue];
  145. model.promotionGoodsId=[NSString stringWithFormat:@"%d",promotionGoodsIdValue];
  146. int promotionDetailIdValue=[[dic objectForKey:@"PromotionDetailID"]intValue];
  147. model.promotionDetailId=[NSString stringWithFormat:@"%d",promotionDetailIdValue];;
  148. model.codeId=[[dic objectForKey:@"CodeID"]intValue];
  149. model.code=[dic objectForKey:@"Code"];
  150. model.onlyCode=[dic objectForKey:@"OnlyCode"];
  151. model.specification=[dic objectForKey:@"Specification"];
  152. model.brandId=[dic objectForKey:@"BrandID"];
  153. model.brandName=[dic objectForKey:@"BrandName"];
  154. model.gradeId=[[dic objectForKey:@"GradeID"]intValue];
  155. model.gradeName=[dic objectForKey:@"GradeName"];
  156. model.kindId=[dic objectForKey:@"KindID"];
  157. model.kindName=[dic objectForKey:@"KindName"];
  158. model.seriesId=[dic objectForKey:@"SeriesID"];
  159. model.seriesName=[dic objectForKey:@"SeriesName"];
  160. model.varietyId=[dic objectForKey:@"VarietyID"];
  161. model.varietyName=[dic objectForKey:@"VarietyName"];
  162. model.unitId=[dic objectForKey:@"UnitID"];
  163. model.unitName=[dic objectForKey:@"UnitName"];
  164. model.warehouseId=[dic objectForKey:@"WarehouseID"];
  165. model.wareHouseName=[dic objectForKey:@"WarehouseName"];
  166. model.positionNumber=[dic objectForKey:@"PositionNumber"];
  167. double salesPriceValue= [[dic objectForKey:@"SalsePrice"]doubleValue];
  168. model.salesPrice=[NSString stringWithFormat:@"%lf",salesPriceValue];
  169. model.giftFlag=[[dic objectForKey:@"GiftGoodsFlag"]boolValue];
  170. int goodsNumberValue= [[dic objectForKey:@"GoodsNumber"]intValue];
  171. model.goodsQuantity=[NSString stringWithFormat:@"%d",goodsNumberValue];
  172. model.usePositionId=@"0";
  173. model.colorNumber=[dic objectForKey:@"ColorNumber"];
  174. model.acreage=[[dic objectForKey:@"Acreage"]doubleValue];
  175. double weightValue= [[dic objectForKey:@"Weight"]doubleValue];
  176. model.weight=[NSString stringWithFormat:@"%lf",weightValue];
  177. double volumeValue= [[dic objectForKey:@"Volume"]doubleValue];
  178. model.volume=[NSString stringWithFormat:@"%lf",volumeValue];
  179. model.decimalPlaces=[dic objectForKey:@"DecimalPlaces"];
  180. model.promotionTypeDetailId=[dic objectForKey:@"PromotionTypeDetailID"];
  181. model.circulateType=[[dic objectForKey:@"CirculateType"]integerValue];
  182. int packageValue= [[dic objectForKey:@"Package"]intValue];
  183. model.package=[NSString stringWithFormat:@"%d",packageValue];
  184. model.goodsName=[dic objectForKey:@"GoodsName"];
  185. model.goodsCateName=[dic objectForKey:@"GoodsCateName"];
  186. double markedPriceValue= [[dic objectForKey:@"MarkedPrice"]doubleValue];
  187. model.markedPrice=[NSString stringWithFormat:@"%lf",markedPriceValue];
  188. int inventoryQuantityValue= [[dic objectForKey:@"InventoryQuantity"]intValue];
  189. model.inventoryQuantity=[NSString stringWithFormat:@"%d",inventoryQuantityValue];
  190. int salesQuantityValue= [[dic objectForKey:@"salesQuantity"]intValue];
  191. model.salesQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
  192. model.canSaleQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
  193. int promotionTypeIdValue= [[dic objectForKey:@"PromotionsTypeID"]intValue];
  194. model.promotionTypeDetailId=[NSString stringWithFormat:@"%d",promotionTypeIdValue];
  195. model.acreageFlag=[[dic objectForKey:@"AcreageFlag"]boolValue];
  196. model.inventoryId=[dic objectForKey:@"InventoryID"];
  197. int goodsNumberHideValue= [[dic objectForKey:@"GoodsNumberHide"]intValue];
  198. model.goodsQuantityHide=[NSString stringWithFormat:@"%d",goodsNumberHideValue];
  199. int minimumPurchaseQuantityValue= [[dic objectForKey:@"MinimPurchaseQuantity"]intValue];
  200. model.minimumPurchaseQuantity=[NSString stringWithFormat:@"%d",minimumPurchaseQuantityValue];
  201. model.combinationId=[dic objectForKey:@"CombinationID"];
  202. model.combinationQuantity=@"0";
  203. OrderQuantity *orderQuantity=[OrderQuantity new];
  204. [orderQuantity setSalesOrderDetailBoxAndPiece:[model.salesQuantity intValue] inventoryModel:model];
  205. if(i==0)
  206. {
  207. [model setIsChecked:YES];
  208. }
  209. else
  210. {
  211. [model setIsChecked:NO];
  212. }
  213. [_orderGoodsDetailList addObject:model];
  214. }
  215. }
  216. if(combinationArray!=nil&&combinationArray.count>0)
  217. {
  218. for(int i=0;i<combinationArray.count;i++)
  219. {
  220. NSDictionary *dic=[combinationArray objectAtIndex:i];
  221. InventoryListModel *model=[InventoryListModel new];
  222. int promotionGoodsIdValue= [[dic objectForKey:@"PromotionGoodsID"]intValue];
  223. model.promotionGoodsId=[NSString stringWithFormat:@"%d",promotionGoodsIdValue];
  224. int promotionDetailIdValue=[ [dic objectForKey:@"PromotionDetailID"]intValue]; model.promotionDetailId=[NSString stringWithFormat:@"%d",promotionDetailIdValue];
  225. model.codeId=[[dic objectForKey:@"CodeID"]intValue];
  226. model.code=[dic objectForKey:@"Code"];
  227. model.usePositionId=@"0";
  228. model.onlyCode=[dic objectForKey:@"OnlyCode"];
  229. model.specification=[dic objectForKey:@"Specification"];
  230. model.brandId=[dic objectForKey:@"BrandID"];
  231. model.brandName=[dic objectForKey:@"BrandName"];
  232. model.gradeId=[[dic objectForKey:@"GradeID"]intValue];
  233. model.gradeName=[dic objectForKey:@"GradeName"];
  234. model.kindId=[dic objectForKey:@"KindID"];
  235. model.kindName=[dic objectForKey:@"KindName"];
  236. model.seriesId=[dic objectForKey:@"SeriesID"];
  237. model.seriesName=[dic objectForKey:@"SeriesName"];
  238. model.varietyId=[dic objectForKey:@"VarietyID"];
  239. model.varietyName=[dic objectForKey:@"VarietyName"];
  240. model.unitId=[dic objectForKey:@"UnitID"];
  241. model.unitName=[dic objectForKey:@"UnitName"];
  242. model.warehouseId=[dic objectForKey:@"WarehouseID"];
  243. model.wareHouseName=[dic objectForKey:@"WarehouseName"];
  244. model.positionNumber=[dic objectForKey:@"PositionNumber"];
  245. double salesPriceValue= [[dic objectForKey:@"SalsePrice"]doubleValue];
  246. model.salesPrice=[NSString stringWithFormat:@"%lf",salesPriceValue];
  247. model.giftFlag=[[dic objectForKey:@"GiftGoodsFlag"]boolValue];
  248. int goodsNumberValue= [[dic objectForKey:@"GoodsNumber"]intValue];
  249. model.goodsQuantity=[NSString stringWithFormat:@"%d",goodsNumberValue];
  250. model.colorNumber=[dic objectForKey:@"ColorNumber"];
  251. model.acreage=[[dic objectForKey:@"Acreage"]doubleValue];
  252. double weightValue= [[dic objectForKey:@"Weight"]doubleValue];
  253. model.weight=[NSString stringWithFormat:@"%lf",weightValue];
  254. double volumeValue= [[dic objectForKey:@"Volume"]doubleValue];
  255. model.volume=[NSString stringWithFormat:@"%lf",volumeValue];
  256. model.decimalPlaces=[dic objectForKey:@"DecimalPlaces"];
  257. model.circulateType=[[dic objectForKey:@"CirculateType"]integerValue];
  258. int packageValue= [[dic objectForKey:@"Package"]intValue];
  259. model.package=[NSString stringWithFormat:@"%d",packageValue];
  260. model.goodsName=[dic objectForKey:@"GoodsName"];
  261. model.goodsCateName=[dic objectForKey:@"GoodsCateName"];
  262. double markedPriceValue= [[dic objectForKey:@"MarkedPrice"]doubleValue];
  263. model.markedPrice=[NSString stringWithFormat:@"%lf",markedPriceValue];
  264. int inventoryQuantityValue= [[dic objectForKey:@"InventoryQuantity"]intValue];
  265. model.inventoryQuantity=[NSString stringWithFormat:@"%d",inventoryQuantityValue];
  266. int salesQuantityValue= [[dic objectForKey:@"salesQuantity"]intValue];
  267. model.salesQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
  268. model.canSaleQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
  269. model.promotionTypeId=[dic objectForKey:@"PromotionsTypeID"];
  270. model.acreageFlag=[[dic objectForKey:@"AcreageFlag"]boolValue];
  271. model.inventoryId=[dic objectForKey:@"InventoryID"];
  272. int goodsNumberHideValue= [[dic objectForKey:@"GoodsNumberHide"]intValue];
  273. model.goodsQuantityHide=[NSString stringWithFormat:@"%d",goodsNumberHideValue];
  274. int minimumPurchaseQuantityValue= [[dic objectForKey:@"MinimPurchaseQuantity"]intValue];
  275. model.minimumPurchaseQuantity=[NSString stringWithFormat:@"%d",minimumPurchaseQuantityValue];
  276. model.combinationId=[dic objectForKey:@"CombinationID"];
  277. model.combinationQuantity=@"0";
  278. [_combinationGoodsDetailList addObject:model];
  279. }
  280. }
  281. if(_orderGoodsDetailList!=nil&&_orderGoodsDetailList.count>0)
  282. {
  283. InventoryListModel *orderGoodsModel=[_orderGoodsDetailList objectAtIndex:0];
  284. NSString *combinationId=orderGoodsModel.combinationId;
  285. _combinationGoodsDetailFilterList=[[NSMutableArray alloc]init];
  286. for(int i=0;i<_combinationGoodsDetailList.count;i++)
  287. {
  288. InventoryListModel *combinationModel=[_combinationGoodsDetailList objectAtIndex:i];
  289. if([combinationId intValue]==[combinationModel.combinationId intValue])
  290. {
  291. [_combinationGoodsDetailFilterList addObject:combinationModel];
  292. }
  293. }
  294. if(_combinationGoodsDetailFilterList!=nil&&_combinationGoodsDetailFilterList.count>0)
  295. {
  296. InventoryListModel *combinationModel= [_combinationGoodsDetailFilterList objectAtIndex:0];
  297. [combinationModel setIsCheckedStatus:YES];
  298. [self.combinationDetailVC loadData:_combinationGoodsDetailFilterList promotionGoodsList:_orderGoodsDetailList];
  299. }
  300. [self.promotionDetailVC loadData:_orderGoodsDetailList combinationGoodsList:_combinationGoodsDetailList ];
  301. }
  302. }
  303. }
  304. }
  305. -(void)onPromotionOrderDetailLoadFail:(ASIDownManager *)sender {
  306. [self stopLoading];
  307. [self showAlertViewText:@"加载失败"];
  308. }
  309. -(void)refreshData:(NSMutableArray *)goodsList
  310. {
  311. [ self.combinationDetailVC loadData:goodsList promotionGoodsList:_orderGoodsDetailList];
  312. }
  313. -(void)refreshPromotionGoodsData:(NSMutableArray*)goodsList
  314. {
  315. [self.promotionDetailVC loadData:goodsList combinationGoodsList:_combinationGoodsDetailList];
  316. }
  317. -(void)goBack
  318. {
  319. [self.navigationController popViewControllerAnimated:YES];
  320. }
  321. /**
  322. 初始化srollView
  323. */
  324. - (void)setMainSrollView{
  325. UIImage *pic = [UIImage imageNamed:@"bt_datasave"];
  326. CGFloat h =50;
  327. // 滚动view
  328. _mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 40, Screen_Width, Screen_Height- h - 10 - rectStatusHeight-rectNavHeight - 40)];
  329. _mainScrollView.delegate = self;
  330. _mainScrollView.backgroundColor = [UIColor whiteColor];
  331. _mainScrollView.pagingEnabled = YES;
  332. _mainScrollView.showsHorizontalScrollIndicator = NO;
  333. _mainScrollView.showsVerticalScrollIndicator = NO;
  334. [self.view addSubview:_mainScrollView];
  335. NSArray *views = @[self.promotionDetailVC.view,self.combinationDetailVC.view];
  336. for (NSInteger i = 0; i< views.count; i++) {
  337. //把三个vc的view依次贴到mainScrollView上面
  338. UIView *pageView = [[UIView alloc]initWithFrame:CGRectMake(Screen_Width * i, 0, _mainScrollView.frame.size.width, _mainScrollView.frame.size.height)];
  339. [pageView addSubview:views[i]];
  340. [_mainScrollView addSubview:pageView];
  341. }
  342. _mainScrollView.contentSize = CGSizeMake(Screen_Width*(views.count), 0);
  343. //滚动到_currentIndex对应的tab
  344. [_mainScrollView setContentOffset:CGPointMake((_mainScrollView.frame.size.width)*_currentIndex, 0) animated:YES];
  345. //保存按钮
  346. _btnSave = [UIButton buttonWithType:UIButtonTypeCustom];
  347. _btnSave.frame=CGRectMake(0, Screen_Height- h- rectStatusHeight-rectNavHeight, Screen_Width,h) ;
  348. [_btnSave setBackgroundImage:pic forState:UIControlStateNormal];
  349. [_btnSave addTarget:self action:@selector(dataSave) forControlEvents:UIControlEventTouchUpInside];
  350. [self.view addSubview:_btnSave];
  351. }
  352. /**
  353. 基本信息vc
  354. @return <#return value description#>
  355. */
  356. - (SalesOrderOptionCombinationPromotionDetailVC *)promotionDetailVC{
  357. if (promotionDetailVC == nil) {
  358. promotionDetailVC = [[SalesOrderOptionCombinationPromotionDetailVC alloc] init];
  359. promotionDetailVC.goodsDelegate = self;
  360. }
  361. return promotionDetailVC;
  362. }
  363. /**
  364. 业绩信息vc
  365. @return <#return value description#>
  366. */
  367. - (SalesOrderOptionCombinationDetailVC *)combinationDetailVC{
  368. if (combinationDetailVC == nil) {
  369. combinationDetailVC = [[SalesOrderOptionCombinationDetailVC alloc] init];
  370. combinationDetailVC.goodsDelegate=self;
  371. }
  372. return combinationDetailVC;
  373. }
  374. /**
  375. 滑动tag
  376. @param tag <#tag description#>
  377. */
  378. - (void)sliderWithTag:(NSInteger)tag{
  379. self.currentIndex = tag;
  380. _promotionDetailBtn.selected = NO;
  381. _combinationDetailBtn.selected = NO;
  382. UIButton *sender = [self buttonWithTag:tag];
  383. sender.selected = YES;
  384. //动画
  385. _sliderLabel.frame = CGRectMake(sender.frame.origin.x, _sliderLabel.frame.origin.y, _sliderLabel.frame.size.width, _sliderLabel.frame.size.height);
  386. }
  387. /**
  388. 返回相应的button
  389. @param tag <#tag description#>
  390. @return <#return value description#>
  391. */
  392. - (UIButton *)buttonWithTag:(NSInteger )tag{
  393. if (tag == 1) {
  394. return _promotionDetailBtn;
  395. }else if (tag == 2){
  396. return _combinationDetailBtn;
  397. }
  398. else{
  399. return nil;
  400. }
  401. }
  402. /**
  403. 按钮点击事件
  404. @param sender <#sender description#>
  405. */
  406. - (void)sliderAction:(UIButton *)sender{
  407. if (self.currentIndex == sender.tag) {
  408. return;
  409. }
  410. // 切换controller
  411. [self.view endEditing:YES];
  412. [self sliderAnimationWithTag:sender.tag];
  413. [UIView animateWithDuration:0.3 animations:^{
  414. _mainScrollView.contentOffset = CGPointMake(Screen_Width*(sender.tag-1), 0);
  415. } completion:^(BOOL finished) {
  416. }];
  417. }
  418. /**
  419. 滑动tag
  420. @param tag <#tag description#>
  421. */
  422. - (void)sliderAnimationWithTag:(NSInteger)tag{
  423. self.currentIndex = tag;
  424. _promotionDetailBtn.selected = NO;
  425. _combinationDetailBtn.selected = NO;
  426. UIButton *sender = [self buttonWithTag:tag];
  427. sender.selected = YES;
  428. //动画
  429. [UIView animateWithDuration:0.3 animations:^{
  430. _sliderLabel.frame = CGRectMake(sender.frame.origin.x, _sliderLabel.frame.origin.y, _sliderLabel.frame.size.width, _sliderLabel.frame.size.height);
  431. } completion:^(BOOL finished) {
  432. }];
  433. }
  434. /**
  435. 滑动label位置
  436. @param scrollView <#scrollView description#>
  437. */
  438. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  439. //实时计算当前位置,实现和titleView上的按钮的联动
  440. CGFloat contentOffSetX = scrollView.contentOffset.x;
  441. CGFloat X = contentOffSetX/ navcount;
  442. CGRect frame = _sliderLabel.frame;
  443. frame.origin.x = X;
  444. _sliderLabel.frame = frame;
  445. if(X > _sliderLabel.frame.size.width/2){
  446. UIView *line = _sliderLabel.subviews[0];
  447. line.frame = CGRectMake(((Screen_Width/navcount)-40)/2, 0, 40, 2);
  448. }else{
  449. UIView *line = _sliderLabel.subviews[0];
  450. line.frame = CGRectMake(((Screen_Width/navcount)-70)/2, 0, 70, 2);
  451. }
  452. }
  453. /**
  454. 滑动完成
  455. @param scrollView <#scrollView description#>
  456. */
  457. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  458. CGFloat contentOffSetX = scrollView.contentOffset.x;
  459. int index_ = contentOffSetX/Screen_Width;
  460. [self sliderWithTag:index_+1];
  461. }
  462. -(void)dataSave
  463. {
  464. NSMutableArray *goodsDetailList=promotionDetailVC.promotionGoodsDetailList;
  465. bool isChecked=NO;
  466. if(goodsDetailList==nil||goodsDetailList.count==0)
  467. {
  468. [self showAlertViewText:@"不允许进行该操作,原因:没有任何数据"];
  469. return;
  470. }
  471. for(int i=0;i<goodsDetailList.count;i++)
  472. {
  473. InventoryListModel *goodsModel=[goodsDetailList objectAtIndex:i];
  474. if(goodsModel.isCheckedStatus)
  475. {
  476. isChecked=YES;
  477. break;
  478. }
  479. }
  480. if(!isChecked)
  481. {
  482. [self showAlertViewText:@"不允许进行该操作,原因:没有任何数据"];
  483. return;
  484. }
  485. NSMutableDictionary *goodsDetailDic=[[NSMutableDictionary alloc]init];
  486. if(goodsDetailList!=nil&&goodsDetailList.count>0)
  487. {
  488. NSMutableString *sb=[[NSMutableString alloc]init];
  489. for(int i=0;i<goodsDetailList.count;i++)
  490. {
  491. InventoryListModel *goodsModel=[goodsDetailList objectAtIndex:i];
  492. NSString *promotionGoodsId=goodsModel.promotionGoodsId;
  493. [sb appendString:promotionGoodsId];
  494. [sb appendString:@","];
  495. }
  496. NSString *opCombinationPromotionFlag=[sb copy];
  497. opCombinationPromotionFlag=[NSString stringWithFormat:@"%@%@%@",_promotionOrderModel.detailId,@"-",opCombinationPromotionFlag];
  498. opCombinationPromotionFlag =[opCombinationPromotionFlag substringToIndex:opCombinationPromotionFlag.length-1];
  499. [goodsDetailDic setObject:opCombinationPromotionFlag forKey:_promotionOrderModel.detailId];
  500. }
  501. if([self.orderDelegate respondsToSelector:@selector(updatePromotionGoodsData: goodsDetailList:giftAmount: goodsDetailDic:)])
  502. {
  503. [self.orderDelegate updatePromotionGoodsData:_promotionOrderModel goodsDetailList:goodsDetailList giftAmount:0 goodsDetailDic:goodsDetailDic];
  504. [self.navigationController popViewControllerAnimated:YES];
  505. }
  506. }
  507. @end