OtherOutStorageListVC.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. //
  2. // OtherOutStorageListVC.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/4/20.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "OtherOutStorageListVC.h"
  9. @interface OtherOutStorageListVC (){
  10. int pageNumber;
  11. }
  12. @end
  13. @implementation OtherOutStorageListVC
  14. #pragma mark 公共函数
  15. /**
  16. 视图加载完成函数
  17. */
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self loadNavStyle];
  21. [self initUI];
  22. [self initSlideSlip];
  23. }
  24. /**
  25. 修改:2017-9-25
  26. 适配机型
  27. 安全区视图发生变化
  28. */
  29. -(void)viewSafeAreaInsetsDidChange{
  30. self.view.backgroundColor = [UIColor whiteColor];
  31. _vCustomTableView.frame = CGRectMake(0, CGRectGetMaxY(_topSeparatorView.frame),Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height- CGRectGetMaxY(_topSeparatorView.frame) );
  32. [super viewSafeAreaInsetsDidChange];
  33. }
  34. #pragma mark 委托函数
  35. /**
  36. 刷新数据函数
  37. */
  38. -(void)refreshData{
  39. pageNumber = 1;
  40. [_dataList removeAllObjects];
  41. [_vCustomTableView reloadData];
  42. _vCustomTableView.mbMoreHidden=YES;
  43. [self startLoading];
  44. [self loadData];
  45. }
  46. /**
  47. 其它出库列表数据加载成功回调
  48. @param sender <#sender description#>
  49. */
  50. - (void)onOtherOutStorageListFinish:(ASIDownManager *)sender {
  51. NSDictionary *dic = [sender.mWebStr JSONValue];
  52. _vCustomTableView.mTableView.backgroundView = nil;
  53. [self stopLoading];
  54. // 服务器返回数据是否正确
  55. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  56. // 服务器返回数据状态值
  57. int iStatus = [[dic objectForKey:@"Status"] intValue];
  58. int iNewCount = 0;
  59. // 服务器返回数据消息
  60. NSString *message=[dic objectForKey:@"Message"];
  61. // 服务器返回数据状态值正确
  62. if (iStatus == 0) {
  63. NSArray * infoArr=[dic objectForKey:@"Result"];
  64. // 返回结果
  65. if(infoArr!=nil&& infoArr.count>0)
  66. {
  67. for (int i = 0; i < infoArr.count; i++) {
  68. NSDictionary * dic=infoArr[i];
  69. OtherOutStorageListModel *otherOutStorageListModel=[[OtherOutStorageListModel alloc]init];
  70. [otherOutStorageListModel parseDic:dic];
  71. [_dataList addObject:otherOutStorageListModel];
  72. }
  73. iNewCount =(int)infoArr.count;
  74. _vCustomTableView.mbMoreHidden = (iNewCount == 0);
  75. [_vCustomTableView FinishLoading];
  76. [_vCustomTableView reloadData];
  77. }
  78. else{
  79. [_vCustomTableView FinishLoading];
  80. _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  81. UIView *noDataView=[[UIView alloc]init];
  82. noDataView.frame=_vCustomTableView.bounds;
  83. UIImageView *nodataImgView=[[UIImageView alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16,noDataView.frame.size.height/2-16,32,32)];
  84. [nodataImgView setImage:[UIImage imageNamed:@"icon_no_data"]];
  85. [noDataView addSubview:nodataImgView];
  86. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16-12,CGRectGetMaxY(nodataImgView.frame)+3,70, 25)];
  87. label.font=[UIFont systemFontOfSize:NoDataFontOfSize];
  88. label.text = @"无数据";
  89. label.numberOfLines = 2;
  90. label.textColor = [UIColor lightGrayColor];
  91. [noDataView addSubview:label];
  92. // 有刷新数据的时候
  93. if(_dataList == nil || _dataList.count==0){
  94. _vCustomTableView.mTableView.backgroundView =noDataView;
  95. [self showAlertViewBackText:@"未找到匹配结果"];
  96. }
  97. }
  98. }
  99. // 服务器返回数据状态值异常
  100. else if(iStatus==ActionResultStatusAuthError
  101. ||iStatus==ActionResultStatusNoLogin
  102. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  103. [self stopLoading];
  104. [self showReLoginDialog:message];
  105. }
  106. else{
  107. [self stopLoading];
  108. [_vCustomTableView FinishLoading];
  109. [self showAlertViewText:message];
  110. }
  111. }
  112. }
  113. /**
  114. 加载总数数据失败回调
  115. @param sender <#sender description#>
  116. */
  117. - (void)onOtherOutStorageListFail:(ASIDownManager *)sender {
  118. [self stopLoading];
  119. [self showAlertViewText:@"加载失败"];
  120. }
  121. #pragma mark 私有函数
  122. /**
  123. 导航按钮样式
  124. */
  125. -(void)loadNavStyle
  126. {
  127. //右边
  128. UIButton *btnAdd = [UIButton buttonWithType:UIButtonTypeCustom];
  129. [btnAdd addTarget:self action:@selector(add)
  130. forControlEvents:UIControlEventTouchUpInside];
  131. UIImage *pic =[UIImage imageNamed:@"title_add"];
  132. btnAdd.frame = CGRectMake(0, 0, 18, 18);
  133. [btnAdd setTitleColor:NavBarItemColor forState:UIControlStateNormal];
  134. [btnAdd setBackgroundImage:pic
  135. forState:UIControlStateNormal];
  136. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:btnAdd];
  137. self.navigationItem.title=@"其他出库列表";
  138. self.navigationItem.rightBarButtonItem = menubtnAdd;
  139. //返回
  140. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  141. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  142. forState:UIControlStateNormal];
  143. [button addTarget:self action:@selector(goBack)
  144. forControlEvents:UIControlEventTouchUpInside];
  145. button.frame = CGRectMake(0, 0, 15, 18);
  146. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  147. self.navigationItem.leftBarButtonItem = menuButton;
  148. }
  149. /**
  150. 跳转到新增其它出库页面
  151. */
  152. -(void)add{
  153. self.hidesBottomBarWhenPushed=YES;
  154. NewOtherOutStorageHomeVC *vc=[[NewOtherOutStorageHomeVC alloc] init];
  155. vc.refreshDelegate = self;
  156. [self.navigationController pushViewController:vc animated:YES];
  157. }
  158. /**
  159. 抽屉初始化
  160. */
  161. - (void)initSlideSlip{
  162. // 抽屉对象
  163. __weak typeof(self) weakself=self;
  164. self.filterController = [[SideSlipFilterController alloc]
  165. initWithSponsor:self
  166. resetBlock:^(NSArray *dataList) {
  167. for (SideSlipModel *model in dataList) {
  168. model.selectedItemList = nil;
  169. model.customDict = nil;
  170. }
  171. } commitBlock:^(NSArray *dataList) {
  172. // 查询条件
  173. SideSlipModel *serviceRegionModel = dataList[0];
  174. OtherOutStorageListSearchModel *m = [serviceRegionModel.customDict objectForKey:OTHER_OUT_STORAGE_SEARCH_RANGE_MODEL];
  175. _outStorageNo =m.outStorageNo;
  176. _supplierId=m.supplierId;
  177. if([m.startDate isEqualToString:@"请选择开始账务日期"]){
  178. _startDate=@"";
  179. }
  180. else{
  181. _startDate=m.startDate;
  182. }
  183. if([m.endDate isEqualToString:@"请选择结束账务日期"]){
  184. _endDate=@"";
  185. }
  186. else{
  187. _endDate=m.endDate;
  188. }
  189. _departmentCode=m.departmentCode;
  190. _customerCode=m.customerCode;
  191. _staffId=m.staffId;
  192. _invoiceStatus=m.invoiceStatus;
  193. [weakself.filterController dismiss];
  194. pageNumber = 1;
  195. [_dataList removeAllObjects];
  196. [_vCustomTableView reloadData];
  197. _vCustomTableView.mbMoreHidden=YES;
  198. [self startLoading];
  199. [self loadData];
  200. }];
  201. _filterController.animationDuration = AnimationDuration;
  202. _filterController.hasHeadView = YES;
  203. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  204. _filterController.dataList = [self packageDataList];
  205. }
  206. /**
  207. 数据源
  208. @return <#return value description#>
  209. */
  210. - (NSArray *)packageDataList {
  211. NSMutableArray *dataArray = [NSMutableArray array];
  212. SideSlipModel *model = [[SideSlipModel alloc] init];
  213. model.containerCellClass = @"OtherOutStorageListSearchCell";
  214. model.regionTitle = @"查询条件";
  215. [dataArray addObject:model];
  216. return [dataArray mutableCopy];
  217. }
  218. /**
  219. 返回函数
  220. */
  221. - (void)goBack
  222. {
  223. [self.navigationController popViewControllerAnimated:YES];
  224. }
  225. /**
  226. 加载数据源
  227. */
  228. -(void)loadData{
  229. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  230. [dict setObject:@"GetSalesInventoryListIphone" forKey:@"Action"];
  231. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  232. [dict setObject:kkUserCode forKey:@"UserCode"];
  233. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  234. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  235. [dict setObject:_outStorageNo== nil? @"" : _outStorageNo forKey:@"DeliveryNo"];
  236. [dict setObject:_supplierId== nil? @"" : _supplierId forKey:@"SupplierID"];
  237. [dict setObject:_departmentCode== nil? @"" : _departmentCode forKey:@"OrganizationCode"];
  238. [dict setObject:_staffId== nil? @"" : _staffId forKey:@"StaffID"];
  239. [dict setObject:@"14" forKey:@"DeliveryType"];
  240. [dict setObject:_customerCode == nil? @"" : _customerCode forKey:@"CustomerCode"];
  241. [dict setObject:_startDate == nil? @"" : _startDate forKey:@"AccountDateFrom"];
  242. [dict setObject:_endDate == nil? @"" : _endDate forKey:@"AccountDateTo"];
  243. [dict setObject:_invoiceStatus == nil? @"" : _invoiceStatus forKey:@"InvoiceStatus"];
  244. [dict setObject:@"20" forKey:@"PageSize"];
  245. [dict setObject:[NSString stringWithFormat:@"%d",pageNumber] forKey:@"PageNum"];
  246. _downManager = [[ASIDownManager alloc] init];
  247. [self startLoading];
  248. _downManager.delegate = self;
  249. _downManager.OnImageDown = @selector(onOtherOutStorageListFinish:);
  250. _downManager.OnImageFail = @selector(onOtherOutStorageListFail:);
  251. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  252. }
  253. -(void)initUI{
  254. CGFloat height = 40;
  255. _searchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 60)];
  256. _searchView.backgroundColor = [UIColor whiteColor];
  257. UIButton *btnSearch = [UIButton buttonWithType:UIButtonTypeCustom];
  258. btnSearch.frame = CGRectMake(20,10, Screen_Width-height, height);
  259. btnSearch.layer.cornerRadius = 6.0f;
  260. [btnSearch setTitle:@"搜索" forState:UIControlStateNormal];
  261. [btnSearch setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  262. btnSearch.titleLabel.textAlignment = NSTextAlignmentCenter;
  263. btnSearch.titleLabel.font = [UIFont systemFontOfSize:LabelAndTextFontOfSize];
  264. btnSearch.backgroundColor = LineBackgroundColor;
  265. [btnSearch addTarget:self action:@selector(dataSearch) forControlEvents:UIControlEventTouchUpInside];
  266. [_searchView addSubview:btnSearch];
  267. [self.view addSubview:_searchView];
  268. _topSeparatorView = [UIView new];
  269. _topSeparatorView.frame=CGRectMake(0, CGRectGetMaxY(_searchView.frame), Screen_Width, 10);
  270. _topSeparatorView.backgroundColor = LineBackgroundColor;
  271. [self.view addSubview:_topSeparatorView];
  272. _dataList=[[NSMutableArray alloc]init];
  273. _vCustomTableView = [[RefreshTableView alloc]
  274. initWithFrame:CGRectMake(0,
  275. CGRectGetMaxY(_topSeparatorView.frame),
  276. self.view.frame.size.width,
  277. Screen_Height - CGRectGetMaxY(_topSeparatorView.frame))];
  278. _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  279. _vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  280. _vCustomTableView.backgroundColor = [UIColor whiteColor];
  281. _vCustomTableView.delegate = self;
  282. [self.view addSubview:_vCustomTableView];
  283. pageNumber=1;
  284. [self loadData];
  285. }
  286. #pragma mark - 委托回调函数
  287. #pragma mark - tableView回调
  288. -(void) goGoodsDetail:(NSInteger)index{
  289. _outStorageListModel=[_dataList objectAtIndex:index];
  290. self.hidesBottomBarWhenPushed = YES;
  291. OtherOutStorageListDetailVC *vc = [[OtherOutStorageListDetailVC alloc] init];
  292. vc.deliveryId=_outStorageListModel.deliveryId;
  293. vc.deliveryNo=_outStorageListModel.deliveryNo;
  294. [self.navigationController pushViewController:vc animated:YES];
  295. }
  296. -(void)goCorrect:(NSInteger)index{
  297. _outStorageListModel=[_dataList objectAtIndex:index];
  298. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@""
  299. message:@"确定要冲正吗?" preferredStyle:UIAlertControllerStyleAlert];
  300. UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定"
  301. style:UIAlertActionStyleDefault
  302. handler:^(UIAlertAction *action){
  303. [self correctData:_outStorageListModel];
  304. }];
  305. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消"
  306. style:UIAlertActionStyleDefault
  307. handler:^(UIAlertAction *action){
  308. }];
  309. UIColor *cancelColor=[UIColor blackColor];
  310. UIColor *sureColor=[UIColor redColor];
  311. [cancelAction setValue:cancelColor forKey:@"titleTextColor"];
  312. [okAction setValue:sureColor forKey:@"titleTextColor"];
  313. [alert addAction:okAction];
  314. [alert addAction:cancelAction];
  315. [self presentViewController:alert animated:YES completion:nil];
  316. }
  317. -(void)correctData:(OtherOutStorageListModel *)model{
  318. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  319. [dict setObject:@"SaveReverseSalesInventoryIphone" forKey:@"Action"];
  320. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  321. [dict setObject:kkUserCode forKey:@"UserCode"];
  322. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  323. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  324. [dict setObject:@"1" forKey:@"IDevicesType"];
  325. [dict setObject:model.deliveryId == nil?@"":model.deliveryId forKey:@"DeliveryID"];
  326. NSString *statusStr = [NSString stringWithFormat:@"%ld",(long)model.invoiceStatusId];
  327. [dict setObject:statusStr == nil?@"":statusStr forKey:@"Status"];
  328. [dict setObject:model.deliveryType forKey:@"DeliveryType"];
  329. [self startLoading];
  330. _downManager = [[ASIDownManager alloc] init];
  331. _downManager.delegate = self;
  332. _downManager.OnImageDown = @selector(onCorrectFinish:);
  333. _downManager.OnImageFail = @selector(onCorrectFail:);
  334. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  335. }
  336. /**
  337. 加载总数数据成功回调
  338. @param sender <#sender description#>
  339. */
  340. - (void)onCorrectFinish:(ASIDownManager *)sender {
  341. NSDictionary *dic = [sender.mWebStr JSONValue];
  342. _vCustomTableView.mTableView.backgroundView = nil;
  343. [self stopLoading];
  344. // 服务器返回数据是否正确
  345. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  346. // 服务器返回数据状态值
  347. int iStatus = [[dic objectForKey:@"Status"] intValue];
  348. // 服务器返回数据消息
  349. NSString *message=[dic objectForKey:@"Message"];
  350. // 服务器返回数据状态值正确
  351. if (iStatus == 0) {
  352. pageNumber = 1;
  353. [_dataList removeAllObjects];
  354. [_vCustomTableView reloadData];
  355. _vCustomTableView.mbMoreHidden=YES;
  356. [self startLoading];
  357. [self loadData];
  358. [self showAlertViewText:@"冲正成功"];
  359. }
  360. // 服务器返回数据状态值异常
  361. else if(iStatus==ActionResultStatusAuthError
  362. ||iStatus==ActionResultStatusNoLogin
  363. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  364. [self showReLoginDialog:message];
  365. }
  366. else{
  367. [_vCustomTableView FinishLoading];
  368. [self showAlertViewText:message];
  369. }
  370. }
  371. }
  372. /**
  373. 加载总数数据失败回调
  374. @param sender <#sender description#>
  375. */
  376. - (void)onCorrectFail:(ASIDownManager *)sender {
  377. [self stopLoading];
  378. [self showAlertViewText:@"加载失败"];
  379. }
  380. /**
  381. 单元格cell个数
  382. @param tableView <#tableView description#>
  383. @param section <#section description#>
  384. @return <#return value description#>
  385. */
  386. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  387. {
  388. return [_dataList count];
  389. }
  390. /**
  391. <#Description#>
  392. @param tableView <#tableView description#>
  393. @return <#return value description#>
  394. */
  395. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  396. return 1;
  397. }
  398. /**
  399. 点击单元格事件
  400. @param tableView tableView description
  401. @param indexPath indexPath description
  402. */
  403. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  404. {
  405. self.hidesBottomBarWhenPushed=YES;
  406. OtherOutStorageDetailVC *detailVc=[[OtherOutStorageDetailVC alloc] init];
  407. OtherOutStorageListModel *salesOutStorageDetailModel= [_dataList objectAtIndex:indexPath.row];
  408. detailVc.outStorageDetailModel= salesOutStorageDetailModel;
  409. [self.navigationController pushViewController:detailVc animated:YES];
  410. }
  411. /**
  412. 高度
  413. @param tableView <#tableView description#>
  414. @param indexPath <#indexPath description#>
  415. @return <#return value description#>
  416. */
  417. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  418. return 315;
  419. }
  420. /**
  421. 每个单元格cell
  422. @param tableView <#tableView description#>
  423. @param indexPath <#indexPath description#>
  424. @return <#return value description#>
  425. */
  426. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  427. {
  428. NSString *cellIdentifier = @"OtherOutStorageListCell";
  429. OtherOutStorageListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  430. if (!cell) {
  431. cell=[[OtherOutStorageListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  432. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  433. }
  434. else
  435. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  436. {
  437. while ([cell.contentView.subviews lastObject] != nil) {
  438. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  439. }
  440. }
  441. _outStorageListModel= [_dataList objectAtIndex:indexPath.row];
  442. cell.otherOutStorageDelegate=self;
  443. cell.index=indexPath.row;
  444. [cell setOtherOutStorageModel:_outStorageListModel];
  445. return cell;
  446. }
  447. #pragma mark - 刷新回调
  448. /**
  449. 取消刷新
  450. @param sender sender description
  451. @return return value description
  452. */
  453. - (BOOL)CanRefreshTableView:(RefreshTableView *)sender {
  454. return YES;
  455. }
  456. /**
  457. 下拉刷新
  458. @param sender <#sender description#>
  459. */
  460. - (void)ReloadList:(RefreshTableView *)sender{
  461. pageNumber = 1;
  462. [_dataList removeAllObjects];
  463. [_vCustomTableView reloadData];
  464. _vCustomTableView.mbMoreHidden=YES;
  465. [self startLoading];
  466. [self loadData];
  467. }
  468. /**
  469. 加载更多
  470. @param sender sender description
  471. */
  472. - (void)LoadMoreList:(RefreshTableView *)sender {
  473. pageNumber++;
  474. [self startLoading];
  475. [self loadData];
  476. }
  477. -(void)dataSearch{
  478. [_filterController show];
  479. }
  480. - (void)didReceiveMemoryWarning {
  481. [super didReceiveMemoryWarning];
  482. }
  483. @end