SalesSlipListVC.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. //
  2. // SalesSlipListVCViewController.m
  3. // IBOSSmini
  4. //
  5. // Created by ssl on 2018/1/26.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "SalesSlipListVC.h"
  9. #import "SalesSlipListModel.h"
  10. #import "SalesSlipListCell.h"
  11. #import "SalesSlipGoodsListVC.h"
  12. #import "SalesSlipListDetailVC.h"
  13. @interface SalesSlipListVC()<UITableViewDataSource,
  14. UITableViewDelegate,SalesSlipListCellDelegate,
  15. RefreshTableViewDelegate>
  16. {
  17. int pageNumber;
  18. }
  19. @end
  20. @implementation SalesSlipListVC
  21. @synthesize vCustomTableView;
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. _endDate = [DateFormat getCurrentDate];
  25. _startDate = [DateFormat getDateBefore:7];
  26. [self loadNavStyle];
  27. [self initUI];
  28. [self initSlideSlip];
  29. [self startLoading];
  30. [self loadData];
  31. }
  32. /**
  33. 导航按钮样式
  34. */
  35. -(void)loadNavStyle
  36. {
  37. //右边
  38. UIButton *btnAdd = [UIButton buttonWithType:UIButtonTypeCustom];
  39. [btnAdd addTarget:self action:@selector(add)
  40. forControlEvents:UIControlEventTouchUpInside];
  41. UIImage *pic =[UIImage imageNamed:@"title_add"];
  42. btnAdd.frame = CGRectMake(0, 0, 18, 18);
  43. [btnAdd setTitleColor:NavBarItemColor forState:UIControlStateNormal];
  44. [btnAdd setBackgroundImage:pic
  45. forState:UIControlStateNormal];
  46. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:btnAdd];
  47. self.navigationItem.title=@"销售单列表";
  48. self.navigationItem.rightBarButtonItem = menubtnAdd;
  49. //返回
  50. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  51. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  52. forState:UIControlStateNormal];
  53. [button addTarget:self action:@selector(goBack)
  54. forControlEvents:UIControlEventTouchUpInside];
  55. button.frame = CGRectMake(0, 0, 15, 18);
  56. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  57. self.navigationItem.leftBarButtonItem = menuButton;
  58. }
  59. - (void)goBack
  60. {
  61. [self.navigationController popViewControllerAnimated:YES];
  62. }
  63. -(void)add{
  64. self.hidesBottomBarWhenPushed=YES;
  65. NewSaleSlipHomeVC *vc=[[NewSaleSlipHomeVC alloc] init];
  66. vc.editFLag=1;
  67. vc.refreshDelegate = self;
  68. [self.navigationController pushViewController:vc animated:YES];
  69. }
  70. /**
  71. 初始化ui
  72. */
  73. - (void)initUI{
  74. CGFloat height = 40;
  75. UIView *searchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 60)];
  76. searchView.backgroundColor = [UIColor whiteColor];
  77. UIButton *btnSearch = [UIButton buttonWithType:UIButtonTypeCustom];
  78. btnSearch.frame = CGRectMake(20,10, Screen_Width-height, height);
  79. btnSearch.layer.cornerRadius = 6.0f;
  80. [btnSearch setTitle:@"搜索" forState:UIControlStateNormal];
  81. [btnSearch setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  82. btnSearch.titleLabel.textAlignment = NSTextAlignmentCenter;
  83. btnSearch.titleLabel.font = [UIFont systemFontOfSize:LabelAndTextFontOfSize];
  84. btnSearch.backgroundColor = LineBackgroundColor;
  85. [btnSearch addTarget:self action:@selector(dataSearch) forControlEvents:UIControlEventTouchUpInside];
  86. [searchView addSubview:btnSearch];
  87. [self.view addSubview:searchView];
  88. UIView *topSeparatorView = [UIView new];
  89. topSeparatorView.frame=CGRectMake(0, CGRectGetMaxY(searchView.frame), Screen_Width, 10);
  90. topSeparatorView.backgroundColor = LineBackgroundColor;
  91. [self.view addSubview:topSeparatorView];
  92. _dataList=[[NSMutableArray alloc]init];
  93. vCustomTableView = [[RefreshTableView alloc]
  94. initWithFrame:CGRectMake(0,
  95. CGRectGetMaxY(topSeparatorView.frame),
  96. self.view.frame.size.width,
  97. Screen_Height - CGRectGetMaxY(topSeparatorView.frame))];
  98. vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  99. vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  100. vCustomTableView.backgroundColor = [UIColor whiteColor];
  101. vCustomTableView.delegate = self;
  102. [self.view addSubview:vCustomTableView];
  103. self.vCustomTableView.mTableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 49, 0);
  104. pageNumber = 1;
  105. [self loadData];
  106. }
  107. -(void)loadData{
  108. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  109. [dict setObject:@"GetSalesListIphone" forKey:@"Action"];
  110. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  111. [dict setObject:kkUserCode forKey:@"UserCode"];
  112. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  113. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  114. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  115. [dict setObject:_salesNo== nil?@"":_salesNo forKey:@"SalesNo"];
  116. [dict setObject:_goodsCode == nil?@"":_goodsCode forKey:@"Code"];
  117. [dict setObject:_customerName == nil?@"":_customerName forKey:@"CustomerName"];
  118. [dict setObject:_customerCode == nil?@"":_customerCode forKey:@"CustomerCode"];
  119. [dict setObject:_startDate == nil?@"":_startDate forKey:@"AccountDateFrom"];
  120. [dict setObject:_address == nil?@"":_address forKey:@"Address"];
  121. [dict setObject:_endDate == nil?@"":_endDate forKey:@"AccountDateTo"];
  122. [dict setObject:_invoiceStatus == nil?@"":_invoiceStatus forKey:@"InvoiceStatus"];
  123. [dict setObject:@"20" forKey:@"PageSize"];
  124. [dict setObject:[NSString stringWithFormat:@"%d",pageNumber] forKey:@"PageNum"];
  125. _downManager = [[ASIDownManager alloc] init];
  126. [self startLoading];
  127. _downManager.delegate = self;
  128. _downManager.OnImageDown = @selector(onOrderListFinish:);
  129. _downManager.OnImageFail = @selector(onOrderListFail:);
  130. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  131. }
  132. -(void)loadImageStyle{
  133. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  134. [dict setObject:@"GetInvoiceLayoutsForInvoice" forKey:@"Action"];
  135. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  136. [dict setObject:kkUserCode forKey:@"UserCode"];
  137. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  138. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  139. [dict setObject:@"SAL001" forKey:@"BusinessType"];
  140. [dict setObject:kkOrganizationId forKey:@"OrgID"];
  141. _downManager = [[ASIDownManager alloc] init];
  142. _downManager.delegate = self;
  143. _downManager.OnImageDown = @selector(onImageStyleLoadFinish:);
  144. _downManager.OnImageFail = @selector(onImageStyleLoadFail:);
  145. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  146. }
  147. -(void)onImageStyleLoadFinish:(ASIDownManager *)sender{
  148. NSDictionary *dic = [sender.mWebStr JSONValue];
  149. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  150. int iStatus = [[dic objectForKey:@"Status"] intValue];
  151. NSString *message=[dic objectForKey:@"Message"];
  152. if (iStatus == 0) {
  153. NSArray *infoArr=[dic objectForKey:@"Result"];
  154. // 返回结果
  155. if(infoArr!=nil&& infoArr.count>0)
  156. {
  157. _invoiceStyleList=[[NSMutableArray alloc]init];
  158. for (int i = 0; i < infoArr.count; i++) {
  159. NSDictionary * dic=infoArr[i];
  160. NSInteger invoiceLayoutId= [[dic objectForKey:@"InvoiceLayoutID"]integerValue];
  161. NSString *invoiceLayoutName=[dic objectForKey:@"InvoiceLayoutName"];
  162. InvoiceStyle *invoiceStyle=[InvoiceStyle new];
  163. [invoiceStyle setInvoiceStyleId:invoiceLayoutId];
  164. [invoiceStyle setInvoiceStyleName:invoiceLayoutName];
  165. [_invoiceStyleList addObject:invoiceStyle];
  166. }
  167. }
  168. }
  169. }
  170. }
  171. - (void)onImageStyleLoadFail:(ASIDownManager *)sender{
  172. [self showAlertViewText:@"加载失败"];
  173. }
  174. /**
  175. 加载总数数据成功回调
  176. @param sender <#sender description#>
  177. */
  178. - (void)onOrderListFinish:(ASIDownManager *)sender {
  179. NSDictionary *dic = [sender.mWebStr JSONValue];
  180. vCustomTableView.mTableView.backgroundView = nil;
  181. [self cancel];
  182. // 服务器返回数据是否正确
  183. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  184. // 服务器返回数据状态值
  185. int iStatus = [[dic objectForKey:@"Status"] intValue];
  186. int iNewCount = 0;
  187. // 服务器返回数据消息
  188. NSString *message=[dic objectForKey:@"Message"];
  189. // 服务器返回数据状态值正确
  190. if (iStatus == 0) {
  191. NSArray * infoArr=[dic objectForKey:@"Result"];
  192. // 返回结果
  193. if(infoArr!=nil&& infoArr.count>0)
  194. {
  195. for (int i = 0; i < infoArr.count; i++) {
  196. NSDictionary * dic=infoArr[i];
  197. SalesSlipListModel *salesSlipListModel=[[SalesSlipListModel alloc]init];
  198. [salesSlipListModel ParseDic:dic];
  199. [_dataList addObject:salesSlipListModel];
  200. }
  201. iNewCount =(int)infoArr.count;
  202. vCustomTableView.mbMoreHidden = (iNewCount == 0);
  203. [vCustomTableView FinishLoading];
  204. [vCustomTableView reloadData];
  205. [self loadImageStyle];
  206. }
  207. else{
  208. [vCustomTableView FinishLoading];
  209. vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  210. UIView *noDataView=[[UIView alloc]init];
  211. noDataView.frame=vCustomTableView.bounds;
  212. UIImageView *nodataImgView=[[UIImageView alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16,noDataView.frame.size.height/2-16,32,32)];
  213. [nodataImgView setImage:[UIImage imageNamed:@"icon_no_data"]];
  214. [noDataView addSubview:nodataImgView];
  215. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16-12,CGRectGetMaxY(nodataImgView.frame)+3,70, 25)];
  216. label.font=[UIFont systemFontOfSize:NoDataFontOfSize];
  217. label.text = @"无数据";
  218. label.numberOfLines = 2;
  219. label.textColor = [UIColor lightGrayColor];
  220. [noDataView addSubview:label];
  221. // 有刷新数据的时候
  222. if(_dataList == nil || _dataList.count==0){
  223. vCustomTableView.mTableView.backgroundView =noDataView;
  224. [self showAlertViewBackText:@"未找到匹配结果"];
  225. }
  226. }
  227. }
  228. // 服务器返回数据状态值异常
  229. else if(iStatus==ActionResultStatusAuthError
  230. ||iStatus==ActionResultStatusNoLogin
  231. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  232. [self cancel];
  233. [self showReLoginDialog:message];
  234. }
  235. else{
  236. [self cancel];
  237. [vCustomTableView FinishLoading];
  238. [self showAlertViewText:message];
  239. }
  240. }
  241. }
  242. /**
  243. 加载总数数据失败回调
  244. @param sender <#sender description#>
  245. */
  246. - (void)onOrderListFail:(ASIDownManager *)sender {
  247. [self cancel];
  248. [self showAlertViewText:@"加载失败"];
  249. }
  250. /**
  251. 加载总数数据成功回调
  252. @param sender <#sender description#>
  253. */
  254. - (void)onCorrectFinish:(ASIDownManager *)sender {
  255. NSDictionary *dic = [sender.mWebStr JSONValue];
  256. vCustomTableView.mTableView.backgroundView = nil;
  257. [self cancel];
  258. // 服务器返回数据是否正确
  259. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  260. // 服务器返回数据状态值
  261. int iStatus = [[dic objectForKey:@"Status"] intValue];
  262. int iNewCount = 0;
  263. // 服务器返回数据消息
  264. NSString *message=[dic objectForKey:@"Message"];
  265. // 服务器返回数据状态值正确
  266. if (iStatus == 0) {
  267. pageNumber = 1;
  268. [_dataList removeAllObjects];
  269. [vCustomTableView reloadData];
  270. vCustomTableView.mbMoreHidden=YES;
  271. [self startLoading];
  272. [self loadData];
  273. [self showAlertViewText:@"冲正成功"];
  274. }
  275. // 服务器返回数据状态值异常
  276. else if(iStatus==ActionResultStatusAuthError
  277. ||iStatus==ActionResultStatusNoLogin
  278. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  279. [self showReLoginDialog:message];
  280. }
  281. else{
  282. [vCustomTableView FinishLoading];
  283. [self showAlertViewText:message];
  284. }
  285. }
  286. }
  287. /**
  288. 加载总数数据失败回调
  289. @param sender <#sender description#>
  290. */
  291. - (void)onCorrectFail:(ASIDownManager *)sender {
  292. [self cancel];
  293. [self showAlertViewText:@"加载失败"];
  294. }
  295. /**
  296. 删除报备
  297. @param cell <#cell description#>
  298. */
  299. - (void)goCorrect:(SalesSlipListCell *)cell {
  300. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@""
  301. message:@"确定要冲正吗?" preferredStyle:UIAlertControllerStyleAlert];
  302. UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定"
  303. style:UIAlertActionStyleDefault
  304. handler:^(UIAlertAction *action){
  305. [self correctData:cell.salesOrder];
  306. }];
  307. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消"
  308. style:UIAlertActionStyleDefault
  309. handler:^(UIAlertAction *action){
  310. }];
  311. UIColor *cancelColor=[UIColor blackColor];
  312. UIColor *sureColor=[UIColor redColor];
  313. [cancelAction setValue:cancelColor forKey:@"titleTextColor"];
  314. [okAction setValue:sureColor forKey:@"titleTextColor"];
  315. [alert addAction:okAction];
  316. [alert addAction:cancelAction];
  317. [self presentViewController:alert animated:YES completion:nil];
  318. }
  319. /**
  320. 搜索抽屉弹出
  321. */
  322. - (void)dataSearch{
  323. [_filterController show];
  324. }
  325. -(void)correctData:(SalesSlipListModel *)model{
  326. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  327. [dict setObject:@"SaveReverseSalesIphone" forKey:@"Action"];
  328. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  329. [dict setObject:kkUserCode forKey:@"UserCode"];
  330. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  331. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  332. [dict setObject:model.salesId == nil?@"":model.salesId forKey:@"SalesID"];
  333. NSString *statusStr = [NSString stringWithFormat:@"%ld",(long)model.status];
  334. [dict setObject:statusStr == nil?@"":statusStr forKey:@"Status"];
  335. [dict setObject:[NSString stringWithFormat:@"%ld",(long)model.salesType] forKey:@"SalesType"];
  336. [self startLoading];
  337. _downManager = [[ASIDownManager alloc] init];
  338. _downManager.delegate = self;
  339. _downManager.OnImageDown = @selector(onCorrectFinish:);
  340. _downManager.OnImageFail = @selector(onCorrectFail:);
  341. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  342. }
  343. -(void)goDetail:(SalesSlipListModel *)model{
  344. self.hidesBottomBarWhenPushed = YES;
  345. SalesSlipGoodsListVC *vc = [[SalesSlipGoodsListVC alloc] init];
  346. vc.salesSlipListModel=model;
  347. [self.navigationController pushViewController:vc animated:YES];
  348. }
  349. /**
  350. 编辑
  351. @param model <#model description#>
  352. */
  353. -(void)goEdit:(SalesSlipListModel*)model{
  354. self.hidesBottomBarWhenPushed = YES;
  355. NewSaleSlipHomeVC *vc = [[NewSaleSlipHomeVC alloc] init];
  356. vc.salesId=model.salesId;
  357. vc.refreshDelegate=self;
  358. vc.editFLag=2;
  359. [self.navigationController pushViewController:vc animated:YES];
  360. }
  361. -(void)goElectronicInvoice:(NSInteger)position{
  362. if(_invoiceStyleList==nil||_invoiceStyleList.count==0){
  363. [self showAlertViewText:@"没有设置相关的票据样式"];
  364. return;
  365. }
  366. NSInteger size=_invoiceStyleList.count;
  367. if(size==1){
  368. self.hidesBottomBarWhenPushed=YES;
  369. InvoiceStyle *style=[_invoiceStyleList objectAtIndex:0];
  370. ElectronicInvoiceVCViewController *vc=[[ElectronicInvoiceVCViewController alloc]init];
  371. SalesSlipListModel *salesSlipModel=[_dataList objectAtIndex:position];
  372. vc.salesId=salesSlipModel.salesId;
  373. vc.salesNo=salesSlipModel.SalesNo;
  374. vc.invoiceStyleId=style.invoiceStyleId;
  375. vc.invoiceFlag=@"saleSlip";
  376. [self.navigationController pushViewController:vc animated:YES];
  377. }
  378. else{
  379. [self showPopView:position ];
  380. }
  381. }
  382. -(void)goReceivables:(SalesSlipListModel*)model{
  383. self.hidesBottomBarWhenPushed = YES;
  384. SalesSlipReceivablesVC *vc=[[SalesSlipReceivablesVC alloc]init];
  385. vc.salesSlipModel=model;
  386. vc.refreshDelegate=self;
  387. [self.navigationController pushViewController:vc animated:YES];
  388. }
  389. -(void)goElectronicInvoice:(InvoiceStyle *)style position:(NSInteger )position{
  390. self.hidesBottomBarWhenPushed=YES;
  391. ElectronicInvoiceVCViewController *vc=[[ElectronicInvoiceVCViewController alloc]init];
  392. SalesSlipListModel *salesSlipModel=[_dataList objectAtIndex:position];
  393. vc.salesId=salesSlipModel.salesId;
  394. vc.salesNo=salesSlipModel.SalesNo;
  395. vc.invoiceStyleId=style.invoiceStyleId;
  396. vc.invoiceFlag=@"saleSlip";
  397. [self.navigationController pushViewController:vc animated:YES];
  398. }
  399. /**
  400. 抽屉初始化
  401. */
  402. - (void)initSlideSlip{
  403. // 抽屉对象
  404. __weak typeof(self) weakself=self;
  405. self.filterController = [[SideSlipFilterController alloc]
  406. initWithSponsor:self
  407. resetBlock:^(NSArray *dataList) {
  408. for (SideSlipModel *model in dataList) {
  409. model.selectedItemList = nil;
  410. model.customDict = nil;
  411. }
  412. } commitBlock:^(NSArray *dataList) {
  413. // 查询条件
  414. SideSlipModel *serviceRegionModel = dataList[0];
  415. SalesSlipSearchModel *m = [serviceRegionModel.customDict objectForKey:ORDER_SEARCH_RANGE_MODEL];
  416. _salesNo= m.SalesNo;
  417. _customerName=m.customerName;
  418. if([m.startDate isEqualToString:@"请选择开始账务日期"]){
  419. _startDate=@"";
  420. }
  421. else{
  422. _startDate=m.startDate;
  423. }
  424. if([m.endDate isEqualToString:@"请选择结束账务日期"]){
  425. _endDate=@"";
  426. }
  427. else{
  428. _endDate=m.endDate;
  429. }
  430. _goodsCode=m.goodsCode;
  431. _customerCode=m.customerCode;
  432. _address = m.customerAddress;
  433. _invoiceStatus=m.invoiceStatus;
  434. [weakself.filterController dismiss];
  435. pageNumber = 1;
  436. [_dataList removeAllObjects];
  437. [vCustomTableView reloadData];
  438. vCustomTableView.mbMoreHidden=YES;
  439. [self startLoading];
  440. [self loadData];
  441. }];
  442. _filterController.animationDuration = AnimationDuration;
  443. _filterController.hasHeadView = YES;
  444. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  445. _filterController.dataList = [self packageDataList];
  446. }
  447. /**
  448. 数据源
  449. @return <#return value description#>
  450. */
  451. - (NSArray *)packageDataList {
  452. NSMutableArray *dataArray = [NSMutableArray array];
  453. SideSlipModel *model = [[SideSlipModel alloc] init];
  454. model.containerCellClass = @"SalesSlipSearchCell";
  455. model.regionTitle = @"查询条件";
  456. [dataArray addObject:model];
  457. return [dataArray mutableCopy];
  458. }
  459. -(void)showPopView:(NSInteger) position{
  460. _sheetView = [[TFSheetView alloc]init];
  461. _sheetView.delegate=self;
  462. [_sheetView showInView:self.view dataArry:_invoiceStyleList position:position];
  463. }
  464. /**
  465. 隐藏进度条
  466. */
  467. - (void)cancel {
  468. [self stopLoading];
  469. }
  470. #pragma mark - 刷新回调
  471. /**
  472. 取消刷新
  473. @param sender sender description
  474. @return return value description
  475. */
  476. - (BOOL)CanRefreshTableView:(RefreshTableView *)sender {
  477. return YES;
  478. }
  479. /**
  480. 返回后刷新
  481. */
  482. -(void)refreshOrderData{
  483. pageNumber = 1;
  484. [_dataList removeAllObjects];
  485. [vCustomTableView reloadData];
  486. vCustomTableView.mbMoreHidden=YES;
  487. [self startLoading];
  488. [self loadData];
  489. }
  490. /**
  491. 加载更多
  492. @param sender sender description
  493. */
  494. - (void)LoadMoreList:(RefreshTableView *)sender {
  495. pageNumber++;
  496. [self startLoading];
  497. [self loadData];
  498. }
  499. /**
  500. 下拉刷新
  501. @param sender <#sender description#>
  502. */
  503. - (void)ReloadList:(RefreshTableView *)sender{
  504. pageNumber = 1;
  505. [_dataList removeAllObjects];
  506. [vCustomTableView reloadData];
  507. vCustomTableView.mbMoreHidden=YES;
  508. [self startLoading];
  509. [self loadData];
  510. }
  511. /**
  512. 隐藏键盘
  513. @param scrollView <#scrollView description#>
  514. */
  515. -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
  516. {
  517. [self.view endEditing:YES];
  518. }
  519. #pragma mark - 委托回调函数
  520. #pragma mark - tableView回调
  521. /**
  522. 单元格cell个数
  523. @param tableView <#tableView description#>
  524. @param section <#section description#>
  525. @return <#return value description#>
  526. */
  527. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  528. {
  529. return [_dataList count];
  530. }
  531. /**
  532. <#Description#>
  533. @param tableView <#tableView description#>
  534. @return <#return value description#>
  535. */
  536. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  537. return 1;
  538. }
  539. /**
  540. 高度
  541. @param tableView <#tableView description#>
  542. @param indexPath <#indexPath description#>
  543. @return <#return value description#>
  544. */
  545. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  546. return 337;
  547. }
  548. /**
  549. 每个单元格cell
  550. @param tableView <#tableView description#>
  551. @param indexPath <#indexPath description#>
  552. @return <#return value description#>
  553. */
  554. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  555. {
  556. static NSString *CellIdentifier = @"SalesSlipListCell";
  557. SalesSlipListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
  558. if (!cell) {
  559. cell=[[SalesSlipListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  560. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  561. }
  562. else
  563. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  564. {
  565. while ([cell.contentView.subviews lastObject] != nil) {
  566. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  567. }
  568. }
  569. _salesSlipListModel= [_dataList objectAtIndex:indexPath.row];
  570. cell.delegate = self;
  571. cell.cellIndex=indexPath.row;
  572. [cell setSalesOrder:_salesSlipListModel];
  573. return cell;
  574. }
  575. /**
  576. 点击单元格事件
  577. @param tableView tableView description
  578. @param indexPath indexPath description
  579. */
  580. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  581. {
  582. self.hidesBottomBarWhenPushed=YES;
  583. SalesSlipListDetailVC *detailVc=[[SalesSlipListDetailVC alloc] init];
  584. detailVc.salesSlipListVC = self;
  585. SalesSlipListModel *infoModel= [_dataList objectAtIndex:indexPath.row];
  586. detailVc.model=infoModel;
  587. [self.navigationController pushViewController:detailVc animated:YES];
  588. }
  589. #pragma mark - scrollView回调
  590. /**
  591. 显示下拉更新
  592. @param scrollView <#scrollView description#>
  593. */
  594. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  595. if (scrollView.isDragging) {//显示下拉更新
  596. if (vCustomTableView.mRefreshHeader.state == PullRefreshPulling && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && [vCustomTableView CanRefresh]) {
  597. [vCustomTableView.mRefreshHeader setState:PullRefreshNormal];
  598. }
  599. else if (vCustomTableView.mRefreshHeader.state == PullRefreshNormal && scrollView.contentOffset.y < -65.0f && [vCustomTableView CanRefresh]) {//显示松开更新
  600. [vCustomTableView.mRefreshHeader setState:PullRefreshPulling];
  601. }
  602. }
  603. }
  604. /**
  605. 修改:2017-9-25
  606. 适配机型
  607. 安全区视图发生变化
  608. */
  609. -(void)viewSafeAreaInsetsDidChange{
  610. self.view.backgroundColor = [UIColor whiteColor];
  611. vCustomTableView.frame = CGRectMake(0, 70, SCREENWIDTH, self.view.safeAreaLayoutGuide.layoutFrame.size.height- 70 );
  612. [super viewSafeAreaInsetsDidChange];
  613. }
  614. - (void)didReceiveMemoryWarning {
  615. [super didReceiveMemoryWarning];
  616. }
  617. /**
  618. 冲正刷新
  619. */
  620. -(void)refreshData{
  621. pageNumber = 1;
  622. [_dataList removeAllObjects];
  623. [vCustomTableView reloadData];
  624. vCustomTableView.mbMoreHidden=YES;
  625. [self startLoading];
  626. [self loadData];
  627. }
  628. @end