XueShiCheckList.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. //
  2. // XueShiCheckList.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/9.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "XueShiCheckList.h"
  9. #import "XueShiCheckCell.h"
  10. #import "MengBanView.h"
  11. #import "MJRefresh.h"
  12. #import "TeachLogForCheckVC.h"
  13. @interface XueShiCheckList ()<UISearchBarDelegate,UIGestureRecognizerDelegate>
  14. {
  15. MengBanView * _mengBanView;
  16. //请求参数
  17. NSString * _kemu;
  18. NSString * _state;
  19. NSString *_stuName;
  20. NSInteger _currentPageNum;//记录页书
  21. //正在加载的状态
  22. BOOL _IS_LOADING;
  23. //加载数据的类型
  24. MyGetDataType _getDataType;
  25. NSMutableArray *_selectedIndexPathes;//记录选中的cell
  26. UISearchBar *_searchBar;
  27. UIButton * _notifyBtn;//审核学时
  28. UIButton *_allBtn;
  29. UIButton *_cancelBtn;
  30. BOOL _isEditing;//这个字段我表示忏悔,直接用tableview。editing就好了
  31. }
  32. @end
  33. @implementation XueShiCheckList
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. self.navigationItem.title = @"学时审核";
  37. if ([self.type isEqualToString:@"1"]) {
  38. [self changeBckBtn];
  39. }
  40. //实例化
  41. _kemu = @"";
  42. _state = @"待审核";
  43. _stuName = @"";
  44. _currentPageNum = 0;
  45. _getDataType = MyGetDataTypeNomal;
  46. _IS_LOADING = NO;
  47. _selectedIndexPathes = [[NSMutableArray alloc] init];
  48. _isEditing = NO;
  49. [self createSelectBtn];
  50. [self setRefreshAction];//设置刷新
  51. [self customRightBtn];//设置筛选
  52. [self creatSearchVC];//添加搜索栏
  53. [self getData];
  54. __weak typeof(self) weakSelf = self;
  55. self.block = ^{
  56. [weakSelf headerRefresh];
  57. };
  58. }
  59. -(void)viewWillDisappear:(BOOL)animated{
  60. [super viewWillDisappear:animated];
  61. _searchBar.text = _stuName;
  62. [_searchBar resignFirstResponder];
  63. }
  64. -(void)viewDidDisappear:(BOOL)animated{
  65. [super viewDidDisappear:animated];
  66. if (_allBtn) {
  67. [_allBtn removeFromSuperview];
  68. }
  69. if (_cancelBtn) {
  70. [_cancelBtn removeFromSuperview];
  71. }
  72. // if (_notifyBtn) {
  73. // [_notifyBtn removeFromSuperview];
  74. // }
  75. }
  76. -(void)changeBckBtn{
  77. UIBarButtonItem* backBbi = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(backBtnAction)];
  78. [backBbi setTintColor:COLOR_THEME];
  79. [self.navigationItem setLeftBarButtonItem:backBbi];
  80. }
  81. -(void)backBtnAction{
  82. [self dismissViewControllerAnimated:YES completion:nil];
  83. }
  84. -(void)createSelectBtn{
  85. _notifyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  86. _notifyBtn.backgroundColor = COLOR_THEME;
  87. _notifyBtn.frame = CGRectMake(kSize.width-80, kSize.height-90-kNavOffSet, 60, 60);
  88. [_notifyBtn setTitle:@"审核\n学时" forState:UIControlStateNormal];
  89. [_notifyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  90. _notifyBtn.titleLabel.numberOfLines = 0;
  91. _notifyBtn.layer.masksToBounds = YES;
  92. _notifyBtn.layer.cornerRadius = 30;
  93. [_notifyBtn addTarget:self action:@selector(notifiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  94. _notifyBtn.hidden = YES;
  95. [self.view addSubview:_notifyBtn];
  96. [self.view bringSubviewToFront:self.holderV];
  97. }
  98. -(void)notifiBtnClick:(UIButton *)sender{
  99. if (self.dataurce.count == 0) {
  100. return;
  101. }
  102. if (!_isEditing) {
  103. _isEditing = YES;
  104. [self.tableView setEditing:YES];//进入编辑模式
  105. [self removeRefreshAction];
  106. [sender setTitle:@"提交\n审核" forState:UIControlStateNormal];
  107. CGRect frame = sender.frame;;
  108. _allBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  109. _allBtn.backgroundColor = [UIColor lightGrayColor];
  110. //_allBtn.backgroundColor = COLOR_THEME;
  111. _allBtn.frame = CGRectMake(frame.origin.x + 30, frame.origin.y, 0, 30);
  112. [_allBtn setTitle:@"全选" forState:UIControlStateNormal];
  113. [_allBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  114. [_allBtn setTitleColor:COLOR_THEME forState:UIControlStateSelected];
  115. [_allBtn addTarget:self action:@selector(allClick:) forControlEvents:UIControlEventTouchUpInside];
  116. [KWINDOW addSubview:_allBtn];
  117. _cancelBtn = [UIButton buttonWithType:UIButtonTypeSystem];
  118. _cancelBtn.backgroundColor = [UIColor lightGrayColor];
  119. _cancelBtn.frame = CGRectMake(frame.origin.x + 30, frame.origin.y + 30, 0, 30);
  120. [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
  121. [_cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  122. [_cancelBtn addTarget:self action:@selector(cancelClick:) forControlEvents:UIControlEventTouchUpInside];
  123. [KWINDOW addSubview:_cancelBtn];
  124. [UIView animateWithDuration:.4 animations:^{
  125. _allBtn.frame = CGRectMake(frame.origin.x-100, frame.origin.y - 5, 80, 30);
  126. _cancelBtn.frame = CGRectMake(frame.origin.x-100, frame.origin.y + 35, 80, 30);
  127. }];
  128. return;
  129. }
  130. NSMutableArray * allId = [NSMutableArray new];
  131. for (NSIndexPath *indexPath in _selectedIndexPathes) {
  132. [allId addObject:self.dataurce[indexPath.row][@"ID"]];
  133. }
  134. if (allId.count > 0) {
  135. [self.tableView setEditing:NO];
  136. [self setRefreshAction];
  137. [sender setTitle:@"审核\n学时" forState:UIControlStateNormal];
  138. [_allBtn removeFromSuperview];
  139. [_cancelBtn removeFromSuperview];
  140. _isEditing = NO;
  141. if (allId.count == 1) {//单条审核
  142. [self shenheSingleXueshiWith:_selectedIndexPathes[0]];
  143. }else{//多条审核
  144. [self shenheXueshiWithIds:allId];
  145. }
  146. [_selectedIndexPathes removeAllObjects];
  147. }else{
  148. [self showMsgByAlertVCWithString:@"请选择学时"];
  149. }
  150. }
  151. -(void)allClick:(UIButton *)button{
  152. button.selected = !button.selected;
  153. //获取表格视图内容的尺寸
  154. CGSize size = self.tableView.contentSize;
  155. CGRect rect = CGRectMake(0, 0, size.width, size.height);
  156. //获取指定区域的cell的indexPath
  157. NSArray *indexPathes = [self.tableView indexPathsForRowsInRect:rect];
  158. if (button.selected) {
  159. for (NSIndexPath *indexPath in indexPathes) {
  160. //使用代码方式选中一行
  161. [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
  162. }
  163. //更新选中数组
  164. _selectedIndexPathes.array = indexPathes;
  165. } else {
  166. for (NSIndexPath *indexPath in indexPathes) {
  167. //使用代码方式取消选中一行
  168. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  169. }
  170. //清空选中cell的记录数组
  171. [_selectedIndexPathes removeAllObjects];
  172. }
  173. }
  174. - (void)cancelClick:(UIButton *)sender {
  175. [self.tableView setEditing:NO];
  176. [self setRefreshAction];
  177. [_notifyBtn setTitle:@"审核\n学时" forState:UIControlStateNormal];
  178. [_allBtn removeFromSuperview];
  179. [_cancelBtn removeFromSuperview];
  180. _isEditing = NO;
  181. [_selectedIndexPathes removeAllObjects];
  182. }
  183. -(void)shenheSingleXueshiWith:(NSIndexPath *)indexPath{
  184. NSDictionary * dic = self.dataurce[indexPath.row];
  185. NSString * message = [NSString stringWithFormat:@"姓名:%@ 训练时长:%@",dic[@"STUNAME"],dic[@"TIME"]];
  186. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:@"审核学时" message:message preferredStyle:UIAlertControllerStyleAlert];
  187. [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
  188. textField.placeholder = @"输入审核原因[二次审核不能为空]";
  189. }];
  190. [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  191. [alertFind addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  192. UITextField *tf = alertFind.textFields[0];
  193. [self trainTimesCheckWithDic:dic withReason:tf.text];
  194. }]];
  195. [self presentViewController:alertFind animated:true completion:nil];
  196. }
  197. -(void)customRightBtn{
  198. UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"筛选" style:UIBarButtonItemStylePlain target:self action:@selector(setMengbanView)];
  199. item.tintColor = COLOR_THEME;
  200. self.navigationItem.rightBarButtonItem = item;
  201. }
  202. -(void)setMengbanView{
  203. //如果是编辑状态 就不弹出筛选条件框
  204. if (_isEditing) {
  205. [self showMsgByMBWithString:@"正在选择待审核学时,无法进行此操作!"];
  206. return;
  207. }
  208. if (_mengBanView) {
  209. [_mengBanView showView];
  210. return;
  211. }
  212. NSArray * btnarr1 = @[@"第一部分",@"第二部分",@"第三部分",@"第四部分"];
  213. NSArray * btnarr2 = @[@"待审核",@"审核通过",@"审核不通过"];
  214. __weak typeof(self) weakSelf = self;
  215. _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:@[btnarr1,btnarr2] block:^(NSArray *array) {
  216. //array 是你已经选择好的内容
  217. _kemu = array[0];
  218. _state = array[1];
  219. [weakSelf headerRefresh];
  220. }];
  221. [_mengBanView showView];
  222. }
  223. - (void)creatSearchVC
  224. {
  225. //
  226. UISearchBar *searcbar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, kNavOffSet, kSize.width, 44)];
  227. searcbar.delegate = self;
  228. searcbar.placeholder = @"请输入学员姓名";
  229. [self.view addSubview:searcbar];
  230. self.tableView.frame = CGRectMake(0, 44.0+kNavOffSet, kSize.width, kSize.height-CGRectGetMaxY(searcbar.frame)-SafeAreaBottomHeight);
  231. _searchBar = searcbar;
  232. //
  233. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapClick)];
  234. tap.delegate = self;
  235. [self.tableView addGestureRecognizer:tap];
  236. //
  237. __weak typeof(self)weakSelf = self;
  238. [self.holderV freshBlock:^{
  239. _searchBar.text = _stuName;
  240. [_searchBar resignFirstResponder];
  241. weakSelf.holderV.hidden = NO;
  242. }];
  243. self.holderV.title = @"暂无数据";
  244. }
  245. -(void)tapClick{
  246. _searchBar.text = _stuName;
  247. [_searchBar resignFirstResponder];
  248. }
  249. #pragma mark-手势代理,解决和tableview点击发生的冲突
  250. -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
  251. if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {//判断如果点击的是tableView的cell,就把手势给关闭了
  252. return NO;
  253. }
  254. return YES;
  255. }
  256. #pragma mark searchbar代理相关
  257. - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{
  258. if (_isEditing) {
  259. return NO;
  260. }
  261. searchBar.showsCancelButton = YES;
  262. UIButton *canceLBtn = [searchBar valueForKey:@"cancelButton"];
  263. [canceLBtn setTitle:@"取消" forState:UIControlStateNormal];
  264. [canceLBtn setTitleColor:COLOR_THEME forState:UIControlStateNormal];
  265. return YES;
  266. }
  267. - (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar{
  268. searchBar.showsCancelButton = NO;
  269. return YES;
  270. }
  271. -(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar{
  272. searchBar.text = _stuName;
  273. [searchBar resignFirstResponder];
  274. }
  275. -(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
  276. _stuName = searchBar.text;
  277. [searchBar resignFirstResponder];
  278. [self headerRefresh];
  279. }
  280. #pragma mark - 下拉刷新,上拉加载 -
  281. -(void)setRefreshAction{
  282. // 下拉加载更多
  283. __weak typeof(self) weakSelf = self;
  284. MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  285. [weakSelf headerRefresh];
  286. }];
  287. self.tableView.mj_header = header;
  288. MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  289. [weakSelf footerRefresh];
  290. }];
  291. self.tableView.mj_footer = footer;
  292. }
  293. -(void)headerRefresh{
  294. //设置获取数据的方式
  295. _getDataType=MyGetDataTypeHeaderRefresh;
  296. //加载数据
  297. [self getData];
  298. [self.tableView.mj_header endRefreshing];
  299. }
  300. -(void)footerRefresh{
  301. //设置获取数据的方式
  302. _getDataType=MyGetDataTypeFooterRefresh;
  303. //加载数据
  304. [self getData];
  305. [self.tableView.mj_footer endRefreshing];
  306. }
  307. -(void)removeRefreshAction{
  308. self.tableView.mj_header = nil;
  309. self.tableView.mj_footer = nil;
  310. }
  311. #pragma mark 代理方法
  312. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  313. // if (_searchController.active) {
  314. // return _searchArr.count;//搜索结果
  315. // }else
  316. // {
  317. // return self.dataurce.count;//原始数据
  318. // }
  319. return self.dataurce.count;
  320. }
  321. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  322. return 100;
  323. }
  324. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath{
  325. XueShiCheckCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellXueShiCheck"];
  326. if (!cell) {
  327. //加载xib文件创建cell
  328. cell = [[[NSBundle mainBundle] loadNibNamed:@"XueShiCheckCell" owner:nil options:nil] lastObject];
  329. }
  330. [cell updataWithDic:self.dataurce[indexPath.row]];
  331. return cell;
  332. }
  333. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  334. //选择单元格
  335. if (_isEditing) {
  336. //当选中cell时,记录其indexPath
  337. if (![_selectedIndexPathes containsObject:indexPath]) {
  338. [_selectedIndexPathes addObject:indexPath];
  339. }
  340. return;
  341. }
  342. //[self showMsgByAlertVCWithString:@"点击右下角图标可选择学时进行审核"];
  343. //查看电子日志详细信息
  344. TeachLogForCheckVC *teachlogVC = [[TeachLogForCheckVC alloc] init];
  345. teachlogVC.checkDic = self.dataurce[indexPath.row];
  346. [self.navigationController pushViewController:teachlogVC animated:YES];
  347. // NSDictionary * dic = self.dataurce[indexPath.row];
  348. // NSString * message = [NSString stringWithFormat:@"姓名:%@ 训练时长:%@",dic[@"STUNAME"],dic[@"TIME"]];
  349. // UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:@"审核学时" message:message preferredStyle:UIAlertControllerStyleAlert];
  350. // [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
  351. // textField.placeholder = @"输入审核原因[二次审核不能为空]";
  352. // }];
  353. // [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  354. // [alertFind addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  355. // UITextField *tf = alertFind.textFields[0];
  356. // [self trainTimesCheckWithDic:dic withReason:tf.text];
  357. // }]];
  358. // [self presentViewController:alertFind animated:true completion:nil];
  359. }
  360. - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
  361. //当取消选中cell时,从记录的数组中删除其indexPath
  362. if ([_selectedIndexPathes containsObject:indexPath] && _isEditing) {
  363. [_selectedIndexPathes removeObject:indexPath];
  364. if (_allBtn.selected) {
  365. _allBtn.selected = NO;
  366. }
  367. }
  368. }
  369. - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  370. return UITableViewCellEditingStyleInsert |UITableViewCellEditingStyleDelete;
  371. }
  372. #pragma mark 网络请求
  373. - (void)getData{
  374. //判断当前是否正在加载数据。如果正在加载数据,直接return。
  375. if (_IS_LOADING) {
  376. return;
  377. }
  378. _IS_LOADING=YES;
  379. //获取第一页数据
  380. NSInteger needLoadPage;
  381. needLoadPage=_currentPageNum+1;
  382. if (_getDataType==MyGetDataTypeHeaderRefresh) {
  383. needLoadPage=1;
  384. }
  385. //@[@"未审核",@"已审核",@"审核不通过"]
  386. NSString * statu = @"";
  387. if ([_state isEqualToString:@"待审核"]) {
  388. statu = @"0";
  389. }else if ([_state isEqualToString:@"审核通过"]){
  390. statu = @"1";
  391. }else if ([_state isEqualToString:@"审核不通过"]){
  392. statu = @"2";
  393. }
  394. NSString * kemuStr = @"";
  395. if ([_kemu isEqualToString:@"第一部分"]) {
  396. kemuStr = @"1";
  397. }else if ([_kemu isEqualToString:@"第二部分"]){
  398. kemuStr = @"2";
  399. }else if ([_kemu isEqualToString:@"第三部分"]){
  400. kemuStr = @"3";
  401. }else if ([_kemu isEqualToString:@"第四部分"]){
  402. kemuStr = @"4";
  403. }
  404. NSMutableDictionary * mdic = [NSMutableDictionary new];
  405. [mdic setValue:@"" forKey:@"dqbh"];
  406. [mdic setValue:@"" forKey:@"qxbh"];
  407. [mdic setValue:@"" forKey:@"inscode"];
  408. [mdic setValue:_stuName forKey:@"studentName"];
  409. [mdic setValue:kemuStr forKey:@"subject"];
  410. [mdic setValue:statu forKey:@"auditStatus"];
  411. [mdic setValue:@"1" forKey:@"isPage"];
  412. [mdic setValue:@"10" forKey:@"pageSize"];
  413. [mdic setValue:[NSString stringWithFormat:@"%d",(int)needLoadPage] forKey:@"currentPage"];
  414. __weak typeof(self) weakSelf = self;
  415. [self getDataWithDic:mdic method:@"trainTimes" block:^(NSDictionary *successDic) {
  416. //设置加载状态
  417. _IS_LOADING=NO;
  418. //处理数据
  419. //如果获取到了数据,而且是下拉刷新,清空数组。
  420. if (_getDataType==MyGetDataTypeHeaderRefresh){
  421. [weakSelf.dataurce removeAllObjects];
  422. }
  423. //追加数据
  424. [weakSelf.dataurce addObjectsFromArray:successDic[@"body"]];
  425. if (weakSelf.dataurce.count != 0) {
  426. self.holderV.hidden = YES;
  427. _notifyBtn.hidden = NO;
  428. }
  429. //如果是切换筛选条件 就重新判断是否显示审核按钮
  430. _notifyBtn.hidden = YES;
  431. if ([_state isEqualToString:@"待审核"]) {
  432. _notifyBtn.hidden = NO;
  433. }
  434. //计数器+1
  435. _currentPageNum=needLoadPage;
  436. //刷新界面
  437. [weakSelf.tableView reloadData];
  438. //恢复初始状态。
  439. _getDataType=MyGetDataTypeNomal;
  440. }];
  441. }
  442. -(void)shenheXueshiWithIds:(NSMutableArray *)ids{
  443. if ([MYAPPDELEGATE.userDic[@"qz"] length] == 0) {
  444. [self showMsgByAlertVCWithString:@"审核失败,不具备审核权限"];
  445. return;
  446. }
  447. NSMutableString *str = [NSMutableString new];
  448. for (NSString *obj in ids) {
  449. [str appendFormat:@",%@",obj];
  450. }
  451. NSString * idsStr = [str substringFromIndex:1];
  452. NSMutableDictionary * mdic = [NSMutableDictionary new];
  453. [mdic setValue:idsStr forKey:@"ids"];
  454. [mdic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"];
  455. [mdic setValue:@"1" forKey:@"auditStatus"];
  456. [mdic setValue:@"" forKey:@"reason"];
  457. //判断网络是否连接
  458. if (![NetworkManager connectedToNetWork]) {
  459. [self showMsgByAlertVCWithString:@"网络连接异常"];
  460. return;
  461. }
  462. [MBProgressHUD hideHUDForView:self.view animated:NO];
  463. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  464. [NetworkManager requestWithMethod:@"trainTimesAudit" parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  465. [MBProgressHUD hideHUDForView:self.view animated:YES];
  466. //设置加载状态
  467. _IS_LOADING=NO;
  468. if (failureStr) {
  469. [self showMsgByAlertVCWithString:failureStr];
  470. return;
  471. }
  472. if ([successDic[@"code"] isEqualToString:@"1"]) {
  473. [self showMsgByAlertVCWithString:successDic[@"msg"]];
  474. return;
  475. }
  476. [self showMsgByMBWithString:@"审核成功"];
  477. [self headerRefresh];
  478. }];
  479. }
  480. -(void)trainTimesCheckWithDic:(NSDictionary *)dic withReason:(NSString *)reason{
  481. if ([MYAPPDELEGATE.userDic[@"qz"] length] == 0) {
  482. [self showMsgByAlertVCWithString:@"审核失败,不具备审核权限"];
  483. return;
  484. }
  485. NSMutableDictionary * mdic = [NSMutableDictionary new];
  486. [mdic setValue:@[dic[@"ID"]] forKey:@"ids"];
  487. [mdic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"];
  488. [mdic setValue:dic[@"STATUS"] forKey:@"auditStatus"];
  489. [mdic setValue:reason forKey:@"reason"];
  490. [self getDataWithDic:mdic method:@"trainTimesAudit" block:^(NSDictionary *successDic) {
  491. [self showMsgByMBWithString:@"审核成功"];
  492. [self headerRefresh];
  493. }];
  494. }
  495. - (void)didReceiveMemoryWarning {
  496. [super didReceiveMemoryWarning];
  497. // Dispose of any resources that can be recreated.
  498. }
  499. /*
  500. #pragma mark - Navigation
  501. // In a storyboard-based application, you will often want to do a little preparation before navigation
  502. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  503. // Get the new view controller using [segue destinationViewController].
  504. // Pass the selected object to the new view controller.
  505. }
  506. */
  507. @end