InventoryUnfreezeOrderSearchViewController.m 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. //
  2. // InventoryUnfreezeOrderSearchViewController.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/5/9.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "InventoryUnfreezeOrderSearchViewController.h"
  9. @interface InventoryUnfreezeOrderSearchViewController ()
  10. @end
  11. @implementation InventoryUnfreezeOrderSearchViewController
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. [self initUI];
  15. _unfreezeOrderList=[[NSMutableArray alloc]init];
  16. [self initSlideSlip];
  17. }
  18. -(void)initUI
  19. {
  20. self.view.backgroundColor = [UIColor whiteColor];
  21. _searchView = [[UIView alloc] init];
  22. _searchView.frame = CGRectMake(15,10,Screen_Width-30,35);
  23. _searchView.backgroundColor = LineBackgroundColor;
  24. _searchView.layer.cornerRadius = 10;
  25. _searchView.layer.masksToBounds = YES;
  26. UIButton *btnSearch = [UIButton buttonWithType:UIButtonTypeCustom];
  27. btnSearch.frame = CGRectMake(20,0, Screen_Width-40, 35);
  28. btnSearch.layer.cornerRadius = 6.0f;
  29. [btnSearch setTitle:@"库存解冻订单查询" forState:UIControlStateNormal];
  30. [btnSearch setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  31. btnSearch.titleLabel.textAlignment = NSTextAlignmentCenter;
  32. btnSearch.titleLabel.font = [UIFont systemFontOfSize:LabelAndTextFontOfSize];
  33. [btnSearch addTarget:self action:@selector(dataSearch) forControlEvents:UIControlEventTouchUpInside];
  34. [_searchView addSubview:btnSearch];
  35. [self.view addSubview:_searchView];
  36. UIView *topSeparator= [UIView new];
  37. topSeparator.frame=CGRectMake(0,CGRectGetMaxY(_searchView.frame)+10, Screen_Width, 10);
  38. topSeparator.backgroundColor = LineBackgroundColor;
  39. [self.view addSubview:topSeparator];
  40. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(topSeparator.frame),self.view.frame.size.width, self.view.frame.size.height-rectStatusHeight-rectNavHeight)];
  41. _tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  42. _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  43. _tableView.delegate = self;
  44. _tableView.dataSource=self;
  45. [self.view addSubview:_tableView];
  46. }
  47. /**
  48. 抽屉初始化
  49. */
  50. - (void)initSlideSlip{
  51. // 抽屉对象
  52. __weak typeof(self) weakself = self;
  53. self.filterController = [[SideSlipFilterController alloc]
  54. initWithSponsor:self
  55. resetBlock:^(NSArray *dataList) {
  56. for (SideSlipModel *model in dataList)
  57. {
  58. model.selectedItemList = nil;
  59. model.customDict = nil;
  60. }
  61. }
  62. commitBlock:^(NSArray *dataList) {
  63. // 查询条件
  64. SideSlipModel *serviceRegionModel = dataList[0];
  65. InventoryUnfreezeOrderSearchModel *searchModel = [serviceRegionModel.customDict objectForKey:INVENTORY_UNFREEZE_ORDER_SEARCH_MODEL];
  66. self->_approver=searchModel.approver;
  67. self->_freezeNo=searchModel.freezeNo;
  68. self->_unfreezeNo=searchModel.unfreezeNo;
  69. self->_accountStartDate=searchModel.accountDateFrom;
  70. self->_accountEndDate=searchModel.accountDateEnd;
  71. if(self->_unfreezeOrderList!=nil&&self->_unfreezeOrderList.count>0)
  72. {
  73. [self->_unfreezeOrderList removeAllObjects];
  74. [self->_tableView reloadData];
  75. }
  76. [self startLoading];
  77. [self loadData];
  78. [weakself.filterController dismiss];
  79. }];
  80. _filterController.animationDuration = AnimationDuration;
  81. _filterController.hasHeadView = YES;
  82. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  83. _filterController.dataList = [self packageDataList];
  84. }
  85. -(void)dataSearch
  86. {
  87. [_filterController showPagerView:self.cNav];
  88. }
  89. -(void)loadData
  90. {
  91. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  92. [dict setObject:@"GetUnFreezeDataIPhone" forKey:@"Action"];
  93. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  94. [dict setObject:kkUserCode forKey:@"UserCode"];
  95. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  96. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  97. [dict setObject:(_unfreezeNo==nil?@"":_unfreezeNo) forKey:@"UnFreezeNo"];
  98. [dict setObject:(_approver==nil?@"":_approver) forKey:@"ReviewerName"];
  99. [dict setObject:(_freezeNo==nil?@"":_freezeNo) forKey:@"FreezeNo"];
  100. [dict setObject:(_accountStartDate==nil?@"":_accountStartDate) forKey:@"AccountDateFrom"];
  101. [dict setObject:(_accountEndDate==nil?@"":_accountEndDate) forKey:@"AccountDateEnd"];
  102. _mDownManager = [[ASIDownManager alloc] init];
  103. [self startLoading];
  104. _mDownManager.delegate = self;
  105. _mDownManager.onRequestSuccess = @selector(onOrderListLoadFinish:);
  106. _mDownManager.onRequestFail = @selector(onOrderListLoadFail:);
  107. [_mDownManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  108. }
  109. -(void)onOrderListLoadFinish:(ASIDownManager *)sender {
  110. [self cancel];
  111. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  112. int iStatus = resultModel.status;
  113. // 服务器返回数据消息
  114. NSString *message = resultModel.message;
  115. if(iStatus==0)
  116. {
  117. NSArray *resultArray=(NSArray*)resultModel.result;
  118. if(resultArray!=nil&&resultArray.count>0)
  119. {
  120. for(int i=0;i<resultArray.count;i++)
  121. {
  122. NSDictionary *resultDic=[resultArray objectAtIndex:i];
  123. InventoryUnfreezeOrderListModel *orderListModel=[InventoryUnfreezeOrderListModel dk_modelWithDictionary:resultDic];
  124. [_unfreezeOrderList addObject:orderListModel];
  125. }
  126. [_tableView reloadData];
  127. }
  128. }
  129. // 服务器返回数据状态值异常
  130. else if(iStatus == ActionResultStatusAuthError
  131. ||iStatus == ActionResultStatusNoLogin
  132. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  133. [self showReLoginDialog:message];
  134. }
  135. else{
  136. [self showAlertViewText:message];
  137. }
  138. }
  139. -(void)onOrderListLoadFail:(ASIDownManager *)sender {
  140. [self cancel];
  141. [self showAlertViewText:@"网络异常"];
  142. }
  143. /**
  144. 进度条隐藏
  145. */
  146. - (void)cancel {
  147. [self stopLoading];
  148. }
  149. /**
  150. 抽屉数据源
  151. @return <#return value description#>
  152. */
  153. - (NSArray *)packageDataList {
  154. NSMutableArray *dataArray = [NSMutableArray array];
  155. SideSlipModel *model = [[SideSlipModel alloc] init];
  156. model.containerCellClass = @"InventoryUnfreezeOrderSearchCell";
  157. model.regionTitle = @"查询条件";
  158. [dataArray addObject:model];
  159. return [dataArray mutableCopy];
  160. }
  161. /**
  162. 单元格cell个数
  163. @param tableView <#tableView description#>
  164. @param section <#section description#>
  165. @return <#return value description#>
  166. */
  167. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  168. {
  169. return [_unfreezeOrderList count];
  170. }
  171. /**
  172. table view 分区数
  173. @param tableView <#tableView description#>
  174. @return <#return value description#>
  175. */
  176. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  177. return 1;
  178. }
  179. /**
  180. cell 高度
  181. @param tableView <#tableView description#>
  182. @param indexPath <#indexPath description#>
  183. @return <#return value description#>
  184. */
  185. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  186. return [self.heights[@(indexPath.row)] doubleValue];;
  187. }
  188. /**
  189. 点击单元格事件
  190. @param tableView tableView description
  191. @param indexPath indexPath description
  192. */
  193. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  194. {
  195. InventoryUnfreezeOrderListModel *orderListModel= [_unfreezeOrderList objectAtIndex:indexPath.row];
  196. InventoryUnfreezeGoodsDetailViewController *detailVc=[[InventoryUnfreezeGoodsDetailViewController alloc]init];
  197. detailVc.unfreezeId=orderListModel.unfreezeId;
  198. [self.cNav pushViewController:detailVc animated:YES];
  199. }
  200. /**
  201. 高度
  202. @return <#return value description#>
  203. */
  204. - (NSMutableDictionary *)heights{
  205. if (_heights == nil){
  206. _heights = [NSMutableDictionary dictionary];
  207. }
  208. return _heights;
  209. }
  210. /**
  211. 预防高度
  212. @param tableView <#tableView description#>
  213. @param indexPath <#indexPath description#>
  214. @return <#return value description#>
  215. */
  216. -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  217. return 250;
  218. }
  219. -(void)editData:(NSInteger)position
  220. {
  221. InventoryUnfreezeOrderListModel *orderModel= [_unfreezeOrderList objectAtIndex:position];
  222. NewInventoryUnfreezeViewController *newVc=[[NewInventoryUnfreezeViewController alloc]init];
  223. newVc.unfreezeId=orderModel.unfreezeId;
  224. newVc.editFlag=YES;
  225. [self.cNav pushViewController:newVc animated:YES];
  226. }
  227. /**
  228. 每个单元格cell
  229. @param tableView <#tableView description#>
  230. @param indexPath <#indexPath description#>
  231. @return <#return value description#>
  232. */
  233. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  234. {
  235. static NSString *cellIdentifier = @"InventoryUnfreezeOrderListCell";
  236. InventoryUnfreezeOrderListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  237. cell = [[InventoryUnfreezeOrderListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  238. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  239. InventoryUnfreezeOrderListModel *orderModel= [_unfreezeOrderList objectAtIndex:indexPath.row];
  240. [cell setInventoryUnfreezeOrderListCell:orderModel];
  241. cell.position = (int)indexPath.row;
  242. cell.delegate=self;
  243. self.heights[@(indexPath.row)] = @(cell.height);
  244. return cell;
  245. }
  246. @end