123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- //
- // ImitateAppiontMentVC.m
- // jiaPei
- //
- // Created by apple on 2017/5/5.
- // Copyright © 2017年 JCZ. All rights reserved.
- //
- #import "ImitateAppiontMentVC.h"
- #import "ImiEquipmentListVC.h"
- #import "HolderView.h"
- @interface ImitateAppiontMentVC ()<UITableViewDelegate,UITableViewDataSource,UIPickerViewDataSource,UIPickerViewDelegate>
- {
- UIBarButtonItem *item;
- UITableView *mainTableView;
- //地区选择栏
- UIPickerView *picker;
- UIView *bgView;
-
- NSArray *dataArray;
- NSArray *areaArray;
- NSString *qxbh;
-
- NSInteger pickRow;
-
- NSString *oldTitle;
- HolderView *holderV;
- }
- @end
- @implementation ImitateAppiontMentVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"模拟预约";
- self.view.backgroundColor = backGroundColor;
- [self configNavigationBar];
-
-
- areaArray = [DB_Que_Helper queryArea];
- NSMutableArray *array = [NSMutableArray array];
- for (NSDictionary *dic in areaArray) {
- if ([dic[@"code"] isEqualToString:RQ_USER_MANAGER.currentUser.city] || [dic[@"parent_code"] isEqualToString:RQ_USER_MANAGER.currentUser.city]) {
- [array addObject:dic];
- }
- }
- if (array.count > 0) {
- areaArray = [NSArray arrayWithArray:array];
- }
- qxbh = @"";
- pickRow = 0;
-
-
- item = [[UIBarButtonItem alloc] initWithTitle:@"区县选择" style:UIBarButtonItemStylePlain target:self action:@selector(clickQX)];
- item.tintColor = RQ_MAIN_COLOR;
- self.navigationItem.rightBarButtonItem = item;
-
-
- mainTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain];
- mainTableView.height -= kNavOffSet;
- mainTableView.delegate = self;
- mainTableView.dataSource = self;
- mainTableView.tableFooterView = [UIView new];
- [self.view addSubview:mainTableView];
-
- [mainTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
-
- //
- holderV = [[HolderView alloc]initWithFrame:mainTableView.frame];
- holderV.title = @"当前区县未设定训练点";
- [self.view addSubview:holderV];
-
- [self getTrainInsList];
- }
- - (void)clickQX {
-
- if (bgView) {
- [bgView removeFromSuperview];
- bgView = nil;
- item.title = oldTitle;
- //既然是取消就什么也别做
- // if (qxbh.length == 0) {
- // for (NSDictionary *dic in areaArray) {
- // if ([dic[@"code"] isEqualToString:RQ_USER_MANAGER.currentUser.city]) {
- // item.title = dic[@"name"];
- // return;
- // }
- // }
- // }else {
- // for (NSDictionary *dic in areaArray) {
- // if ([dic[@"code"] isEqualToString:qxbh]) {
- // item.title = dic[@"name"];
- // return;
- // }
- // }
- // }
-
- return;
- }
- oldTitle = item.title;
- item.title = @"取消";
- bgView = [[UIView alloc] initWithFrame:CGRectMake(0, kSize.height - 285 - kNavOffSet - kSafeAreaBottomHeight, kSize.width, 285)];
- bgView.backgroundColor = backGroundColor;
- [self.view addSubview:bgView];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(kSize.width/2.0, 0, kSize.width/2.0 - 20, 40)];
- [label setText:@"完成" Font:Font17 TextColor:RQ_MAIN_COLOR Alignment:NSTextAlignmentRight];
- [bgView addSubview:label];
-
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/2.0, 0, kSize.width/2.0, 40)];
- [btn target:self tag:1];
- [bgView addSubview:btn];
-
-
- picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, kSize.width, 245)];
- picker.delegate = self;
- picker.dataSource = self;
- [picker selectRow:pickRow inComponent:0 animated:NO];
- [bgView addSubview:picker];
-
- [btn addViewWithRect:CGRectMake(0, 40, kSize.width, 1.5) Color:contentTextColor];
- }
- - (void)btnClick:(UIButton *)sender
- {
- if (sender.tag == 1) {
- if (bgView) {
- [bgView removeFromSuperview];
- bgView = nil;
-
- if (qxbh.length == 0) {
- for (NSDictionary *dic in areaArray) {
- if ([dic[@"code"] isEqualToString:RQ_USER_MANAGER.currentUser.city]) {
- item.title = dic[@"name"];
- break;
- }
- }
- }else {
- for (NSDictionary *dic in areaArray) {
- if ([dic[@"code"] isEqualToString:qxbh]) {
- item.title = dic[@"name"];
- break;
- }
- }
- }
- }
-
- [self getTrainInsList];
- }
- }
- #pragma mark pickerView
- -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
- return 1;
- }
- //每列对应多少行
- -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
- return areaArray.count;
- }
- //每列每行对应显示的数据
- -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
- NSDictionary *dic = areaArray[row];
- return dic[@"name"];
- }
- -(CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
- return 40;
- }
- //选中
- -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
-
- pickRow = row;
- NSDictionary *dic = areaArray[row];
- qxbh = dic[@"code"];
-
- if ([qxbh isEqualToString:RQ_USER_MANAGER.currentUser.city]) {
- qxbh = @"";
- }
- }
- #pragma mark tableView
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return dataArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- cell.backgroundColor = backGroundColor;
- NSDictionary *dic = dataArray[indexPath.row];
- cell.textLabel.text = dic[@"NAME"];
- cell.textLabel.textColor = kTitleColor;
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- NSDictionary *dic = dataArray[indexPath.row];
- ImiEquipmentListVC *vc = [[ImiEquipmentListVC alloc] init];
- vc.trainAppointDic = dic;
- [self navPushHideTabbarToVC:vc];
- }
- - (void)getTrainInsList {
-
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
- [arr addPro:@"qxbh" Value:qxbh];
-
- NSString* method = @"getTrainInsList";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- RemoveHUD();
-
- if (!root) {
- ShowMsg(@"网络异常,未查询到训练点");
- return;
- }
-
- if ([root[@"code"] intValue] == 1) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- if ([(NSArray *)root[@"body"] count] < 1) {
- ShowMsg(@"当前区县未设定训练点");
- dataArray = [NSArray array];
- [mainTableView reloadData];
- holderV.hidden = NO;
- return;
- }
- dataArray = root[@"body"];
- holderV.hidden = YES;
- [mainTableView reloadData];
- }];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|