// // PromotionOrderListViewController.m // IBOSS // // Created by 关宏厚 on 2020/9/7. // Copyright © 2020 elongtian. All rights reserved. // #import "PromotionOrderListVC.h" @interface PromotionOrderListVC () @end @implementation PromotionOrderListVC - (void)viewDidLoad { [super viewDidLoad]; [self loadNavStyle]; _promotionOrderList=[[NSMutableArray alloc]init]; [self initSlideSlip]; [self initUI]; } /** 导航按钮样式 */ -(void)loadNavStyle { self.navigationItem.title=@"促销订单列表"; //返回 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(0, 0, 15, 18); UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button]; self.navigationItem.leftBarButtonItem = menuButton; } /** 初始化ui */ - (void)initUI{ CGFloat height = 40; UIView *searchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 60)]; searchView.backgroundColor = [UIColor whiteColor]; UIButton *btnSearch = [UIButton buttonWithType:UIButtonTypeCustom]; btnSearch.frame = CGRectMake(20, 10, Screen_Width-height, height); btnSearch.layer.cornerRadius = 6.0f; [btnSearch setTitle:@"搜索" forState:UIControlStateNormal]; [btnSearch setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal]; btnSearch.titleLabel.textAlignment = NSTextAlignmentCenter; btnSearch.titleLabel.font = [UIFont systemFontOfSize:LabelAndTextFontOfSize]; btnSearch.backgroundColor = LineBackgroundColor; [btnSearch addTarget:self action:@selector(dataSearch) forControlEvents:UIControlEventTouchUpInside]; [searchView addSubview:btnSearch]; [self.view addSubview:searchView]; UIView *topSeparatorView = [UIView new]; topSeparatorView.frame=CGRectMake(0, CGRectGetMaxY(searchView.frame), Screen_Width, 10); topSeparatorView.backgroundColor = LineBackgroundColor; [self.view addSubview:topSeparatorView]; _dataList=[[NSMutableArray alloc]init]; _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(topSeparatorView.frame), self.view.frame.size.width, Screen_Height - CGRectGetMaxY(topSeparatorView.frame))]; _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone; _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight; _vTableView.backgroundColor = [UIColor whiteColor]; _vTableView.delegate = self; _vTableView.dataSource=self; [self.view addSubview:_vTableView]; } /** 返回函数 */ - (void)goBack { [self.navigationController popViewControllerAnimated:YES]; } /** 搜索抽屉弹出 */ - (void)dataSearch{ [_filterController show]; } /** 抽屉初始化 */ - (void)initSlideSlip{ // 抽屉对象 __weak typeof(self) weakself=self; self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) { for (SideSlipModel *model in dataList) { model.selectedItemList = nil; model.customDict = nil; } } commitBlock:^(NSArray *dataList) { // 查询条件 SideSlipModel *serviceRegionModel = dataList[0]; self->_searchModel= [serviceRegionModel.customDict objectForKey:SALES_ORDER_LIST_SEARCH_RANGE_MODEL]; self->_goodsCode=self->_searchModel.goodsCode; self->_onlyCode=self->_searchModel.onlyCode; self->_strategyName=self->_searchModel.strategyName; self->_promotionName=self->_searchModel.promotionName; self->_specification=self->_searchModel.specification; self->_colorNumber=self->_searchModel.colorNumber; self->_warehouseAreaId=self->_searchModel.warehouseAreaId; self->_brandId=self->_searchModel.brandId; self->_seriesId=self->_searchModel.seriesId; self->_kindCode=self->_searchModel.kindCode; self->_varietyId=self->_searchModel.varietyId; self->_gradeIds=self->_searchModel.gradeIds; self->_promotionTypeId=self->_searchModel.promotionTypeId; if(self->_gradeIds==nil||[self->_gradeIds isEqualToString:@""]) { [self showAlertViewText:@"请选择等级"]; return; } [weakself.filterController dismiss]; if(self->_promotionOrderList!=nil&&_promotionOrderList.count>0) { [self->_promotionOrderList removeAllObjects]; [self->_vTableView reloadData]; } [self loadData]; }]; _filterController.animationDuration = AnimationDuration; _filterController.hasHeadView = YES; _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width; _filterController.dataList = [self packageDataList]; } /** 抽屉数据源 @return <#return value description#> */ - (NSArray *)packageDataList { NSMutableArray *dataArray = [NSMutableArray array]; SideSlipModel *model = [[SideSlipModel alloc] init]; model.containerCellClass = @"PromotionOrderSearchCell"; model.regionTitle = @"查询条件"; [dataArray addObject:model]; return [dataArray mutableCopy]; } -(void)loadData { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetPromotionDetailData" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:_goodsCode forKeyedSubscript:@"Code"]; [dict setObject:_brandId forKeyedSubscript:@"BrandID"]; [dict setObject:_kindCode forKeyedSubscript:@"KindCode"]; [dict setObject:_warehouseAreaId forKeyedSubscript:@"WarehouseID"]; [dict setObject:_varietyId forKeyedSubscript:@"VarietyID"]; [dict setObject:_seriesId forKeyedSubscript:@"SeriesID"]; [dict setObject:_specification forKeyedSubscript:@"Specification"]; [dict setObject:_onlyCode forKeyedSubscript:@"OnlyCode"]; [dict setObject:_colorNumber forKeyedSubscript:@"ColorNumber"]; [dict setObject:_gradeIds forKeyedSubscript:@"GradeIDs"]; [dict setObject:_promotionTypeId forKeyedSubscript:@"PromotionsType"]; [dict setObject:_promotionName forKeyedSubscript:@"PromotionDetailName"]; [dict setObject:_strategyName forKeyedSubscript:@"PromotionName"]; [dict setObject:_organizationCode forKeyedSubscript:@"OrganizationCode"]; _downManager = [[ASIDownManager alloc] init]; [self startLoading]; _downManager.delegate = self; _downManager.onRequestSuccess = @selector(onPromotionOrderListLoadFinish:); _downManager.onRequestFail = @selector(onPromotionOrderListLoadFail:); [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil]; } /** 隐藏进度条 */ - (void)cancel { [self stopLoading]; } -(void)onPromotionOrderListLoadFinish:(ASIDownManager *)sender { NSDictionary *dic = [sender.mWebStr JSONValue]; [self cancel]; // 服务器返回数据是否正确 if (dic && [dic isKindOfClass:[NSDictionary class]]) { // 服务器返回数据状态值 int iStatus = [[dic objectForKey:@"Status"] intValue]; int iNewCount = 0; // 服务器返回数据消息 NSString *message=[dic objectForKey:@"Message"]; // 服务器返回数据状态值正确 if (iStatus == 0) { NSDictionary *resultDic=[dic objectForKey:@"Result"]; NSArray *resultArray= [resultDic objectForKey:@"Table"]; if(resultArray!=nil&&resultArray.count>0) { for(int i=0;i @param section <#section description#> @return <#return value description#> */ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [_promotionOrderList 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 383; } /** 每个单元格cell @param tableView <#tableView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"PromotionOrderListCell"; PromotionOrderListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ]; if (!cell) { cell=[[PromotionOrderListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.selectionStyle=UITableViewCellSelectionStyleNone; } else //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免 { while ([cell.contentView.subviews lastObject] != nil) { [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview]; } } PromotionOrderModel *promotionOrderModel= [_promotionOrderList objectAtIndex:indexPath.row]; [cell setPromotionOrderCell:promotionOrderModel]; return cell; } /** 点击单元格事件 @param tableView tableView description @param indexPath indexPath description */ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { self.hidesBottomBarWhenPushed=YES; PromotionOrderModel *orderModel= [_promotionOrderList objectAtIndex:indexPath.row]; if([orderModel.promotionTypeId intValue]==5) { SalesOrderOptionCombinationPromotionDetailHomeVC *detailVc=[[SalesOrderOptionCombinationPromotionDetailHomeVC alloc] init]; detailVc.code=_goodsCode; detailVc.specification=_specification; detailVc.onlyCode=_onlyCode; detailVc.orderDelegate=self; detailVc.promotionName=_strategyName; detailVc.promotionDetailName=_promotionName; detailVc.colorNumber=_colorNumber; detailVc.gradeIds=_gradeIds; detailVc.brandId=_brandId; detailVc.kindCode=_kindCode; detailVc.warehouseId=_warehouseAreaId; detailVc.varietyId=_varietyId; detailVc.seriesId=_seriesId; detailVc.promotionTypeId=_promotionTypeId; detailVc.organizationCode=_organizationCode; detailVc.goodsAmount=_goodsAmount; detailVc.markPriceAmount=_markPriceAmount; detailVc.fullDiscount=_fullDiscount; detailVc.promotionOrderModel=orderModel; detailVc.orderGoodsDetailList=_orderGoodsDetailList; [self.navigationController pushViewController:detailVc animated:YES]; } else { OrderGoodsSinglePromotionDetailVC *detailVc=[[OrderGoodsSinglePromotionDetailVC alloc] init]; detailVc.code=_goodsCode; detailVc.specification=_specification; detailVc.onlyCode=_onlyCode; detailVc.orderDelegate=self; detailVc.promotionName=_strategyName; detailVc.promotionDetailName=_promotionName; detailVc.colorNumber=_colorNumber; detailVc.gradeIds=_gradeIds; detailVc.brandId=_brandId; detailVc.kindCode=_kindCode; detailVc.warehouseId=_warehouseAreaId; detailVc.varietyId=_varietyId; detailVc.seriesId=_seriesId; detailVc.promotionTypeId=_promotionTypeId; detailVc.organizationCode=_organizationCode; detailVc.goodsAmount=_goodsAmount; detailVc.markPriceAmount=_markPriceAmount; detailVc.fullDiscount=_fullDiscount; detailVc.promotionOrderModel=orderModel; detailVc.orderGoodsDetailList=_orderGoodsDetailList; [self.navigationController pushViewController:detailVc animated:YES]; } } -(void)updatePromotionGoodsData:(PromotionOrderModel*)orderModel goodsDetailList:(NSMutableArray*)goodsList giftAmount:(double)amount goodsDetailDic:(NSMutableDictionary*)detailDic { if([self.orderDelegate respondsToSelector:@selector(updatePromotionGoodsData: goodsDetailList:giftAmount:goodsDetailDic:)]) { [self.orderDelegate updatePromotionGoodsData:orderModel goodsDetailList:goodsList giftAmount:amount goodsDetailDic:detailDic]; [self.navigationController popViewControllerAnimated:YES]; } } @end