ProcurementApplyListVc.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. //
  2. // ProcurementApplyListVC.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 2018/7/23.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "ProcurementApplyListVc.h"
  9. @interface ProcurementApplyListVc (){
  10. int _pageNumber;
  11. }
  12. @end
  13. @implementation ProcurementApplyListVc
  14. #pragma mark -公共函数
  15. /**
  16. 视图加载完成函数
  17. */
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self loadNavStyle];
  21. _dataList=[[NSMutableArray alloc]init];
  22. [self initUI];
  23. _pageNumber=1;
  24. [self startLoading];
  25. [self loadData];
  26. [self initSlideSlip];
  27. }
  28. /**
  29. 安全区视图发生变化
  30. */
  31. -(void)viewSafeAreaInsetsDidChange{
  32. [self.view setBackgroundColor:[UIColor whiteColor]];
  33. _vCustomTableView.frame=CGRectMake(0, 0, Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height);
  34. [super viewSafeAreaInsetsDidChange];
  35. }
  36. #pragma mark -委托函数
  37. /**
  38. 加载列表数据成功回调
  39. @param sender <#sender description#>
  40. */
  41. - (void)onLoadFinish:(ASIDownManager *)sender {
  42. // 取消进度条
  43. [self stopLoading];
  44. _vCustomTableView.mTableView.backgroundView = nil;
  45. // 服务器返回数据
  46. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  47. // 服务器返回数据状态值
  48. int iStatus = resultModel.status;
  49. int iNewCount=0;
  50. // 服务器返回数据消息
  51. NSString *message = resultModel.message;
  52. // 服务器返回数据状态值正确
  53. if (iStatus == 0) {
  54. // 返回结果
  55. NSDictionary *infoDic = (NSDictionary *)resultModel.result;
  56. // 是否有数据
  57. if(infoDic != nil)
  58. {
  59. NSArray *infoArray=[infoDic objectForKey:@"Table"];
  60. if(infoArray!=nil&&infoArray.count>0){
  61. for(int i=0;i<infoArray.count;i++){
  62. NSDictionary *infoDic=[infoArray objectAtIndex:i];
  63. ProcurementApplyListModel *model = [ProcurementApplyListModel dk_modelWithDictionary:infoDic];
  64. [_dataList addObject:model];
  65. }
  66. iNewCount =(int)infoArray.count;
  67. _vCustomTableView.mbMoreHidden = (iNewCount == 0);
  68. [_vCustomTableView FinishLoading];
  69. [_vCustomTableView reloadData];
  70. }
  71. else{
  72. [_vCustomTableView FinishLoading];
  73. _vCustomTableView.mbMoreHidden = YES;
  74. _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  75. // 未找到匹配结果
  76. if(_dataList == nil || _dataList.count == 0){
  77. _vCustomTableView.mTableView.backgroundView = [self noDataViewByFrame:_vCustomTableView.bounds];
  78. [self showAlertViewBackText:@"未找到匹配结果"];
  79. }
  80. }
  81. }
  82. }
  83. // 服务器返回数据状态值异常
  84. else if(iStatus == ActionResultStatusAuthError
  85. ||iStatus == ActionResultStatusNoLogin
  86. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  87. [_vCustomTableView FinishLoading];
  88. _vCustomTableView.mbMoreHidden = YES;
  89. [self showReLoginDialog:message];
  90. }
  91. else{
  92. [_vCustomTableView FinishLoading];
  93. _vCustomTableView.mbMoreHidden = YES;
  94. [self showAlertViewText:message];
  95. return;
  96. }
  97. }
  98. /**
  99. 加载数据失败回调
  100. @param sender <#sender description#>
  101. */
  102. - (void)onLoadFail:(ASIDownManager *)sender {
  103. [self stopLoading];
  104. [self showAlertViewText:@"网络异常"];
  105. }
  106. -(void)goProcurementDetail:(int)pos{
  107. self.hidesBottomBarWhenPushed=YES;
  108. ProcurementApplyListDetailVc *detailVc = [[ProcurementApplyListDetailVc alloc] init];
  109. _applyListModel= [_dataList objectAtIndex:pos];
  110. detailVc.applyId = _applyListModel.applyId;
  111. detailVc.sortType =_summaryTypeId;
  112. [self.navigationController pushViewController:detailVc animated:YES];
  113. }
  114. /**
  115. 单元格cell个数
  116. @param tableView <#tableView description#>
  117. @param section <#section description#>
  118. @return <#return value description#>
  119. */
  120. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  121. {
  122. return [_dataList count];
  123. }
  124. /**
  125. <#Description#>
  126. @param tableView <#tableView description#>
  127. @return <#return value description#>
  128. */
  129. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  130. return 1;
  131. }
  132. /**
  133. 高度
  134. @param tableView <#tableView description#>
  135. @param indexPath <#indexPath description#>
  136. @return <#return value description#>
  137. */
  138. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  139. return 246;
  140. }
  141. /**
  142. 每个单元格cell
  143. @param tableView <#tableView description#>
  144. @param indexPath <#indexPath description#>
  145. @return <#return value description#>
  146. */
  147. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  148. {
  149. static NSString *cellIdentifier = @"ProcurementApplyListCell";
  150. ProcurementApplyListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  151. if (!cell) {
  152. cell = [[ProcurementApplyListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  153. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  154. }
  155. else
  156. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  157. {
  158. while ([cell.contentView.subviews lastObject] != nil) {
  159. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  160. }
  161. }
  162. cell.delegate=self;
  163. cell.position=indexPath.row;
  164. _applyListModel= [_dataList objectAtIndex:indexPath.row];
  165. [cell setProcurementApplyListCell:_applyListModel];
  166. return cell;
  167. }
  168. /**
  169. 点击单元格事件
  170. @param tableView tableView description
  171. @param indexPath indexPath description
  172. */
  173. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  174. {
  175. self.hidesBottomBarWhenPushed=YES;
  176. ProcurementApplyDetailListVc *detailVc = [[ProcurementApplyDetailListVc alloc] init];
  177. _applyListModel= [_dataList objectAtIndex:indexPath.row];
  178. detailVc.applyListModel=_applyListModel;
  179. [self.navigationController pushViewController:detailVc animated:YES];
  180. }
  181. #pragma mark - scrollView回调
  182. /**
  183. 显示下拉更新
  184. @param scrollView <#scrollView description#>
  185. */
  186. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  187. if (scrollView.isDragging) {//显示下拉更新
  188. if (_vCustomTableView.mRefreshHeader.state == PullRefreshPulling && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && [_vCustomTableView CanRefresh]) {
  189. [_vCustomTableView.mRefreshHeader setState:PullRefreshNormal];
  190. }
  191. else if (_vCustomTableView.mRefreshHeader.state == PullRefreshNormal && scrollView.contentOffset.y < -65.0f && [_vCustomTableView CanRefresh]) {//显示松开更新
  192. [_vCustomTableView.mRefreshHeader setState:PullRefreshPulling];
  193. }
  194. }
  195. }
  196. /**
  197. 取消刷新
  198. @param sender sender description
  199. @return return value description
  200. */
  201. - (BOOL)CanRefreshTableView:(RefreshTableView *)sender {
  202. return YES;
  203. }
  204. /**
  205. 加载更多
  206. @param sender sender description
  207. */
  208. - (void)LoadMoreList:(RefreshTableView *)sender {
  209. _pageNumber++;
  210. [self startLoading];
  211. [self loadData];
  212. }
  213. /**
  214. 下拉刷新
  215. @param sender <#sender description#>
  216. */
  217. - (void)ReloadList:(RefreshTableView *)sender{
  218. _pageNumber = 1;
  219. [_dataList removeAllObjects];
  220. [_vCustomTableView reloadData];
  221. _vCustomTableView.mbMoreHidden=YES;
  222. [self startLoading];
  223. [self loadData];
  224. }
  225. #pragma mark -私有函数
  226. /**
  227. 导航按钮样式
  228. */
  229. - (void)loadNavStyle {
  230. self.navigationItem.title = @"请购总表";
  231. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  232. [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
  233. [button addTarget:self action:@selector(goBack)
  234. forControlEvents:UIControlEventTouchUpInside];
  235. button.frame = CGRectMake(0, 0,45,22);
  236. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  237. self.navigationItem.leftBarButtonItem = menuButton;
  238. // 右边
  239. UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 42, 12)];
  240. UIButton *btnfilter = [UIButton buttonWithType:UIButtonTypeCustom];
  241. [btnfilter addTarget:self action:@selector(search)
  242. forControlEvents:UIControlEventTouchUpInside];
  243. btnfilter.frame = CGRectMake(0, 0,16, 16);
  244. [btnfilter setTitleColor:NavBarItemColor forState:UIControlStateNormal];
  245. [btnfilter setBackgroundImage:[UIImage imageNamed:@"icon_filter_white"]
  246. forState:UIControlStateNormal];
  247. [v addSubview:btnfilter];
  248. UIButton *filterLbl = [[UIButton alloc]init];
  249. filterLbl.frame=CGRectMake(CGRectGetMaxX(btnfilter.frame)+3,0,28, 16);
  250. [filterLbl setTitle:@"筛选" forState:UIControlStateNormal];
  251. [filterLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  252. filterLbl.titleLabel.font = [UIFont systemFontOfSize:ButtonFontOfSize];
  253. [filterLbl addTarget:self action:@selector(search)
  254. forControlEvents:UIControlEventTouchUpInside];
  255. [v addSubview:filterLbl];
  256. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:v];
  257. self.navigationItem.rightBarButtonItem = menubtnAdd;
  258. }
  259. /**
  260. 初始化UI
  261. */
  262. -(void)initUI
  263. {
  264. _vCustomTableView = [[RefreshTableView alloc]
  265. initWithFrame:CGRectMake(0,0,
  266. self.view.frame.size.width,
  267. Screen_Height)];
  268. _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  269. _vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  270. _vCustomTableView.backgroundColor = [UIColor whiteColor];
  271. _vCustomTableView.delegate = self;
  272. [self.view addSubview:_vCustomTableView];
  273. self.vCustomTableView.mTableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 49, 0);
  274. }
  275. /**
  276. 加载数据源
  277. */
  278. -(void)loadData
  279. {
  280. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  281. [dict setObject:@"GetProcurementApplyReportIphone" forKey:@"Action"];
  282. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  283. [dict setObject:kkUserCode forKey:@"UserCode"];
  284. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  285. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  286. [dict setObject:[NSString stringWithFormat:@"%d",_pageNumber] forKey:@"PageNum"];
  287. [dict setObject:[NSString stringWithFormat:@"%d",pageSize] forKey:@"PageSize"];
  288. [dict setObject:_applyNo == nil?@"":_applyNo forKey:@"ApplyNo"];
  289. [dict setObject:_applyTitle == nil?@"":_applyTitle forKey:@"ApplyTitle"];
  290. [dict setObject:_customerCode == nil?@"":_customerCode forKey:@"CustomerCode"];
  291. [dict setObject:_customerName == nil?@"":_customerName forKey:@"CustomerName"];
  292. [dict setObject:_applierId == nil?@"":_applierId forKey:@"Applicant"];
  293. [dict setObject:_organizationCode==nil?@"":_organizationCode forKey:@"ApplyOrganizationCode"];
  294. [dict setObject:_sStartDate == nil?@"":_sStartDate forKey:@"AccountDateFrom"];
  295. [dict setObject:_sEndDate == nil?@"":_sEndDate forKey:@"AccountDateTo"];
  296. [dict setObject:_summaryTypeId == nil?@"":_summaryTypeId forKey:@"SortType"];
  297. _downManager = [[ASIDownManager alloc] init];
  298. _downManager.delegate = self;
  299. _downManager.onRequestSuccess = @selector(onLoadFinish:);
  300. _downManager.onRequestFail = @selector(onLoadFail:);
  301. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  302. }
  303. /**
  304. 抽屉初始化
  305. */
  306. - (void)initSlideSlip{
  307. // 抽屉对象
  308. __weak typeof(self) weakself=self;
  309. self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
  310. for (SideSlipModel *model in dataList) {
  311. model.selectedItemList = nil;
  312. model.customDict = nil;
  313. }
  314. } commitBlock:^(NSArray *dataList) {
  315. // 查询条件
  316. SideSlipModel *model = dataList[0];
  317. ProcurementApplySearchModel *searchModel = [model.customDict objectForKey:PROCUREMENT_APPLY_SEARCH_RANGE_MODEL];
  318. _applyNo=searchModel.applyNo;
  319. _applyTitle=searchModel.applyTitle;
  320. _customerCode=searchModel.customerCode;
  321. _customerName=searchModel.customerName;
  322. _organizationCode=searchModel.organizationCode;
  323. _applierId=searchModel.applierId;
  324. _sStartDate=searchModel.startDate;
  325. _sEndDate=searchModel.endDate;
  326. _summaryTypeId=searchModel.summaryTypeId;
  327. _pageNumber=1;
  328. if(_dataList!=nil&&_dataList.count>0){
  329. [_dataList removeAllObjects];
  330. [_vCustomTableView reloadData];
  331. }
  332. [self startLoading];
  333. [self loadData];
  334. [weakself.filterController dismiss];
  335. }];
  336. _filterController.animationDuration = AnimationDuration;
  337. _filterController.hasHeadView = YES;
  338. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  339. _filterController.dataList = [self packageDataList];
  340. }
  341. /**
  342. 数据源
  343. @return <#return value description#>
  344. */
  345. - (NSArray *)packageDataList {
  346. NSMutableArray *dataArray = [NSMutableArray array];
  347. SideSlipModel *model = [[SideSlipModel alloc] init];
  348. model.containerCellClass = @"ProcurementApplySearchCell";
  349. model.regionTitle = @"查询条件";
  350. [dataArray addObject:model];
  351. return [dataArray mutableCopy];
  352. }
  353. /**
  354. 打开抽屉
  355. */
  356. -(void)search{
  357. [_filterController show];
  358. }
  359. @end