| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653 |
- //
- // SingleProfitViewController.m
- // IBOSS
- //
- // Created by apple on 2017/5/15.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:每单利润表控制器
- //
- #import "SingleProfitViewController.h"
- #import "SingleProfitDetailViewController.h"
- #import "SingleProfitSearchModel.h"
- #import "SingleProfitCell.h"
- #import "DateFormat.h"
- @interface SingleProfitViewController ()<UITableViewDelegate,UITableViewDataSource>{
-
- //TableView对象
- UITableView *_vTableView;
- // 头信息view
- UIView *_headView;
- }
- /**
- 原始数据源
- */
- @property (strong,nonatomic) NSMutableArray *arrDataList;
- /**
- 原始数据源
- */
- @property (strong,nonatomic) NSMutableArray *arrDataNewList;
- /**
- 请求数据对象
- */
- @property (nonatomic,strong) ASIDownManager *downManager;
- @end
- static CGFloat headerH = 188;
- @implementation SingleProfitViewController
- #pragma mark - 公共函数
- /**
- viewDidLoad函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- //[self showTitle:@"每单利润表"];
- [self loadNavStyle];
- [self initUI];
- [self initSlideSlip];
- [self defaultInterfaceRequest];
- // UIView *view = [self backGroundPromptViewByFrame:_vTableView.bounds promptStr:@"请筛选后查询"];
- // _vTableView.tableHeaderView = nil;
- // _vTableView.backgroundView = view;
- // [self reloadData];
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- CGRect tblVFrame = self.view.safeAreaLayoutGuide.layoutFrame;
- tblVFrame.origin.y = headerH;
- _vTableView.frame=tblVFrame;
- //修改tableView尺寸(2019-06-10 yesen)
- // _vTableView.frame=self.view.safeAreaLayoutGuide.layoutFrame;
- [super viewSafeAreaInsetsDidChange];
- }
- #pragma mark - 数据源list属性
- /**
- 原始数据源
-
- @return <#return value description#>
- */
- - (NSMutableArray *)arrDataList{
- if(_arrDataList == nil){
- _arrDataList = [[NSMutableArray alloc]init];
- }
- return _arrDataList;
-
- }
- /**
- 新数据源
-
- @return <#return value description#>
- */
- - (NSMutableArray *)arrDataNewList{
- if(_arrDataNewList == nil){
- _arrDataNewList = [[NSMutableArray alloc]init];
- }
- return _arrDataNewList;
-
- }
- #pragma mark 委托接口回调函数
- /**
- 调用接口成功回调
-
- @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.tableHeaderView = nil;
- _vTableView.backgroundView = nil;
-
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- // 服务器返回数据结果
- NSArray *approvArr = (NSArray *)resultModel.result;
- [self.arrDataList removeAllObjects];
- [self.arrDataNewList removeAllObjects];
- // 是否有数据
- if(approvArr != nil && approvArr.count > 0)
- {
- [self.arrDataList addObjectsFromArray:approvArr];
-
- double totalCostValue = 0.0;
- double totalIncometValue = 0.0;
- double totalProfitValue = 0.0;
- // 合计信息
- for (int i = 0; i < self.arrDataList.count; i++) {
- NSDictionary *dicValue = self.arrDataList[i];
- // 去除空数据
- if ([[dicValue objectForKey:@"InvoiceID"] intValue]>0) {
- // _vTableView.tableHeaderView = _headView;
- [self.arrDataNewList addObject:self.arrDataList[i]];
- totalCostValue+= [[dicValue objectForKey:@"CostAmount"] doubleValue];
- totalProfitValue+= [[dicValue objectForKey:@"MarginAmount"] doubleValue];
- totalIncometValue+= [[dicValue objectForKey:@"Amount"] doubleValue];
- }
-
- }
- if(self.arrDataNewList.count == 0){
- [self showNoData];
- }
- // 合计信息
- self.lbtotalCostValue.text =[Util positiveFormat:[NSString stringWithFormat:@"%.2f",totalCostValue]];
- self.lbtotalIncometValue.text = [Util positiveFormat:[NSString stringWithFormat:@"%.2f",totalIncometValue]];
- self.lbtotalProfitValue.text =[Util positiveFormat:[NSString stringWithFormat:@"%.2f",totalProfitValue]];
- }
- else
- {
- [self showNoData];
- }
- // 属性数据源
- [_vTableView reloadData];
- }
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
- [self showReLoginDialog:message];
- }
- else {
- [_vTableView reloadData];
- [self showAlertViewText:message];
- }
- }
- -(void) showNoData{
- // 无数据的view
- UIView *noDataView = [self noDataViewByFrame:_vTableView.bounds];
- // 有刷新数据的时候
- _vTableView.backgroundView = noDataView;
- _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- [self showAlertViewBackText:@"未找到匹配结果"];
- }
- /**
- 调用接口失败回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [_vTableView reloadData];
- [self showAlertViewText:@"网络异常"];
- }
- #pragma mark 委托tablview回调函数
- /**
- 行数
-
- @param tableView tableView description
- @param section section description
- @return return value description
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [self.arrDataNewList count];
- }
- /**
- Sections数
-
- @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 185;
- }
- /**
- 单元格
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"SingleProfitCell";
- SingleProfitCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[SingleProfitCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- // SingleProfitCell *cell = [[ SingleProfitCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SingleProfitCell"];
- NSDictionary *dic = self.arrDataNewList[indexPath.row];
- if(dic != nil)
- {
- cell.lblValueCustomerName.text = [dic objectForKey:@"CustomerName"];
- // 格式化日期
- DateFormat *df = [DateFormat new];
- cell.lblValueCreateTime.text = [df dateFormat:[dic objectForKey:@"AccountDate"]];
- //业务类型
- cell.lblValueCustomerType.text = [dic objectForKey:@"InvoiceTypeName"];
- cell.lblValueStaff.text = [dic objectForKey:@"StaffName"];
- cell.lblValueOrg.text = [dic objectForKey:@"OrganizationName"];
-
- double amountValue= [[dic objectForKey:@"Amount"]doubleValue];
- NSString *amountStr= [NSString stringWithFormat:@"%.2f",amountValue];
- amountStr= [Util positiveFormat:amountStr];
- double costValue= [[dic objectForKey:@"CostAmount"]doubleValue];
- NSString *costStr= [NSString stringWithFormat:@"%.2f",costValue];
- costStr=[Util positiveFormat:costStr];
- double marginAmountValue= [[dic objectForKey:@"MarginAmount"]doubleValue];
- NSString *marginAmountStr= [NSString stringWithFormat:@"%.2f",marginAmountValue];
- marginAmountStr=[Util positiveFormat:marginAmountStr];
- NSString *str = [NSString stringWithFormat:@"收入%@;成本:%@;毛利:%@",amountStr,costStr,marginAmountStr];
- cell.lblValueIncomeAndCostAndProfit.text = str;
- }
- return cell;
- }
- /**
- 单元格选择事件
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSDictionary *dic = self.arrDataNewList[indexPath.row];
- if(dic != nil)
- {
- self.hidesBottomBarWhenPushed=YES;
- SingleProfitDetailViewController *detailVC = [[SingleProfitDetailViewController alloc]init];
- detailVC.sInvoiceNo = [dic objectForKey:@"InvoiceNo"];
- detailVC.sInvoiceType = [dic objectForKey:@"InvoiceTypeName"];
- detailVC.sOrganizationCode = [dic objectForKey:@"OrganizationCode"];
- detailVC.sCustomerCode = [dic objectForKey:@"CustomerCode"];
- detailVC.sTelephone = [dic objectForKey:@"Telephone"];
- detailVC.sCustomerAddress = [dic objectForKey:@"CustomerAddress"];
- detailVC.sChannelName = [dic objectForKey:@"ChannelName"];
- detailVC.sRemarks = [dic objectForKey:@"Remarks"];
- detailVC.sCustomerName = [dic objectForKey:@"CustomerName"];
-
- // 格式化日期
- DateFormat *df = [DateFormat new];
- detailVC.sAccountDate = [df dateFormat:[dic objectForKey:@"AccountDate"]];
- detailVC.sCustomerTypeName = [dic objectForKey:@"CustomerTypeName"];
- detailVC.sStaffName = [dic objectForKey:@"StaffName"];
- detailVC.sOrganizationName = [dic objectForKey:@"OrganizationName"];
- detailVC.sMarginAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"MarginAmount"]floatValue]];
- detailVC.sIncomeAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"Amount"]floatValue]];
- detailVC.sCostAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"CostAmount"]floatValue]];;
- detailVC.sCustomerAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"CustomerAmount"]floatValue]];;
- detailVC.sStaffAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"StaffAmount"]floatValue]];;
- detailVC.sServiceAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"ServiceAmount"]floatValue]];;
- detailVC.sFeesAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"FeesAmount"]floatValue]];;
- detailVC.sProfitAmount = [NSString stringWithFormat:@"¥%.2f",[[dic objectForKey:@"ProfitAmount"]floatValue]];;
-
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- }
- #pragma mark - 私有函数
- /**
- 初始化ui
- */
- - (void)initUI {
- CGFloat height = 188;
- self.navigationItem.title = @"每单利润表";
- self.view.backgroundColor = [UIColor whiteColor];
-
- //分割线
- UIView *viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, 0, Screen_Width, 0);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [self.view addSubview:viewBackgroud];
-
- _vTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,height, Screen_Width, Screen_Height - 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];
- //头布局
- _headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, height)];
- [self.view addSubview:_headView];
- UIButton *btnHead = [UIButton buttonWithType:UIButtonTypeCustom];
- btnHead.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- CGFloat titleHeight = 46;
- 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];
-
- //分割线
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotal.frame), Screen_Width, heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [_headView addSubview:viewBackgroud];
-
- //收入总额 —————————
- UIView *vtotalIncome = [UIView new];
- vtotalIncome.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
- [_headView addSubview:vtotalIncome];
-
- UIImageView *imgview = [UIImageView new];
- imgview.frame=CGRectMake(lblx, valuey+5, 21, 16);
- [imgview setImage:[UIImage imageNamed:@"profit_income"]];
- [vtotalIncome addSubview:imgview];
-
- UILabel *lbtotalReceipt = [UILabel new];
- lbtotalReceipt.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+5, valuey, lblwidth, valueheight);
- lbtotalReceipt.font = [UIFont systemFontOfSize:fontsize];
- lbtotalReceipt.text = @"收入";
- [vtotalIncome addSubview:lbtotalReceipt];
-
- self.lbtotalIncometValue = [UILabel new];
- self.lbtotalIncometValue.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
- self.lbtotalIncometValue.font = [UIFont systemFontOfSize:fontsize];
- //lbtotalIncometValue = @"¥0";
- self.lbtotalIncometValue.textAlignment = NSTextAlignmentRight;
- [vtotalIncome addSubview:self.lbtotalIncometValue];
-
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalIncome.frame), Screen_Width, heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [_headView addSubview:viewBackgroud];
-
- //成本总额 —————————
- UIView *vtotalCost = [UIView new];
- vtotalCost.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
- [_headView addSubview:vtotalCost];
- UIImageView *imgviewReceivable = [UIImageView new];
- imgviewReceivable.frame=CGRectMake(lblx, valuey+1, 20, 20);
- [imgviewReceivable setImage:[UIImage imageNamed:@"profit_cost"]];
- [vtotalCost addSubview:imgviewReceivable];
-
- UILabel *lbtotalReceivable = [UILabel new];
- lbtotalReceivable.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey, lblwidth, valueheight);
- lbtotalReceivable.font = [UIFont systemFontOfSize:fontsize];
- lbtotalReceivable.text = @"成本";
- [vtotalCost addSubview:lbtotalReceivable];
-
- self.lbtotalCostValue = [UILabel new];
- self.lbtotalCostValue.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
- self.lbtotalCostValue.font = [UIFont systemFontOfSize:fontsize];
- //lbtotalCostValue = @"¥0";
- self.lbtotalCostValue.textAlignment = NSTextAlignmentRight;
- [vtotalCost addSubview:self.lbtotalCostValue];
-
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalCost.frame), Screen_Width,heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [_headView addSubview:viewBackgroud];
-
- // —————————
- UIView *vtotalProfit = [UIView new];
- vtotalProfit.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight);
- [_headView addSubview:vtotalProfit];
- UIImageView *imgviewProfit = [UIImageView new];
- imgviewProfit.frame=CGRectMake(lblx, valuey+1, 20, 20);
- [imgviewProfit setImage:[UIImage imageNamed:@"profit_value"]];
- [vtotalProfit addSubview:imgviewProfit];
-
- UILabel *lbtotalProfit = [UILabel new];
- lbtotalProfit.frame=CGRectMake(CGRectGetMaxX(imgviewReceivable.frame)+5, valuey, lblwidth, valueheight);
- lbtotalProfit.font = [UIFont systemFontOfSize:fontsize];
- lbtotalProfit.text = @"毛利";
- [vtotalProfit addSubview:lbtotalProfit];
-
- self.lbtotalProfitValue = [UILabel new];
- self.lbtotalProfitValue.frame=CGRectMake(Screen_Width - valuewidth - lblx, valuey, valuewidth, valueheight);
- self.lbtotalProfitValue.font = [UIFont systemFontOfSize:fontsize];
- //lbtotalProfitValue = @"¥0";
- self.lbtotalProfitValue.textAlignment = NSTextAlignmentRight;
- [vtotalProfit addSubview:self.lbtotalProfitValue];
-
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalProfit.frame), Screen_Width, 10);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- //[headView addSubview:viewBackgroud];
-
- viewBackgroud = [UIView new];
- viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vtotalProfit.frame), Screen_Width, heightLine);
- viewBackgroud.backgroundColor = LineBackgroundColor;
- [_headView addSubview:viewBackgroud];
-
- _headView.frame = CGRectMake(0, 0, Screen_Width, CGRectGetMaxY(vtotalProfit.frame));
-
- //头部改为固定 2019-06-10 (yesen)
- // _vTableView.tableHeaderView = _headView;
-
- //开始结束日期 初始值
- // 格式化日期
- // NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- // [dateFormatter setDateFormat:@"yyyy-MM-dd"];
- // NSTimeInterval time = 366 * 24 * 60 * 60; //31天的秒数
- // self.sEndDate = [dateFormatter stringFromDate:[NSDate new]];
- // self.sStartDate = [dateFormatter stringFromDate: [[NSDate new] dateByAddingTimeInterval:-time]];
- }
- /**
- 进度条隐藏
- */
- - (void)cancel {
- [self stopLoading];
- }
- - (void)defaultInterfaceRequest{
- //NSString *startDateStr = [DateFormat getDateBefore:365];
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"YYYY-MM-dd"];
- NSString *endDateStr = [DateFormat getCurrentDate];
-
- NSDate *currentDate = [NSDate date];
-
- NSDate *startDate = [DateFormat getPriorLaterDateFromDate:currentDate withMonth:-12];
- self.sStartDate = [dateFormatter stringFromDate:startDate];
-
- self.sEndDate = endDateStr;
- self.sBusinessType=@"7";
- [self reloadData];
- }
- /**
- 加载数据
- */
- - (void)reloadData
- {
- [self startLoading];
- NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
-
- [dict setObject:@"GetSingleProfitIphone" 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:self.sBusinessType forKeyedSubscript:@"BusinessType"];
- [dict setObject:self.sOrgCode forKeyedSubscript:@"OrganizationCode"];
- [dict setObject:self.sStaffName forKeyedSubscript:@"StaffName"];
- [dict setObject:self.sStartDate forKeyedSubscript:@"AccountDateFrom"];
- [dict setObject:self.sEndDate forKeyedSubscript:@"AccountDateTo"];
- [dict setObject:self.sCustomerName forKeyedSubscript:@"CustomerName"];
- [dict setObject:self.sCustomerAddress forKeyedSubscript:@"Address"];
- [dict setObject:self.sCustomerCode forKeyedSubscript:@"CustomerCode"];
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onLoadFinish:);
- _downManager.onRequestFail = @selector(onLoadFail:);
- [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- /**
- 返回
- */
- - (void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- /**
- 导航按钮样式
- */
- - (void)loadNavStyle
- {
- //右边
- UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 42, 16)];
-
- 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;
-
- //返回
- 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;
- }
- /**
- 抽屉弹出
- */
- - (void)search{
- [_filterController show];
- }
- /**
- 抽屉初始化
- */
- - (void)initSlideSlip{
- // 抽屉对象
- __weak typeof(self) weakself=self;
- self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
- for (SideSlipModel *model in dataList) {
-
- //selectedItem
- model.selectedItemList = nil;
- model.customDict = nil;
- }
- } commitBlock:^(NSArray *dataList) {
- // 查询条件
- SideSlipModel *serviceRegionModel = dataList[0];
- SingleProfitSearchModel *m = [serviceRegionModel.customDict objectForKey:SINGLE_PROFIT_SEARCH_RANGE_MODEL];
- //NSLog(@"%@--%@--%@--%@--%@",m.startDate,m.endDate,m.sCustomerName,m.sOrg,m.sStaff);
- self.sOrgCode = m.sOrg;
- self.sStaffName = m.sStaff;
- self.sStartDate = m.sStartDate;
- self.sEndDate = m.sEndDate;
- self.sCustomerName = m.sCustomerName;
- self.sCustomerCode=m.sCustomerCode;
- self.sCustomerAddress=m.sCustomerAddress;
- self.sBusinessType=m.sBusinessType;
- if(self.sStartDate == nil || self.sStartDate.length == 0){
- [self showAlertViewText:@"请选择开始日期"];
- return;
- }
- if(self.sEndDate == nil || self.sEndDate.length == 0){
- [self showAlertViewText:@"请选择结束日期"];
- return;
- }
- NSUInteger result= [DateFormat compareDate:self.sStartDate withDate:self.sEndDate];
- if(result == -1){
- [self showAlertViewText:@"开始日期不能大于结束日期"];
- return;
- }
- // NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];
- // [dateFormat setDateFormat:@"yyyy-MM-dd"];//设定时间格式,这里可以设置成自己需要的格式
- //
- // NSDate *startD = [dateFormat dateFromString:self.sStartDate];
- // NSDate *endD = [dateFormat dateFromString:self.sEndDate];
- // NSInteger days= [DateFormat calculateDaysFromBegin:startD end:endD];
- //
- // 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 = @"SingleProfitSearchCell";
- model.regionTitle = @"查询条件";
-
- [dataArray addObject:model];
- return [dataArray mutableCopy];
- }
- @end
|