TrainPriceDetail.m 8.5 KB

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