You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
212 lines
7.3 KiB
212 lines
7.3 KiB
// |
|
// ClockAndOtherViewController.m |
|
// LekangGuard |
|
// |
|
// Created by ecell on 2022/12/5. |
|
// |
|
|
|
#import "ClockAndOtherViewController.h" |
|
#import "ClockAndOtherTableViewCell.h" |
|
#import "AddClockAdnOtherViewController.h" |
|
#import "AddAttendClassAlarmViewController.h" |
|
|
|
@interface ClockAndOtherViewController ()<CommonTableViewDelegate,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate> |
|
|
|
@property (nonatomic ,strong) UIImageView *topView; |
|
|
|
@property (nonatomic ,strong) CommonTableView *comTable; |
|
|
|
|
|
|
|
@property (nonatomic ,strong) UIView *headerView; |
|
|
|
@end |
|
|
|
@implementation ClockAndOtherViewController |
|
|
|
- (void)viewDidLoad { |
|
[super viewDidLoad]; |
|
// Do any additional setup after loading the view. |
|
self.view.backgroundColor = KKBackgroundGrey; |
|
self.zx_navTitle = self.viewType == 1 ? GJText(@"设备闹钟") : GJText(@"上课禁用"); |
|
[self zx_setRightBtnWithText:GJText(@"添加") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) { |
|
[self pusView:nil redact:1]; |
|
}]; |
|
|
|
self.ImgType = self.viewType == 1 ? Naozhong : Shangkejinyong; |
|
self.emptyText = self.viewType == 1 ? GJText(@"未添加闹钟") : GJText(@"未添加上课禁用时段"); |
|
|
|
[self.view addSubview:self.topView]; |
|
[self.view addSubview:self.comTable]; |
|
[self.comTable mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.view); |
|
make.top.equalTo(self.topView.mas_bottom); |
|
make.bottom.equalTo(self.view.mas_bottom); |
|
}]; |
|
[self GetQueryAlarm]; |
|
} |
|
|
|
|
|
- (CommonTableView *)comTable |
|
{ |
|
if (!_comTable) |
|
{ |
|
kWeakSelf(self) |
|
_comTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:100 cellRow:0 isAdaptive:YES isLine:YES commonCell:ClockAndOtherTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) { |
|
ClockAndOtherTableViewCell *cell = (ClockAndOtherTableViewCell *)cells; |
|
if (indexPath.row < weakself.modelListArr.count) |
|
{ |
|
cell.viewType = weakself.viewType; |
|
cell.alarmModel = weakself.modelListArr[indexPath.row]; |
|
cell.isUpdataSucceed = ^(NSInteger row, BOOL status) { |
|
AlarmModel *model = weakself.modelListArr[row]; |
|
model.alarmStatus = status; |
|
[weakself.modelListArr replaceObjectAtIndex:row withObject:model]; |
|
}; |
|
} |
|
|
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) { |
|
[weakself pusView:weakself.modelListArr[indexPath.row] redact:2]; |
|
|
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) { |
|
|
|
}]; |
|
_comTable.delegates = self; |
|
_comTable.isEditing = YES; |
|
_comTable.emptyDataSetSource = self; |
|
_comTable.emptyDataSetDelegate = self; |
|
_comTable.backgroundColor = KKClearColor; |
|
if(self.viewType == 2) |
|
{ |
|
_comTable.tableHeaderView = self.headerView; |
|
_comTable.tableHeaderView.height = Adapted(60); |
|
} |
|
} |
|
return _comTable; |
|
} |
|
|
|
|
|
|
|
|
|
#pragma mark 查询设置闹钟 |
|
/// 查询设置闹钟 |
|
- (void)GetQueryAlarm |
|
{ |
|
[UICommon MessageUpload:@"加载中"]; |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[parameters setValue:APIManager.sharedManager.deviceModel.imei forKey:@"imei"]; |
|
[[[APIManager sharedManager] APGET:self.viewType == 1 ? QueryAlarm_URL : DisabledList_URL parameters:parameters resultClass:nil] subscribeNext:^(NSArray *arr) { |
|
[UICommon HidenLoading]; |
|
[self.modelListArr removeAllObjects]; |
|
if (ARRAYHASVALUE(arr)) |
|
{ |
|
for (NSDictionary *dic in arr) |
|
{ |
|
AlarmModel *model = [AlarmModel yy_modelWithJSON:dic]; |
|
[self.modelListArr addObject:model]; |
|
} |
|
} |
|
self.comTable.cellRow = arr.count; |
|
[self.comTable reloadData]; |
|
|
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
|
|
- (UIImageView *)topView |
|
{ |
|
if (!_topView) |
|
{ |
|
_topView = [UIImageView new]; |
|
_topView.image = self.viewType == 1 ? ImageName_(@"img_clock_bg") : ImageName_(@"img_class_disable_bg"); |
|
_topView.frame = CGRectMake(0, iPhoneX_NavHeight, SCREEN_WIDTH, Adapted(_topView.image.size.height)); |
|
} |
|
return _topView; |
|
} |
|
|
|
/// 上课禁用头部提醒 |
|
- (UIView *)headerView |
|
{ |
|
if (!_headerView) |
|
{ |
|
_headerView = [UIView new]; |
|
_headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, Adapted(60)); |
|
|
|
UILabel *headerTitle = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:FontADA_(12) textColor:KKGrey121 text:@"" Radius:0]; |
|
headerTitle.text = GJText(@"温馨提示:\n禁用时设备除可以呼出SOS号码外,设备仅可以查看时间,同时拒接所有电话和信息."); |
|
[_headerView addSubview:headerTitle]; |
|
[headerTitle mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(_headerView).inset(15); |
|
make.centerY.equalTo(_headerView); |
|
}]; |
|
} |
|
return _headerView; |
|
} |
|
|
|
- (void)pusView:(AlarmModel *)model redact:(NSInteger)redact |
|
{ |
|
if (self.viewType == 1) |
|
{ |
|
AddClockAdnOtherViewController *vc = [AddClockAdnOtherViewController new]; |
|
vc.isRedact = redact; |
|
vc.alarmModel = model; |
|
vc.isUpdataMsg = ^{ |
|
[self GetQueryAlarm]; |
|
}; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
} |
|
else |
|
{ |
|
AddAttendClassAlarmViewController *vc = [AddAttendClassAlarmViewController new]; |
|
vc.isRedact = redact; |
|
vc.alarmModel = model; |
|
vc.isUpdataMsg = ^{ |
|
[self GetQueryAlarm]; |
|
}; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
} |
|
} |
|
|
|
#pragma mark CommTableViewDelegate |
|
- (void)CommTableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath |
|
{ |
|
AlarmModel *model = self.modelListArr[indexPath.row]; |
|
[UICommon MessageUpload:@"加载中"]; |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[parameters setValue:model.Id forKey:@"id"]; |
|
[parameters setValue:APIManager.sharedManager.deviceModel.imei forKey:@"imei"]; |
|
[[[APIManager sharedManager] APPOST:self.viewType == 1 ? DeleteAlarm_URL : DeleteDisabled_URL parameters:parameters isJson:YES resultClass:nil] subscribeNext:^(id _Nullable x) { |
|
[UICommon HidenLoading]; |
|
[UICommon MessageSuccessText:@"删除成功"]; |
|
[self GetQueryAlarm]; |
|
|
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
|
|
|
|
|
|
#pragma mark - DZNEmptyDataSetSource,DZNEmptyDataSetDelegate |
|
- (void)emptyDataSet:(UIScrollView *)scrollView didTapView:(UIView *)view |
|
{ |
|
[self pusView:nil redact:1]; |
|
} |
|
|
|
|
|
/* |
|
#pragma mark - Navigation |
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation |
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { |
|
// Get the new view controller using [segue destinationViewController]. |
|
// Pass the selected object to the new view controller. |
|
} |
|
*/ |
|
|
|
@end
|
|
|