JobVC.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. //
  2. // JobVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/13.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "JobVC.h"
  9. #import "SchoolListVC.h"
  10. #import "RegionsList.h"
  11. #import "XueShiCheckList.h"
  12. #import "EvaluationListVC.h"
  13. #import "ComplaintsListVC.h"
  14. #import "WaringVC.h"
  15. #import "NotifySelectObjVC.h"
  16. #import "AdvertisingColumn.h"
  17. @interface JobVC ()<UITableViewDelegate,UITableViewDataSource>
  18. {
  19. NSArray *_titleArr;
  20. UITableView * _tableView;
  21. NSMutableArray *_topLabArr;//存放需要更新显示的lab
  22. }
  23. @end
  24. @implementation JobVC
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.navigationItem.title = @"工作";
  28. _titleArr = @[@[@"预警信息",@"未读消息",@"待审围栏",@"在线终端"],//@"待我审核",
  29. @[@"投诉管理",@"教学日志",@"通知下发",@"终端管理"],//@"学时审核",
  30. @[@"机构管理",
  31. @"教练管理",
  32. @"考核员管理",
  33. @"安全员管理",
  34. @"教练车管理",
  35. @"学员管理",
  36. @"教学区域",
  37. @"评价管理",
  38. //@"举报管理",
  39. @"预警"]];
  40. _topLabArr = [NSMutableArray new];
  41. [self myInit];
  42. }
  43. -(void)viewDidAppear:(BOOL)animated{
  44. [super viewDidAppear:animated];
  45. [self getData];
  46. [self getWillDoVCNews];
  47. }
  48. -(void)viewWillDisappear:(BOOL)animated{
  49. // [self setHidesBottomBarWhenPushed:NO];
  50. [super viewWillDisappear:animated];
  51. }
  52. -(void)myInit{
  53. _tableView = [[UITableView alloc]initWithFrame:kFrame style:UITableViewStyleGrouped];
  54. _tableView.delegate = self;
  55. _tableView.dataSource = self;
  56. _tableView.showsVerticalScrollIndicator = NO;
  57. _tableView.estimatedRowHeight = 0;
  58. _tableView.estimatedSectionHeaderHeight = 0;
  59. _tableView.estimatedSectionFooterHeight = 0;
  60. [self.view addSubview:_tableView];
  61. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 100)];
  62. _tableView.tableFooterView = view;
  63. }
  64. #pragma mark tableview代理相关
  65. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  66. return 3;
  67. }
  68. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  69. return 1;
  70. }
  71. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  72. CGFloat height = kSize.width/4;
  73. switch (indexPath.section) {
  74. case 0:
  75. return kSize.width*((double)201/721);//+height 隐藏预警信息/未读消息。。。
  76. break;
  77. case 1:
  78. return height+30+40;
  79. break;
  80. case 2:
  81. return height*3+30;
  82. break;
  83. default:
  84. break;
  85. }
  86. return 0;
  87. }
  88. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  89. NSArray * imgTitles = @[@[@"ic_tousu_manager",@"ic_teach_log",@"ic_notify",@"ic_terminal_manager"],//ic_check_train
  90. @[@"ic_school_manager",
  91. @"ic_coach_manager",
  92. @"ic_assessor_manager",
  93. @"ic_securitor_manager",
  94. @"ic_car_manager",
  95. @"ic_student_manager",
  96. @"ic_teach_area",
  97. @"ic_pingjia_manager",
  98. @"ic_waring_manager",
  99. // @"ic_jubao_manager",
  100. @"ic_waring_manager",
  101. ]];
  102. NSString * cellId = [NSString stringWithFormat:@"cellId%ld",(long)indexPath.row];
  103. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  104. if (cell) {
  105. return cell;
  106. }else{
  107. cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
  108. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  109. CGSize size = kSize;//cell.contentView.frame.size因为上面的特殊处理导致这个行不通了
  110. CGFloat height = kSize.width/4;
  111. if (indexPath.section == 0) {
  112. for (int i=0; i<[_titleArr[0] count]; i++) {
  113. UILabel *topLab = [[UILabel alloc]init];
  114. topLab.text = @"0";
  115. [_topLabArr addObject:topLab];
  116. UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
  117. button.frame = CGRectMake(i*size.width/4, kSize.width*((double)201/721), size.width/4, size.width/4);
  118. [button setTitleUnderImgWithTitle:_titleArr[0][i] TitleColor:[UIColor grayColor] Image:nil label:topLab];
  119. button.tag = 10+i;
  120. [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  121. // [cell.contentView addSubview:button]; 去掉预警/未读消息
  122. }
  123. NSArray *topImgs = @[@"job_top1",@"job_top2",@"job_top3"];
  124. AdvertisingColumn *adView = [[AdvertisingColumn alloc]initWithFrame:CGRectMake(0, 0, size.width, kSize.width*((double)201/721))];
  125. [adView setImgArray:topImgs];
  126. [cell.contentView addSubview:adView];
  127. }else if (indexPath.section == 1){
  128. //
  129. UILabel * lab2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kSize.width, 40)];
  130. lab2.text = [NSString stringWithFormat:@" %@,欢迎您!",MYAPPDELEGATE.userDic[@"realName"]];
  131. lab2.textColor = RGB_COLOR(70, 70, 70);
  132. lab2.font = [UIFont systemFontOfSize:20];
  133. lab2.layer.borderWidth = .7f;
  134. lab2.layer.borderColor = [UIColor colorWithRed:230/255.0f green:230/255.0f blue:230/255.0f alpha:1].CGColor;
  135. [cell.contentView addSubview:lab2];
  136. //
  137. UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 40, kSize.width, 30)];
  138. lab.text = @" 常用功能";
  139. lab.textColor = [UIColor darkGrayColor];
  140. lab.font = [UIFont systemFontOfSize:17];
  141. [cell.contentView addSubview:lab];
  142. //
  143. for (int i=0; i<[_titleArr[1] count]; i++) {
  144. UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
  145. button.frame = CGRectMake(i*size.width/4, 70, size.width/4, height);
  146. [button setTitleUnderImgWithTitle:_titleArr[1][i] TitleColor:[UIColor blackColor] Image:[UIImage imageNamed:imgTitles[0][i]] label:nil];
  147. button.tag = 100+i;
  148. [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  149. [cell.contentView addSubview:button];
  150. }
  151. }else if (indexPath.section == 2){
  152. UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kSize.width, 30)];
  153. lab.text = @" 其它功能";
  154. lab.textColor = [UIColor darkGrayColor];
  155. lab.font = [UIFont systemFontOfSize:17];
  156. [cell.contentView addSubview:lab];
  157. for (int i=0; i<[_titleArr[2] count]; i++) {
  158. UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
  159. button.frame = CGRectMake(i%4*size.width/4, 30+i/4*height, size.width/4, height);
  160. [button setTitleUnderImgWithTitle:_titleArr[2][i] TitleColor:[UIColor blackColor] Image:[UIImage imageNamed:imgTitles[1][i]] label:nil];
  161. button.tag = 1000+i;
  162. [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  163. [cell.contentView addSubview:button];
  164. }
  165. }
  166. return cell;
  167. }
  168. }
  169. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  170. return .1;
  171. }
  172. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  173. if (section == 0) {
  174. return 0.1f;//设置为0无效
  175. }
  176. return 15;
  177. }
  178. -(void)btnClick:(UIButton *)sender{
  179. //type/@[@"驾校管理0",@"教练管理1",@"考核员管理2",@"安全员管理3",@"教练车管理5",@"学员管理4",@"学时审核6"] @"教学日志"7 @"通知下发"8 终端管理9 家学区域 10
  180. switch (sender.tag) {
  181. case 10:
  182. {
  183. // XueShiCheckList * vc = [[XueShiCheckList alloc]init];
  184. // [self.navigationController pushViewController:vc animated:YES];
  185. //预警
  186. WaringVC *vc = [[WaringVC alloc] init];
  187. [self.navigationController pushViewController:vc animated:YES];
  188. }
  189. break;
  190. case 11:
  191. {
  192. //未读消息
  193. self.tabBarController.selectedIndex = 0;
  194. }
  195. break;
  196. case 12:
  197. {
  198. //待审核教学区域
  199. [Tools permissionValidationWithID:@"804" result:^(BOOL isCan, NSString *failureStr) {
  200. if (!isCan) {
  201. if (failureStr) {
  202. [self showMsgByMBWithString:failureStr];
  203. }
  204. return;
  205. }
  206. RegionsList *vc = [[RegionsList alloc]init];
  207. vc.type = @"1";
  208. [self.navigationController pushViewController:vc animated:YES];
  209. }];
  210. }
  211. break;
  212. case 13:
  213. {
  214. //在线终端
  215. SchoolListVC *vc = [[SchoolListVC alloc]init];
  216. vc.navigationItem.title = @"终端管理";
  217. vc.type = 9;//终端管理
  218. [self.navigationController pushViewController:vc animated:YES];
  219. }
  220. break;
  221. case 100:
  222. {
  223. ComplaintsListVC *vc = [[ComplaintsListVC alloc]init];
  224. vc.navigationItem.title = @"投诉管理";
  225. [self.navigationController pushViewController:vc animated:YES];
  226. }
  227. break;
  228. case 101:
  229. {
  230. [Tools permissionValidationWithID:@"18" result:^(BOOL isCan, NSString *failureStr) {
  231. if (!isCan) {
  232. if (failureStr) {
  233. [self showMsgByMBWithString:failureStr];
  234. }
  235. return;
  236. }
  237. SchoolListVC *vc = [[SchoolListVC alloc]init];
  238. vc.navigationItem.title = @"教学日志";
  239. vc.type = 7;//教学日志
  240. [self.navigationController pushViewController:vc animated:YES];
  241. }];
  242. }
  243. break;
  244. case 102:
  245. {
  246. //通知下发
  247. NotifySelectObjVC *vc = [[NotifySelectObjVC alloc]init];
  248. vc.navigationItem.title = @"通知下发";
  249. [self.navigationController pushViewController:vc animated:YES];
  250. }
  251. break;
  252. case 103:
  253. {
  254. [Tools permissionValidationWithID:@"15" result:^(BOOL isCan, NSString *failureStr) {
  255. if (!isCan) {
  256. if (failureStr) {
  257. [self showMsgByMBWithString:failureStr];
  258. }
  259. return;
  260. }
  261. SchoolListVC *vc = [[SchoolListVC alloc]init];
  262. vc.navigationItem.title = @"终端管理";
  263. vc.type = 9;//终端管理
  264. [self.navigationController pushViewController:vc animated:YES];
  265. }];
  266. }
  267. break;
  268. case 1000:
  269. {
  270. [Tools permissionValidationWithID:@"9" result:^(BOOL isCan, NSString *failureStr) {
  271. if (!isCan) {
  272. if (failureStr) {
  273. [self showMsgByMBWithString:failureStr];
  274. }
  275. return;
  276. }
  277. SchoolListVC *vc = [[SchoolListVC alloc]init];
  278. vc.navigationItem.title = @"驾校管理";
  279. vc.type = 0;//驾校管理0
  280. [self.navigationController pushViewController:vc animated:YES];
  281. }];
  282. }
  283. break;
  284. case 1001:
  285. {
  286. [Tools permissionValidationWithID:@"10" result:^(BOOL isCan, NSString *failureStr) {
  287. if (!isCan) {
  288. if (failureStr) {
  289. [self showMsgByMBWithString:failureStr];
  290. }
  291. return;
  292. }
  293. SchoolListVC *vc = [[SchoolListVC alloc]init];
  294. vc.navigationItem.title = @"教练管理";
  295. vc.type = 1;//教练管理1
  296. [self.navigationController pushViewController:vc animated:YES];
  297. }];
  298. }
  299. break;
  300. case 1002:
  301. {
  302. [Tools permissionValidationWithID:@"11" result:^(BOOL isCan, NSString *failureStr) {
  303. if (!isCan) {
  304. if (failureStr) {
  305. [self showMsgByMBWithString:failureStr];
  306. }
  307. return;
  308. }
  309. SchoolListVC *vc = [[SchoolListVC alloc]init];
  310. vc.navigationItem.title = @"考核员管理";
  311. vc.type = 2;//考核员管理2
  312. [self.navigationController pushViewController:vc animated:YES];
  313. }];
  314. }
  315. break;
  316. case 1003:
  317. {
  318. [Tools permissionValidationWithID:@"12" result:^(BOOL isCan, NSString *failureStr) {
  319. if (!isCan) {
  320. if (failureStr) {
  321. [self showMsgByMBWithString:failureStr];
  322. }
  323. return;
  324. }
  325. SchoolListVC *vc = [[SchoolListVC alloc]init];
  326. vc.navigationItem.title = @"安全员管理";
  327. vc.type = 3;//安全员管理3
  328. [self.navigationController pushViewController:vc animated:YES];
  329. }];
  330. }
  331. break;
  332. case 1004:
  333. {
  334. [Tools permissionValidationWithID:@"13" result:^(BOOL isCan, NSString *failureStr) {
  335. if (!isCan) {
  336. if (failureStr) {
  337. [self showMsgByMBWithString:failureStr];
  338. }
  339. return;
  340. }
  341. SchoolListVC *vc = [[SchoolListVC alloc]init];
  342. vc.navigationItem.title = @"教练车管理";
  343. vc.type = 5;//@""教练车管理5
  344. [self.navigationController pushViewController:vc animated:YES];
  345. }];
  346. }
  347. break;
  348. case 1005:
  349. {
  350. [Tools permissionValidationWithID:@"17" result:^(BOOL isCan, NSString *failureStr) {
  351. if (!isCan) {
  352. if (failureStr) {
  353. [self showMsgByMBWithString:failureStr];
  354. }
  355. return;
  356. }
  357. SchoolListVC *vc = [[SchoolListVC alloc]init];
  358. vc.navigationItem.title = @"学员管理";
  359. vc.type = 4;//学员管理4
  360. [self.navigationController pushViewController:vc animated:YES];
  361. }];
  362. }
  363. break;
  364. case 1006:
  365. {
  366. [Tools permissionValidationWithID:@"563" result:^(BOOL isCan, NSString *failureStr) {
  367. if (!isCan) {
  368. if (failureStr) {
  369. [self showMsgByMBWithString:failureStr];
  370. }
  371. return;
  372. }
  373. //教学区域
  374. RegionsList *vc = [[RegionsList alloc]init];
  375. [self.navigationController pushViewController:vc animated:YES];
  376. }];
  377. }
  378. break;
  379. case 1007:
  380. {
  381. //评价管理
  382. EvaluationListVC *vc = [[EvaluationListVC alloc]init];
  383. vc.navigationItem.title = @"评价管理";
  384. [self.navigationController pushViewController:vc animated:YES];
  385. }
  386. break;
  387. case 1008:
  388. {
  389. //预警
  390. WaringVC *vc = [[WaringVC alloc] init];
  391. [self.navigationController pushViewController:vc animated:YES];
  392. }
  393. break;
  394. default:
  395. break;
  396. }
  397. }
  398. - (void)didReceiveMemoryWarning {
  399. [super didReceiveMemoryWarning];
  400. // Dispose of any resources that can be recreated.
  401. }
  402. #pragma mark - 网络请求
  403. -(void)getWillDoVCNews{
  404. NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
  405. [mDic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"];
  406. [NetworkManager requestWithMethod:@"getMsgStatistics" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  407. if (failureStr) {
  408. return;
  409. }
  410. if ([successDic[@"code"] isEqualToString:@"1"]) {
  411. return;
  412. }
  413. NSArray * keys = @[@"SYSTEMNOTICENUM",@"REGIONAUDITNUM",@"SCHOOLAUDITNUM",@"COACHAUDITNUM",@"CARAUDITNUM",@"DEVAUDITNUM",@"NOTICENUM"];
  414. NSDictionary * dic = successDic[@"body"][0];
  415. int count = 0;
  416. for (int i=0; i<keys.count; i++) {
  417. NSString *str = dic[keys[i]];
  418. count += [str intValue];
  419. }
  420. UITabBarController *tabC = (UITabBarController *)self.parentViewController.parentViewController;
  421. if (count == 0) {
  422. [[[tabC.tabBar items] objectAtIndex:0] setBadgeValue:nil];
  423. }else{
  424. [[[tabC.tabBar items] objectAtIndex:0] setBadgeValue:[NSString stringWithFormat:@"%d", count]];
  425. }
  426. [_tableView reloadData];
  427. }];
  428. }
  429. -(void)getData{
  430. NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
  431. [mDic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"];
  432. [mDic setValue:MYAPPDELEGATE.userDic[@"qxbh"] forKey:@"qxbh"];
  433. [mDic setValue:MYAPPDELEGATE.userDic[@"dqbh"] forKey:@"dqbh"];
  434. [NetworkManager requestWithMethod:@"getStatistics" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  435. if (failureStr) {
  436. return;
  437. }
  438. if ([successDic[@"code"] isEqualToString:@"1"]) {
  439. return;
  440. }
  441. NSArray * keys = @[@"warningCnt",@"msgCnt",@"auditRegionCnt",@"onlineDevCnt"];
  442. if (successDic) {
  443. NSDictionary * dic = successDic[@"body"];
  444. int i=0;
  445. for (UILabel *lab in _topLabArr) {
  446. lab.text = [NSString stringWithFormat:@"%@",dic[keys[i]]];
  447. NSInteger count = [lab.text integerValue];
  448. lab.text = count<999?[NSString stringWithFormat:@"%ld",(long)count]:@"999+";
  449. i++;
  450. }
  451. }
  452. }];
  453. }
  454. /*
  455. #pragma mark - Navigation
  456. // In a storyboard-based application, you will often want to do a little preparation before navigation
  457. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  458. // Get the new view controller using [segue destinationViewController].
  459. // Pass the selected object to the new view controller.
  460. }
  461. */
  462. @end