| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 |
- //
- // CustomerFilingSearchCell.m
- // IBOSS
- //
- // Created by 关宏厚 on 2020/8/28.
- // Copyright © 2020 elongtian. All rights reserved.
- //
- #import "CustomerFilingSearchCell.h"
- #import "BaseIDAndNameViewController.h"
- #import "UIColor+hexColor.h"
- #import "CustomerSearchModel.h"
- #import "SideSlipConfig.h"
- #import "BRDatePickerView.h"
- #import "BaseIDAndNameModel.h"
- #import "LogCommentVC.h"
- #import "LogShareAndCommentModel.h"
- @interface CustomerFilingSearchCell () <UITextFieldDelegate,BaseIDAndNameProtocol,CommentDelegate>
- // 抽屉model
- @property (strong,nonatomic) SideSlipModel *regionModel;
- // 日期对象
- @property (strong,nonatomic) BRDatePickerView *dealDatePicker;
- // 临时开始日期
- @property (copy, nonatomic) NSString *tempStartDate;
- // 临时结束日期
- @property (copy, nonatomic) NSString *tempEndDate;
- @end
- @implementation CustomerFilingSearchCell
- /**
- 高度
-
- @return return value description
- */
- - (CGFloat)cellHeight {
- return 920.0f;
- }
- /**
- cell
-
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- CustomerFilingSearchCell *cell = [[NSBundle mainBundle]
- loadNibNamed:@"CustomerFilingSearchCell"
- owner:nil
- options:nil][0];
- cell.txtCustomerName.delegate = cell;
- cell.txtTel.delegate = cell;
- cell.txtCustomerAddress.delegate = cell;
- cell.boolFlagValue = YES;
- cell.filedIntermediateCustomers.delegate = cell;
- [cell configureKeyboard];
- return cell;
- }
- /**
- awakeFromNib
- */
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- /**
- Identifier
-
- @return <#return value description#>
- */
- + (NSString *)cellReuseIdentifier {
-
- return @"CustomerFilingSearchCell";
- }
- /**
- 有效无效标识
-
- @return <#return value description#>
- */
- - (NSMutableArray *)valueFlagArr{
- if (_valueFlagArr == nil) {
- _valueFlagArr = [[NSMutableArray alloc]init];
- BaseIDAndNameModel *m = [BaseIDAndNameModel new];
- m.id = @"0";
- m.name = @"有效";
- [_valueFlagArr addObject:m];
- m = [BaseIDAndNameModel new];
- m.id = @"1";
- m.name = @"无效";
- [_valueFlagArr addObject:m];
- }
- return _valueFlagArr;
- }
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
- _txtTel.inputAccessoryView = keyBoardAccessoryView;
- _txtCustomerAddress.inputAccessoryView = keyBoardAccessoryView;
- _filedIntermediateCustomers.inputAccessoryView = keyBoardAccessoryView;
- }
- /**
- 更新model
-
- @param model <#model description#>
- @param indexPath <#indexPath description#>
- */
- - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
- indexPath:(NSIndexPath *)indexPath{
- self.regionModel = *model;
- _isExistsSceneAttachment=NO;
- _isExistsDrawingAttachment=NO;
-
- _btnDrawingAttachment.layer.borderWidth=1;
- [ _btnDrawingAttachment setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
- _btnDrawingAttachment.layer.borderColor = [UIColor lightGrayColor].CGColor;
-
- _btnSceneAttachment.layer.borderWidth=1;
- [ _btnSceneAttachment setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
- _btnSceneAttachment.layer.borderColor = [UIColor lightGrayColor].CGColor;
-
-
- [self updateModel];
- }
- /**
- 更新frame
-
- @param w <#w description#>
- */
- - (void)updateFrame:(CGFloat)w{
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
-
- [_txtCustomerName setText:@""];
- [_txtTel setText:@""];
- [_txtCustomerAddress setText:@""];
- [_btnFlagValue setTitle:@"请选择有效标识(默认有效)" forState:UIControlStateNormal];
- _boolFlagValue = YES;
- [_btnStaDate setTitle:@"请选择开始日期" forState:UIControlStateNormal];
- _sStartDate = @"";
- [_btnEndDate setTitle:@"请选择结束日期" forState:UIControlStateNormal];
- _sEndDate = @"";
- [_filedIntermediateCustomers setText:@""];
- _createUserID = @"";
- [_btnCreateUserName setTitle:@"请选择创建人" forState:UIControlStateNormal];
- _isExistsDrawingAttachment=NO;
- _isExistsSceneAttachment=NO;
- [_btnSceneAttachment setTitle:@"全部" forState:UIControlStateNormal];
- [_btnDrawingAttachment setTitle:@"全部" forState:UIControlStateNormal];
-
- }
- /**
- 文本编辑时候 弹出取消完成按钮
-
- @return <#return value description#>
- */
- - (UIView *)createKeyBoardAccessoryView {
- UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
- [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
- UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
- [backButton setTitle:@"取消" forState:UIControlStateNormal];
- [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
- [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
- [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
- UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
- [doneButton setTitle:@"完成" forState:UIControlStateNormal];
- [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
- [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
- [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
- [keyBoardAccessoryView addSubview:backButton];
- [keyBoardAccessoryView addSubview:doneButton];
- return keyBoardAccessoryView;
- }
- /**
- 长度
-
- @param textField <#textField description#>
- @param range <#range description#>
- @param string <#string description#>
- @return <#return value description#>
- */
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
-
- return YES;
- }
- /**
- 文本编辑结束事件
-
- @param textField <#textField description#>
- */
- - (void)textFieldDidEndEditing:(UITextField *)textField {
- [self updateModel];
- }
- - (IBAction)clickSceneAttachmentAction:(id)sender
- {
-
- if(_isExistsSceneAttachment){
- _isExistsSceneAttachment=NO;
- [_btnSceneAttachment setTitle:@"全部" forState:UIControlStateNormal];
- _btnSceneAttachment.layer.borderWidth=1;
- [ _btnSceneAttachment setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
- _btnSceneAttachment.layer.borderColor = [UIColor lightGrayColor].CGColor;
- }
- else{
- _isExistsSceneAttachment=YES;
- _btnSceneAttachment.layer.borderWidth=1;
- [_btnSceneAttachment setTitle:@"存在" forState:UIControlStateNormal];
- [ _btnSceneAttachment setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- _btnSceneAttachment.layer.borderColor = [UIColor redColor].CGColor;
- }
- [self updateModel];
-
- }
- - (IBAction)clickDrawingAttachmentAction:(id)sender {
-
- if(_isExistsDrawingAttachment){
- _isExistsDrawingAttachment=NO;
- [_btnDrawingAttachment setTitle:@"全部" forState:UIControlStateNormal];
- _btnDrawingAttachment.layer.borderWidth=1;
- [ _btnDrawingAttachment setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
- _btnDrawingAttachment.layer.borderColor = [UIColor lightGrayColor].CGColor;
- }
- else
- {
- _isExistsDrawingAttachment=YES;
- _btnDrawingAttachment.layer.borderWidth=1;
- [_btnDrawingAttachment setTitle:@"存在" forState:UIControlStateNormal];
- [ _btnDrawingAttachment setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- _btnDrawingAttachment.layer.borderColor = [UIColor redColor].CGColor;
-
- }
- [self updateModel];
- }
- /**
- 触摸事件
-
- @param touches <#touches description#>
- @param event <#event description#>
- */
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self hideKey];
- [_txtCustomerName resignFirstResponder];
- [_txtCustomerAddress resignFirstResponder];
- [_filedIntermediateCustomers resignFirstResponder];
- [_txtTel resignFirstResponder];
- }
- /**
- 有效标识
-
- @param model <#model description#>
- @param value <#value description#>
- */
- - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)model
- BaseIDAndName:(baseIdAndName)value{
-
- if ([model.id isEqualToString:@"0"]) {
- self.boolFlagValue = YES;
- }
- if ([model.id isEqualToString:@"1"]) {
- self.boolFlagValue = NO;
- }
- [self.btnFlagValue setTitle:model.name forState:UIControlStateNormal];
- [self updateModel];
- }
- /**
- 取消文本
- */
- - (void)accessoryButtonBack {
- NSLog(@"accessoryButtonBack");
- [self hideKey];}
- /**
- 确定文本
- */
- - (void)accessoryButtonDone {
- NSLog(@"accessoryButtonDone");
- [_txtCustomerName resignFirstResponder];
- [self hideKey];
- }
- /**
- * 隐藏键盘
- */
- - (void)hideKey
- {
- [self.contentView endEditing:YES];
- }
- /**
- 显示创建人列表
-
- @param sender <#sender description#>
- */
- - (IBAction)showCreateUserList:(id)sender {
- LogCommentVC *tc = [[LogCommentVC alloc] init];
- tc.commentDelegate = self;
- tc.ispresentView = YES;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
- }
- /**
- 创建人回调
-
- @param model <#model description#>
- */
- - (void)reCommentData:(LogShareAndCommentInfoModel*)model
- {
- self.createUserID = model.userId;
- [_btnCreateUserName setTitle:model.userName forState:UIControlStateNormal];
- [self updateModel];
- }
- /**
- 开始日期
-
- @param sender
- */
- - (IBAction)showStaDate:(id)sender {
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- _tempStartDate=date;
- } andCompletionBlock:^(void){
- weakself.sStartDate = _tempStartDate;
- [weakself.btnStaDate setTitle:weakself.sStartDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
-
- }
- /**
- 结束日期
-
- @param sender <#sender description#>
- */
- - (IBAction)showEndDate:(id)sender {
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- self->_tempEndDate=date;
- } andCompletionBlock:^(void){
- weakself.sEndDate = self->_tempEndDate;
- [weakself.btnEndDate setTitle:weakself.sEndDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
- }
- /**
- 有效标识
-
- @param sender <#sender description#>
- */
- - (IBAction)showValueFlag:(id)sender {
- BaseIDAndNameViewController *tc = [[BaseIDAndNameViewController alloc ]init];
- tc.bDelegate = self;
- tc.isPresentViewFlg = YES;
- tc.arrFilter = self.valueFlagArr;
- tc.arrSearch = self.valueFlagArr;
- tc.showDialogViewTag = baseIdAndNameValueFlag;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
- }
- /**
- 更新model
- */
- - (void)updateModel{
- CustomerSearchModel *model = [[CustomerSearchModel alloc] init];
- model.customerName = [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.customerTelephone = [_txtTel.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.customerAddress = [_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.IntermediateCustomers = [_filedIntermediateCustomers.text stringByReplacingOccurrencesOfString:@" " withString:@""];;
- model.createUserID = _createUserID;
- model.valueFlag = _boolFlagValue;
- model.customerStaDate = _sStartDate;
- model.customerEndDate = _sEndDate;
- model.isSceneAttachment=_isExistsSceneAttachment;
- model.isDrawingAttachment=_isExistsDrawingAttachment;
-
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:model forKey:CUSTOMER_SEARCH_RANGE_MODEL];
- _regionModel.customDict = [mutDict copy];
- }
- @end
|