TrainPriceDetail.m 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. //
  2. // TrainPriceDetail.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/4/19.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "TrainPriceDetail.h"
  9. #import "EditPriceVC.h"
  10. @interface TrainPriceDetail ()
  11. @end
  12. @implementation TrainPriceDetail
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.navigationItem.title = @"培训价格详情";
  16. [self setSegmentControllWithTitles:@[@"基本信息"] isBttomBar:_isPermission];
  17. if (_isPermission) {
  18. [self createBottomBarWithtoolTitles:@[@"删除",@"修改"]];
  19. }
  20. [self getData];
  21. }
  22. -(void)setData{
  23. _keysArr = @[
  24. @[@"所属机构",@"JXMC"],
  25. @[@"培训车型",@"CSI_VEHICLETYPE"],
  26. @[@"收费模式",@"CSI_CHARGEMODE"],
  27. @[@"培训时段",@"CSI_TRAINNINGTIME"],
  28. @[@"付费模式",@"CSI_PAYMODE"],
  29. @[@"金额",@"CSI_PRICE"],
  30. @[@"班型名称",@"CSI_CLASSCURR"],
  31. @[@"培训模式",@"CSI_TRAINNINGMODE"],
  32. @[@"培训部分及方式 ",@"CSI_SUBJECT"],
  33. @[@"服务内容",@"CSI_SERVICE"],
  34. @[@"编号",@"CSI_SEQ"],
  35. @[@"备案时间",@"CSI_RECORD_DATE"],
  36. ];
  37. [super setData];
  38. }
  39. #pragma mark 创建BottomBarButton
  40. -(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{
  41. float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count;
  42. float HeightBth = JOb_DETAIL_BOTTOMBAR_HEIGHT;
  43. for (int i=0; i<toolTitles.count; i++) {
  44. UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
  45. button.frame = CGRectMake(i*(widthBtn+1), kSize.height-HeightBth-kNavOffSet-SafeAreaBottomHeight, widthBtn, HeightBth);
  46. [button setTitle:toolTitles[i] forState:UIControlStateNormal];
  47. button.backgroundColor = defGreen;
  48. [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  49. [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  50. button.tag = 10+i;
  51. [self.view addSubview:button];
  52. }
  53. }
  54. -(void)btnClick:(UIButton *)sender{
  55. switch (sender.tag) {
  56. case 10:
  57. {
  58. //删除培训价格
  59. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"您确定要删除吗?" preferredStyle:UIAlertControllerStyleAlert];
  60. [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  61. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  62. [self delPrice];
  63. }]];
  64. [self presentViewController:alertFind animated:true completion:nil];
  65. }
  66. break;
  67. case 11:
  68. {
  69. [self willEditPrice];//修改培训价格
  70. }
  71. break;
  72. default:
  73. break;
  74. }
  75. }
  76. #pragma mark 重写代理方法
  77. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  78. if (self.dataSource.allKeys.count == 0) {
  79. return 0;
  80. }
  81. return [_keysArr count];
  82. }
  83. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  84. {
  85. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  86. if (!cell) {
  87. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
  88. }
  89. cell.textLabel.text = _keysArr[indexPath.row][0];
  90. if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
  91. cell.detailTextLabel.numberOfLines = 0;
  92. cell.detailTextLabel.textAlignment = NSTextAlignmentLeft;
  93. }else{
  94. cell.detailTextLabel.numberOfLines = 1;
  95. cell.detailTextLabel.textAlignment = NSTextAlignmentRight;
  96. }
  97. NSString * key = _keysArr[indexPath.row][1];
  98. if ([key isEqualToString:@"CSI_CHARGEMODE"]){
  99. NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  100. //@"一次性收费",@"计时收费",@"分段式收费",@"其他"
  101. switch ([status integerValue]) {
  102. case 1:
  103. cell.detailTextLabel.text = @"一次性收费";
  104. break;
  105. case 2:
  106. cell.detailTextLabel.text = @"计时收费";
  107. break;
  108. case 3:
  109. cell.detailTextLabel.text = @"分段式收费";
  110. break;
  111. case 9:
  112. cell.detailTextLabel.text = @"其它";
  113. break;
  114. default:
  115. break;
  116. }
  117. }else if ([key isEqualToString:@"CSI_TRAINNINGTIME"]){
  118. NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  119. //@"普通时段",@"高峰时段",@"节假日时段"
  120. switch ([status integerValue]) {
  121. case 1:
  122. cell.detailTextLabel.text = @"普通时段";
  123. break;
  124. case 2:
  125. cell.detailTextLabel.text = @"高峰时段";
  126. break;
  127. case 3:
  128. cell.detailTextLabel.text = @"节假日时段";
  129. break;
  130. default:
  131. break;
  132. }
  133. }else if ([key isEqualToString:@"CSI_PAYMODE"]){
  134. NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  135. //@"先学后付",@"先付后学",@"其它"
  136. switch ([status integerValue]) {
  137. case 1:
  138. cell.detailTextLabel.text = @"先学后付";
  139. break;
  140. case 2:
  141. cell.detailTextLabel.text = @"先付后学";
  142. break;
  143. case 9:
  144. cell.detailTextLabel.text = @"其它";
  145. break;
  146. default:
  147. break;
  148. }
  149. }else if ([key isEqualToString:@"CSI_TRAINNINGMODE"]){
  150. NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  151. //@[@"定时培训",@"预约培训",@"c"]
  152. switch ([status integerValue]) {
  153. case 1:
  154. cell.detailTextLabel.text = @"定时培训";
  155. break;
  156. case 2:
  157. cell.detailTextLabel.text = @"预约培训";
  158. break;
  159. case 9:
  160. cell.detailTextLabel.text = @"其它";
  161. break;
  162. default:
  163. break;
  164. }
  165. }else if ([key isEqualToString:@"CSI_SUBJECT"]){
  166. NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  167. NSArray * arr = @[@"第一部份集中教学",@"第一部份网络教学",@"第四部份集中教学",@"第四部份网络教学",@"模拟器教学",@"第二部份普通教学",@"第二部份智能教学",@"第三部份普通教学",@"第三部份智能教学"];
  168. if ([status integerValue] == 0) {
  169. cell.detailTextLabel.text = @"";
  170. }else{
  171. cell.detailTextLabel.text = arr[[status integerValue]-1];
  172. }
  173. }else if ([key isEqualToString:@"CSI_SERVICE"]){
  174. NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  175. if ([status isEqualToString:@"<null>"]) {
  176. status = @"";
  177. }
  178. cell.detailTextLabel.text = status;
  179. }else{
  180. cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dataSource[_keysArr[indexPath.row][1]]];
  181. }
  182. return cell;
  183. }
  184. #pragma mark 数据请求
  185. -(void)getData{
  186. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  187. [dic setObject:_theId forKey:@"id"];
  188. [self getDataWithDic:dic method:@"viewPrice" block:^(NSDictionary *successDic) {
  189. self.dataSource = successDic[@"body"];
  190. [_tableViews[0] reloadData];
  191. }];
  192. }
  193. -(void)delPrice{
  194. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  195. [dic setObject:_theId forKey:@"ids"];
  196. [dic setObject:defUser.userDict[@"id"] forKey:@"userId"];
  197. [self getDataWithDic:dic method:@"delPrice" block:^(NSDictionary *successDic) {
  198. ShowMsg(@"删除成功!");
  199. [self.navigationController popViewControllerAnimated:YES];
  200. }];
  201. }
  202. -(void)willEditPrice{
  203. EditPriceVC * vc = [[EditPriceVC alloc]init];
  204. vc.theDic = self.dataSource;
  205. vc.type = @"2";
  206. vc.blcok = ^{
  207. [self getData];
  208. };
  209. [self navPushHideTabbarToVC:vc];
  210. }
  211. - (void)didReceiveMemoryWarning {
  212. [super didReceiveMemoryWarning];
  213. // Dispose of any resources that can be recreated.
  214. }
  215. /*
  216. #pragma mark - Navigation
  217. // In a storyboard-based application, you will often want to do a little preparation before navigation
  218. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  219. // Get the new view controller using [segue destinationViewController].
  220. // Pass the selected object to the new view controller.
  221. }
  222. */
  223. @end