| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- //
- // 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<resultArray.count;i++)
- {
- NSDictionary *dic=[resultArray objectAtIndex:i];
- PromotionOrderModel *orderListModel=[PromotionOrderModel dk_modelWithDictionary:dic];
- [_promotionOrderList addObject:orderListModel];
-
- }
-
- [_vTableView reloadData];
- }
- }
-
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
- [self showReLoginDialog:message];
- return;
- }else {
- [self showAlertViewText:message];
- }
-
-
- }
- }
- -(void)onPromotionOrderListLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"加载失败"];
- }
- #pragma mark - 委托回调函数
- /**
- 单元格cell个数
-
- @param tableView <#tableView description#>
- @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
|