DeliveryRequirementNoReceiptController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. //
  2. // DeliveryRequirementNoReceiptController.m
  3. // IBOSSHSH
  4. //
  5. // Created by ssl on 2018/1/12.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "DeliveryRequirementNoReceiptController.h"
  9. #import "RequirementNoReceiptCell.h"
  10. #import "NewDeliveryRequirementController.h"
  11. #import "SideSlipModel.h"
  12. #import "RequirementNoReceiptSearchModel.h"
  13. #import "DateFormat.h"
  14. #define receiptTextFont [UIFont systemFontOfSize:14]
  15. @interface DeliveryRequirementNoReceiptController ()
  16. @end
  17. @implementation DeliveryRequirementNoReceiptController
  18. #pragma mark - 公共函数
  19. /**
  20. 加载视图函数
  21. */
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. _pageNumber = 1;
  25. _dataList = [[NSMutableArray alloc]init];
  26. UIView *searchView=[[UIView alloc]init];
  27. searchView.frame=CGRectMake(0, 0, Screen_Width,55);
  28. [searchView setBackgroundColor:[UIColor whiteColor]];
  29. _btnSearch = [UIButton buttonWithType:UIButtonTypeCustom];
  30. _btnSearch.frame=CGRectMake(15, 10, Screen_Width-30, 35);
  31. [_btnSearch setTitle:@"查询" forState:UIControlStateNormal];
  32. [_btnSearch setBackgroundColor:[UIColor colorWithRed:232.0/255.0 green:233.0/255.0 blue:235.0/255.0 alpha:1]];
  33. [self.view addSubview:searchView];
  34. [searchView addSubview:_btnSearch];
  35. _btnSearch.layer.cornerRadius = 10;
  36. _btnSearch.layer.masksToBounds = YES;
  37. [_btnSearch setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
  38. _btnSearch.titleLabel.font=receiptTextFont;
  39. [_btnSearch addTarget:self action:@selector(searchUnreceiptData)
  40. forControlEvents:UIControlEventTouchUpInside];
  41. [self.view addSubview:_btnSearch];
  42. _tableView = [[RefreshTableView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(searchView.frame), self.view.frame.size.width - 20, self.view.frame.size.height-55)];
  43. _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  44. _tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  45. _tableView.backgroundColor = [UIColor clearColor];
  46. _tableView.mTableView.showsVerticalScrollIndicator = NO;
  47. _tableView.delegate = self;
  48. [self.view addSubview:_tableView];
  49. _deliveryNo=@"";
  50. _arrangementNo=@"";
  51. _customerName=@"";
  52. _startDate=@"";
  53. _endDate=@"";
  54. __weak typeof(self) weakself=self;
  55. self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
  56. for (SideSlipModel *model in dataList) {
  57. model.selectedItemList = nil;
  58. model.customDict = nil;
  59. }
  60. } commitBlock:^(NSArray *dataList) {
  61. SideSlipModel *serviceRegionModel = dataList[0];
  62. _pageNumber=1;
  63. RequirementNoReceiptSearchModel *m = [serviceRegionModel.customDict objectForKey:SEARCH_RANGE_MODEL];
  64. _deliveryNo=m.deliveryNo;
  65. _arrangementNo=m.arrangementNo;
  66. _customerName=m.customerName;
  67. _startDate=m.startDate;
  68. _endDate=m.endDate;
  69. if(_startDate!=nil&&_endDate!=nil){
  70. NSUInteger result= [DateFormat compareDate:_startDate withDate:_endDate];
  71. if(result == -1){
  72. [self showAlertViewText:@"开始日期不能大于结束日期"];
  73. return;
  74. }
  75. }
  76. if(_dataList!=nil&&_dataList.count>0){
  77. [_dataList removeAllObjects];
  78. [_tableView reloadData];
  79. }
  80. [weakself.filterController dismiss];
  81. [self initData];
  82. }];
  83. _filterController.animationDuration = .3f;
  84. _filterController.hasHeadView = YES;
  85. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  86. _filterController.dataList = [self packageDataList];
  87. [self initData];
  88. }
  89. #pragma mark - 委托函数
  90. /**
  91. 数据加载完成函数
  92. @param sender <#sender description#>
  93. */
  94. - (void)onLoadFinish:(ASIDownManager *)sender {
  95. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  96. [self cancel];
  97. long iNewCount = 0;
  98. _tableView.mTableView.backgroundView = nil;
  99. int iStatus = resultModel.status;
  100. NSString *message =resultModel.message;
  101. if (iStatus == 0) {
  102. NSArray * infoArr = (NSArray *)resultModel.result;
  103. if(infoArr != nil&&infoArr.count > 0)
  104. {
  105. for(int i=0;i<infoArr.count;i++)
  106. {
  107. RequirementNoReceiptModel *model = [RequirementNoReceiptModel dk_modelWithDictionary:infoArr[i]];
  108. RequirementNoReceiptFrame *listFrame = [RequirementNoReceiptFrame new];
  109. [listFrame setUnReceiptListFrame:model];
  110. [_dataList addObject:listFrame];
  111. }
  112. iNewCount = infoArr.count;
  113. _tableView.mbMoreHidden = (iNewCount == 0);
  114. [_tableView FinishLoading];
  115. [_tableView reloadData];
  116. }
  117. else{
  118. [_tableView FinishLoading];
  119. if(_pageNumber == 1)
  120. {
  121. _tableView.mbMoreHidden=YES;
  122. _tableView.mTableView.backgroundView = [self noDataViewByFrame:_tableView.mTableView.bounds];
  123. //[self showAlertViewText:@"未找到匹配结果"];
  124. return;
  125. }
  126. else{
  127. _tableView.mbMoreHidden = 1;
  128. }
  129. }
  130. }
  131. else if(iStatus == ActionResultStatusAuthError
  132. ||iStatus == ActionResultStatusNoLogin
  133. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  134. [self showReLoginDialog:message];
  135. return;
  136. }
  137. else{
  138. [self showAlertViewText:message];
  139. [_tableView FinishLoading];
  140. return;
  141. }
  142. }
  143. /**
  144. 数据加载失败函数
  145. @param sender <#sender description#>
  146. */
  147. - (void)onLoadFail:(ASIDownManager *)sender {
  148. [self cancel];
  149. [_tableView reloadData];
  150. [self showAlertViewText:@"网络异常"];
  151. }
  152. -(void)dialTelephone:(NSString *)telephone{
  153. NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@",telephone];
  154. CGFloat version = [[[UIDevice currentDevice]systemVersion]floatValue];
  155. if (version >= 10.0) {
  156. /// 大于等于10.0系统使用此openURL方法
  157. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil];
  158. } else {
  159. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
  160. }
  161. }
  162. /**
  163. 加载更多函数
  164. @param sender <#sender description#>
  165. */
  166. - (void)LoadMoreList:(RefreshTableView *)sender {
  167. _pageNumber++;
  168. [self initData];
  169. }
  170. /**
  171. 上拉刷新函数
  172. @param sender <#sender description#>
  173. */
  174. - (void)ReloadList:(RefreshTableView *)sender{
  175. _pageNumber = 1;
  176. [_dataList removeAllObjects];
  177. [_tableView reloadData];
  178. _tableView.mbMoreHidden=YES;
  179. [self initData];
  180. }
  181. /**
  182. tableview的行数
  183. @param tableView <#tableView description#>
  184. @param section <#section description#>
  185. @return <#return value description#>
  186. */
  187. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  188. {
  189. return 1;
  190. }
  191. /**
  192. tableview的分区数
  193. @param tableView <#tableView description#>
  194. @return <#return value description#>
  195. */
  196. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  197. return [_dataList count] ;
  198. }
  199. /**
  200. 获取tableview cell
  201. @param tableView <#tableView description#>
  202. @param indexPath <#indexPath description#>
  203. @return <#return value description#>
  204. */
  205. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  206. {
  207. static NSString *DeliveryCellIdentifier = @"CellId";
  208. RequirementNoReceiptCell *cell = [tableView dequeueReusableCellWithIdentifier:DeliveryCellIdentifier];
  209. cell = [[RequirementNoReceiptCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DeliveryCellIdentifier];
  210. cell.telephoneDelegate=self;
  211. NSUInteger row = [indexPath section];
  212. RequirementNoReceiptFrame *frame = [_dataList objectAtIndex:row];
  213. [cell setUnReceiptListFrame:frame];
  214. return cell;
  215. }
  216. /**
  217. tableview分区视图
  218. @param tableView <#tableView description#>
  219. @param section <#section description#>
  220. @return <#return value description#>
  221. */
  222. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  223. {
  224. UIView *view = [[UIView alloc] init];
  225. view.backgroundColor = [UIColor clearColor];
  226. return view ;
  227. }
  228. /**
  229. tableview分区的间隔高度
  230. @param tableView <#tableView description#>
  231. @param section <#section description#>
  232. @return <#return value description#>
  233. */
  234. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  235. {
  236. return 10;
  237. }
  238. /**
  239. tableview的高度
  240. @param tableView <#tableView description#>
  241. @param indexPath <#indexPath description#>
  242. @return <#return value description#>
  243. */
  244. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  245. NSUInteger row = [indexPath section];
  246. RequirementNoReceiptFrame *unReceiptListFrame = [_dataList objectAtIndex:row];
  247. NSInteger cellHeight = [unReceiptListFrame cellHeight];
  248. return cellHeight;
  249. }
  250. /**
  251. scrollview滚动代理
  252. @param scrollView <#scrollView description#>
  253. */
  254. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  255. if (scrollView.isDragging) {//显示下拉更新
  256. if (_tableView.mRefreshHeader.state == PullRefreshPulling && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && [_tableView CanRefresh]) {
  257. [_tableView.mRefreshHeader setState:PullRefreshNormal];
  258. }
  259. else if (_tableView.mRefreshHeader.state == PullRefreshNormal && scrollView.contentOffset.y < -65.0f && [_tableView CanRefresh]) {
  260. //显示松开更新
  261. [_tableView.mRefreshHeader setState:PullRefreshPulling];
  262. }
  263. }
  264. }
  265. /**
  266. tableview点击函数
  267. @param tableView <#tableView description#>
  268. @param indexPath <#indexPath description#>
  269. */
  270. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  271. {
  272. NewDeliveryRequirementController *newDeliveryVC = [[NewDeliveryRequirementController alloc] init];
  273. NSUInteger row = [indexPath section];
  274. newDeliveryVC.refreshDelegate = self;
  275. RequirementNoReceiptFrame *frame = [_dataList objectAtIndex:row];
  276. RequirementNoReceiptModel *model = [frame unReceiptListModel];
  277. newDeliveryVC.sReceiptCode = model.deliveryNo;
  278. newDeliveryVC.deliveryId =model.deliveryId;
  279. newDeliveryVC.arrangementID =model.arrangementId;
  280. self.cNav.visibleViewController.hidesBottomBarWhenPushed = YES;
  281. [self.cNav pushViewController:newDeliveryVC animated:YES];
  282. }
  283. /**
  284. 刷新数据函数
  285. */
  286. - (void)refreshFollowUpData{
  287. [_dataList removeAllObjects];
  288. _tableView.mbMoreHidden = YES;
  289. [_tableView reloadData];
  290. _pageNumber = 1;
  291. [self initData];
  292. }
  293. /**
  294. 是否能刷新tableview
  295. @param sender <#sender description#>
  296. @return <#return value description#>
  297. */
  298. - (BOOL)CanRefreshTableView:(RefreshTableView *)sender {
  299. return YES;
  300. }
  301. #pragma mark - 私有函数
  302. /**
  303. 加载数据函数
  304. */
  305. - (void)initData
  306. {
  307. [self startLoading];
  308. NSString *urlStr = ServerURL;
  309. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  310. [dict setObject:@"GetDeliveryRequirementNoReceiptIphone" forKey:@"Action"];
  311. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  312. [dict setObject:kkUserCode forKey:@"UserCode"];
  313. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  314. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  315. [dict setObject:_deliveryNo forKeyedSubscript:@"DeliveryNo"];
  316. [dict setObject:_arrangementNo forKeyedSubscript:@"ArrangementNo"];
  317. [dict setObject:_customerName forKeyedSubscript:@"CustomerName"];
  318. [dict setObject:_startDate forKeyedSubscript:@"BeginTime"];
  319. [dict setObject:_endDate forKeyedSubscript:@"EndTime"];
  320. [dict setObject:[NSString stringWithFormat:@"%d",(int)_pageNumber] forKey:@"PageNum"];
  321. [dict setObject:[NSString stringWithFormat:@"%d",pageSize] forKey:@"PageSize"];
  322. self.mDownManager = [[ASIDownManager alloc] init];
  323. self.mDownManager.delegate = self;
  324. self.mDownManager.onRequestSuccess = @selector(onLoadFinish:);
  325. self.mDownManager.onRequestFail = @selector(onLoadFail:);
  326. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  327. }
  328. /**
  329. 弹出抽屉
  330. */
  331. -(void)searchUnreceiptData{
  332. [_filterController showPagerView:self.cNav];
  333. }
  334. /**
  335. 抽屉加载布局
  336. @return
  337. */
  338. - (NSArray *)packageDataList {
  339. NSMutableArray *dataArray = [NSMutableArray array];
  340. SideSlipModel *model = [[SideSlipModel alloc] init];
  341. model.containerCellClass = @"RequirementNoReceiptSearchCell";
  342. model.regionTitle = @"查询条件";
  343. [dataArray addObject:model];
  344. return [dataArray mutableCopy];
  345. }
  346. /**
  347. 取消进度条
  348. */
  349. - (void)cancel {
  350. [self stopLoading];
  351. }
  352. @end