123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- //
- // SchoolDetail.m
- // LNManager
- //
- // Created by EchoShacolee on 2017/4/9.
- // Copyright © 2017年 lee. All rights reserved.
- //
- #import "SchoolDetail.h"
- #import "LockCell.h"
- @interface SchoolDetail ()
- {
-
- NSArray *_titles2;//_tableviews[1] 的相关key值
-
- BOOL _isLock;//锁定状态
- UIButton * _locakBtn;//锁定/解锁
- NSArray * _dataArr;//锁定记录
- HolderView * _holderV;
- }
- @end
- @implementation SchoolDetail
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.navigationItem.title = @"驾校详情";
- if (self.byWillDo) {
- [self createBottomBarWithtoolTitles:@[@"审核"]];
- [self setSegmentControllWithTitles:@[@"基本信息",@"场地信息"]];
- }else{
- [self createBottomBarWithtoolTitles:@[@"设置培训能力",@"锁定/解锁"]];
- [self setSegmentControllWithTitles:@[@"基本信息",@"场地信息",@"锁定历史记录"]];
- [self getLockLogs];
- [self getRequsetData];
-
- UITableView * tabV = [_tableViews lastObject];
- _holderV = [[HolderView alloc] initWithFrame:tabV.frame];
- [_holderV freshBlock:^{
-
- [self getLockLogs];
- }];
- [_mainScroolView addSubview:_holderV];
- }
-
- }
- -(void)setData{
- _keysArr = @[@[@"地市名称",@"TSI_DQMC"],
- @[@"区县名称",@"TSI_QXMC"],
- @[@"机构名称",@"TSI_NAME"],
- @[@"机构简称",@"TSI_SHORTNAME"],
- @[@"培训机构地址",@"TSI_ADDRESS"],
-
- @[@"经营范围",@"TSI_BUSISCOPE"],
- @[@"经营状态",@"TSI_BUSISTATUS"],
- @[@"经营许可证编号",@"TSI_LICNUM"],
- @[@"经营许可日期",@"TSI_LICETIME"],
- @[@"营业执照注册号",@"TSI_BUSINESS"],
- @[@"统一社会信用代码",@"TSI_CREDITCODE"],
-
- @[@"法人代表",@"TSI_LEGAL"],
- @[@"联系人",@"TSI_CONTACT"],
- @[@"联系电话",@"TSI_PHONE"],
-
- @[@"分类等级",@"TSI_LEVEL"],
- @[@"全国编号",@"TSI_INSCODE"],
- @[@"邮政编码",@"TSI_POSTCODE"],
- @[@"备案时间",@"TSI_RECORD_DATE"],
- @[@"锁定状态",@"TSI_LOCK_STATUS"],
- @[@"锁定/解锁时间",@"TSI_LOCK_DATE"]];
-
- _titles2 = @[@[@"教练员总数",@"TSI_COACHNUMBER"],
- @[@"考核员总数",@"TSI_GRASUPVNUM"],
- @[@"安全员总数",@"TSI_SAFMNGNUM"],
- @[@"教练车总数",@"TSI_TRACARNUM"],
-
- @[@"教室总面积(m2)",@"TSI_CLASSROOM"],
- @[@"理论教室面积(单位:m2)",@"TSI_THCLASSROOM"],
- @[@"教练场总面积(单位:m2)",@"TSI_PRATICEFIELD"]];
-
- [super setData];
-
- }
- -(void)getRequsetData{
-
- [self getDataWithDic:self.requesetDic method:@"schools" block:^(NSDictionary *successDic) {
- self.dataSource = [NSMutableDictionary dictionaryWithDictionary:successDic[@"body"][0]];
- for (UITableView * tableView in _tableViews) {
- [tableView reloadData];
- }
- _isLock = [[NSString stringWithFormat:@"%@",self.dataSource[@"TSI_LOCK_STATUS"]] isEqualToString:@"1"];
- [_locakBtn setTitle:_isLock ? @"解锁" : @"锁定" forState:UIControlStateNormal];
-
- //
- if (self.lockBlock) {
- self.lockBlock(self.dataSource);
- }
- }];
- }
- -(void)getLockLogs{
-
- //判断网络是否连接
- if (![NetworkManager connectedToNetWork]) {
- [self showMsgByAlertVCWithString:@"网络连接异常"];
- return;
- }
-
- NSMutableDictionary * mdic = [[NSMutableDictionary alloc]init];
- [mdic setValue:@"1" forKey:@"type"];//类型 1 培训机构 2 教练 3 教练车 4 学员 5 终端
- [mdic setValue:self.requesetDic[@"inscode"] forKey:@"objnum"];
-
- [MBProgressHUD hideHUDForView:self.view animated:NO];
- [MBProgressHUD showHUDAddedTo:self.view animated:NO];
- [NetworkManager requestWithMethod:@"lockLogs" parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
-
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- [_holderV setHidden:NO];
-
- if (failureStr) {
- [self showMsgByAlertVCWithString:failureStr];
- return;
- }
-
- if ([successDic[@"code"] isEqualToString:@"1"]) {
- [self showMsgByAlertVCWithString:successDic[@"msg"]];
- return;
- }
-
- _dataArr = successDic[@"body"];
-
- if (_dataArr.count != 0) {
- _holderV.hidden = YES;
- }
-
- [_tableViews[2] reloadData];
-
- }];
-
- }
- #pragma mark 创建BottomBarButton
- -(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{
-
- float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count;
- float HeightBth = JOb_DETAIL_BOTTOMBAR_HEIGHT;
-
- for (int i=0; i<toolTitles.count; i++) {
-
- UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
- button.frame = CGRectMake(i*(widthBtn+1), kSize.height-HeightBth-SafeAreaBottomHeight, widthBtn, HeightBth);
- if (i == 1) {
- [button setTitle:@"锁定" forState:UIControlStateNormal];
- _locakBtn = button;
- }else{
- [button setTitle:toolTitles[i] forState:UIControlStateNormal];
- }
-
- UIColor * color = COLOR_THEME;
- button.backgroundColor = color;
- [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
- button.tag = 100+i;
-
- [self.view addSubview:button];
- }
- }
- - (void)buttonClick:(UIButton *)sender{
-
- if (self.byWillDo && self.shenheBLock) {
- self.shenheBLock();
- return;
- }
-
- if (sender.tag == 100) {
- [Tools permissionValidationWithID:@"752" result:^(BOOL isCan, NSString *failureStr) {
- if (!isCan) {
- if (failureStr) {
- [self showMsgByMBWithString:failureStr];
- }
- return;
- }
-
- [self setTrainability];
-
- }];
-
- }else if (sender.tag == 101){
- NSString * title = _isLock ? @"解锁":@"锁定";
- NSString *message = [NSString stringWithFormat:@"请输入%@理由:",title];
- UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
-
- [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- textField.placeholder = [NSString stringWithFormat:@"(必须填写,否则将无法完成%@)",title];
- }];
- [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
-
- UITextField *tf = alertFind.textFields[0];
- if (tf.text.length > 0) {
- [self lockSchoolWith:tf.text];
- }else{
- [self showMsgByMBWithString:@"操作失败,请输入锁定/解锁理由"];
- }
-
- }]];
-
- NSString *theId = _isLock ? @"544":@"542";
-
- [Tools permissionValidationWithID:theId result:^(BOOL isCan, NSString *failureStr) {
- if (!isCan) {
- if (failureStr) {
- [self showMsgByMBWithString:failureStr];
- }
- return;
- }
-
- [self presentViewController:alertFind animated:true completion:nil];
-
- }];
- }
-
- }
- -(void)setTrainability{
- UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"设置培训能力" message:@"请选择设置方式" preferredStyle:UIAlertControllerStyleActionSheet];
- //添加操作
- [ac addAction:[UIAlertAction actionWithTitle:@"按车设置(每辆车最大带教人数)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [self setCountWithType:@"1"];
- }]];
- [ac addAction:[UIAlertAction actionWithTitle:@"按月设置(每月最大允许招生量)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [self setCountWithType:@"2"];
- }]];
- [ac addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- [self presentViewController:ac animated:YES completion:nil];
- }
- - (void)setCountWithType:(NSString *)type
- {
- BOOL isCar = [type isEqualToString:@"1"];
- NSString * title = isCar ? @"按车设置" : @"按月设置";
- NSString * message = isCar ? @"请写入每辆车最大带教人数" : @"请写入每月最大允许招生量";
- UIAlertController *ac = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
- [ac addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- textField.placeholder = message;
- textField.keyboardType = UIKeyboardTypeNumberPad;
- }];
- [ac addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- NSString *tfStr = [ac.textFields firstObject].text;
- NSMutableDictionary * mdic = [NSMutableDictionary new];
- [mdic setValue:self.dataSource[@"TSI_INSCODE"] forKey:@"inscode"];
- [mdic setValue:type forKey:@"type"];//类型 1 按车设置 2 按月设置
- [mdic setValue:isCar ? tfStr : @"" forKey:@"limitCar"];//如果type=1 则不能为空
- [mdic setValue:isCar ? @"" : tfStr forKey:@"limitMonth"];//如果type=2 则不能为空
-
- [self getDataWithDic:mdic method:@"setSchoolTrain" block:^(NSDictionary *successdic) {
-
- if (isCar) {
- [self showMsgByAlertVCWithString:[NSString stringWithFormat:@"已成功设置该驾校每辆车最大带教人数为:%@个",tfStr]];
- }else{
- [self showMsgByAlertVCWithString:[NSString stringWithFormat:@"已成功设置该驾校每月最大允许招生量为:%@个",tfStr]];
- }
- }];
- }]];
- [ac addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
-
- [self presentViewController:ac animated:YES completion:nil];
- }
- -(void)lockSchoolWith:(NSString *)reason{
- NSMutableDictionary * mdic = [NSMutableDictionary new];
- [mdic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"];
- [mdic setValue:reason forKey:@"reason"];
- [mdic setValue:_isLock ? @"0" : @"1" forKey:@"status"];
- [mdic setValue:self.dataSource[@"TSI_INSCODE"] forKey:@"inscode"];
-
- [self getDataWithDic:mdic method:@"lockSchool" block:^(NSDictionary *successdic) {
-
- //解锁成功,重新请求数据
- [self getRequsetData];
- [self getLockLogs];
- }];
- }
- #pragma mark 重写代理方法
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- NSInteger index = [_tableViews indexOfObject:tableView];
-
- if (index == 2) {
- return _dataArr.count;
- }
-
- if (index == 1) {
- return _titles2.count;
- }
-
- if (self.dataSource == nil) {
- return 0;
- }
- return [_keysArr count];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- if ([_tableViews indexOfObject:tableView] == 2) {
- return [LockCell heightForDic:_dataArr[indexPath.row]];
- }else if([_tableViews indexOfObject:tableView] == 1){
- return 44;
- }
-
- return [super tableView:tableView heightForRowAtIndexPath:indexPath];
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSInteger index = [_tableViews indexOfObject:tableView];
-
- if (index == 2) {
-
- LockCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
- if (!cell) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"LockCell" owner:nil options:nil]lastObject];
- }
- [cell upDataWithDic:_dataArr[indexPath.row]];
-
- return cell;
- }
-
- if (index == 1) {
- UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId2"];
-
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId2"];
- }
-
- NSString * key = _titles2[indexPath.row][1];
- cell.textLabel.text = _titles2[indexPath.row][0];
- cell.detailTextLabel.numberOfLines = 0;
-
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- return cell;
- }
-
- //index == 0
- return [super tableView:tableView cellForRowAtIndexPath:indexPath];
-
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|