123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- //
- // YOUPAIHRGuildCenterSearchVC.m
- // VQU
- //
- // Created by xiaohaoran on 2021/11/3.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAIHRAddManagementVC.h"
- #import "YOUPAIHRAddManagementCell.h"
- #import "YOUPAIHRGuildCenterDetailVC.h"
- #import "UIScrollView+LZRefresh.h"
- #import "YOUPAIHRPersonnelManagementModel.h"
- #import "BRPickerView.h"
- @interface YOUPAIHRAddManagementVC ()<UISearchBarDelegate,UITableViewDelegate,UITableViewDataSource>
- @property(nonatomic,strong)UISearchBar* youpaipsearchBar;
- @property(nonatomic,strong)UITableView *youpaiptableView;
- @property (nonatomic, strong) NSMutableArray *youpaipdataSource;
- @property (nonatomic, assign) NSInteger youpaipselectIndex;
- @property(nonatomic,assign)BOOL youpaipisSearch;
- @property(nonatomic,copy)NSString *youpaipIDStr;
- @property(nonatomic,strong)BRStringPickerView *youpaipstringPickerView;
- @end
- @implementation YOUPAIHRAddManagementVC
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
- [self.view endEditing:YES];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"添加管理";
- [self youpaifsetSearchUI];
- [self youpaiptableView];
-
-
- }
- -(void)youpaifgetData{
-
- @weakify(self);
- [LCHttpHelper requestWithURLString:ChatRoom_AddManManagement parameters:@{@"usercode":@"",@"room_id":@(self.youpaiproom_id)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
-
- if (self.youpaipdataSource!= nil) {
- [self.youpaipdataSource removeAllObjects];
- }
- NSArray <YOUPAIHRPersonnelManagementModel *>*list = [YOUPAIHRPersonnelManagementModel mj_objectArrayWithKeyValuesArray:dict[@"data"]];
- [self.youpaipdataSource addObjectsFromArray:list];
- [self.youpaiptableView reloadData];
- if (self.youpaipdataSource.count != 0) {
- [self.youpaiptableView lz_hideEmptyView];
- }else{
- [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"];
- }
- }
- } failure:^(NSError *error) {
-
- }];
-
- }
- - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
- [searchBar resignFirstResponder];
- //判断空格
- if ([[searchBar.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]length]==0) {
- searchBar.text = @"";
-
- }else{
- @weakify(self);
- [LCHttpHelper requestWithURLString:ChatRoom_AddManManagement parameters:@{@"usercode":searchBar.text,@"room_id":@(self.youpaiproom_id)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- if (self.youpaipdataSource!= nil) {
- [self.youpaipdataSource removeAllObjects];
- }
- NSArray <YOUPAIHRPersonnelManagementModel *>*list = [YOUPAIHRPersonnelManagementModel mj_objectArrayWithKeyValuesArray:dict[@"data"]];
- [self.youpaipdataSource addObjectsFromArray:list];
- [self.youpaiptableView reloadData];
- if (self.youpaipdataSource.count != 0) {
- [self.youpaiptableView lz_hideEmptyView];
- }else{
- [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"未搜索到相关结果~"];
- }
- }
- } failure:^(NSError *error) {
-
- }];
- }
- }
- - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
- NSLog(@"%@",searchText);
- NSLog(@"%@",searchBar.text);
- if ([searchBar.text isEqualToString:@""]) {
- [self.youpaipdataSource removeAllObjects];
- [self.youpaiptableView.mj_header beginRefreshing];
-
- }else{
- // self.youpaipisSearch = YES;
- // self.isLabelSearch = NO;
- }
- }
- -(void)youpaifaddManageAction{
-
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
-
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- return 68;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return self.youpaipdataSource.count;
- }
- -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAIHRAddManagementCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HRPersonnelManagementID" forIndexPath:indexPath];;
- if (cell == nil) {
- cell = [[YOUPAIHRAddManagementCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"HRPersonnelManagementID"];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- cell.backgroundColor = LCBkgColor;
- YOUPAIHRPersonnelManagementModel *model = self.youpaipdataSource[indexPath.row];
- cell.youpaipmodel = model;
- @weakify(self);
- [cell setYoupaipdidClickBlock:^(YOUPAIHRPersonnelManagementModel * _Nonnull model) {
- @strongify(self);
- [self youpaifsetStatus:model];
- }];
- return cell;
- }
- -(void)youpaifsetStatus:(YOUPAIHRPersonnelManagementModel*)model{
-
- NSMutableArray *actionArray = [NSMutableArray new];
- @weakify(self);
- ZCAlertAction* action1 = [ZCAlertAction actionWithTitle:[NSString stringWithFormat:@"设为主持"] andblock:^{//删除动态
- @strongify(self);
-
- [LCHttpHelper requestWithURLString:ChatRoom_UpdateManManagement parameters:@{@"usercode":model.youpaipusercode,@"room_id":@(self.youpaiproom_id),@"is_set":@(2),@"identity":@"host"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
-
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- [ZCHUDHelper showTitle:dict[@"message"]];
- self.youpaipsearchBar.text = @"";
- [self youpaifgetData];
- }else{
- [ZCHUDHelper showTitle:dict[@"message"]];
- }
- } failure:^(NSError *error) {
-
- }];
-
-
- }];
- ZCAlertAction* action2 = [ZCAlertAction actionWithTitle:[NSString stringWithFormat:@"设为管理"] andblock:^{//删除动态
- @strongify(self);
-
- [LCHttpHelper requestWithURLString:ChatRoom_UpdateManManagement parameters:@{@"usercode":model.youpaipusercode,@"room_id":@(self.youpaiproom_id),@"is_set":@(2),@"identity":@"manager"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
-
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- [ZCHUDHelper showTitle:dict[@"message"]];
- self.youpaipsearchBar.text = @"";
- [self youpaifgetData];
- }else{
- [ZCHUDHelper showTitle:dict[@"message"]];
- }
- } failure:^(NSError *error) {
-
- }];
-
-
- }];
- [actionArray addObject:action1];
- [actionArray addObject:action2];
-
- ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
- alertSheet.alertWindow.hidden = NO;
- [alertSheet show];
- }
- - (void)youpaifsetSearchUI{
-
- UIView *bgSearchView = [UIView new];
- [self.view addSubview:bgSearchView];
- [bgSearchView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(NavBarHeight+8);
- make.height.mas_equalTo(44);
- }];
- bgSearchView.backgroundColor = LCBkgColor;
-
- UISearchBar* search = [[UISearchBar alloc]initWithFrame:CGRectZero];
- [bgSearchView addSubview:search];
- [search mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.width.mas_equalTo(KScreenWidth-70);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
- [search setImage:[UIImage imageNamed:@"vqu_images_H_search_icon"]
- forSearchBarIcon:UISearchBarIconSearch
- state:UIControlStateNormal];
- // search.tintColor = ZYPinkColor;
- search.backgroundImage = [UIImage imageWithColor:LCBkgColor size:CGSizeMake(KScreenWidth-70, 44)];
- [search setSearchFieldBackgroundImage:[UIImage imageWithColor:HexColorFromRGB(0x4F4B5B) size:CGSizeMake(KScreenWidth-70, 38.0f)] forState:UIControlStateNormal];
- // search.searchTextField.clearButtonMode = UITextFieldViewModeAlways;
- UITextField *searchField = [search valueForKey:@"searchField"];
- if (searchField) {
- searchField.frame = CGRectMake(16,8,search.frame.size.width-16,38);
- [searchField setBackgroundColor:HexColorFromRGB(0x4F4B5B)];
- searchField.layer.cornerRadius = 19.0f;
- searchField.layer.masksToBounds = YES;
- searchField.font = LCFont(14);
- searchField.textColor = [UIColor whiteColor];
- NSMutableAttributedString* placeholder = [[NSMutableAttributedString alloc]initWithString:@"搜索用户ID 添加管理"];
- [placeholder addAttribute:NSFontAttributeName value:LCFont(14) range:NSMakeRange(0, placeholder.length)];
- [placeholder addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0x6C6B70) range:NSMakeRange(0, placeholder.length)];
- searchField.attributedPlaceholder = placeholder;
- searchField.clearButtonMode = UITextFieldViewModeAlways;
- }
- search.delegate = self;
- self.youpaipsearchBar = search;
- //取消
- UIButton *cancelBtn = [UIButton new];
- [bgSearchView addSubview:cancelBtn];
- [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(search.mas_right);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
- [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
- [cancelBtn setTitleColor:HexColorFromRGB(0x9F9DA5) forState:UIControlStateNormal];
- [cancelBtn addTarget:self action:@selector(youpaifcancelButtonClick) forControlEvents:UIControlEventTouchUpInside];
- }
- -(UITableView *)youpaiptableView{
- if (_youpaiptableView == nil) {
- _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
- [self.view addSubview:_youpaiptableView];
- [_youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(44+8+NavBarHeight);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(-SafeHeight);
- }];
- _youpaiptableView.delegate = self;
- _youpaiptableView.dataSource = self;
- _youpaiptableView.backgroundColor = [UIColor clearColor];
- _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _youpaiptableView.showsVerticalScrollIndicator = NO;
- _youpaiptableView.showsHorizontalScrollIndicator = NO;
- if (@available(iOS 15.0, *)) {
- _youpaiptableView.sectionHeaderTopPadding = 0;
- }
- [_youpaiptableView registerClass:[YOUPAIHRAddManagementCell class] forCellReuseIdentifier:@"HRPersonnelManagementID"];
- }
-
- return _youpaiptableView;
- }
- -(void)youpaifcancelButtonClick{
- [self.youpaipsearchBar resignFirstResponder];
- if (self.youpaipsearchBar.text.length>0) {
- self.youpaipsearchBar.text = @"";
- }else{
- [self.navigationController popViewControllerAnimated:YES];
- }
-
- }
- -(NSMutableArray *)youpaipdataSource{
-
- if (_youpaipdataSource == nil) {
- _youpaipdataSource = [NSMutableArray new];
- }
- return _youpaipdataSource;
- }
- @end
|