SalesSlipSearchListVC.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. //
  2. // SalesSlipSearchListVC.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/4/13.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "SalesSlipSearchListVC.h"
  9. @interface SalesSlipSearchListVC (){
  10. int pageNumber;
  11. }
  12. @end
  13. @implementation SalesSlipSearchListVC
  14. @synthesize vCustomTableView;
  15. #pragma mark 公共函数
  16. /**
  17. 视图加载完成函数
  18. */
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. [self loadNavStyle];
  22. [self initUI];
  23. pageNumber=1;
  24. _dataList=[[NSMutableArray alloc]init];
  25. _goodsDetailList=[[NSMutableArray alloc]init];
  26. [self loadData];
  27. }
  28. /**
  29. 安全区变化函数
  30. */
  31. -(void)viewSafeAreaInsetsDidChange{
  32. vCustomTableView.frame=CGRectMake(0,0,self.view.frame.size.width,self.view.safeAreaLayoutGuide.layoutFrame.size.height-50);
  33. _bottomView.frame=CGRectMake(0, self.view.safeAreaLayoutGuide.layoutFrame.size.height-50, self.view.frame.size.width, 50);
  34. [super viewSafeAreaInsetsDidChange];
  35. }
  36. - (void)didReceiveMemoryWarning {
  37. [super didReceiveMemoryWarning];
  38. }
  39. #pragma mark 委托函数
  40. /**
  41. 销售单数据加载成功回调
  42. @param sender <#sender description#>
  43. */
  44. - (void)onSalesSlipListFinish:(ASIDownManager *)sender {
  45. NSDictionary *dic = [sender.mWebStr JSONValue];
  46. vCustomTableView.mTableView.backgroundView = nil;
  47. [self stopLoading];
  48. // 服务器返回数据是否正确
  49. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  50. // 服务器返回数据状态值
  51. int iStatus = [[dic objectForKey:@"Status"] intValue];
  52. int iNewCount = 0;
  53. // 服务器返回数据消息
  54. NSString *message=[dic objectForKey:@"Message"];
  55. // 服务器返回数据状态值正确
  56. if (iStatus == 0) {
  57. NSArray * infoArr=[dic objectForKey:@"Result"];
  58. // 返回结果
  59. if(infoArr!=nil&& infoArr.count>0)
  60. {
  61. for (int i = 0; i < infoArr.count; i++) {
  62. NSDictionary * dic=infoArr[i];
  63. SalesOutStorageSalesSlipModel *salesSlipListModel=[[SalesOutStorageSalesSlipModel alloc]init];
  64. [salesSlipListModel parseDic:dic];
  65. [_dataList addObject:salesSlipListModel];
  66. }
  67. iNewCount =(int)infoArr.count;
  68. vCustomTableView.mbMoreHidden = (iNewCount == 0);
  69. [vCustomTableView FinishLoading];
  70. [vCustomTableView reloadData];
  71. }
  72. else{
  73. [vCustomTableView FinishLoading];
  74. vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  75. UIView *noDataView=[[UIView alloc]init];
  76. noDataView.frame=vCustomTableView.bounds;
  77. UIImageView *nodataImgView=[[UIImageView alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16,noDataView.frame.size.height/2-16,32,32)];
  78. [nodataImgView setImage:[UIImage imageNamed:@"icon_no_data"]];
  79. [noDataView addSubview:nodataImgView];
  80. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(noDataView.frame.size.width/2-16-12,CGRectGetMaxY(nodataImgView.frame)+3,70, 25)];
  81. label.font=[UIFont systemFontOfSize:NoDataFontOfSize];
  82. label.text = @"无数据";
  83. label.numberOfLines = 2;
  84. label.textColor = [UIColor lightGrayColor];
  85. [noDataView addSubview:label];
  86. // 有刷新数据的时候
  87. if(_dataList == nil || _dataList.count==0){
  88. vCustomTableView.mTableView.backgroundView =noDataView;
  89. [self showAlertViewBackText:@"未找到匹配结果"];
  90. }
  91. }
  92. }
  93. // 服务器返回数据状态值异常
  94. else if(iStatus==ActionResultStatusAuthError
  95. ||iStatus==ActionResultStatusNoLogin
  96. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  97. [self showReLoginDialog:message];
  98. }
  99. else{
  100. [vCustomTableView FinishLoading];
  101. [self showAlertViewText:message];
  102. }
  103. }
  104. }
  105. /**
  106. 销售单数据加载失败回调
  107. @param sender <#sender description#>
  108. */
  109. - (void)onSalesSlipListFail:(ASIDownManager *)sender {
  110. [self stopLoading];
  111. [self showAlertViewText:@"加载失败"];
  112. }
  113. /**
  114. 销售单产品明细加载成功回调
  115. @param sender <#sender description#>
  116. */
  117. - (void)onSalesSlipGoodsDetailLoadFinish:(ASIDownManager *)sender {
  118. NSDictionary *dic = [sender.mWebStr JSONValue];
  119. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  120. // 服务器返回数据状态值
  121. int iStatus = [[dic objectForKey:@"Status"] intValue];
  122. // 服务器返回数据消息
  123. NSString *message=[dic objectForKey:@"Message"];
  124. // 服务器返回数据状态值正确
  125. if (iStatus == 0) {
  126. NSArray * infoArr=[dic objectForKey:@"Result"];
  127. // 返回结果
  128. if(infoArr!=nil&& infoArr.count>0)
  129. {
  130. _salesSlipModel.goodsDetailArray=[[NSMutableArray alloc]init];
  131. for (int i = 0; i < infoArr.count; i++) {
  132. NSDictionary * dic=infoArr[i];
  133. SalesOutStorageSalesSlipGoodsListModel *goodsListModel=[[SalesOutStorageSalesSlipGoodsListModel alloc]init];
  134. [goodsListModel parseDic:dic];
  135. [goodsListModel setCustomerId:_salesSlipModel.customerId];
  136. [goodsListModel setCheckedFlag:YES];
  137. [_salesSlipModel.goodsDetailArray addObject:goodsListModel];
  138. }
  139. NSString *goodsCountStr= [NSString stringWithFormat:@"共%d件商品", _salesSlipModel.goodsDetailArray.count];
  140. _salesSlipModel.goodsCount=goodsCountStr;
  141. }
  142. else{
  143. NSString *goodsCountStr= @"共0件商品";
  144. _salesSlipModel.goodsCount=goodsCountStr;
  145. }
  146. [vCustomTableView reloadData];
  147. }
  148. else if(iStatus==ActionResultStatusAuthError
  149. ||iStatus==ActionResultStatusNoLogin
  150. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  151. [self showReLoginDialog:message];
  152. }
  153. else{
  154. [self showAlertViewText:message];
  155. }
  156. [self stopLoading];
  157. }
  158. }
  159. /**
  160. 销售单产品明细加载失败回调
  161. @param sender <#sender description#>
  162. */
  163. - (void)onSalesSlipGoodsDetailLoadFail:(ASIDownManager *)sender {
  164. [self stopLoading];
  165. [self showAlertViewText:@"加载失败"];
  166. }
  167. /**
  168. 加载更多
  169. @param sender sender description
  170. */
  171. - (void)LoadMoreList:(RefreshTableView *)sender {
  172. pageNumber++;
  173. [self startLoading];
  174. [self loadData];
  175. }
  176. /**
  177. 下拉刷新
  178. @param sender <#sender description#>
  179. */
  180. - (void)ReloadList:(RefreshTableView *)sender{
  181. pageNumber = 1;
  182. [_dataList removeAllObjects];
  183. [vCustomTableView reloadData];
  184. vCustomTableView.mbMoreHidden=YES;
  185. [self startLoading];
  186. [self loadData];
  187. }
  188. /**
  189. 取消刷新
  190. @param sender sender description
  191. @return return value description
  192. */
  193. - (BOOL)CanRefreshTableView:(RefreshTableView *)sender {
  194. return YES;
  195. }
  196. /**
  197. 隐藏键盘
  198. @param scrollView <#scrollView description#>
  199. */
  200. -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
  201. {
  202. [self.view endEditing:YES];
  203. }
  204. /**
  205. 选中销售单状态
  206. @param index <#index description#>
  207. */
  208. -(void)btnCheckPressed:(NSInteger)index{
  209. _salesSlipModel= [_dataList objectAtIndex:index];
  210. _salesSlipModel.checkedFlag=!_salesSlipModel.checkedFlag;
  211. if(_salesSlipModel.checkedFlag){
  212. if(_salesSlipModel.goodsDetailArray==nil||_salesSlipModel.goodsDetailArray.count==0){
  213. [self loadGoodsDetailData:_salesSlipModel.salesId];
  214. }
  215. else{
  216. [self updateCheckedStatus:YES];
  217. NSString *goodsCountStr= [NSString stringWithFormat:@"共%lu件商品", (unsigned long)_salesSlipModel.goodsDetailArray.count];
  218. _salesSlipModel.goodsCount=goodsCountStr;
  219. }
  220. }
  221. else{
  222. [self updateCheckedStatus:NO];
  223. _salesSlipModel.goodsCount=@"";
  224. }
  225. [vCustomTableView reloadData];
  226. }
  227. /**
  228. 跳转到产品明细页面
  229. @param index <#index description#>
  230. */
  231. -(void)btnGoGoodsDetail:(NSInteger)index{
  232. _salesSlipModel= [_dataList objectAtIndex:index];
  233. _dataTempList=[[NSMutableArray alloc] initWithArray:_dataList copyItems:YES];
  234. SalesOutStorageSalesSlipGoodsListVC *goodsListVc=[[SalesOutStorageSalesSlipGoodsListVC alloc]init];
  235. goodsListVc.salesSlipModel=_salesSlipModel;
  236. goodsListVc.position=index;
  237. goodsListVc.goodsListDelegate=self;
  238. [self.navigationController pushViewController:goodsListVc animated:YES];
  239. }
  240. /**
  241. 刷新数据
  242. */
  243. -(void) recoveryData{
  244. if(_dataTempList!=nil&&_dataTempList.count>0){
  245. _dataList =[[NSMutableArray alloc] initWithArray:_dataTempList copyItems:YES];
  246. }
  247. }
  248. /**
  249. 单元格cell个数
  250. @param tableView <#tableView description#>
  251. @param section <#section description#>
  252. @return <#return value description#>
  253. */
  254. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  255. {
  256. return [_dataList count];
  257. }
  258. /**
  259. tableview的分区数
  260. @param tableView <#tableView description#>
  261. @return <#return value description#>
  262. */
  263. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  264. return 1;
  265. }
  266. /**
  267. 高度
  268. @param tableView <#tableView description#>
  269. @param indexPath <#indexPath description#>
  270. @return <#return value description#>
  271. */
  272. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  273. return 315;
  274. }
  275. /**
  276. 每个单元格cell
  277. @param tableView <#tableView description#>
  278. @param indexPath <#indexPath description#>
  279. @return <#return value description#>
  280. */
  281. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  282. {
  283. static NSString *cellIdentifier = @"SalesSlipListCell";
  284. SalesSlipSearchListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  285. if (!cell) {
  286. cell=[[SalesSlipSearchListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  287. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  288. }
  289. else
  290. //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
  291. {
  292. while ([cell.contentView.subviews lastObject] != nil) {
  293. [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
  294. }
  295. }
  296. SalesOutStorageSalesSlipModel *salesSlipModel= [_dataList objectAtIndex:indexPath.row];
  297. cell.checkDelegate = self;
  298. cell.cellIndex=indexPath.row;
  299. [cell setSalesSlipModel:salesSlipModel];
  300. [cell setCheckBackground:salesSlipModel.checkedFlag];
  301. return cell;
  302. }
  303. /**
  304. 获取选中的产品列表
  305. @param checkedGoodsList <#checkedGoodsList description#>
  306. @param pos <#pos description#>
  307. */
  308. -(void)btnGetCheckedGoodsList:(NSMutableArray *)checkedGoodsList position:(NSInteger)pos{
  309. NSMutableArray *tempCheckedGoodsList=[[NSMutableArray alloc] initWithArray:checkedGoodsList copyItems:YES];
  310. SalesOutStorageSalesSlipModel *salesSlipModel= [_dataList objectAtIndex:pos];
  311. if(salesSlipModel.goodsDetailArray!=nil&&salesSlipModel.goodsDetailArray.count>0){
  312. for(SalesOutStorageSalesSlipGoodsListModel *goodsModel in salesSlipModel.goodsDetailArray){
  313. goodsModel.checkedFlag=NO;
  314. }
  315. }
  316. if(tempCheckedGoodsList!=nil&&tempCheckedGoodsList.count>0){
  317. if((salesSlipModel.goodsDetailArray!=nil&&salesSlipModel.goodsDetailArray.count>0)&&(checkedGoodsList!=nil&&checkedGoodsList.count>0)){
  318. for(SalesOutStorageSalesSlipGoodsListModel *checkedGoodsModel in tempCheckedGoodsList){
  319. for(SalesOutStorageSalesSlipGoodsListModel *goodsModel in salesSlipModel.goodsDetailArray){
  320. if([checkedGoodsModel.detailId integerValue]==[goodsModel.detailId integerValue]){
  321. if(checkedGoodsModel.checkedFlag){
  322. goodsModel.checkedFlag=checkedGoodsModel.checkedFlag;
  323. }
  324. }
  325. }
  326. }
  327. }
  328. }
  329. if(tempCheckedGoodsList.count>0){
  330. NSString *goodsCountStr= [NSString stringWithFormat:@"共%lu件商品",(unsigned long)tempCheckedGoodsList.count];
  331. salesSlipModel.goodsCount=goodsCountStr;
  332. salesSlipModel.checkedFlag=YES;
  333. }
  334. else{
  335. salesSlipModel.checkedFlag=NO;
  336. salesSlipModel.goodsCount=@"";
  337. }
  338. [vCustomTableView reloadData];
  339. }
  340. /**
  341. 显示下拉更新
  342. @param scrollView <#scrollView description#>
  343. */
  344. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  345. if (scrollView.isDragging) {//显示下拉更新
  346. if (vCustomTableView.mRefreshHeader.state == PullRefreshPulling && scrollView.contentOffset.y > -65.0f && scrollView.contentOffset.y < 0.0f && [vCustomTableView CanRefresh]) {
  347. [vCustomTableView.mRefreshHeader setState:PullRefreshNormal];
  348. }
  349. else if (vCustomTableView.mRefreshHeader.state == PullRefreshNormal && scrollView.contentOffset.y < -65.0f && [vCustomTableView CanRefresh]) {//显示松开更新
  350. [vCustomTableView.mRefreshHeader setState:PullRefreshPulling];
  351. }
  352. }
  353. }
  354. #pragma mark 私有函数
  355. /**
  356. 导航按钮样式
  357. */
  358. -(void)loadNavStyle
  359. {
  360. self.navigationItem.title=@"销售单列表";
  361. //返回
  362. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  363. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  364. forState:UIControlStateNormal];
  365. [button addTarget:self action:@selector(goBack)
  366. forControlEvents:UIControlEventTouchUpInside];
  367. button.frame = CGRectMake(0, 0, 15, 18);
  368. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  369. self.navigationItem.leftBarButtonItem = menuButton;
  370. }
  371. /**
  372. 返回函数
  373. */
  374. - (void)goBack
  375. {
  376. [self.navigationController popViewControllerAnimated:YES];
  377. }
  378. /**
  379. 初始化UI
  380. */
  381. -(void)initUI{
  382. [self.view setBackgroundColor:[UIColor whiteColor]];
  383. vCustomTableView = [[RefreshTableView alloc]
  384. initWithFrame:CGRectMake(0,
  385. 0,
  386. self.view.frame.size.width,
  387. self.view.frame.size.height-50)];
  388. vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  389. vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  390. vCustomTableView.backgroundColor = [UIColor whiteColor];
  391. vCustomTableView.delegate = self;
  392. [self.view addSubview:vCustomTableView];
  393. self.vCustomTableView.mTableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 49, 0);
  394. //保存
  395. _bottomView=[UIView new];
  396. _bottomView.frame=CGRectMake(0, self.view.frame.size.height-110, self.view.frame.size.width, 50);
  397. [self.view addSubview:_bottomView];
  398. //提交结算
  399. _sureBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  400. [_sureBtn setTitle:@"确定" forState:UIControlStateNormal];
  401. [_sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  402. _sureBtn.frame=CGRectMake(20,5,Screen_Width-40,40);
  403. [_sureBtn setBackgroundColor:[UIColor colorWithRed:189.0/255.0 green:0 blue:7.0/255.0 alpha:1]];
  404. [_sureBtn addTarget:self action:@selector(submitData) forControlEvents:UIControlEventTouchUpInside];
  405. [_bottomView addSubview:_sureBtn];
  406. }
  407. /**
  408. 提交数据函数
  409. */
  410. -(void)submitData{
  411. Boolean checkedFlag=[self isCheckedSalesSlip:_dataList];
  412. if(!checkedFlag){
  413. [self showAlertViewText:@"请选择销售单"];
  414. return;
  415. }
  416. NSMutableArray *checkedSalesSlip=[self getSelectedSalesSlip:_dataList];
  417. Boolean isHasGoods=[self isHasGoods:checkedSalesSlip];
  418. if(!isHasGoods){
  419. [self showAlertViewText:@"销售单下没有商品,请重新选择"];
  420. return;
  421. }
  422. Boolean isSameCustomer= [self isSameCustomer:checkedSalesSlip];
  423. if(!isSameCustomer){
  424. [self showAlertViewText:@"请选择同样的客户"];
  425. return;
  426. }
  427. if(_goodsDetailVc.goodsList!=nil&&_goodsDetailVc.goodsList.count>0){
  428. Boolean isCompareSameCustomer= [self compareSameCustomer:checkedSalesSlip goodsList:_goodsDetailVc.goodsList];
  429. if(!isCompareSameCustomer){
  430. [self showAlertViewText:@"请选择同样的客户"];
  431. return;
  432. }
  433. }
  434. if(_goodsDetailVc.goodsList!=nil&&_goodsDetailVc.goodsList.count>0){
  435. Boolean isSameGoods=[self isHasSameGoods:checkedSalesSlip goodsList:_goodsDetailVc.goodsList];
  436. if(isSameGoods){
  437. [self showAlertViewText:@"商品重复,请重新选择商品"];
  438. return;
  439. }
  440. }
  441. if([self.salesSlipDelegate respondsToSelector:@selector(getSelectedSalesSlipList: )]){
  442. [self.salesSlipDelegate getSelectedSalesSlipList:checkedSalesSlip];
  443. }
  444. [self.navigationController popViewControllerAnimated:YES];
  445. }
  446. /**
  447. 是否是同一种商品
  448. @param checkedSalesOutStorageList <#checkedSalesOutStorageList description#>
  449. @param goodsList <#goodsList description#>
  450. @return <#return value description#>
  451. */
  452. -(Boolean) isHasSameGoods:(NSMutableArray*)checkedSalesOutStorageList goodsList:(NSMutableArray*)goodsList{
  453. Boolean isHasSame;
  454. for( SalesOutStorageSalesSlipModel *checkedGoodsModel in checkedSalesOutStorageList){
  455. isHasSame =[self checkSameGoods:checkedGoodsModel.goodsDetailArray goodsList:goodsList];
  456. if(isHasSame){
  457. break;
  458. }
  459. }
  460. return isHasSame;
  461. }
  462. /**
  463. 判断是否是同一种商品
  464. @param checkedGoodsList <#checkedGoodsList description#>
  465. @param goodsList <#goodsList description#>
  466. @return <#return value description#>
  467. */
  468. -(Boolean) checkSameGoods:(NSMutableArray*)checkedGoodsList goodsList:(NSMutableArray*)goodsList{
  469. Boolean isHasSame=NO;
  470. for( SalesOutStorageSalesSlipGoodsListModel *checkedGoodsModel in checkedGoodsList){
  471. for(SalesOutStorageSalesSlipGoodsListModel *goodsModel in goodsList){
  472. if([checkedGoodsModel.salesNo isEqualToString:goodsModel.salesNo]&&[checkedGoodsModel.detailId integerValue]==[goodsModel.detailId integerValue]&&checkedGoodsModel.checkedFlag==YES){
  473. isHasSame=YES;
  474. break;
  475. }
  476. }
  477. }
  478. return isHasSame;
  479. }
  480. /**
  481. 判断是否是同一个客户
  482. @param checkedSalesSlipList <#checkedSalesSlipList description#>
  483. @return <#return value description#>
  484. */
  485. -(Boolean) isSameCustomer:(NSMutableArray*)checkedSalesSlipList{
  486. Boolean isSameCustomer=YES;
  487. for(int i=0;i<checkedSalesSlipList.count;i++){
  488. SalesOutStorageSalesSlipModel *outerModel=[checkedSalesSlipList objectAtIndex:i];
  489. for(int j=i+1;j<checkedSalesSlipList.count;j++){
  490. SalesOutStorageSalesSlipModel *innerModel=[checkedSalesSlipList objectAtIndex:j];
  491. if([outerModel.customerId integerValue]!=[innerModel.customerId integerValue]){
  492. isSameCustomer=NO;
  493. break;
  494. }
  495. }
  496. }
  497. return isSameCustomer;
  498. }
  499. /**
  500. 判断是否是同一个客户
  501. @param checkedSalesSlipList <#checkedSalesSlipList description#>
  502. @param goodsList <#goodsList description#>
  503. @return <#return value description#>
  504. */
  505. -(Boolean) compareSameCustomer:(NSMutableArray*)checkedSalesSlipList goodsList:(NSMutableArray*)goodsList{
  506. Boolean isSameCustomer=YES;
  507. for(int i=0;i<checkedSalesSlipList.count;i++){
  508. SalesOutStorageSalesSlipModel *salesSlipModel=[checkedSalesSlipList objectAtIndex:i];
  509. for(int j=0;j<goodsList.count;j++){
  510. SalesOutStorageSalesSlipGoodsListModel *goodsModel=[goodsList objectAtIndex:j];
  511. if([salesSlipModel.customerId integerValue]!=[goodsModel.customerId integerValue]){
  512. isSameCustomer=NO;
  513. break;
  514. }
  515. }
  516. }
  517. return isSameCustomer;
  518. }
  519. /**
  520. 判断是否选中销售出库单
  521. @param salesSlipList <#salesSlipList description#>
  522. @return <#return value description#>
  523. */
  524. -(Boolean) isCheckedSalesSlip:(NSMutableArray*)salesSlipList{
  525. Boolean isChecked=NO;
  526. for(SalesOutStorageSalesSlipModel *salesSlipModel in _dataList){
  527. if(salesSlipModel.checkedFlag){
  528. isChecked=YES;
  529. break;
  530. }
  531. }
  532. return isChecked;
  533. }
  534. /**
  535. 判断是否有商品
  536. @param salesSlipList <#salesSlipList description#>
  537. @return <#return value description#>
  538. */
  539. -(Boolean) isHasGoods:(NSMutableArray*)salesSlipList{
  540. Boolean isHasGoods=YES;
  541. for(SalesOutStorageSalesSlipModel *salesSlipModel in salesSlipList){
  542. if(salesSlipModel.goodsDetailArray==nil){
  543. isHasGoods=NO;
  544. break;
  545. }
  546. }
  547. return isHasGoods;
  548. }
  549. /**
  550. 获取选中的销售单
  551. @param salesSlipList <#salesSlipList description#>
  552. @return <#return value description#>
  553. */
  554. -(NSMutableArray*) getSelectedSalesSlip:(NSMutableArray*)salesSlipList{
  555. NSMutableArray *checkedSalesSlip=[[NSMutableArray alloc]init];
  556. for(SalesOutStorageSalesSlipModel *salesSlipModel in _dataList){
  557. if(salesSlipModel.checkedFlag){
  558. [checkedSalesSlip addObject:salesSlipModel];
  559. }
  560. }
  561. return checkedSalesSlip;
  562. }
  563. /**
  564. 加载数据源
  565. */
  566. -(void)loadData{
  567. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  568. [dict setObject:@"GetSalesDataSearchIphone" forKey:@"Action"];
  569. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  570. [dict setObject:kkUserCode forKey:@"UserCode"];
  571. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  572. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  573. [dict setObject:_salesNo== nil? @"" : _salesNo forKey:@"SalesNo"];
  574. [dict setObject:_customerName == nil? @"" : _customerName forKey:@"CustomerName"];
  575. [dict setObject:_customerCode == nil? @"" : _customerCode forKey:@"CustomerCode"];
  576. [dict setObject:_address == nil? @"" : _address forKey:@"Address"];
  577. [dict setObject:_startDate == nil? @"" : _startDate forKey:@"AccountDateFrom"];
  578. [dict setObject:_endDate == nil? @"" : _endDate forKey:@"AccountDateTo"];
  579. [dict setObject:_goodsCode == nil? @"" : _goodsCode forKey:@"Code"];
  580. [dict setObject:_invoiceStatus == nil? @"" : _invoiceStatus forKey:@"InvoiceStatus"];
  581. [dict setObject:@"20" forKey:@"PageSize"];
  582. [dict setObject:[NSString stringWithFormat:@"%d",pageNumber] forKey:@"PageNum"];
  583. [self startLoading];
  584. _downManager = [[ASIDownManager alloc] init];
  585. _downManager.delegate = self;
  586. _downManager.OnImageDown = @selector(onSalesSlipListFinish:);
  587. _downManager.OnImageFail = @selector(onSalesSlipListFail:);
  588. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  589. }
  590. /**
  591. 更新产品选中的状态
  592. @param checkedStatus <#checkedStatus description#>
  593. */
  594. -(void)updateCheckedStatus:(Boolean) checkedStatus{
  595. if(_salesSlipModel.goodsDetailArray!=nil&&_salesSlipModel.goodsDetailArray.count>0){
  596. for(int i=0;i<_salesSlipModel.goodsDetailArray.count;i++){
  597. SalesOutStorageSalesSlipGoodsListModel *goodsModel=[_salesSlipModel.goodsDetailArray objectAtIndex:i];
  598. goodsModel.checkedFlag=checkedStatus;
  599. }
  600. }
  601. }
  602. /**
  603. 加载产品明细数据源
  604. @param salesId <#salesId description#>
  605. */
  606. -(void)loadGoodsDetailData:(NSString*)salesId{
  607. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  608. [dict setObject:@"GetSalesDataSearchDetailIphone" forKey:@"Action"];
  609. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  610. [dict setObject:kkUserCode forKey:@"UserCode"];
  611. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  612. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  613. [dict setObject:salesId== nil? @"" : salesId forKey:@"SalesID"];
  614. [self startLoading];
  615. _downManager = [[ASIDownManager alloc] init];
  616. _downManager.delegate = self;
  617. _downManager.OnImageDown = @selector(onSalesSlipGoodsDetailLoadFinish:);
  618. _downManager.OnImageFail = @selector(onSalesSlipGoodsDetailLoadFail:);
  619. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  620. }
  621. @end