RepairReceiptedVC.m 12 KB

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