InventoryFrozenOrderViewController.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. //
  2. // InventoryFrozenOrderViewController.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/4/28.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "InventoryFrozenOrderViewController.h"
  9. @interface InventoryFrozenOrderViewController ()
  10. @end
  11. @implementation InventoryFrozenOrderViewController
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. [self initUI];
  15. [self initSlideSlip];
  16. _orderList=[[NSMutableArray alloc]init];
  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. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_searchView.frame)+10,self.view.frame.size.width, self.view.frame.size.height-rectStatusHeight-rectNavHeight)];
  37. _tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  38. _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  39. _tableView.delegate = self;
  40. _tableView.dataSource=self;
  41. [self.view addSubview:_tableView];
  42. }
  43. -(void)editData:(NSInteger)position
  44. {
  45. InventoryFreezeOrderListModel *orderListModel=[_orderList objectAtIndex:position];
  46. NSString *freezeId=orderListModel.freezeId;
  47. self.cNav.visibleViewController.hidesBottomBarWhenPushed=YES;
  48. NewInventoryFreezeViewController *newVc = [[NewInventoryFreezeViewController alloc] init];
  49. newVc.inventoryDelegate=self;
  50. newVc.freezeId=freezeId;
  51. newVc.editFlag=YES;
  52. [self.cNav pushViewController:newVc animated:YES];
  53. }
  54. -(void)dataSearch
  55. {
  56. [_filterController showPagerView:self.cNav];
  57. }
  58. /**
  59. 抽屉初始化
  60. */
  61. - (void)initSlideSlip{
  62. // 抽屉对象
  63. __weak typeof(self) weakself = self;
  64. self.filterController = [[SideSlipFilterController alloc]
  65. initWithSponsor:self
  66. resetBlock:^(NSArray *dataList) {
  67. for (SideSlipModel *model in dataList)
  68. {
  69. model.selectedItemList = nil;
  70. model.customDict = nil;
  71. }
  72. }
  73. commitBlock:^(NSArray *dataList) {
  74. // 查询条件
  75. SideSlipModel *serviceRegionModel = dataList[0];
  76. InventoryFreezeOrderSearchModel *searchModel = [serviceRegionModel.customDict objectForKey:INVENTORY_FREEZE_ORDER_SEARCH_MODEL];
  77. self->_customerName=searchModel.customerName;
  78. self->_contacts=searchModel.contacts;
  79. self->_telephone=searchModel.telephone;
  80. self->_staffName=searchModel.staffName;
  81. self->_freezeReasonName=searchModel.freezeReasonName;
  82. self->_accountStartDate=searchModel.accountStartDate;
  83. self->_accountEndDate=searchModel.accountEndDate;
  84. self->_freezeStartDate=searchModel.freezeStartDate;
  85. self->_freezeEndDate=searchModel.freezeEndDate;
  86. [weakself.filterController dismiss];
  87. if(self->_orderList!=nil&&self->_orderList.count>0)
  88. {
  89. [self->_orderList removeAllObjects];
  90. [self->_tableView reloadData];
  91. }
  92. [self startLoading];
  93. [self loadData];
  94. }];
  95. _filterController.animationDuration = AnimationDuration;
  96. _filterController.hasHeadView = YES;
  97. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  98. _filterController.dataList = [self packageDataList];
  99. }
  100. -(void)loadData
  101. {
  102. _downManager = [[ASIDownManager alloc] init];
  103. _downManager.delegate = self;
  104. _downManager.onRequestSuccess = @selector(onDataLoadFinish:);
  105. _downManager.onRequestFail = @selector(onDataLoadFail:);
  106. NSString *urlStr = ServerURL;
  107. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  108. [dict setObject:@"GetFreezeData" forKey:@"Action"];
  109. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  110. [dict setObject:kkUserCode forKey:@"UserCode"];
  111. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  112. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  113. [dict setObject:(_contacts==nil?@"":_contacts) forKey:@"Contacts"];
  114. [dict setObject:(_telephone==nil?@"":_telephone) forKey:@"Telephone"];
  115. [dict setObject:(_customerName==nil?@"":_customerName) forKey:@"CustomerName"];
  116. [dict setObject:(_staffName==nil?@"":_staffName) forKey:@"SalesmanName"];
  117. [dict setObject:(_freezeReasonName==nil?@"":_freezeReasonName) forKey:@"FreezeReason"];
  118. [dict setObject:(_accountStartDate==nil?@"":_accountStartDate) forKey:@"AccountDateFrom"];
  119. [dict setObject:(_accountEndDate==nil?@"":_accountEndDate) forKey:@"AccountDateEnd"];
  120. [dict setObject:(_freezeStartDate==nil?@"":_freezeStartDate) forKey:@"FreezePeriodFrom"];
  121. [dict setObject:(_freezeEndDate==nil?@"":_freezeEndDate) forKey:@"FreezePeriodTo"];
  122. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  123. }
  124. -(void)onDataLoadFail:(ASIDownManager *)sender {
  125. [self cancel];
  126. [self showAlertViewText:@"网络异常"];
  127. }
  128. -(void)onDataLoadFinish:(ASIDownManager*)sender {
  129. [self cancel];
  130. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  131. int iStatus = resultModel.status;
  132. // 服务器返回数据消息
  133. NSString *message = resultModel.message;
  134. if(iStatus==0)
  135. {
  136. NSArray *resultArray=(NSArray*)resultModel.result;
  137. if(resultArray!=nil&&resultArray.count>0)
  138. {
  139. for(int i=0;i<resultArray.count;i++)
  140. {
  141. NSDictionary *resultDic=[resultArray objectAtIndex:i];
  142. InventoryFreezeOrderListModel *orderListModel=[InventoryFreezeOrderListModel dk_modelWithDictionary:resultDic];
  143. [_orderList addObject:orderListModel];
  144. }
  145. [_tableView reloadData];
  146. }
  147. }
  148. // 服务器返回数据状态值异常
  149. else if(iStatus == ActionResultStatusAuthError
  150. ||iStatus == ActionResultStatusNoLogin
  151. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  152. [self showReLoginDialog:message];
  153. }
  154. else{
  155. [self showAlertViewText:message];
  156. }
  157. }
  158. /**
  159. 进度条隐藏
  160. */
  161. - (void)cancel {
  162. [self stopLoading];
  163. }
  164. /**
  165. 单元格cell个数
  166. @param tableView <#tableView description#>
  167. @param section <#section description#>
  168. @return <#return value description#>
  169. */
  170. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  171. {
  172. return [_orderList count];
  173. }
  174. /**
  175. table view 分区数
  176. @param tableView <#tableView description#>
  177. @return <#return value description#>
  178. */
  179. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  180. return 1;
  181. }
  182. /**
  183. cell 高度
  184. @param tableView <#tableView description#>
  185. @param indexPath <#indexPath description#>
  186. @return <#return value description#>
  187. */
  188. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  189. return [self.heights[@(indexPath.row)] doubleValue];;
  190. }
  191. /**
  192. 点击单元格事件
  193. @param tableView tableView description
  194. @param indexPath indexPath description
  195. */
  196. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  197. {
  198. self.cNav.visibleViewController.hidesBottomBarWhenPushed=YES;
  199. InventoryFreezeGoodsDetailViewController *detailVc = [[InventoryFreezeGoodsDetailViewController alloc] init];
  200. InventoryFreezeOrderListModel *orderModel = [_orderList objectAtIndex:indexPath.row];
  201. detailVc.freezeId=orderModel.freezeId;
  202. [self.cNav pushViewController:detailVc animated:YES];
  203. }
  204. /**
  205. 高度
  206. @return <#return value description#>
  207. */
  208. - (NSMutableDictionary *)heights{
  209. if (_heights == nil){
  210. _heights = [NSMutableDictionary dictionary];
  211. }
  212. return _heights;
  213. }
  214. /**
  215. 预防高度
  216. @param tableView <#tableView description#>
  217. @param indexPath <#indexPath description#>
  218. @return <#return value description#>
  219. */
  220. -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  221. return 250;
  222. }
  223. /**
  224. 每个单元格cell
  225. @param tableView <#tableView description#>
  226. @param indexPath <#indexPath description#>
  227. @return <#return value description#>
  228. */
  229. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  230. {
  231. static NSString *cellIdentifier = @"InventoryFreezeOrderListCell";
  232. InventoryFreezeOrderListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  233. cell = [[InventoryFreezeOrderListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  234. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  235. InventoryFreezeOrderListModel *orderModel= [_orderList objectAtIndex:indexPath.row];
  236. cell.delegate = self;
  237. [cell setInventoryFreezeOrderListCell:orderModel];
  238. cell.position = (int)indexPath.row;
  239. self.heights[@(indexPath.row)] = @(cell.height);
  240. return cell;
  241. }
  242. -(void)refreshData
  243. {
  244. if(_orderList!=nil&&_orderList.count>0)
  245. {
  246. [_orderList removeAllObjects];
  247. [_tableView reloadData];
  248. }
  249. [self startLoading];
  250. [self loadData];
  251. }
  252. /**
  253. 抽屉数据源
  254. @return <#return value description#>
  255. */
  256. - (NSArray *)packageDataList {
  257. NSMutableArray *dataArray = [NSMutableArray array];
  258. SideSlipModel *model = [[SideSlipModel alloc] init];
  259. model.containerCellClass = @"InventoryOrderSearchListCell";
  260. model.regionTitle = @"查询条件";
  261. [dataArray addObject:model];
  262. return [dataArray mutableCopy];
  263. }
  264. @end