SalesOrderListVC.m 26 KB

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