| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- //
- // StockingGoodsListViewController.m
- // IBOSS
- //
- // Created by apple on 2017/5/17.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:库存商品一览控制器
- //
- #import "StockingGoodsListViewController.h"
- #import "StockingGoodsCell.h"
- @interface StockingGoodsListViewController ()<UITableViewDataSource, UITableViewDelegate>
- @end
- @implementation StockingGoodsListViewController
- @synthesize customTableView;
- #pragma mark - 公共函数
- /**
- viewDidLoad函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self showTitle:@"库存商品一览"];
- [self initUI];
- [self reloadDataByOnlyCode];
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- [self.view setBackgroundColor:[UIColor whiteColor]];
- customTableView.frame =self.view.safeAreaLayoutGuide.layoutFrame;
- [super viewSafeAreaInsetsDidChange];
- }
- #pragma mark - 委托回调函数
- #pragma mark - tableView回调
- /**
- 单元格cell个数
-
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [self.arrNewDataList count];
- }
- /**
- <#Description#>
-
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- /**
- 高度
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 181;
- }
- /**
- 每个单元格cell
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"StockingGoodsCell";
- StockingGoodsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- // 新建cell
- if (!cell) {
- cell = [[StockingGoodsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
-
- _infoModel = [self.arrNewDataList objectAtIndex:indexPath.row];
- cell.model = _infoModel;
- // 强制布局 xib时调用
- //[cell layoutIfNeeded];
- return cell;
- }
- /**
- 点击单元格事件
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if ([self.stockDelegate respondsToSelector:@selector(stockTextDoneDatas:)]) {
- [self.stockDelegate stockTextDoneDatas:self.arrNewDataList[indexPath.row]];
- }
-
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark - scrollView回调
- /**
- 刷新数据源
- */
- - (void)refreshTableView
- {
- [self.customTableView reloadData];
- }
- /**
- 加载列表数据失败回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"网络异常"];
- }
- /**
- 加载列表数据成功回调
-
- @param sender <#sender description#>
- */
- - (void)onLoadFinish:(ASIDownManager *)sender
- {
- [self cancel];
- // 服务器返回数据
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- NSString *message = resultModel.message;
-
- // 服务器返回数据状态值正确
- if (iStatus == 0)
- {
- NSArray * infoArr = (NSArray *)resultModel.result;
- if(infoArr != nil && infoArr.count > 0)
- {
- [self.arrDataList removeAllObjects];
- [self.arrNewDataList removeAllObjects];
- [self.arrDataList addObjectsFromArray:infoArr];
- // 转换model对象
- for (int i = 0; i < self.arrDataList.count; i++)
- {
- NSDictionary *dicValue = self.arrDataList[i];
- StockingModel *model = [StockingModel dk_modelWithDictionary:dicValue];
- [self.arrNewDataList addObject:model];
- }
-
- [customTableView reloadData];
-
- }
- else{
- // 有刷新数据的时候
- if(self.arrDataList == nil || self.arrDataList.count == 0){
- [self showAlertViewBackText:@"未找到匹配结果"];
- }
- }
- }
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- || iStatus == ActionResultStatusNoLogin
- || iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue)
- {
- [self showReLoginDialog:message];
- }
- else
- {
- [self showAlertViewText:message];
- return;
- }
- }
- #pragma mark - 刷新回调
- /**
- 隐藏进度条
- */
- - (void)cancel {
- [self stopLoading];
- }
- /**
- 隐藏键盘
-
- @param scrollView <#scrollView description#>
- */
- - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
- {
- [self.view endEditing:YES];
- }
- #pragma mark - 私有函数
- /**
- 初始化ui
- */
- - (void)initUI{
- self.arrDataList = [[NSMutableArray alloc]init];
- self.arrNewDataList = [[NSMutableArray alloc]init];
- _infoModel = [[StockingModel alloc]init];
- customTableView = [[UITableView alloc]
- initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,
- Screen_Height-rectNavHeight-rectStatusHeight)];
-
- customTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- customTableView.delegate = self;
- customTableView.dataSource = self;
- [self.view addSubview:customTableView];
- }
- /**
- 加载数据
- */
- - (void)reloadDataByOnlyCode
- {
- //NSString *urlStr = ServerURL;
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetInventoryByOnlyCodeIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:_onlyCode forKeyedSubscript:@"OnlyCode"];
-
- self.downManager = [[ASIDownManager alloc] init];
- self.downManager.delegate = self;
- self.downManager.onRequestSuccess = @selector(onLoadFinish:);
- self.downManager.onRequestFail = @selector(onLoadFail:);
- [self.downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- @end
|