CustomerCodeSearchVC.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. //
  2. // KeHuBianMaSearchTC.m
  3. // IBOSSIPAD
  4. //
  5. // Created by iHope on 14-8-14.
  6. // Copyright (c) 2014年 elongtian. All rights reserved.
  7. //
  8. #import "CustomerCodeSearchVC.h"
  9. #import "ChannelSearchVC.h"
  10. #import "CustomerTypeSearchVC.h"
  11. @interface CustomerCodeSearchVC()<UISearchBarDelegate,UITableViewDataSource,UITableViewDelegate>{
  12. UITextField *txtCode;
  13. UITextField *txtCustomerName;
  14. UIButton *_btnSearch;
  15. }
  16. @property(nonatomic,strong) ASIDownManager *mDownManager;
  17. @property(strong) IBOutlet UISearchBar *searchBar;
  18. @property(strong) UITableView *tableView;
  19. @end
  20. @implementation CustomerCodeSearchVC
  21. #pragma mark - 公共函数
  22. /**
  23. viewDidLoad函数
  24. */
  25. - (void)viewDidLoad
  26. {
  27. [super viewDidLoad];
  28. self.navigationItem.title=@"客户编码";
  29. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  30. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  31. forState:UIControlStateNormal];
  32. [button addTarget:self action:@selector(goBack)
  33. forControlEvents:UIControlEventTouchUpInside];
  34. button.frame = CGRectMake(0, 0, 15, 18);
  35. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  36. self.navigationItem.leftBarButtonItem = menuButton;
  37. self.navigationController.navigationBar.barTintColor = NavigationBarTintColor;
  38. self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
  39. _tableView=[UITableView new];
  40. _tableView.delegate=self;
  41. _tableView.dataSource=self;
  42. _tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
  43. _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  44. _tableView.frame=CGRectMake(0, 0, Screen_Width, Screen_Height-40) ;
  45. [self.view addSubview:_tableView];
  46. _searchBar=[[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
  47. _searchBar.delegate=self;
  48. [self initHeaderView];
  49. }
  50. /**
  51. 修改:2017-9-25
  52. 适配机型
  53. 安全区视图发生变化
  54. */
  55. -(void)viewSafeAreaInsetsDidChange{
  56. _tableView.frame = CGRectMake(0, 0, SCREENWIDTH, self.view.safeAreaLayoutGuide.layoutFrame.size.height-40);;
  57. _btnSearch.frame=CGRectMake(20, self.view.safeAreaLayoutGuide.layoutFrame.size.height-40,Screen_Width-40,35);
  58. [super viewSafeAreaInsetsDidChange];
  59. }
  60. /**
  61. 初始化函数
  62. */
  63. -(id)init
  64. {
  65. self =[super init];
  66. if(self){
  67. _channelStr=@"";
  68. _customerTypeStr=@"";
  69. }
  70. return self;
  71. }
  72. /**
  73. 取消进度条函数
  74. */
  75. -(void)dealloc
  76. {
  77. [self cancel];
  78. }
  79. #pragma mark - 委托函数
  80. //客户编码数据加载完成
  81. - (void)onLoadFinish:(ASIDownManager *)sender {
  82. NSDictionary *dic = [sender.mWebStr JSONValue];
  83. [self cancel];
  84. if (dic && [dic isKindOfClass:[NSDictionary class]]) {
  85. int iStatus = [[dic objectForKey:@"Status"] intValue];
  86. NSString *message=[dic objectForKey:@"Message"];
  87. if (iStatus == 0) {
  88. NSArray * approvArr=[dic objectForKey:@"Result"];
  89. if(approvArr!=nil)
  90. {
  91. if(approvArr!=nil&&approvArr.count>0){
  92. _searchArr=[[NSMutableArray alloc] init];
  93. for(int i=0;i<approvArr.count;i++){
  94. NSDictionary * dic=approvArr[i];
  95. NSInteger fillingId=[[dic objectForKey:@"FilingID"]integerValue];
  96. NSInteger customerId=[[dic objectForKey:@"CustomerID"]integerValue];
  97. NSString *customerCode=[dic objectForKey:@"CustomerCode"];
  98. NSString *customerName=[dic objectForKey:@"CustomerName"];
  99. NSString *channelName=[dic objectForKey:@"ChannelName"];
  100. NSInteger channelId=[[dic objectForKey:@"ChannelID"]integerValue];
  101. NSString *telephone=[dic objectForKey:@"Telephone"];
  102. NSString *address=[dic objectForKey:@"Address"];
  103. NSString *staffName=[dic objectForKey:@"StaffName"];
  104. NSInteger staffId=[[dic objectForKey:@"StaffID"]integerValue];
  105. NSInteger customerTypeId=[[dic objectForKey:@"CustomerType"]integerValue];
  106. NSString *customerTypeName=[dic objectForKey:@"CustomerTypeName"];
  107. NSInteger organizationId=[[dic objectForKey:@"OrganizationID"]integerValue];
  108. NSString *organizationName=[dic objectForKey:@"OrganizationName"];
  109. NSString *organizationCode=[dic objectForKey:@"OrganizationCode"];
  110. NSInteger districtId=[[dic objectForKey:@"District"]integerValue];
  111. NSString *districtName=[dic objectForKey:@"DistrictName"];
  112. NSString *contacts=[dic objectForKey:@"Contacts"];
  113. CustomerCodeSearchModel *searchModel=[CustomerCodeSearchModel new];
  114. searchModel.filingId=fillingId;
  115. searchModel.customerId=customerId;
  116. searchModel.customerCode=customerCode;
  117. searchModel.customerName=customerName;
  118. searchModel.channelId=channelId;
  119. searchModel.channelName=channelName;
  120. searchModel.telephone=telephone;
  121. searchModel.address=address;
  122. searchModel.staffId=staffId;
  123. searchModel.staffName=staffName;
  124. searchModel.districtId=districtId;
  125. searchModel.districtName=districtName;
  126. searchModel.customerTypeId=customerTypeId;
  127. searchModel.customerTypeName=customerTypeName;
  128. searchModel.organizationId=organizationId;
  129. searchModel.organizationCode=organizationCode;
  130. searchModel.organizationName=organizationName;
  131. searchModel.contacts=contacts;
  132. [_searchArr addObject:searchModel];
  133. }
  134. }
  135. else{
  136. [self showAlertViewText:@"未找到匹配结果"];
  137. return;
  138. }
  139. _tableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
  140. [self.tableView reloadData];
  141. }
  142. }
  143. else if(iStatus==ActionResultStatusAuthError
  144. ||iStatus==ActionResultStatusNoLogin
  145. ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
  146. [self showReLoginDialog:message];
  147. return;
  148. }
  149. else {
  150. [self.tableView reloadData];
  151. [self showAlertViewText:message];
  152. }
  153. }
  154. }
  155. //客户编码数据加载失败
  156. - (void)onLoadFail:(ASIDownManager *)sender {
  157. [self cancel];
  158. [self.tableView reloadData];
  159. [self showAlertViewText:@"加载失败"];
  160. }
  161. -(void)textEnd:(id)sender customerCode:(NSString*)code;{
  162. }
  163. -(void)department:(NSString*)organizationId organizationCode:(NSString*)code organizationName:(NSString*)name{
  164. }
  165. -(void)salesman:(NSString*)salesmanId salesmanName:(NSString*)salesmanName{
  166. }
  167. //tableview的分区数
  168. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  169. {
  170. return 1;
  171. }
  172. //tableview的行数
  173. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  174. {
  175. return _searchArr.count;
  176. }
  177. //获取tableviewcell
  178. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  179. {
  180. static NSString *CellIdentifier = @"Cell";
  181. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
  182. if(cell==nil)
  183. {
  184. cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  185. }
  186. CustomerCodeSearchModel *searchModel=_searchArr[indexPath.row];
  187. NSString *code=searchModel.customerCode;
  188. if (code == nil || code.length ==0) {
  189. code=searchModel.telephone;
  190. }
  191. NSString *name=searchModel.customerName;
  192. cell.textLabel.textAlignment=NSTextAlignmentCenter;
  193. cell.textLabel.text=[[code stringByAppendingString:@"-"] stringByAppendingString:name];
  194. cell.textLabel.font=orderTextFont;
  195. return cell;
  196. }
  197. //选中tableviewcell
  198. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  199. CustomerCodeSearchModel *searchModel=_searchArr[indexPath.row];
  200. NSString *customerCode=searchModel.customerCode;
  201. if (customerCode == nil|| customerCode.length ==0) {
  202. customerCode = searchModel.telephone;
  203. }
  204. UIButton *btn=[UIButton new];
  205. btn.tag=1301;
  206. if([_flag isEqualToString:@"salesOrder"]){
  207. if([self.orderDelegate respondsToSelector:@selector(getCustomerOrder:)]){
  208. [self.orderDelegate getCustomerOrder:searchModel];
  209. }
  210. [self.navigationController popViewControllerAnimated:YES];
  211. }
  212. else if([_flag isEqualToString:@"otherInStorage"]){
  213. [self.navigationController popViewControllerAnimated:YES];
  214. if([self.orderDelegate respondsToSelector:@selector(getCustomerOrder:)]){
  215. [self.orderDelegate getCustomerOrder:searchModel];
  216. }
  217. }
  218. else
  219. {
  220. [self dismissViewControllerAnimated:YES completion:^(void){
  221. if([self.orderDelegate respondsToSelector:@selector(textEnd:customerCode:)]){
  222. [self.orderDelegate textEnd:btn customerCode:customerCode];
  223. }
  224. }];
  225. }
  226. }
  227. //searchbar开始编辑
  228. - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
  229. {
  230. [self addCancelButton];
  231. return YES;
  232. }
  233. //searchbar替换文本
  234. - (BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
  235. {
  236. return YES;
  237. }
  238. //searchbar编辑结束
  239. - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  240. {
  241. if ([searchText isEqualToString:@""]) {
  242. self.filterArr = _searchArr;
  243. [_tableView reloadData];
  244. return;
  245. }
  246. NSString *keyName = @"";
  247. keyName = @"OrganizationName";
  248. //< 模糊查找
  249. // NSPredicate *predicateString = [NSPredicate predicateWithFormat:@"%K contains[cd] %@ Or %K contains[cd] %@", keyName, searchText,@"OrganizationCode",searchText];
  250. NSPredicate *predicateString = [NSPredicate predicateWithFormat:@"%K contains[cd] %@ Or %K contains[cd] %@", keyName, searchText,@"OrganizationCode",searchText];
  251. //< 精确查找
  252. // NSPredicate *predicateString = [NSPredicate predicateWithFormat:@"%K == %@", keyName, searchText];
  253. NSLog(@"predicate %@",predicateString);
  254. NSMutableArray *filteredArray = [NSMutableArray arrayWithArray:[_searchArr filteredArrayUsingPredicate:predicateString]];
  255. self.filterArr = filteredArray;
  256. [_tableView reloadData];
  257. }
  258. //取消搜索按钮
  259. - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
  260. {
  261. [searchBar resignFirstResponder];
  262. [self cancelSearch];
  263. }
  264. //scrollview开始拖拽函数
  265. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
  266. {
  267. [_searchBar resignFirstResponder];
  268. [self.view endEditing:YES];
  269. [self cancelSearch];
  270. }
  271. -(void)channel:(NSString *)channelId channelName:(NSString *)channelName{
  272. [_btnChannel setTitle:channelName forState:UIControlStateNormal];
  273. [_btnChannel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  274. _channelStr=channelId;
  275. }
  276. -(void)customerType:(NSString *)customerTypeId customerTypeName:(NSString *)customerTypeName{
  277. [_btnCustomerType setTitle:customerTypeName forState:UIControlStateNormal];
  278. [_btnCustomerType setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  279. _customerTypeStr=customerTypeId;
  280. }
  281. #pragma mark - 私有函数
  282. //取消进度条函数
  283. - (void)cancel {
  284. [self stopLoading];
  285. }
  286. //加载数据函数
  287. -(void)reloadData
  288. {
  289. [self startLoading];
  290. _searchArr=[NSMutableArray new];
  291. _filterArr=[NSMutableArray new];
  292. self.mDownManager = [[ASIDownManager alloc] init];
  293. _mDownManager.delegate = self;
  294. _mDownManager.OnImageDown = @selector(onLoadFinish:);
  295. _mDownManager.OnImageFail = @selector(onLoadFail:);
  296. NSString *urlStr = ServerURL;
  297. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  298. [dict setObject:@"GetCutomersDataSource" forKey:@"Action"];
  299. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  300. [dict setObject:kkUserCode forKey:@"UserCode"];
  301. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  302. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  303. [dict setObject:txtCode.text forKey:@"CustomerCode"];
  304. [dict setObject:txtCustomerName.text forKey:@"CustomerName"];
  305. [dict setObject:_channelStr forKey:@"ChannelID"];
  306. [dict setObject:_customerTypeStr forKey:@"CustomerType"];
  307. [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  308. }
  309. //返回按钮
  310. -(void)goBack
  311. {
  312. if([_flag isEqualToString:@"salesOrder"]||[_flag isEqualToString:@"otherInStorage"]){
  313. [self.navigationController popViewControllerAnimated:YES];
  314. }
  315. else{
  316. [self dismissViewControllerAnimated:YES completion:^(void){
  317. }];
  318. }
  319. }
  320. //初始化查询条件UI
  321. -(void)initHeaderView
  322. {
  323. UIView *headerView=[UIView new];
  324. headerView.frame=CGRectZero;
  325. UILabel *lblCode=[UILabel new];
  326. lblCode.text=@"客户编码";
  327. lblCode.font=orderTextFont;
  328. lblCode.frame=CGRectMake(15, 10, 100, 22);
  329. [headerView addSubview:lblCode];
  330. txtCode=[UITextField new];
  331. txtCode.placeholder=@"客户编码和客户名称不能同时为空";
  332. txtCode.font=orderTextFont;
  333. txtCode.frame=CGRectMake(CGRectGetMaxX(lblCode.frame)+10,10, SCREENWIDTH - (CGRectGetMaxX(lblCode.frame)+10), 22);
  334. UIView *codeSeparator=[[UIView alloc]init];
  335. codeSeparator.frame=CGRectMake(CGRectGetMaxX(lblCode.frame)+10,CGRectGetMaxY(txtCode.frame)+10,Screen_Width-CGRectGetMaxX(lblCode.frame)+10, 1);
  336. codeSeparator.backgroundColor=LineBackgroundColor;
  337. [headerView addSubview:codeSeparator];
  338. [headerView addSubview:txtCode];
  339. UILabel *lblName=[UILabel new];
  340. lblName.text=@"客户名称";
  341. lblName.font=orderTextFont;
  342. lblName.frame=CGRectMake(15,CGRectGetMaxY(codeSeparator.frame)+10, 100, 22);
  343. [headerView addSubview:lblName];
  344. txtCustomerName=[UITextField new];
  345. txtCustomerName.placeholder=@"客户编码和客户名称不能同时为空";
  346. txtCustomerName.font=orderTextFont;
  347. txtCustomerName.frame=CGRectMake(CGRectGetMaxX(lblName.frame)+10,CGRectGetMaxY(codeSeparator.frame)+10, SCREENWIDTH - (CGRectGetMaxX(lblName.frame)+10), 22);
  348. [headerView addSubview:txtCustomerName];
  349. UIView *nameSeparator=[[UIView alloc]init];
  350. nameSeparator.frame=CGRectMake(CGRectGetMaxX(lblName.frame)+10,CGRectGetMaxY(txtCustomerName.frame)+10,Screen_Width-CGRectGetMaxX(lblName.frame)+10, 1);
  351. nameSeparator.backgroundColor=LineBackgroundColor;
  352. [headerView addSubview:nameSeparator];
  353. UILabel *lblChannel=[UILabel new];
  354. lblChannel.frame=CGRectMake(15,CGRectGetMaxY( nameSeparator.frame)+10, 100, 22);
  355. lblChannel.text=@"渠 道";
  356. lblChannel.font=orderTextFont;
  357. [headerView addSubview:lblChannel];
  358. _btnChannel=[UIButton buttonWithType:UIButtonTypeCustom];
  359. _btnChannel.frame=CGRectMake(CGRectGetMaxX(lblChannel.frame)+10,CGRectGetMaxY( nameSeparator.frame)+10, 150, 25);
  360. _btnChannel.titleLabel.font=orderTextFont;
  361. [_btnChannel setTitle:@"请选择渠道" forState:UIControlStateNormal];
  362. [_btnChannel setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  363. _btnChannel.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft ;
  364. [_btnChannel addTarget:self action:@selector(showChannelAlert) forControlEvents:UIControlEventTouchUpInside];
  365. [headerView addSubview:_btnChannel];
  366. UIButton *btnArrow=[UIButton new];
  367. UIImage *btnArrowImg= [UIImage imageNamed:@"rightarrow"];
  368. btnArrow.frame=CGRectMake(Screen_Width-21, CGRectGetMaxY( nameSeparator.frame)+15,btnArrowImg.size.width,btnArrowImg.size.height);
  369. [btnArrow setBackgroundImage:btnArrowImg forState:UIControlStateNormal];
  370. [headerView addSubview:btnArrow];
  371. UIView *channelSeparator=[[UIView alloc]init];
  372. channelSeparator.frame=CGRectMake(CGRectGetMaxX(lblChannel.frame)+10,CGRectGetMaxY(_btnChannel.frame)+10,Screen_Width-CGRectGetMaxX(lblChannel.frame)+10, 1);
  373. channelSeparator.backgroundColor=LineBackgroundColor;
  374. [headerView addSubview:channelSeparator];
  375. //客户性质
  376. UILabel *lblCustomerType=[UILabel new];
  377. lblCustomerType.frame=CGRectMake(15,CGRectGetMaxY(channelSeparator.frame)+10, 100, 25);
  378. lblCustomerType.text=@"客户性质";
  379. lblCustomerType.font=orderTextFont;
  380. [headerView addSubview:lblCustomerType];
  381. _btnCustomerType=[UIButton buttonWithType:UIButtonTypeCustom];
  382. _btnCustomerType.frame=CGRectMake(CGRectGetMaxX(lblCustomerType.frame)+10,CGRectGetMaxY(channelSeparator.frame)+10, 150, 25);
  383. [headerView addSubview:_btnCustomerType];
  384. _btnCustomerType.titleLabel.font=orderTextFont;
  385. [_btnCustomerType setTitle:@"请选择客户性质" forState:UIControlStateNormal];
  386. [_btnCustomerType setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  387. _btnCustomerType.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft ;
  388. [_btnCustomerType addTarget:self action:@selector(showCustomerTypeAlert) forControlEvents:UIControlEventTouchUpInside];
  389. [headerView addSubview:_btnCustomerType];
  390. UIButton *btnCustomerTypeArrow=[UIButton new];
  391. btnCustomerTypeArrow.frame=CGRectMake(Screen_Width-21, CGRectGetMaxY(channelSeparator.frame)+15,btnArrowImg.size.width,btnArrowImg.size.height);
  392. [ btnCustomerTypeArrow setBackgroundImage:btnArrowImg forState:UIControlStateNormal];
  393. [headerView addSubview:btnCustomerTypeArrow];
  394. UIView *typeSeparator=[[UIView alloc]init];
  395. typeSeparator.frame=CGRectMake(CGRectGetMaxX(lblCustomerType.frame)+10,CGRectGetMaxY(lblCustomerType.frame)+10,Screen_Width-CGRectGetMaxX(lblCustomerType.frame)+10, 1);
  396. typeSeparator.backgroundColor=LineBackgroundColor;
  397. [headerView addSubview:typeSeparator];
  398. headerView.frame=CGRectMake(0, 0, self.navigationController.view.bounds.size.width, CGRectGetMaxY(typeSeparator.frame));
  399. _btnSearch=[UIButton buttonWithType:UIButtonTypeCustom];
  400. _btnSearch.frame=CGRectMake(20, Screen_Height-rectNavHeight-rectStatusHeight-35-5,Screen_Width-40,35);
  401. _btnSearch.layer.cornerRadius=5;
  402. [_btnSearch setBackgroundColor:NavBarItemColor];
  403. [_btnSearch setTitle:@"查询" forState:UIControlStateNormal];
  404. _btnSearch.titleLabel.font = [UIFont systemFontOfSize: 16.0];
  405. [_btnSearch addTarget:self action:@selector(goSearch) forControlEvents:UIControlEventTouchUpInside];
  406. [self.view addSubview:_btnSearch];
  407. _tableView.tableHeaderView=headerView;
  408. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(resighKey)];
  409. tap.numberOfTapsRequired = 1;
  410. tap.cancelsTouchesInView = NO;
  411. [self.tableView addGestureRecognizer:tap];
  412. }
  413. //渠道查询
  414. -(void)showChannelAlert{
  415. ChannelSearchVC *channel=[[ ChannelSearchVC alloc] init];
  416. channel.channelDelegate=self;
  417. channel.subview=YES;
  418. [self.navigationController pushViewController:channel animated:YES];
  419. }
  420. //客户性质
  421. -(void)showCustomerTypeAlert{
  422. CustomerTypeSearchVC *customerType=[[CustomerTypeSearchVC alloc] init];
  423. customerType.orderDelegate=self;
  424. customerType.subview=YES;
  425. [self.navigationController pushViewController:customerType animated:YES];
  426. }
  427. //查询客户编码
  428. -(void)goSearch
  429. {
  430. [self.view endEditing:YES];
  431. NSString *customerCode= txtCode.text;
  432. NSString *customerName=txtCustomerName.text;
  433. if((customerCode==nil||[customerCode isEqualToString:@""])&&(customerName==nil||[customerName isEqualToString:@""])){
  434. [self showAlertViewText:@"客户编码与客户名称不能同时为空"];
  435. return;
  436. }
  437. // NSString *channelName= _btnChannel.titleLabel.text;
  438. // if([channelName isEqualToString:@"请选择渠道"]){
  439. // [self showAlertViewText:@"请选择渠道"];
  440. // return;
  441. // }
  442. [self reloadData];
  443. }
  444. //添加取消按钮
  445. -(void)addCancelButton
  446. {
  447. //添加取消按钮
  448. UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
  449. [button2 addTarget:self action:@selector(cancelSearch)
  450. forControlEvents:UIControlEventTouchUpInside];
  451. button2.frame = CGRectMake(0, 0, 40, 24);
  452. [button2 setTitle:@"取消" forState:UIControlStateNormal];
  453. [button2 setTitleColor:NavBarItemColor forState:UIControlStateNormal];
  454. UIBarButtonItem *menuButton2 = [[UIBarButtonItem alloc] initWithCustomView:button2];
  455. self.navigationItem.rightBarButtonItem = menuButton2;
  456. }
  457. //取消搜索
  458. -(void)cancelSearch
  459. {
  460. [_searchBar resignFirstResponder];
  461. [self removeCancel];
  462. }
  463. //移除取消按钮
  464. -(void)removeCancel
  465. {
  466. self.navigationItem.rightBarButtonItem = nil;
  467. }
  468. //收键盘
  469. -(void)resighKey{
  470. [self.tableView endEditing:YES];
  471. }
  472. @end