OrderSaleViewController.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. //
  2. // OrderSaleViewController.m
  3. // IBOSSmini
  4. //
  5. // Created by apple on 2017/5/15.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "OrderSaleViewController.h"
  9. #import "OrderSaleTotalModel.h"
  10. #import "DateFormat.h"
  11. #import "OrderSaleListModel.h"
  12. #import "OrderSalesTableViewCell.h"
  13. #import "SideSlipModel.h"
  14. #import "OrderSalesSearchModel.h"
  15. #import "OrderSalesDetailViewController.h"
  16. @interface OrderSaleViewController ()
  17. @end
  18. @implementation OrderSaleViewController
  19. #pragma mark - 公共函数
  20. /**
  21. viewDidLoad函数
  22. */
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. [self showTitle:@"销售单订单"];
  26. _mEndDate= [DateFormat getCurrentDate];
  27. _mStartDate=[DateFormat getDateBefore:7];
  28. [self loadNavStyle];
  29. [self initUI];
  30. [self initSlideSlip];
  31. _stockArr=[NSMutableArray new];
  32. _details=[NSMutableArray new];
  33. _correctStatus=@"1";
  34. [self reloadData];
  35. }
  36. /**
  37. 安全区视图发生变化
  38. */
  39. -(void)viewSafeAreaInsetsDidChange{
  40. self.view.backgroundColor = [UIColor whiteColor];
  41. _vCustomTableView.frame = self.view.safeAreaLayoutGuide.layoutFrame;
  42. [super viewSafeAreaInsetsDidChange];
  43. }
  44. /**
  45. 抽屉初始化
  46. */
  47. - (void)initSlideSlip{
  48. // 抽屉对象
  49. __weak typeof(self) weakself=self;
  50. self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
  51. for (SideSlipModel *model in dataList) {
  52. model.selectedItemList = nil;
  53. model.customDict = nil;
  54. }
  55. } commitBlock:^(NSArray *dataList) {
  56. // 查询条件
  57. SideSlipModel *model = dataList[0];
  58. OrderSalesSearchModel *m = [model.customDict objectForKey:SEARCH_RANGE_MODEL];
  59. _mStartDate=m.startDate;
  60. _mEndDate=m.endDate;
  61. _mCustomerName=m.customerName;
  62. _mTelephone=m.contactTelephone;
  63. _mInvoiceType=m.invoiceTypeId;
  64. _correctStatus=m.correctStatus;
  65. if(_mStartDate==nil){
  66. [self showAlertViewText:@"请选择开始日期"];
  67. return;
  68. }
  69. if(_mEndDate==nil){
  70. [self showAlertViewText:@"请选择结束日期"];
  71. return;
  72. }
  73. NSUInteger result= [DateFormat compareDate:_mStartDate withDate:_mEndDate];
  74. if(result == -1){
  75. [self showAlertViewText:@"开始日期不能大于结束日期"];
  76. return;
  77. }
  78. NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];
  79. [dateFormat setDateFormat:@"yyyy-MM-dd"];//设定时间格式,这里可以设置成自己需要的格式
  80. NSDate *startD =[dateFormat dateFromString:_mStartDate];
  81. NSDate *endD = [dateFormat dateFromString:_mEndDate];
  82. NSInteger days= [DateFormat calculateDaysFromBegin:startD end:endD];
  83. if(days > 31){
  84. [self showAlertViewText:@"日期间隔天数不能大于31天"];
  85. return;
  86. }
  87. [weakself.filterController dismiss];
  88. [self reloadData];
  89. }];
  90. _filterController.animationDuration = AnimationDuration;
  91. _filterController.hasHeadView = YES;
  92. _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
  93. _filterController.dataList = [self packageDataList];
  94. }
  95. /**
  96. 数据源
  97. @return <#return value description#>
  98. */
  99. - (NSArray *)packageDataList {
  100. NSMutableArray *dataArray = [NSMutableArray array];
  101. SideSlipModel *model = [[SideSlipModel alloc] init];
  102. model.containerCellClass = @"OrderSalesSearchTableViewCell";
  103. model.regionTitle = @"查询条件";
  104. [dataArray addObject:model];
  105. return [dataArray mutableCopy];
  106. }
  107. #pragma mark - 代理函数
  108. /**
  109. Sections
  110. @param tableView <#tableView description#>
  111. @return <#return value description#>
  112. */
  113. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  114. return 1;
  115. }
  116. /**
  117. 头高
  118. @param tableView <#tableView description#>
  119. @param section <#section description#>
  120. @return <#return value description#>
  121. */
  122. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  123. {
  124. return 5;
  125. }
  126. /**
  127. 列表个数
  128. @param tableView <#tableView description#>
  129. @param section <#section description#>
  130. @return <#return value description#>
  131. */
  132. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  133. return _details.count;
  134. }
  135. /**
  136. 行高
  137. @param tableView <#tableView description#>
  138. @param indexPath <#indexPath description#>
  139. @return <#return value description#>
  140. */
  141. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  142. return 134+35;
  143. }
  144. /**
  145. cell
  146. @param tableView <#tableView description#>
  147. @param indexPath <#indexPath description#>
  148. @return <#return value description#>
  149. */
  150. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  151. static NSString *CellIdentifier = @"OrderSalesTableViewCell";
  152. OrderSalesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  153. if (!cell) {
  154. cell=[[OrderSalesTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  155. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  156. }
  157. else
  158. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  159. {
  160. while ([cell.contentView.subviews lastObject] != nil) {
  161. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  162. }
  163. }
  164. // NSString *CellIdentifier=@"OrderSalesCell";
  165. // OrderSalesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  166. // cell=[[OrderSalesTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  167. // cell.selectionStyle=UITableViewCellSelectionStyleNone;
  168. OrderSaleListModel *model=_details[indexPath.row];
  169. [cell parseOrderSalesInfo:model];
  170. return cell;
  171. }
  172. /**
  173. 单元格点击事件
  174. @param tableView <#tableView description#>
  175. @param indexPath <#indexPath description#>
  176. */
  177. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  178. self.hidesBottomBarWhenPushed=YES;
  179. OrderSalesDetailViewController *detailvc=[[OrderSalesDetailViewController alloc] init];
  180. OrderSaleListModel *m = _details[indexPath.row];
  181. detailvc.invoiceNo = m.invoiceNo;
  182. [self.navigationController pushViewController:detailvc animated:YES];
  183. }
  184. #pragma mark - 私有函数
  185. /**
  186. 初始化ui
  187. */
  188. - (void)initUI{
  189. self.navigationItem.title = @"订单销售单列表";
  190. self.view.backgroundColor = [UIColor whiteColor];
  191. _vCustomTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height )];
  192. _vCustomTableView.rowHeight = UITableViewAutomaticDimension;
  193. _vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  194. _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  195. _vCustomTableView.backgroundColor = [UIColor whiteColor];
  196. _vCustomTableView.delegate = self;
  197. _vCustomTableView.dataSource=self;
  198. [self.view addSubview:_vCustomTableView];
  199. // 合计
  200. _headView = [[UIView alloc]initWithFrame:CGRectZero];
  201. CGFloat lblx = 20;
  202. CGFloat lblwidth = 130;
  203. CGFloat valuey = 10;
  204. CGFloat valuewidth = 200;
  205. CGFloat valueheight = 25;
  206. CGFloat heightLine =1;
  207. UILabel *lbtotal = [UILabel new];
  208. lbtotal.frame=CGRectMake(lblx, valuey, lblwidth, valueheight);
  209. lbtotal.font = reportTextFont;
  210. lbtotal.text = @"合计";
  211. [_headView addSubview:lbtotal];
  212. UIView *topSeparator = [UIView new];
  213. topSeparator.frame = CGRectMake(0, CGRectGetMaxY(lbtotal.frame)+valuey, Screen_Width, heightLine);
  214. topSeparator.backgroundColor = LineBackgroundColor;
  215. [_headView addSubview:topSeparator];
  216. UIImageView *goodsimgview = [UIImageView new];
  217. UIImage *goodsImg= [UIImage imageNamed:@"goods_amount"];
  218. goodsimgview.frame=CGRectMake(lblx,CGRectGetMaxY(topSeparator.frame)+valuey,goodsImg.size.width,goodsImg.size.height);
  219. [goodsimgview setImage:goodsImg];
  220. [_headView addSubview:goodsimgview];
  221. //货款总额
  222. UILabel *lblTitleGoodsAmount = [UILabel new];
  223. lblTitleGoodsAmount.frame=CGRectMake(CGRectGetMaxX(goodsimgview.frame)+5, CGRectGetMaxY(topSeparator.frame)+valuey-3, lblwidth, valueheight);
  224. lblTitleGoodsAmount.font = reportTextFont;
  225. lblTitleGoodsAmount.text = @"货款总额";
  226. [_headView addSubview:lblTitleGoodsAmount];
  227. _lblGoodsAmount = [UILabel new];
  228. _lblGoodsAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(topSeparator.frame)+valuey-3, valuewidth, valueheight);
  229. _lblGoodsAmount.font = reportTextFont;
  230. _lblGoodsAmount.textAlignment = NSTextAlignmentRight;
  231. [_headView addSubview:_lblGoodsAmount];
  232. UIView *goodsSeparator = [UIView new];
  233. goodsSeparator.frame = CGRectMake(CGRectGetMaxX(goodsimgview.frame)+5, CGRectGetMaxY(goodsimgview.frame)+valuey, Screen_Width, heightLine);
  234. goodsSeparator.backgroundColor = LineBackgroundColor;
  235. [_headView addSubview:goodsSeparator];
  236. UIImageView *discountimgview = [UIImageView new];
  237. UIImage *discountAmountImg= [UIImage imageNamed:@"discount_amount"];
  238. discountimgview.frame=CGRectMake(lblx,CGRectGetMaxY(goodsSeparator.frame)+valuey,discountAmountImg.size.width,discountAmountImg.size.height);
  239. [discountimgview setImage:discountAmountImg];
  240. [_headView addSubview:discountimgview];
  241. // 舍零金额
  242. UILabel *lblTitleDiscountAmount = [UILabel new];
  243. lblTitleDiscountAmount.frame=CGRectMake(CGRectGetMaxX(discountimgview.frame)+5, CGRectGetMaxY(goodsSeparator.frame)+valuey, lblwidth, valueheight);
  244. lblTitleDiscountAmount.font = reportTextFont;
  245. lblTitleDiscountAmount.text = @"舍零金额";
  246. [_headView addSubview:lblTitleDiscountAmount];
  247. _lblDiscountAmount = [UILabel new];
  248. _lblDiscountAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(goodsSeparator.frame)+valuey, valuewidth, valueheight);
  249. _lblDiscountAmount.font = reportTextFont;
  250. _lblDiscountAmount.textAlignment = NSTextAlignmentRight;
  251. [_headView addSubview:_lblDiscountAmount];
  252. UIView *discountSeparator = [UIView new];
  253. discountSeparator.frame = CGRectMake(CGRectGetMaxX(discountimgview.frame)+5, CGRectGetMaxY(discountimgview.frame)+valuey, Screen_Width, heightLine);
  254. discountSeparator.backgroundColor = LineBackgroundColor;
  255. [_headView addSubview:discountSeparator];
  256. //合计金额
  257. UIImageView *totalimgview = [UIImageView new];
  258. UIImage *totalImg= [UIImage imageNamed:@"total_amount"];
  259. totalimgview.frame=CGRectMake(lblx,CGRectGetMaxY(discountSeparator.frame)+valuey,totalImg.size.width,totalImg.size.height);
  260. [totalimgview setImage:totalImg];
  261. [_headView addSubview:totalimgview];
  262. UILabel *lblTitleTotalAmount = [UILabel new];
  263. lblTitleTotalAmount.frame=CGRectMake(CGRectGetMaxX(totalimgview.frame)+5, CGRectGetMaxY(discountSeparator.frame)+valuey-3, lblwidth, valueheight);
  264. lblTitleTotalAmount.font = reportTextFont;
  265. lblTitleTotalAmount.text = @"合计金额";
  266. [_headView addSubview:lblTitleTotalAmount];
  267. _lblTotalAmount = [UILabel new];
  268. _lblTotalAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(discountSeparator.frame)+valuey-3, valuewidth, valueheight);
  269. _lblTotalAmount.font = reportTextFont;
  270. _lblTotalAmount.textAlignment = NSTextAlignmentRight;
  271. [_headView addSubview:_lblTotalAmount];
  272. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_lblTotalAmount.frame)+5, SCREENWIDTH, 10)];
  273. line.backgroundColor = LineBackgroundColor;
  274. [_headView addSubview:line];
  275. _headView.frame=CGRectMake(0,0, Screen_Width, CGRectGetMaxY(line.frame));
  276. }
  277. /**
  278. 导航菜单
  279. */
  280. - (void)loadNavStyle
  281. {
  282. // 右边
  283. UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 42, 12)];
  284. UIButton *btnfilter = [UIButton buttonWithType:UIButtonTypeCustom];
  285. [btnfilter addTarget:self action:@selector(search)
  286. forControlEvents:UIControlEventTouchUpInside];
  287. btnfilter.frame = CGRectMake(0, 0,16, 16);
  288. [btnfilter setTitleColor:NavBarItemColor forState:UIControlStateNormal];
  289. [btnfilter setBackgroundImage:[UIImage imageNamed:@"icon_filter_white"]
  290. forState:UIControlStateNormal];
  291. [v addSubview:btnfilter];
  292. UIButton *filterLbl=[[UIButton alloc]init];
  293. filterLbl.frame=CGRectMake(CGRectGetMaxX(btnfilter.frame)+3,0,28, 16);
  294. [filterLbl setTitle:@"筛选" forState:UIControlStateNormal];
  295. [filterLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  296. filterLbl.titleLabel.font=[UIFont systemFontOfSize:ButtonFontOfSize];
  297. [filterLbl addTarget:self action:@selector(search)
  298. forControlEvents:UIControlEventTouchUpInside];
  299. [v addSubview:filterLbl];
  300. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:v];
  301. self.navigationItem.rightBarButtonItem = menubtnAdd;
  302. //返回
  303. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  304. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  305. forState:UIControlStateNormal];
  306. [button addTarget:self action:@selector(goBack)
  307. forControlEvents:UIControlEventTouchUpInside];
  308. button.frame = CGRectMake(0, 0, 15, 18);
  309. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  310. self.navigationItem.leftBarButtonItem = menuButton;
  311. }
  312. /**
  313. 抽屉弹出
  314. */
  315. - (void)search{
  316. [_filterController show];
  317. }
  318. /**
  319. 头数据
  320. @param md <#md description#>
  321. */
  322. - (void)initUIData:(OrderSaleTotalModel *)md{
  323. _lblGoodsAmount.text=[NSString stringWithFormat:@"¥%@",md.goodsAmount];
  324. _lblDiscountAmount.text=[NSString stringWithFormat:@"¥%@",md.discountAmount];
  325. _lblTotalAmount.text=[NSString stringWithFormat:@"¥%@",md.totalAmount];
  326. [self loadDetailData];
  327. }
  328. /**
  329. 加载数据
  330. */
  331. -(void)loadDetailData{
  332. [self startLoading];
  333. NSString *urlStr = ServerURL;
  334. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  335. [dict setObject:@"GetOrderSalesReportListIphone" forKey:@"Action"];
  336. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  337. [dict setObject:kkUserCode forKey:@"UserCode"];
  338. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  339. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  340. if(_mStartDate==nil){
  341. [dict setObject:@"" forKeyedSubscript:@"BeginTime"];
  342. }
  343. else{
  344. [dict setObject:_mStartDate forKeyedSubscript:@"BeginTime"];
  345. }
  346. if(_mEndDate==nil){
  347. [dict setObject:@"" forKeyedSubscript:@"EndTime"];
  348. }
  349. else{
  350. [dict setObject:_mEndDate forKeyedSubscript:@"EndTime"];
  351. }
  352. if(_mCustomerName==nil){
  353. [dict setObject:@"" forKeyedSubscript:@"CustomerName"];
  354. }
  355. else{
  356. [dict setObject:_mCustomerName forKeyedSubscript:@"CustomerName"];
  357. }
  358. if(_mInvoiceType==nil){
  359. [dict setObject:@"0" forKeyedSubscript:@"InvoiceType"];
  360. }
  361. else{
  362. [dict setObject:_mInvoiceType forKeyedSubscript:@"InvoiceType"];
  363. }
  364. if(_mTelephone==nil){
  365. [dict setObject:@"" forKeyedSubscript:@"Telephone"];
  366. }
  367. else{
  368. [dict setObject:_mTelephone forKeyedSubscript:@"Telephone"];
  369. }
  370. [dict setObject:@"1" forKeyedSubscript:@"IsTotalFlg"];
  371. int correctStatus;
  372. if(_correctStatus){
  373. correctStatus=1;
  374. }
  375. else{
  376. correctStatus=0;
  377. }
  378. [dict setObject:[NSString stringWithFormat:@"%@",_correctStatus] forKeyedSubscript:@"Status"];
  379. _downManager = [[ASIDownManager alloc] init];
  380. _downManager.delegate = self;
  381. _downManager.OnImageDown = @selector(onLoadDetailFinish:);
  382. _downManager.OnImageFail = @selector(onLoadDetailFail:);
  383. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  384. }
  385. /**
  386. 加载合集数据
  387. */
  388. - (void)reloadData
  389. {
  390. [self startLoading];
  391. NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
  392. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  393. [dict setObject:@"GetOrderSalesReportTotalIphone" forKey:@"Action"];
  394. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  395. [dict setObject:kkUserCode forKey:@"UserCode"];
  396. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  397. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  398. if(_mStartDate==nil){
  399. [dict setObject:@"" forKeyedSubscript:@"BeginTime"];
  400. }
  401. else{
  402. [dict setObject:_mStartDate forKeyedSubscript:@"BeginTime"];
  403. }
  404. if(_mEndDate==nil){
  405. [dict setObject:@"" forKeyedSubscript:@"EndTime"];
  406. }
  407. else{
  408. [dict setObject:_mEndDate forKeyedSubscript:@"EndTime"];
  409. }
  410. if(_mTelephone==nil){
  411. [dict setObject:@"" forKeyedSubscript:@"Telephone"];
  412. }
  413. else{
  414. [dict setObject:_mTelephone forKeyedSubscript:@"Telephone"];
  415. }
  416. if(_mInvoiceType==nil){
  417. [dict setObject:@"0" forKeyedSubscript:@"InvoiceType"];
  418. }
  419. else{
  420. [dict setObject:_mInvoiceType forKeyedSubscript:@"InvoiceType"];
  421. }
  422. if(_mCustomerName==nil){
  423. [dict setObject:@"" forKeyedSubscript:@"CustomerName"];
  424. }
  425. else{
  426. [dict setObject:_mCustomerName forKeyedSubscript:@"CustomerName"];
  427. }
  428. [dict setObject:@"0" forKeyedSubscript:@"IsTotalFlg"];
  429. [dict setObject:[NSString stringWithFormat:@"%@",_correctStatus] forKeyedSubscript:@"Status"];
  430. _downManager = [[ASIDownManager alloc] init];
  431. _downManager.delegate = self;
  432. _downManager.OnImageDown = @selector(onLoadFinish:);
  433. _downManager.OnImageFail = @selector(onLoadFail:);
  434. [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  435. }
  436. #pragma mark - 代理函数
  437. /**
  438. * 查询正常数据
  439. *
  440. * @param sender <#sender description#>
  441. */
  442. - (void)onLoadFinish:(ASIDownManager *)sender {
  443. // 服务器返回数据
  444. NSDictionary *dic =[[NSDictionary alloc] init];
  445. dic = [sender.mWebStr JSONValue];
  446. [self cancel];
  447. // 服务器返回数据是否正确
  448. if (dic && [dic isKindOfClass:[NSDictionary class]])
  449. {
  450. // 服务器返回数据状态值
  451. int iStatus = [[dic objectForKey:@"Status"] intValue];
  452. // 服务器返回数据消息
  453. NSString *message=[dic objectForKey:@"Message"];
  454. // 服务器返回数据状态值正确
  455. if (iStatus == 0)
  456. {
  457. _vCustomTableView.tableHeaderView=nil;
  458. NSArray * approvArr=[dic objectForKey:@"Result"];
  459. if(approvArr!=nil&&approvArr.count>0)
  460. {
  461. _vCustomTableView.backgroundView = nil;
  462. [_stockArr removeAllObjects];
  463. _vCustomTableView.tableHeaderView = nil;
  464. [_stockArr addObjectsFromArray:approvArr];
  465. [_details removeAllObjects];
  466. [_vCustomTableView reloadData];
  467. NSDictionary *dic=_stockArr[0];
  468. NSInteger recount = [[dic objectForKey:@"RecCount"]integerValue];
  469. if(recount>0){
  470. _vCustomTableView.tableHeaderView=_headView;
  471. OrderSaleTotalModel *md = [OrderSaleTotalModel orderSaleWithDict:_stockArr[0]];
  472. [self initUIData:md];
  473. }
  474. else{
  475. UIView *noDataView=[[UIView alloc]init];
  476. noDataView.frame=_vCustomTableView.bounds;
  477. UIImageView *nodataImgView=[[UIImageView alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16,noDataView.frame.size.height/2-16,32,32)];
  478. [nodataImgView setImage:[UIImage imageNamed:@"icon_no_data"]];
  479. [noDataView addSubview:nodataImgView];
  480. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16-12,CGRectGetMaxY(nodataImgView.frame)+3,70, 25)];
  481. label.font=[UIFont systemFontOfSize:NoDataFontOfSize];
  482. label.text = @"无数据";
  483. label.numberOfLines = 2;
  484. label.textColor = [UIColor lightGrayColor];
  485. [noDataView addSubview:label];
  486. _vCustomTableView.backgroundView=noDataView;
  487. [self showAlertViewText:@"未找到匹配结果"];
  488. return;
  489. }
  490. }
  491. }
  492. // 服务器返回数据状态值异常
  493. else if(iStatus==ActionResultStatusAuthError
  494. ||iStatus==ActionResultStatusNoLogin
  495. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  496. [self showReLoginDialog:message];
  497. return;
  498. }
  499. else {
  500. [_details removeAllObjects];
  501. [_vCustomTableView reloadData];
  502. [self showAlertViewText:message];
  503. }
  504. }
  505. }
  506. /**
  507. * 异常数据
  508. *
  509. * @param sender <#sender description#>
  510. */
  511. - (void)onLoadFail:(ASIDownManager *)sender {
  512. [self cancel];
  513. [self showAlertViewText:@"加载失败"];
  514. }
  515. /**
  516. * 列表数据
  517. *
  518. * @param sender <#sender description#>
  519. */
  520. - (void)onLoadDetailFinish:(ASIDownManager *)sender {
  521. NSDictionary *dic =[[NSDictionary alloc] init];
  522. dic = [sender.mWebStr JSONValue];
  523. [self cancel];
  524. // 服务器返回数据是否正确
  525. if (dic && [dic isKindOfClass:[NSDictionary class]])
  526. {
  527. // 服务器返回数据状态值
  528. int iStatus = [[dic objectForKey:@"Status"] intValue];
  529. // 服务器返回数据消息
  530. NSString *message=[dic objectForKey:@"Message"];
  531. // 服务器返回数据状态值正确
  532. if (iStatus == 0)
  533. {
  534. // 返回结果
  535. NSArray * approvArr=[dic objectForKey:@"Result"];
  536. if(approvArr!=nil)
  537. {
  538. [_details removeAllObjects];
  539. if(approvArr.count==0){
  540. [self showAlertViewText:@"未找到匹配结果"];
  541. }
  542. else
  543. {
  544. NSMutableArray *detailArray = [NSMutableArray array];
  545. for (NSDictionary *dic in approvArr)
  546. {
  547. OrderSaleListModel *md = [OrderSaleListModel orderSaleDetailWithDict:dic];
  548. [detailArray addObject:md];
  549. }
  550. _details = detailArray;
  551. [_vCustomTableView reloadData];
  552. }
  553. }
  554. }
  555. // 服务器返回数据状态值异常
  556. else if(iStatus==ActionResultStatusAuthError
  557. ||iStatus==ActionResultStatusNoLogin
  558. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid)
  559. {
  560. [self showReLoginDialog:message];
  561. return;
  562. }
  563. else
  564. {
  565. [self showAlertViewText:message];
  566. }
  567. }
  568. }
  569. /**
  570. 加载失败
  571. @param sender <#sender description#>
  572. */
  573. - (void)onLoadDetailFail:(ASIDownManager *)sender {
  574. [self cancel];
  575. [self showAlertViewText:@"加载失败"];
  576. }
  577. /**
  578. * 隐藏进度条
  579. */
  580. - (void)cancel {
  581. [self stopLoading];
  582. }
  583. @end