| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719 |
- //
- // SalesSlipListVCViewController.m
- // IBOSSmini
- //
- // Created by ssl on 2018/1/26.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "SalesSlipListVC.h"
- #import "SalesSlipListModel.h"
- #import "SalesSlipListCell.h"
- #import "SalesSlipGoodsListVC.h"
- #import "SalesSlipListDetailVC.h"
- @interface SalesSlipListVC()<UITableViewDataSource,
- UITableViewDelegate,SalesSlipListCellDelegate,
- RefreshTableViewDelegate>
- {
- int pageNumber;
- }
- @end
- @implementation SalesSlipListVC
- @synthesize vCustomTableView;
- - (void)viewDidLoad {
- [super viewDidLoad];
- _endDate = [DateFormat getCurrentDate];
- _startDate = [DateFormat getDateBefore:7];
- [self loadNavStyle];
- [self initUI];
- [self initSlideSlip];
- [self startLoading];
- [self loadData];
- }
- /**
- 导航按钮样式
- */
- -(void)loadNavStyle
- {
- //右边
- UIButton *btnAdd = [UIButton buttonWithType:UIButtonTypeCustom];
- [btnAdd addTarget:self action:@selector(add)
- forControlEvents:UIControlEventTouchUpInside];
- UIImage *pic =[UIImage imageNamed:@"title_add"];
- btnAdd.frame = CGRectMake(0, 0, 18, 18);
- [btnAdd setTitleColor:NavBarItemColor forState:UIControlStateNormal];
- [btnAdd setBackgroundImage:pic
- forState:UIControlStateNormal];
- UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:btnAdd];
- self.navigationItem.title=@"销售单列表";
- self.navigationItem.rightBarButtonItem = menubtnAdd;
-
- //返回
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
- forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0, 15, 18);
-
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- }
- - (void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)add{
- self.hidesBottomBarWhenPushed=YES;
- NewSaleSlipHomeVC *vc=[[NewSaleSlipHomeVC alloc] init];
- vc.editFLag=1;
- vc.refreshDelegate = self;
- [self.navigationController pushViewController:vc animated:YES];
- }
- /**
- 初始化ui
- */
- - (void)initUI{
-
- CGFloat height = 40;
- UIView *searchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 60)];
- searchView.backgroundColor = [UIColor whiteColor];
- UIButton *btnSearch = [UIButton buttonWithType:UIButtonTypeCustom];
- btnSearch.frame = CGRectMake(20,10, Screen_Width-height, height);
- btnSearch.layer.cornerRadius = 6.0f;
- [btnSearch setTitle:@"搜索" forState:UIControlStateNormal];
- [btnSearch setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- btnSearch.titleLabel.textAlignment = NSTextAlignmentCenter;
- btnSearch.titleLabel.font = [UIFont systemFontOfSize:LabelAndTextFontOfSize];
- btnSearch.backgroundColor = LineBackgroundColor;
- [btnSearch addTarget:self action:@selector(dataSearch) forControlEvents:UIControlEventTouchUpInside];
- [searchView addSubview:btnSearch];
- [self.view addSubview:searchView];
-
- UIView *topSeparatorView = [UIView new];
- topSeparatorView.frame=CGRectMake(0, CGRectGetMaxY(searchView.frame), Screen_Width, 10);
- topSeparatorView.backgroundColor = LineBackgroundColor;
- [self.view addSubview:topSeparatorView];
- _dataList=[[NSMutableArray alloc]init];
- vCustomTableView = [[RefreshTableView alloc]
- initWithFrame:CGRectMake(0,
- CGRectGetMaxY(topSeparatorView.frame),
- self.view.frame.size.width,
- Screen_Height - CGRectGetMaxY(topSeparatorView.frame))];
-
- vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- vCustomTableView.backgroundColor = [UIColor whiteColor];
- vCustomTableView.delegate = self;
-
- [self.view addSubview:vCustomTableView];
- self.vCustomTableView.mTableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 49, 0);
- pageNumber = 1;
- [self loadData];
- }
- -(void)loadData{
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetSalesListIphone" 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:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:_salesNo== nil?@"":_salesNo forKey:@"SalesNo"];
- [dict setObject:_goodsCode == nil?@"":_goodsCode forKey:@"Code"];
- [dict setObject:_customerName == nil?@"":_customerName forKey:@"CustomerName"];
- [dict setObject:_customerCode == nil?@"":_customerCode forKey:@"CustomerCode"];
- [dict setObject:_startDate == nil?@"":_startDate forKey:@"AccountDateFrom"];
- [dict setObject:_address == nil?@"":_address forKey:@"Address"];
- [dict setObject:_endDate == nil?@"":_endDate forKey:@"AccountDateTo"];
- [dict setObject:_invoiceStatus == nil?@"":_invoiceStatus forKey:@"InvoiceStatus"];
- [dict setObject:@"20" forKey:@"PageSize"];
- [dict setObject:[NSString stringWithFormat:@"%d",pageNumber] forKey:@"PageNum"];
- _downManager = [[ASIDownManager alloc] init];
- [self startLoading];
- _downManager.delegate = self;
- _downManager.OnImageDown = @selector(onOrderListFinish:);
- _downManager.OnImageFail = @selector(onOrderListFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- -(void)loadImageStyle{
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetInvoiceLayoutsForInvoice" 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:@"SAL001" forKey:@"BusinessType"];
- [dict setObject:kkOrganizationId forKey:@"OrgID"];
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.OnImageDown = @selector(onImageStyleLoadFinish:);
- _downManager.OnImageFail = @selector(onImageStyleLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- -(void)onImageStyleLoadFinish:(ASIDownManager *)sender{
- NSDictionary *dic = [sender.mWebStr JSONValue];
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- NSString *message=[dic objectForKey:@"Message"];
- if (iStatus == 0) {
- NSArray *infoArr=[dic objectForKey:@"Result"];
- // 返回结果
- if(infoArr!=nil&& infoArr.count>0)
- {
- _invoiceStyleList=[[NSMutableArray alloc]init];
- for (int i = 0; i < infoArr.count; i++) {
- NSDictionary * dic=infoArr[i];
- NSInteger invoiceLayoutId= [[dic objectForKey:@"InvoiceLayoutID"]integerValue];
-
- NSString *invoiceLayoutName=[dic objectForKey:@"InvoiceLayoutName"];
- InvoiceStyle *invoiceStyle=[InvoiceStyle new];
- [invoiceStyle setInvoiceStyleId:invoiceLayoutId];
- [invoiceStyle setInvoiceStyleName:invoiceLayoutName];
- [_invoiceStyleList addObject:invoiceStyle];
- }
- }
- }
- }
- }
- - (void)onImageStyleLoadFail:(ASIDownManager *)sender{
- [self showAlertViewText:@"加载失败"];
- }
- /**
- 加载总数数据成功回调
-
- @param sender <#sender description#>
- */
- - (void)onOrderListFinish:(ASIDownManager *)sender {
- NSDictionary *dic = [sender.mWebStr JSONValue];
- vCustomTableView.mTableView.backgroundView = nil;
- [self cancel];
- // 服务器返回数据是否正确
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- // 服务器返回数据状态值
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- int iNewCount = 0;
- // 服务器返回数据消息
- NSString *message=[dic objectForKey:@"Message"];
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- NSArray * infoArr=[dic objectForKey:@"Result"];
- // 返回结果
- if(infoArr!=nil&& infoArr.count>0)
- {
- for (int i = 0; i < infoArr.count; i++) {
- NSDictionary * dic=infoArr[i];
- SalesSlipListModel *salesSlipListModel=[[SalesSlipListModel alloc]init];
- [salesSlipListModel ParseDic:dic];
- [_dataList addObject:salesSlipListModel];
- }
- iNewCount =(int)infoArr.count;
- vCustomTableView.mbMoreHidden = (iNewCount == 0);
- [vCustomTableView FinishLoading];
- [vCustomTableView reloadData];
- [self loadImageStyle];
- }
- else{
-
- [vCustomTableView FinishLoading];
- vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- UIView *noDataView=[[UIView alloc]init];
- noDataView.frame=vCustomTableView.bounds;
- UIImageView *nodataImgView=[[UIImageView alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16,noDataView.frame.size.height/2-16,32,32)];
- [nodataImgView setImage:[UIImage imageNamed:@"icon_no_data"]];
- [noDataView addSubview:nodataImgView];
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16-12,CGRectGetMaxY(nodataImgView.frame)+3,70, 25)];
- label.font=[UIFont systemFontOfSize:NoDataFontOfSize];
- label.text = @"无数据";
- label.numberOfLines = 2;
- label.textColor = [UIColor lightGrayColor];
- [noDataView addSubview:label];
-
- // 有刷新数据的时候
- if(_dataList == nil || _dataList.count==0){
- vCustomTableView.mTableView.backgroundView =noDataView;
- [self showAlertViewBackText:@"未找到匹配结果"];
- }
-
-
- }
- }
- // 服务器返回数据状态值异常
- else if(iStatus==ActionResultStatusAuthError
- ||iStatus==ActionResultStatusNoLogin
- ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
- [self cancel];
- [self showReLoginDialog:message];
- }
- else{
- [self cancel];
- [vCustomTableView FinishLoading];
- [self showAlertViewText:message];
- }
- }
- }
- /**
- 加载总数数据失败回调
-
- @param sender <#sender description#>
- */
- - (void)onOrderListFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"加载失败"];
- }
- /**
- 加载总数数据成功回调
-
- @param sender <#sender description#>
- */
- - (void)onCorrectFinish:(ASIDownManager *)sender {
- NSDictionary *dic = [sender.mWebStr JSONValue];
- vCustomTableView.mTableView.backgroundView = nil;
- [self cancel];
- // 服务器返回数据是否正确
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- // 服务器返回数据状态值
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- int iNewCount = 0;
- // 服务器返回数据消息
- NSString *message=[dic objectForKey:@"Message"];
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- pageNumber = 1;
- [_dataList removeAllObjects];
- [vCustomTableView reloadData];
- vCustomTableView.mbMoreHidden=YES;
- [self startLoading];
- [self loadData];
- [self showAlertViewText:@"冲正成功"];
-
- }
- // 服务器返回数据状态值异常
- else if(iStatus==ActionResultStatusAuthError
- ||iStatus==ActionResultStatusNoLogin
- ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
-
- [self showReLoginDialog:message];
- }
- else{
-
- [vCustomTableView FinishLoading];
- [self showAlertViewText:message];
- }
- }
- }
- /**
- 加载总数数据失败回调
-
- @param sender <#sender description#>
- */
- - (void)onCorrectFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"加载失败"];
- }
- /**
- 删除报备
-
- @param cell <#cell description#>
- */
- - (void)goCorrect:(SalesSlipListCell *)cell {
-
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@""
- message:@"确定要冲正吗?" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定"
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *action){
- [self correctData:cell.salesOrder];
- }];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消"
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *action){
-
- }];
- UIColor *cancelColor=[UIColor blackColor];
- UIColor *sureColor=[UIColor redColor];
- [cancelAction setValue:cancelColor forKey:@"titleTextColor"];
- [okAction setValue:sureColor forKey:@"titleTextColor"];
- [alert addAction:okAction];
- [alert addAction:cancelAction];
- [self presentViewController:alert animated:YES completion:nil];
-
- }
- /**
- 搜索抽屉弹出
- */
- - (void)dataSearch{
- [_filterController show];
- }
- -(void)correctData:(SalesSlipListModel *)model{
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"SaveReverseSalesIphone" 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:model.salesId == nil?@"":model.salesId forKey:@"SalesID"];
- NSString *statusStr = [NSString stringWithFormat:@"%ld",(long)model.status];
- [dict setObject:statusStr == nil?@"":statusStr forKey:@"Status"];
- [dict setObject:[NSString stringWithFormat:@"%ld",(long)model.salesType] forKey:@"SalesType"];
- [self startLoading];
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.OnImageDown = @selector(onCorrectFinish:);
- _downManager.OnImageFail = @selector(onCorrectFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- -(void)goDetail:(SalesSlipListModel *)model{
- self.hidesBottomBarWhenPushed = YES;
- SalesSlipGoodsListVC *vc = [[SalesSlipGoodsListVC alloc] init];
- vc.salesSlipListModel=model;
- [self.navigationController pushViewController:vc animated:YES];
- }
- /**
- 编辑
- @param model <#model description#>
- */
- -(void)goEdit:(SalesSlipListModel*)model{
- self.hidesBottomBarWhenPushed = YES;
- NewSaleSlipHomeVC *vc = [[NewSaleSlipHomeVC alloc] init];
- vc.salesId=model.salesId;
- vc.refreshDelegate=self;
- vc.editFLag=2;
- [self.navigationController pushViewController:vc animated:YES];
- }
- -(void)goElectronicInvoice:(NSInteger)position{
-
- if(_invoiceStyleList==nil||_invoiceStyleList.count==0){
- [self showAlertViewText:@"没有设置相关的票据样式"];
- return;
- }
-
- NSInteger size=_invoiceStyleList.count;
-
- if(size==1){
- self.hidesBottomBarWhenPushed=YES;
- InvoiceStyle *style=[_invoiceStyleList objectAtIndex:0];
- ElectronicInvoiceVCViewController *vc=[[ElectronicInvoiceVCViewController alloc]init];
- SalesSlipListModel *salesSlipModel=[_dataList objectAtIndex:position];
- vc.salesId=salesSlipModel.salesId;
- vc.salesNo=salesSlipModel.SalesNo;
- vc.invoiceStyleId=style.invoiceStyleId;
- vc.invoiceFlag=@"saleSlip";
- [self.navigationController pushViewController:vc animated:YES];
-
- }
- else{
- [self showPopView:position ];
- }
-
- }
- -(void)goReceivables:(SalesSlipListModel*)model{
- self.hidesBottomBarWhenPushed = YES;
- SalesSlipReceivablesVC *vc=[[SalesSlipReceivablesVC alloc]init];
- vc.salesSlipModel=model;
- vc.refreshDelegate=self;
- [self.navigationController pushViewController:vc animated:YES];
- }
- -(void)goElectronicInvoice:(InvoiceStyle *)style position:(NSInteger )position{
- self.hidesBottomBarWhenPushed=YES;
- ElectronicInvoiceVCViewController *vc=[[ElectronicInvoiceVCViewController alloc]init];
- SalesSlipListModel *salesSlipModel=[_dataList objectAtIndex:position];
- vc.salesId=salesSlipModel.salesId;
- vc.salesNo=salesSlipModel.SalesNo;
- vc.invoiceStyleId=style.invoiceStyleId;
- vc.invoiceFlag=@"saleSlip";
- [self.navigationController pushViewController:vc animated:YES];
- }
- /**
- 抽屉初始化
- */
- - (void)initSlideSlip{
- // 抽屉对象
- __weak typeof(self) weakself=self;
- self.filterController = [[SideSlipFilterController alloc]
- initWithSponsor:self
- resetBlock:^(NSArray *dataList) {
- for (SideSlipModel *model in dataList) {
-
- model.selectedItemList = nil;
- model.customDict = nil;
- }
- } commitBlock:^(NSArray *dataList) {
- // 查询条件
- SideSlipModel *serviceRegionModel = dataList[0];
- SalesSlipSearchModel *m = [serviceRegionModel.customDict objectForKey:ORDER_SEARCH_RANGE_MODEL];
-
- _salesNo= m.SalesNo;
- _customerName=m.customerName;
- if([m.startDate isEqualToString:@"请选择开始账务日期"]){
- _startDate=@"";
- }
- else{
- _startDate=m.startDate;
- }
-
- if([m.endDate isEqualToString:@"请选择结束账务日期"]){
- _endDate=@"";
- }
- else{
- _endDate=m.endDate;
- }
-
-
- _goodsCode=m.goodsCode;
- _customerCode=m.customerCode;
- _address = m.customerAddress;
- _invoiceStatus=m.invoiceStatus;
- [weakself.filterController dismiss];
- pageNumber = 1;
- [_dataList removeAllObjects];
- [vCustomTableView reloadData];
- vCustomTableView.mbMoreHidden=YES;
- [self startLoading];
- [self loadData];
- }];
- _filterController.animationDuration = AnimationDuration;
- _filterController.hasHeadView = YES;
- _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
- _filterController.dataList = [self packageDataList];
- }
- /**
- 数据源
-
- @return <#return value description#>
- */
- - (NSArray *)packageDataList {
- NSMutableArray *dataArray = [NSMutableArray array];
- SideSlipModel *model = [[SideSlipModel alloc] init];
- model.containerCellClass = @"SalesSlipSearchCell";
- model.regionTitle = @"查询条件";
-
- [dataArray addObject:model];
- return [dataArray mutableCopy];
- }
- -(void)showPopView:(NSInteger) position{
- _sheetView = [[TFSheetView alloc]init];
- _sheetView.delegate=self;
- [_sheetView showInView:self.view dataArry:_invoiceStyleList position:position];
- }
- /**
- 隐藏进度条
- */
- - (void)cancel {
- [self stopLoading];
- }
- #pragma mark - 刷新回调
- /**
- 取消刷新
-
- @param sender sender description
- @return return value description
- */
- - (BOOL)CanRefreshTableView:(RefreshTableView *)sender {
- return YES;
- }
- /**
- 返回后刷新
- */
- -(void)refreshOrderData{
- pageNumber = 1;
- [_dataList removeAllObjects];
- [vCustomTableView reloadData];
- vCustomTableView.mbMoreHidden=YES;
- [self startLoading];
- [self loadData];
- }
- /**
- 加载更多
-
- @param sender sender description
- */
- - (void)LoadMoreList:(RefreshTableView *)sender {
- pageNumber++;
- [self startLoading];
- [self loadData];
- }
- /**
- 下拉刷新
-
- @param sender <#sender description#>
- */
- - (void)ReloadList:(RefreshTableView *)sender{
- pageNumber = 1;
- [_dataList removeAllObjects];
- [vCustomTableView reloadData];
- vCustomTableView.mbMoreHidden=YES;
- [self startLoading];
- [self loadData];
- }
- /**
- 隐藏键盘
-
- @param scrollView <#scrollView description#>
- */
- -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
- {
- [self.view endEditing:YES];
- }
- #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 [_dataList 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 337;
-
- }
- /**
- 每个单元格cell
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"SalesSlipListCell";
- SalesSlipListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
- if (!cell) {
- cell=[[SalesSlipListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
-
- _salesSlipListModel= [_dataList objectAtIndex:indexPath.row];
- cell.delegate = self;
- cell.cellIndex=indexPath.row;
- [cell setSalesOrder:_salesSlipListModel];
-
- return cell;
- }
- /**
- 点击单元格事件
-
- @param tableView tableView description
- @param indexPath indexPath description
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- self.hidesBottomBarWhenPushed=YES;
- SalesSlipListDetailVC *detailVc=[[SalesSlipListDetailVC alloc] init];
- detailVc.salesSlipListVC = self;
- SalesSlipListModel *infoModel= [_dataList objectAtIndex:indexPath.row];
- detailVc.model=infoModel;
- [self.navigationController pushViewController:detailVc animated:YES];
- }
- #pragma mark - scrollView回调
- /**
- 显示下拉更新
-
- @param scrollView <#scrollView description#>
- */
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- if (scrollView.isDragging) {//显示下拉更新
-
- if (vCustomTableView.mRefreshHeader.state == PullRefreshPulling && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && [vCustomTableView CanRefresh]) {
- [vCustomTableView.mRefreshHeader setState:PullRefreshNormal];
- }
- else if (vCustomTableView.mRefreshHeader.state == PullRefreshNormal && scrollView.contentOffset.y < -65.0f && [vCustomTableView CanRefresh]) {//显示松开更新
- [vCustomTableView.mRefreshHeader setState:PullRefreshPulling];
- }
- }
- }
- /**
- 修改:2017-9-25
- 适配机型
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- self.view.backgroundColor = [UIColor whiteColor];
- vCustomTableView.frame = CGRectMake(0, 70, SCREENWIDTH, self.view.safeAreaLayoutGuide.layoutFrame.size.height- 70 );
-
- [super viewSafeAreaInsetsDidChange];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-
- }
- /**
- 冲正刷新
- */
- -(void)refreshData{
- pageNumber = 1;
- [_dataList removeAllObjects];
- [vCustomTableView reloadData];
- vCustomTableView.mbMoreHidden=YES;
- [self startLoading];
- [self loadData];
- }
- @end
|