PromotionOrderListVC.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. //
  2. // PromotionOrderListViewController.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/9/7.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "PromotionOrderListVC.h"
  9. @interface PromotionOrderListVC ()
  10. @end
  11. @implementation PromotionOrderListVC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. [self loadNavStyle];
  15. _promotionOrderList=[[NSMutableArray alloc]init];
  16. [self initSlideSlip];
  17. [self initUI];
  18. }
  19. /**
  20. 导航按钮样式
  21. */
  22. -(void)loadNavStyle
  23. {
  24. self.navigationItem.title=@"促销订单列表";
  25. //返回
  26. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  27. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  28. forState:UIControlStateNormal];
  29. [button addTarget:self action:@selector(goBack)
  30. forControlEvents:UIControlEventTouchUpInside];
  31. button.frame = CGRectMake(0, 0, 15, 18);
  32. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  33. self.navigationItem.leftBarButtonItem = menuButton;
  34. }
  35. /**
  36. 初始化ui
  37. */
  38. - (void)initUI{
  39. CGFloat height = 40;
  40. UIView *searchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 60)];
  41. searchView.backgroundColor = [UIColor whiteColor];
  42. UIButton *btnSearch = [UIButton buttonWithType:UIButtonTypeCustom];
  43. btnSearch.frame = CGRectMake(20, 10, Screen_Width-height, height);
  44. btnSearch.layer.cornerRadius = 6.0f;
  45. [btnSearch setTitle:@"搜索" forState:UIControlStateNormal];
  46. [btnSearch setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  47. btnSearch.titleLabel.textAlignment = NSTextAlignmentCenter;
  48. btnSearch.titleLabel.font = [UIFont systemFontOfSize:LabelAndTextFontOfSize];
  49. btnSearch.backgroundColor = LineBackgroundColor;
  50. [btnSearch addTarget:self action:@selector(dataSearch) forControlEvents:UIControlEventTouchUpInside];
  51. [searchView addSubview:btnSearch];
  52. [self.view addSubview:searchView];
  53. UIView *topSeparatorView = [UIView new];
  54. topSeparatorView.frame=CGRectMake(0, CGRectGetMaxY(searchView.frame), Screen_Width, 10);
  55. topSeparatorView.backgroundColor = LineBackgroundColor;
  56. [self.view addSubview:topSeparatorView];
  57. _dataList=[[NSMutableArray alloc]init];
  58. _vTableView = [[UITableView alloc]
  59. initWithFrame:CGRectMake(0, CGRectGetMaxY(topSeparatorView.frame),
  60. self.view.frame.size.width,
  61. Screen_Height - CGRectGetMaxY(topSeparatorView.frame))];
  62. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  63. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  64. _vTableView.backgroundColor = [UIColor whiteColor];
  65. _vTableView.delegate = self;
  66. _vTableView.dataSource=self;
  67. [self.view addSubview:_vTableView];
  68. }
  69. /**
  70. 返回函数
  71. */
  72. - (void)goBack
  73. {
  74. [self.navigationController popViewControllerAnimated:YES];
  75. }
  76. /**
  77. 搜索抽屉弹出
  78. */
  79. - (void)dataSearch{
  80. [_filterController show];
  81. }
  82. /**
  83. 抽屉初始化
  84. */
  85. - (void)initSlideSlip{
  86. // 抽屉对象
  87. __weak typeof(self) weakself=self;
  88. self.filterController = [[SideSlipFilterController alloc]
  89. initWithSponsor:self
  90. resetBlock:^(NSArray *dataList) {
  91. for (SideSlipModel *model in dataList) {
  92. model.selectedItemList = nil;
  93. model.customDict = nil;
  94. }
  95. } commitBlock:^(NSArray *dataList) {
  96. // 查询条件
  97. SideSlipModel *serviceRegionModel = dataList[0];
  98. self->_searchModel= [serviceRegionModel.customDict objectForKey:SALES_ORDER_LIST_SEARCH_RANGE_MODEL];
  99. self->_goodsCode=self->_searchModel.goodsCode;
  100. self->_onlyCode=self->_searchModel.onlyCode;
  101. self->_strategyName=self->_searchModel.strategyName;
  102. self->_promotionName=self->_searchModel.promotionName;
  103. self->_specification=self->_searchModel.specification;
  104. self->_colorNumber=self->_searchModel.colorNumber;
  105. self->_warehouseAreaId=self->_searchModel.warehouseAreaId;
  106. self->_brandId=self->_searchModel.brandId;
  107. self->_seriesId=self->_searchModel.seriesId;
  108. self->_kindCode=self->_searchModel.kindCode;
  109. self->_varietyId=self->_searchModel.varietyId;
  110. self->_gradeIds=self->_searchModel.gradeIds;
  111. self->_promotionTypeId=self->_searchModel.promotionTypeId;
  112. if(self->_gradeIds==nil||[self->_gradeIds isEqualToString:@""])
  113. {
  114. [self showAlertViewText:@"请选择等级"];
  115. return;
  116. }
  117. [weakself.filterController dismiss];
  118. if(self->_promotionOrderList!=nil&&_promotionOrderList.count>0)
  119. {
  120. [self->_promotionOrderList removeAllObjects];
  121. [self->_vTableView reloadData];
  122. }
  123. [self loadData];
  124. }];
  125. _filterController.animationDuration = AnimationDuration;
  126. _filterController.hasHeadView = YES;
  127. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  128. _filterController.dataList = [self packageDataList];
  129. }
  130. /**
  131. 抽屉数据源
  132. @return <#return value description#>
  133. */
  134. - (NSArray *)packageDataList {
  135. NSMutableArray *dataArray = [NSMutableArray array];
  136. SideSlipModel *model = [[SideSlipModel alloc] init];
  137. model.containerCellClass = @"PromotionOrderSearchCell";
  138. model.regionTitle = @"查询条件";
  139. [dataArray addObject:model];
  140. return [dataArray mutableCopy];
  141. }
  142. -(void)loadData
  143. {
  144. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  145. [dict setObject:@"GetPromotionDetailData" forKey:@"Action"];
  146. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  147. [dict setObject:kkUserCode forKey:@"UserCode"];
  148. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  149. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  150. [dict setObject:_goodsCode forKeyedSubscript:@"Code"];
  151. [dict setObject:_brandId forKeyedSubscript:@"BrandID"];
  152. [dict setObject:_kindCode forKeyedSubscript:@"KindCode"];
  153. [dict setObject:_warehouseAreaId forKeyedSubscript:@"WarehouseID"];
  154. [dict setObject:_varietyId forKeyedSubscript:@"VarietyID"];
  155. [dict setObject:_seriesId forKeyedSubscript:@"SeriesID"];
  156. [dict setObject:_specification forKeyedSubscript:@"Specification"];
  157. [dict setObject:_onlyCode forKeyedSubscript:@"OnlyCode"];
  158. [dict setObject:_colorNumber forKeyedSubscript:@"ColorNumber"];
  159. [dict setObject:_gradeIds forKeyedSubscript:@"GradeIDs"];
  160. [dict setObject:_promotionTypeId forKeyedSubscript:@"PromotionsType"];
  161. [dict setObject:_promotionName forKeyedSubscript:@"PromotionDetailName"];
  162. [dict setObject:_strategyName forKeyedSubscript:@"PromotionName"];
  163. [dict setObject:_organizationCode forKeyedSubscript:@"OrganizationCode"];
  164. _downManager = [[ASIDownManager alloc] init];
  165. [self startLoading];
  166. _downManager.delegate = self;
  167. _downManager.onRequestSuccess = @selector(onPromotionOrderListLoadFinish:);
  168. _downManager.onRequestFail = @selector(onPromotionOrderListLoadFail:);
  169. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  170. }
  171. /**
  172. 隐藏进度条
  173. */
  174. - (void)cancel {
  175. [self stopLoading];
  176. }
  177. -(void)onPromotionOrderListLoadFinish:(ASIDownManager *)sender {
  178. NSDictionary *dic = [sender.mWebStr JSONValue];
  179. [self cancel];
  180. // 服务器返回数据是否正确
  181. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  182. // 服务器返回数据状态值
  183. int iStatus = [[dic objectForKey:@"Status"] intValue];
  184. int iNewCount = 0;
  185. // 服务器返回数据消息
  186. NSString *message=[dic objectForKey:@"Message"];
  187. // 服务器返回数据状态值正确
  188. if (iStatus == 0)
  189. {
  190. NSDictionary *resultDic=[dic objectForKey:@"Result"];
  191. NSArray *resultArray= [resultDic objectForKey:@"Table"];
  192. if(resultArray!=nil&&resultArray.count>0)
  193. {
  194. for(int i=0;i<resultArray.count;i++)
  195. {
  196. NSDictionary *dic=[resultArray objectAtIndex:i];
  197. PromotionOrderModel *orderListModel=[PromotionOrderModel dk_modelWithDictionary:dic];
  198. [_promotionOrderList addObject:orderListModel];
  199. }
  200. [_vTableView reloadData];
  201. }
  202. }
  203. else if(iStatus == ActionResultStatusAuthError
  204. ||iStatus == ActionResultStatusNoLogin
  205. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  206. [self showReLoginDialog:message];
  207. return;
  208. }else {
  209. [self showAlertViewText:message];
  210. }
  211. }
  212. }
  213. -(void)onPromotionOrderListLoadFail:(ASIDownManager *)sender {
  214. [self cancel];
  215. [self showAlertViewText:@"加载失败"];
  216. }
  217. #pragma mark - 委托回调函数
  218. /**
  219. 单元格cell个数
  220. @param tableView <#tableView description#>
  221. @param section <#section description#>
  222. @return <#return value description#>
  223. */
  224. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  225. {
  226. return [_promotionOrderList count];
  227. }
  228. /**
  229. <#Description#>
  230. @param tableView <#tableView description#>
  231. @return <#return value description#>
  232. */
  233. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  234. return 1;
  235. }
  236. /**
  237. 高度
  238. @param tableView <#tableView description#>
  239. @param indexPath <#indexPath description#>
  240. @return <#return value description#>
  241. */
  242. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  243. return 383;
  244. }
  245. /**
  246. 每个单元格cell
  247. @param tableView <#tableView description#>
  248. @param indexPath <#indexPath description#>
  249. @return <#return value description#>
  250. */
  251. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  252. {
  253. static NSString *CellIdentifier = @"PromotionOrderListCell";
  254. PromotionOrderListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
  255. if (!cell) {
  256. cell=[[PromotionOrderListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  257. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  258. }
  259. else
  260. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  261. {
  262. while ([cell.contentView.subviews lastObject] != nil) {
  263. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  264. }
  265. }
  266. PromotionOrderModel *promotionOrderModel= [_promotionOrderList objectAtIndex:indexPath.row];
  267. [cell setPromotionOrderCell:promotionOrderModel];
  268. return cell;
  269. }
  270. /**
  271. 点击单元格事件
  272. @param tableView tableView description
  273. @param indexPath indexPath description
  274. */
  275. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  276. {
  277. self.hidesBottomBarWhenPushed=YES;
  278. PromotionOrderModel *orderModel= [_promotionOrderList objectAtIndex:indexPath.row];
  279. if([orderModel.promotionTypeId intValue]==5)
  280. {
  281. SalesOrderOptionCombinationPromotionDetailHomeVC *detailVc=[[SalesOrderOptionCombinationPromotionDetailHomeVC alloc] init];
  282. detailVc.code=_goodsCode;
  283. detailVc.specification=_specification;
  284. detailVc.onlyCode=_onlyCode;
  285. detailVc.orderDelegate=self;
  286. detailVc.promotionName=_strategyName;
  287. detailVc.promotionDetailName=_promotionName;
  288. detailVc.colorNumber=_colorNumber;
  289. detailVc.gradeIds=_gradeIds;
  290. detailVc.brandId=_brandId;
  291. detailVc.kindCode=_kindCode;
  292. detailVc.warehouseId=_warehouseAreaId;
  293. detailVc.varietyId=_varietyId;
  294. detailVc.seriesId=_seriesId;
  295. detailVc.promotionTypeId=_promotionTypeId;
  296. detailVc.organizationCode=_organizationCode;
  297. detailVc.goodsAmount=_goodsAmount;
  298. detailVc.markPriceAmount=_markPriceAmount;
  299. detailVc.fullDiscount=_fullDiscount;
  300. detailVc.promotionOrderModel=orderModel;
  301. detailVc.orderGoodsDetailList=_orderGoodsDetailList;
  302. [self.navigationController pushViewController:detailVc animated:YES];
  303. }
  304. else
  305. {
  306. OrderGoodsSinglePromotionDetailVC *detailVc=[[OrderGoodsSinglePromotionDetailVC alloc] init];
  307. detailVc.code=_goodsCode;
  308. detailVc.specification=_specification;
  309. detailVc.onlyCode=_onlyCode;
  310. detailVc.orderDelegate=self;
  311. detailVc.promotionName=_strategyName;
  312. detailVc.promotionDetailName=_promotionName;
  313. detailVc.colorNumber=_colorNumber;
  314. detailVc.gradeIds=_gradeIds;
  315. detailVc.brandId=_brandId;
  316. detailVc.kindCode=_kindCode;
  317. detailVc.warehouseId=_warehouseAreaId;
  318. detailVc.varietyId=_varietyId;
  319. detailVc.seriesId=_seriesId;
  320. detailVc.promotionTypeId=_promotionTypeId;
  321. detailVc.organizationCode=_organizationCode;
  322. detailVc.goodsAmount=_goodsAmount;
  323. detailVc.markPriceAmount=_markPriceAmount;
  324. detailVc.fullDiscount=_fullDiscount;
  325. detailVc.promotionOrderModel=orderModel;
  326. detailVc.orderGoodsDetailList=_orderGoodsDetailList;
  327. [self.navigationController pushViewController:detailVc animated:YES];
  328. }
  329. }
  330. -(void)updatePromotionGoodsData:(PromotionOrderModel*)orderModel goodsDetailList:(NSMutableArray*)goodsList giftAmount:(double)amount
  331. goodsDetailDic:(NSMutableDictionary*)detailDic
  332. {
  333. if([self.orderDelegate respondsToSelector:@selector(updatePromotionGoodsData: goodsDetailList:giftAmount:goodsDetailDic:)])
  334. {
  335. [self.orderDelegate updatePromotionGoodsData:orderModel goodsDetailList:goodsList giftAmount:amount goodsDetailDic:detailDic];
  336. [self.navigationController popViewControllerAnimated:YES];
  337. }
  338. }
  339. @end