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.
160 lines
5.2 KiB
160 lines
5.2 KiB
// |
|
// ElectronicFenceViewController.m |
|
// LekangGuard |
|
// |
|
// Created by ecell on 2022/12/12. |
|
// |
|
|
|
#import "ElectronicFenceViewController.h" |
|
#import "ElectronicFenceTableViewCell.h" |
|
#import "AddRailViewController.h" |
|
|
|
@interface ElectronicFenceViewController ()<DZNEmptyDataSetSource,DZNEmptyDataSetDelegate> |
|
|
|
@property (nonatomic ,strong) UIImageView *topView; |
|
|
|
@property (nonatomic ,strong) CommonTableView *comTable; |
|
|
|
@end |
|
|
|
@implementation ElectronicFenceViewController |
|
|
|
- (void)viewDidLoad { |
|
[super viewDidLoad]; |
|
// Do any additional setup after loading the view. |
|
self.zx_navTitle = GJText(@"电子围栏"); |
|
|
|
self.ImgType = Dianziweilan; |
|
self.emptyText = GJText(@"未添加电子围栏"); |
|
|
|
[self zx_setRightBtnWithText:GJText(@"添加") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) { |
|
[self pusView:1 model:nil]; |
|
}]; |
|
|
|
[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 GetQueryRails]; |
|
} |
|
|
|
- (CommonTableView *)comTable |
|
{ |
|
if (!_comTable) |
|
{ |
|
kWeakSelf(self) |
|
_comTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:100 cellRow:0 isAdaptive:YES isLine:YES commonCell:ElectronicFenceTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) { |
|
ElectronicFenceTableViewCell *cell = (ElectronicFenceTableViewCell *)cells; |
|
if (indexPath.row < self.modelListArr.count) |
|
{ |
|
cell.railModel = weakself.modelListArr[indexPath.row]; |
|
cell.isEditAndDeleteModel = ^(SafetyRailModel * _Nonnull model, NSInteger type) { |
|
if (type == 2) |
|
[weakself pusView:2 model:model]; |
|
else |
|
[weakself deleteRails:model.Id]; |
|
}; |
|
} |
|
|
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) { |
|
|
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) { |
|
|
|
}]; |
|
_comTable.emptyDataSetSource = self; |
|
_comTable.emptyDataSetDelegate = self; |
|
_comTable.backgroundColor = KKClearColor; |
|
} |
|
return _comTable; |
|
} |
|
|
|
|
|
#pragma mark 查询安全围栏信息 |
|
/// 查询安全围栏信息 |
|
- (void)GetQueryRails |
|
{ |
|
[UICommon MessageUpload:@"加载中"]; |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[parameters setValue:APIManager.sharedManager.deviceModel.imei forKey:@"imei"]; |
|
[[[APIManager sharedManager] APGET:QueryRails_URL parameters:parameters resultClass:nil] subscribeNext:^(NSArray *arr) { |
|
[UICommon HidenLoading]; |
|
[self.modelListArr removeAllObjects]; |
|
if (ARRAYHASVALUE(arr)) |
|
{ |
|
for (NSDictionary *dic in arr) |
|
{ |
|
SafetyRailModel *model = [SafetyRailModel 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]]; |
|
}]; |
|
} |
|
|
|
|
|
#pragma mark 删除电子围栏 |
|
/// 删除电子围栏 |
|
- (void)deleteRails:(NSString *)Id |
|
{ |
|
[UICommon MessageUpload:@"加载中"]; |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[parameters setValue:Id forKey:@"id"]; |
|
[[[APIManager sharedManager] APPOST:DelRails_URL parameters:parameters isJson:NO resultClass:nil] subscribeNext:^(id _Nullable x) { |
|
[UICommon HidenLoading]; |
|
[UICommon MessageSuccessText:@"删除成功"]; |
|
[self GetQueryRails]; |
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
|
|
- (UIImageView *)topView |
|
{ |
|
if (!_topView) |
|
{ |
|
_topView = [UIImageView new]; |
|
_topView.image = ImageName_(@"img_school_guardian_bg"); |
|
_topView.frame = CGRectMake(0, iPhoneX_NavHeight, SCREEN_WIDTH, Adapted(_topView.image.size.height)); |
|
} |
|
return _topView; |
|
} |
|
|
|
- (void)pusView:(NSInteger)type model:(SafetyRailModel *)model |
|
{ |
|
AddRailViewController *vc = [AddRailViewController new]; |
|
vc.railModel = model; |
|
vc.isUpdataModel = ^{ |
|
[self GetQueryRails]; |
|
}; |
|
vc.isRedact = type; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
} |
|
|
|
#pragma mark - DZNEmptyDataSetSource,DZNEmptyDataSetDelegate |
|
- (void)emptyDataSet:(UIScrollView *)scrollView didTapView:(UIView *)view |
|
{ |
|
[self pusView:1 model:nil]; |
|
} |
|
/* |
|
#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
|
|
|