| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- //
- // OrderSalesApproveListVc.m
- // IBOSS
- //
- // Created by 关宏厚 on 2019/4/12.
- // Copyright © 2019 elongtian. All rights reserved.
- //
- #import "OrderSalesApproveListVc.h"
- @interface OrderSalesApproveListVc ()
- {
- UIView *_headView;
- }
- @end
- @implementation OrderSalesApproveListVc
- - (void)viewDidLoad {
- [super viewDidLoad];
- _dataList=[[NSMutableArray alloc]init];
- [self initSlideSlip];
- [self loadNavStyle];
- [self initUI];
- UIView *view = [self backGroundPromptViewByFrame:_vTableView.bounds promptStr:@"请筛选后查询"];
- _vTableView.tableHeaderView = nil;
- _vTableView.backgroundView = view;
-
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- _vTableView.frame = self.view.safeAreaLayoutGuide.layoutFrame;
- [super viewSafeAreaInsetsDidChange];
- }
- -(void)search{
- [_filterController show];
- }
- /**
- 导航按钮样式
- */
- - (void)loadNavStyle {
- self.navigationItem.title = @"订单销售审批报表";
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,45,22);
-
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
-
- // 右边
- UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 42, 12)];
-
- UIButton *btnfilter = [UIButton buttonWithType:UIButtonTypeCustom];
- [btnfilter addTarget:self action:@selector(search)
- forControlEvents:UIControlEventTouchUpInside];
- btnfilter.frame = CGRectMake(0, 0,16, 16);
- [btnfilter setTitleColor:NavBarItemColor forState:UIControlStateNormal];
- [btnfilter setBackgroundImage:[UIImage imageNamed:@"icon_filter_white"]
- forState:UIControlStateNormal];
- [v addSubview:btnfilter];
- UIButton *filterLbl = [[UIButton alloc]init];
- filterLbl.frame=CGRectMake(CGRectGetMaxX(btnfilter.frame)+3,0,28, 16);
- [filterLbl setTitle:@"筛选" forState:UIControlStateNormal];
- [filterLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- filterLbl.titleLabel.font = [UIFont systemFontOfSize:ButtonFontOfSize];
- [filterLbl addTarget:self action:@selector(search)
- forControlEvents:UIControlEventTouchUpInside];
- [v addSubview:filterLbl];
- UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:v];
- self.navigationItem.rightBarButtonItem = menubtnAdd;
-
- }
- -(void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)initUI
- {
- _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height )];
-
- _vTableView.rowHeight = UITableViewAutomaticDimension;
- _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vTableView.backgroundColor = [UIColor whiteColor];
- _vTableView.delegate = self;
- _vTableView.dataSource=self;
- _vTableView.tableHeaderView = nil;
- [self.view addSubview:_vTableView];
- //头布局
- CGFloat height = 170;
- _headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, height)];
- CGFloat titleHeight = 50;
- CGFloat lblx = 20;
- CGFloat lblwidth = 130;
- CGFloat fontsize = 14;
- //CGFloat valuex = 125;
- CGFloat valuey = 10;
- CGFloat valuewidth = 200;
- CGFloat valueheight = 25;
- CGFloat heightLine =1;
-
- //总合计 —————————
- UIView *vtotal = [UIView new];
- vtotal.frame=CGRectMake(0, 0, Screen_Width, titleHeight);
- [_headView addSubview:vtotal];
- UILabel *lbtotal = [UILabel new];
- lbtotal.frame=CGRectMake(lblx, valuey, lblwidth, valueheight);
- lbtotal.font = [UIFont boldSystemFontOfSize:fontsize];
- lbtotal.text = @"合计";
- [vtotal addSubview:lbtotal];
-
- //分割线
- UIView *viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotal.frame), Screen_Width, heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [_headView addSubview:viewBackgroud];
-
- //收入总额 —————————
- UIView *vtotalGoodsAmount= [UIView new];
- vtotalGoodsAmount.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
- [_headView addSubview:vtotalGoodsAmount];
-
- UIImageView *imgview = [UIImageView new];
- imgview.frame=CGRectMake(lblx, valuey+5, 21, 16);
- [imgview setImage:[UIImage imageNamed:@"profit_income"]];
- [vtotalGoodsAmount addSubview:imgview];
-
- UILabel *lbtotalGoodsAmountTitle = [UILabel new];
- lbtotalGoodsAmountTitle.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+5, valuey, lblwidth, valueheight);
- lbtotalGoodsAmountTitle.font = [UIFont systemFontOfSize:fontsize];
- lbtotalGoodsAmountTitle.text = @"货物总额";
- [vtotalGoodsAmount addSubview:lbtotalGoodsAmountTitle];
-
- self.lbtotalGoodsAmount= [UILabel new];
- self.lbtotalGoodsAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
- self.lbtotalGoodsAmount.font = [UIFont systemFontOfSize:fontsize];
-
- self.lbtotalGoodsAmount.textAlignment = NSTextAlignmentRight;
- [vtotalGoodsAmount addSubview:self.lbtotalGoodsAmount];
-
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalGoodsAmount.frame), Screen_Width, heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [_headView addSubview:viewBackgroud];
-
-
- UIView *vtotalFeesAmount = [UIView new];
- vtotalFeesAmount.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
- [_headView addSubview:vtotalFeesAmount];
-
- UIImageView *imgviewReceivable = [UIImageView new];
- imgviewReceivable.frame=CGRectMake(lblx, valuey+1, 20, 20);
- [imgviewReceivable setImage:[UIImage imageNamed:@"profit_cost"]];
- [vtotalFeesAmount addSubview:imgviewReceivable];
-
- UILabel *lbtotalFeesAmount = [UILabel new];
- lbtotalFeesAmount.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey, lblwidth, valueheight);
- lbtotalFeesAmount.font = [UIFont systemFontOfSize:fontsize];
- lbtotalFeesAmount.text = @"费用金额";
- [vtotalFeesAmount addSubview:lbtotalFeesAmount];
-
- self.lbtotalFeesAmount = [UILabel new];
- self.lbtotalFeesAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
- self.lbtotalFeesAmount.font = [UIFont systemFontOfSize:fontsize];
- self.lbtotalFeesAmount.textAlignment = NSTextAlignmentRight;
- [vtotalFeesAmount addSubview:self.lbtotalFeesAmount];
- _headView.frame = CGRectMake(0, 0, Screen_Width, CGRectGetMaxY(vtotalFeesAmount.frame));
-
- }
- /**
- 抽屉初始化
- */
- - (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:Order_SALES_APPROVE_SEARCH_MODEL];
-
- if(self->_dataList!=nil&&self->_dataList.count>0){
- [self->_dataList removeAllObjects];
- [self->_vTableView reloadData];
- }
- if([self->_searchModel.startDate isEqualToString:@"请选择开始日期"]){
- self->_searchModel.startDate=@"";
-
- }
-
- if([self->_searchModel.endDate isEqualToString:@"请选择结束日期"]){
- self->_searchModel.endDate=@"";
-
- }
- if(self->_searchModel.startDate.length>0&&self->_searchModel.endDate.length>0){
- NSUInteger result= [DateFormat compareDate:self->_searchModel.startDate withDate:self->_searchModel.endDate];
- if(result == -1){
- [self showAlertViewText:@"开始日期不能大于结束日期"];
- return;
- }
- NSDateFormatter *dateformater = [[NSDateFormatter alloc] init];
- [dateformater setDateFormat:@"yyyy-MM-dd"];
- NSDate *dta = [[NSDate alloc] init];
- NSDate *dtb = [[NSDate alloc] init];
-
- dta = [dateformater dateFromString:self->_searchModel.startDate];
-
- dtb = [dateformater dateFromString:self->_searchModel.endDate];
-
- NSInteger days=[DateFormat calculateDaysFromBegin:dta end:dtb];
- // if(days>31){
- // [self showAlertViewText:@"日期间隔不能超过31天"];
- // return;
- // }
- }
-
- [weakself.filterController dismiss];
- [self reloadData];
- }];
- _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 = @"OrderSalesApproveSearchCell";
- model.regionTitle = @"查询条件";
- [dataArray addObject:model];
- return [dataArray mutableCopy];
- }
- /**
- 加载数据
- */
- - (void)reloadData
- {
- [self startLoading];
- NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetOrderSalesAuditIphone" 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:_searchModel.invoiceNo==nil?@"":_searchModel.invoiceNo forKeyedSubscript:@"InvoiceNo"];
- [dict setObject:_searchModel.invoiceType==nil?@"0":_searchModel.invoiceType forKeyedSubscript:@"SalesFunctionID"];
-
- [dict setObject:_searchModel.reviewerName==nil?@"":_searchModel.reviewerName forKeyedSubscript:@"ReviewerName"];
-
- [dict setObject:_searchModel.customerAddress==nil?@"":_searchModel.customerAddress forKeyedSubscript:@"CustomerAddress"];
-
- [dict setObject:_searchModel.organizationCode==nil?@"":_searchModel.organizationCode forKeyedSubscript:@"OrganizationCode"];
-
- [dict setObject:_searchModel.staffId==nil?@"":_searchModel.staffId forKeyedSubscript:@"StaffID"];
-
- [dict setObject:_searchModel.startDate==nil?@"":_searchModel.startDate forKeyedSubscript:@"AccountDateFrom"];
- [dict setObject:_searchModel.endDate==nil?@"":_searchModel.endDate forKeyedSubscript:@"AccountDateTo"];
-
- [dict setObject:_searchModel.approveResult==nil?@"2":_searchModel.approveResult forKeyedSubscript:@"Result"];
-
- [dict setObject:_searchModel.customerCode==nil?@"":_searchModel.customerCode forKeyedSubscript:@"CustomerCode"];
- [dict setObject:_searchModel.customerName==nil?@"":_searchModel.customerName forKeyedSubscript:@"CustomerName"];
-
- [dict setObject:_searchModel.customerAddress==nil?@"":_searchModel.customerAddress forKeyedSubscript:@"CustomerAddress"];
-
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onLoadFinish:);
- _downManager.onRequestFail = @selector(onLoadFail:);
- [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- /**
- 调用接口成功回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFinish:(ASIDownManager *)sender {
- // 取消进度条
- [self cancel];
- // 服务器返回数据
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- NSString *message = resultModel.message;
- _vTableView.backgroundView = nil;
- _vTableView.tableHeaderView = nil;
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- NSArray *infoArray = (NSArray *)resultModel.result;
-
- if(infoArray!=nil&&infoArray.count>0){
- _vTableView.tableHeaderView=_headView;
- double totalGoodsAmountValue = 0.0;
- double totalFeesAmountValue = 0.0;
- for(int i=0;i<infoArray.count;i++){
- NSDictionary *infoDic=[infoArray objectAtIndex:i];
- OrderSalesApproveListModel *model = [OrderSalesApproveListModel dk_modelWithDictionary:infoDic];
- totalGoodsAmountValue+=[model.goodsAmount doubleValue];
- totalFeesAmountValue+=[model.feeAmount doubleValue];
- [_dataList addObject:model];
- }
-
-
- // 合计信息
- self.lbtotalGoodsAmount.text = [NSString stringWithFormat:@"¥%.2f",totalGoodsAmountValue];
- self.lbtotalFeesAmount.text = [NSString stringWithFormat:@"¥%.2f",totalFeesAmountValue];
-
- [_vTableView reloadData];
- }
-
-
- else
- {
- _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- // 未找到匹配结果
- if(_dataList == nil || _dataList.count == 0){
- _vTableView.backgroundView = [self noDataViewByFrame:_vTableView.bounds];
- [self showAlertViewBackText:@"未找到匹配结果"];
- }
- }
- }
-
-
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
-
- [self showReLoginDialog:message];
- }
- else{
- [self showAlertViewText:message];
- return;
- }
- }
- /**
- 调用接口失败回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"网络异常"];
- }
- /**
- 单元格cell个数
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_dataList 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 301;
-
- }
- /**
- 每个单元格cell
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellIdentifier = @"OrderSalesApproveListCell";
- OrderSalesApproveListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
- if (!cell) {
- cell = [[OrderSalesApproveListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
-
- OrderSalesApproveListModel *approveListModel= [_dataList objectAtIndex:indexPath.row];
- [cell setOrderSalesApproveListCell:approveListModel];
- return cell;
- }
- /**
- 点击单元格事件
-
- @param tableView tableView description
- @param indexPath indexPath description
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- self.hidesBottomBarWhenPushed=YES;
-
- OrderSalesApproveListDetailVc *detailVc = [[OrderSalesApproveListDetailVc alloc] init];
- OrderSalesApproveListModel *approveListModel= [_dataList objectAtIndex:indexPath.row];
- detailVc.approveListModel=approveListModel;
- detailVc.invoiceId= approveListModel.invoiceId;
- [self.navigationController pushViewController:detailVc animated:YES];
-
- }
- /**
- 进度条隐藏
- */
- - (void)cancel {
- [self stopLoading];
- }
- @end
|