B2BSchedulingSettingVC.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. //
  2. // B2BSchedulingSettingVC.m
  3. // shiku_im
  4. //
  5. // Created by liyangyang-pc on 17/3/13.
  6. // Copyright © 2017年 UAS. All rights reserved.
  7. //
  8. #import "B2BSchedulingSettingVC.h"
  9. #import "JLFastenSchedulingCell.h" //固定班次
  10. #import "JLFreeSchedulingCell.h" //自由班次
  11. #import "B2BChangeClassVC.h"
  12. #import "MJExtension.h"
  13. #import "JLSchedulingModel.h" //班次模型
  14. #import "JLFastenSchedulingCellfirest.h"
  15. @interface B2BSchedulingSettingVC ()<UITableViewDelegate,UITableViewDataSource>
  16. @property (strong , nonatomic) UITableView *tableView;
  17. @property (strong , nonatomic) NSMutableArray *dataArr;
  18. @property(nonatomic,strong)MBProgressHUD * hub;
  19. @end
  20. @implementation B2BSchedulingSettingVC
  21. {
  22. UIImageView *_noDataImage;//没数据图片
  23. }
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. // Do any additional setup after loading the view.
  27. self.view.backgroundColor = BGB_COLOR;
  28. [self setNavi];
  29. [self setTabelView];
  30. _dataArr = [NSMutableArray array];
  31. _noDataImage = [UIImageView new];
  32. _noDataImage.image = [UIImage imageNamed:@"crm_all_noData"];
  33. _noDataImage.hidden = YES;
  34. [self.view addSubview:_noDataImage];
  35. [_noDataImage mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.width.mas_equalTo(100);
  37. make.height.mas_equalTo(126);
  38. make.center.equalTo(self.view);
  39. }];
  40. }
  41. - (void)viewWillAppear:(BOOL)animated
  42. {
  43. [super viewWillAppear:YES];
  44. if (_dataArr.count != 0) {
  45. [_dataArr removeAllObjects];
  46. }
  47. [SVProgressHUD showWithStatus:@"正在加载中"];
  48. self.tableView.userInteractionEnabled = NO;
  49. [self loadData];
  50. }
  51. #pragma mark --获取详情数据
  52. - (void)loadData{
  53. [B2BHTTPRequest Get:B2B_DaKa_Class_get_All pageSize:0 condition:@"" Completion:^(id ObjectData, NSError *error) {
  54. if (error == nil) {
  55. // DLog(@"%@",ObjectData);
  56. [MBProgressHUD hideHUD];
  57. JLSchedulingModel *model = [JLSchedulingModel mj_objectWithKeyValues:ObjectData[@"data"]];
  58. [_dataArr addObject:model];
  59. SLog(@"%@",model.wd_day);
  60. [self.tableView reloadData];
  61. if (_dataArr.count == 0) {
  62. _noDataImage.hidden = NO;
  63. }else
  64. _noDataImage.hidden = YES;
  65. }else{
  66. [MBProgressHUD hideHUD];
  67. _noDataImage.hidden = NO;
  68. if (error.code==-1009)
  69. {
  70. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  71. }else if (error.code==-1001)
  72. {
  73. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  74. }
  75. else{
  76. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_getDataFaild") ToNavi:self.navigationController withColor:nil];
  77. }
  78. }
  79. }];
  80. }
  81. - (void)setNavi{
  82. UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
  83. btn2.frame = CGRectMake(0, 5, 22, 22);
  84. UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
  85. image.image = [UIImage imageNamed:@"icon_back_nor3"];
  86. [btn2 addSubview:image];
  87. [btn2 addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
  88. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
  89. self.navigationItem.leftBarButtonItems = @[bbi2];
  90. //
  91. self.title = Localized(@"UU_work_OA_punchClock_SchedulingSetting");
  92. }
  93. - (void)setTabelView
  94. {
  95. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 2, self_width, self_height) style:UITableViewStylePlain];
  96. _tableView.delegate=self;
  97. _tableView.dataSource=self;
  98. _tableView.backgroundColor = Color(235, 233, 233, 1.0);
  99. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  100. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  101. [self.view addSubview:_tableView];
  102. }
  103. #pragma mark -- 创建排版
  104. - (void)createAction
  105. {
  106. B2BChangeClassVC *vc = [[ B2BChangeClassVC alloc] init];
  107. vc.type = work_add_Sch;
  108. [self.navigationController pushViewController:vc animated:YES];
  109. }
  110. - (void)backView
  111. {
  112. [self.navigationController popViewControllerAnimated:YES];
  113. }
  114. #pragma tableView delegate
  115. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  116. {
  117. return self.dataArr.count;
  118. }
  119. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  120. {
  121. // if (indexPath.row == 1) {
  122. // JLFreeSchedulingCell *cell = [JLFreeSchedulingCell cellWithTableView:tableView];
  123. // return cell;
  124. //
  125. //
  126. // }else
  127. // if (indexPath.row > 0){
  128. //
  129. // JLFastenSchedulingCell *cell = [JLFastenSchedulingCell cellWithTableView:tableView];
  130. // if (self.dataArr.count == 0) {
  131. //
  132. // }else{
  133. //
  134. // cell.model = self.dataArr[indexPath.row];
  135. //
  136. // }
  137. // UIImageView *delteimage = [[UIImageView alloc] initWithFrame:CGRectMake(self_width -35, 22, 15, 15)];
  138. // delteimage.image = [UIImage imageNamed:@"icon_delete_nor"];
  139. // [cell.contentView addSubview:delteimage];
  140. //
  141. // UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  142. // button.frame = CGRectMake(self_width -50, 0, 50, 50);
  143. // button.backgroundColor = [UIColor clearColor];
  144. // [button addTarget:self action:@selector(deleteAction:) forControlEvents:UIControlEventTouchUpInside];
  145. // button.tag = indexPath.row;
  146. // [cell.contentView addSubview:button];
  147. //
  148. //
  149. //
  150. //
  151. // return cell;
  152. //
  153. // }else{
  154. JLFastenSchedulingCellfirest *cell = [JLFastenSchedulingCellfirest cellWithTableView:tableView];
  155. cell.model = self.dataArr[0];
  156. return cell;
  157. //}
  158. }
  159. #pragma mark -- 删除班次
  160. - (void)deleteAction:(UIButton *)btn
  161. {
  162. [UASAlertView showWithTitle:nil content:Localized(@"UU_work_OA_PC_SchedulingSetting_DeleteTitle") sureTitle:Localized(@"UU_custom_yes") cancelTitle:Localized(@"UU_custom_no") click:^(NSInteger index) {
  163. if (index == 2) {
  164. JLSchedulingModel *model = _dataArr[btn.tag];
  165. [LYHTTPRequest Get:KQin_schedulingSetting_delete page:0 condition:model.wd_code Completion:^(id ObjectData, NSError *error) {
  166. if (error == nil) {
  167. [_dataArr removeObjectAtIndex:btn.tag];
  168. [self.tableView reloadData];
  169. }else{
  170. if (error.code==-1009)
  171. {
  172. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  173. }else if (error.code==-1001)
  174. {
  175. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  176. }
  177. else{
  178. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_deleteFaild") ToNavi:self.navigationController withColor:nil];
  179. }
  180. }
  181. }];
  182. }
  183. }];
  184. }
  185. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  186. {
  187. if (buttonIndex == 0) {
  188. JLSchedulingModel *model = _dataArr[alertView.tag];
  189. [LYHTTPRequest Get:KQin_schedulingSetting_delete page:0 condition:model.wd_code Completion:^(id ObjectData, NSError *error) {
  190. if (error == nil) {
  191. [_dataArr removeObjectAtIndex:alertView.tag];
  192. [self.tableView reloadData];
  193. }else{
  194. if (error.code==-1009)
  195. {
  196. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  197. }else if (error.code==-1001)
  198. {
  199. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  200. }
  201. else{
  202. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_deleteFaild") ToNavi:self.navigationController withColor:nil];
  203. }
  204. }
  205. }];
  206. }else{
  207. }
  208. }
  209. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  210. // if (indexPath.row == 1) {
  211. // return 64+8;
  212. // }
  213. return 84+8+10;
  214. }
  215. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  216. {[tableView deselectRowAtIndexPath:indexPath animated:NO];
  217. if (indexPath.row == 1000000) {
  218. }else{
  219. B2BChangeClassVC *vc = [[ B2BChangeClassVC alloc] init];
  220. vc.type = work_change_Sch;
  221. // if (indexPath.row == 0) {
  222. // vc.model = _dataArr[indexPath.row];
  223. // }else{
  224. // vc.model = _dataArr[indexPath.row-1];
  225. // }
  226. vc.model = _dataArr[indexPath.row];
  227. [self.navigationController pushViewController:vc animated:YES];
  228. }
  229. }
  230. /*
  231. #pragma mark - Navigation
  232. // In a storyboard-based application, you will often want to do a little preparation before navigation
  233. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  234. // Get the new view controller using [segue destinationViewController].
  235. // Pass the selected object to the new view controller.
  236. }
  237. */
  238. @end