InstallUnreceiptVC.m 13 KB

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