RepairUnreceiptVC.m 13 KB

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