| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- //
- // ProcurementApplyListVC.m
- // IBOSS
- //
- // Created by guan hong hou on 2018/7/23.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "ProcurementApplyListVc.h"
- @interface ProcurementApplyListVc (){
- int _pageNumber;
- }
- @end
- @implementation ProcurementApplyListVc
- #pragma mark -公共函数
- /**
- 视图加载完成函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self loadNavStyle];
- _dataList=[[NSMutableArray alloc]init];
- [self initUI];
- _pageNumber=1;
- [self startLoading];
- [self loadData];
- [self initSlideSlip];
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- [self.view setBackgroundColor:[UIColor whiteColor]];
- _vCustomTableView.frame=CGRectMake(0, 0, Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height);
- [super viewSafeAreaInsetsDidChange];
- }
- #pragma mark -委托函数
- /**
- 加载列表数据成功回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFinish:(ASIDownManager *)sender {
-
- // 取消进度条
- [self stopLoading];
- _vCustomTableView.mTableView.backgroundView = nil;
- // 服务器返回数据
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- int iNewCount=0;
- // 服务器返回数据消息
- NSString *message = resultModel.message;
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- // 返回结果
- NSDictionary *infoDic = (NSDictionary *)resultModel.result;
- // 是否有数据
- if(infoDic != nil)
- {
- NSArray *infoArray=[infoDic objectForKey:@"Table"];
- if(infoArray!=nil&&infoArray.count>0){
- for(int i=0;i<infoArray.count;i++){
- NSDictionary *infoDic=[infoArray objectAtIndex:i];
- ProcurementApplyListModel *model = [ProcurementApplyListModel dk_modelWithDictionary:infoDic];
- [_dataList addObject:model];
- }
- iNewCount =(int)infoArray.count;
- _vCustomTableView.mbMoreHidden = (iNewCount == 0);
- [_vCustomTableView FinishLoading];
- [_vCustomTableView reloadData];
- }
- else{
- [_vCustomTableView FinishLoading];
- _vCustomTableView.mbMoreHidden = YES;
- _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- // 未找到匹配结果
- if(_dataList == nil || _dataList.count == 0){
- _vCustomTableView.mTableView.backgroundView = [self noDataViewByFrame:_vCustomTableView.bounds];
- [self showAlertViewBackText:@"未找到匹配结果"];
- }
- }
-
-
- }
-
- }
-
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
- [_vCustomTableView FinishLoading];
- _vCustomTableView.mbMoreHidden = YES;
- [self showReLoginDialog:message];
- }
- else{
- [_vCustomTableView FinishLoading];
- _vCustomTableView.mbMoreHidden = YES;
- [self showAlertViewText:message];
- return;
- }
- }
- /**
- 加载数据失败回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self stopLoading];
- [self showAlertViewText:@"网络异常"];
- }
- -(void)goProcurementDetail:(int)pos{
- self.hidesBottomBarWhenPushed=YES;
- ProcurementApplyListDetailVc *detailVc = [[ProcurementApplyListDetailVc alloc] init];
- _applyListModel= [_dataList objectAtIndex:pos];
- detailVc.applyId = _applyListModel.applyId;
- detailVc.sortType =_summaryTypeId;
- [self.navigationController pushViewController:detailVc animated:YES];
- }
- /**
- 单元格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 246;
-
- }
- /**
- 每个单元格cell
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellIdentifier = @"ProcurementApplyListCell";
- ProcurementApplyListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
- if (!cell) {
- cell = [[ProcurementApplyListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
- cell.delegate=self;
- cell.position=indexPath.row;
- _applyListModel= [_dataList objectAtIndex:indexPath.row];
- [cell setProcurementApplyListCell:_applyListModel];
- return cell;
- }
- /**
- 点击单元格事件
-
- @param tableView tableView description
- @param indexPath indexPath description
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- self.hidesBottomBarWhenPushed=YES;
- ProcurementApplyDetailListVc *detailVc = [[ProcurementApplyDetailListVc alloc] init];
- _applyListModel= [_dataList objectAtIndex:indexPath.row];
- detailVc.applyListModel=_applyListModel;
- [self.navigationController pushViewController:detailVc animated:YES];
-
- }
- #pragma mark - scrollView回调
- /**
- 显示下拉更新
-
- @param scrollView <#scrollView description#>
- */
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- if (scrollView.isDragging) {//显示下拉更新
-
- if (_vCustomTableView.mRefreshHeader.state == PullRefreshPulling && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && [_vCustomTableView CanRefresh]) {
- [_vCustomTableView.mRefreshHeader setState:PullRefreshNormal];
- }
- else if (_vCustomTableView.mRefreshHeader.state == PullRefreshNormal && scrollView.contentOffset.y < -65.0f && [_vCustomTableView CanRefresh]) {//显示松开更新
- [_vCustomTableView.mRefreshHeader setState:PullRefreshPulling];
- }
- }
- }
- /**
- 取消刷新
-
- @param sender sender description
- @return return value description
- */
- - (BOOL)CanRefreshTableView:(RefreshTableView *)sender {
- return YES;
- }
- /**
- 加载更多
-
- @param sender sender description
- */
- - (void)LoadMoreList:(RefreshTableView *)sender {
- _pageNumber++;
- [self startLoading];
- [self loadData];
- }
- /**
- 下拉刷新
-
- @param sender <#sender description#>
- */
- - (void)ReloadList:(RefreshTableView *)sender{
- _pageNumber = 1;
- [_dataList removeAllObjects];
- [_vCustomTableView reloadData];
- _vCustomTableView.mbMoreHidden=YES;
- [self startLoading];
- [self loadData];
- }
- #pragma mark -私有函数
- /**
- 导航按钮样式
- */
- - (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;
-
- }
- /**
- 初始化UI
- */
- -(void)initUI
- {
- _vCustomTableView = [[RefreshTableView alloc]
- initWithFrame:CGRectMake(0,0,
- self.view.frame.size.width,
- Screen_Height)];
-
- _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _vCustomTableView.backgroundColor = [UIColor whiteColor];
- _vCustomTableView.delegate = self;
-
- [self.view addSubview:_vCustomTableView];
- self.vCustomTableView.mTableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 49, 0);
- }
- /**
- 加载数据源
- */
- -(void)loadData
- {
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetProcurementApplyReportIphone" 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:[NSString stringWithFormat:@"%d",_pageNumber] forKey:@"PageNum"];
- [dict setObject:[NSString stringWithFormat:@"%d",pageSize] forKey:@"PageSize"];
- [dict setObject:_applyNo == nil?@"":_applyNo forKey:@"ApplyNo"];
- [dict setObject:_applyTitle == nil?@"":_applyTitle forKey:@"ApplyTitle"];
- [dict setObject:_customerCode == nil?@"":_customerCode forKey:@"CustomerCode"];
- [dict setObject:_customerName == nil?@"":_customerName forKey:@"CustomerName"];
- [dict setObject:_applierId == nil?@"":_applierId forKey:@"Applicant"];
- [dict setObject:_organizationCode==nil?@"":_organizationCode forKey:@"ApplyOrganizationCode"];
- [dict setObject:_sStartDate == nil?@"":_sStartDate forKey:@"AccountDateFrom"];
- [dict setObject:_sEndDate == nil?@"":_sEndDate forKey:@"AccountDateTo"];
- [dict setObject:_summaryTypeId == nil?@"":_summaryTypeId forKey:@"SortType"];
-
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onLoadFinish:);
- _downManager.onRequestFail = @selector(onLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- /**
- 抽屉初始化
- */
- - (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 *model = dataList[0];
- ProcurementApplySearchModel *searchModel = [model.customDict objectForKey:PROCUREMENT_APPLY_SEARCH_RANGE_MODEL];
- _applyNo=searchModel.applyNo;
- _applyTitle=searchModel.applyTitle;
- _customerCode=searchModel.customerCode;
- _customerName=searchModel.customerName;
- _organizationCode=searchModel.organizationCode;
- _applierId=searchModel.applierId;
- _sStartDate=searchModel.startDate;
- _sEndDate=searchModel.endDate;
- _summaryTypeId=searchModel.summaryTypeId;
- _pageNumber=1;
- if(_dataList!=nil&&_dataList.count>0){
- [_dataList removeAllObjects];
- [_vCustomTableView reloadData];
- }
- [self startLoading];
- [self loadData];
- [weakself.filterController dismiss];
-
- }];
- _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 = @"ProcurementApplySearchCell";
- model.regionTitle = @"查询条件";
- [dataArray addObject:model];
- return [dataArray mutableCopy];
- }
- /**
- 打开抽屉
- */
- -(void)search{
- [_filterController show];
- }
- @end
|