| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- // ReceiptSearchCell
- // IOBSS 2.0
- //
- // Created by 刘瀚璘 on 2017.7.17
- // Copyright 2017 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 系统名称:
- // 功能描述:搜索Cell
- #import "SideSlipBaseTableViewCell.h"
- #import "RepairReceiptSearchCell.h"
- #import "UIColor+hexColor.h"
- #import "SideSlipConfig.h"
- #import "ReceiptSearchModel.h"
- #import "BRDatePickerView.h"
- #import "StatusInfo.h"
- #import "StatusInfoTextVC.h"
- @interface RepairReceiptSearchCell() <UITextFieldDelegate,StatusInfoTextDelegate>{
-
- /**
- 开始时间
- */
- NSString *_strStartDate;
-
- /**
- 结束时间
- */
- NSString *_strEndDate;
-
- /**
- 回执类型
- */
- NSString *_strReceiptType;
-
- /**
- 时间控件
- */
- BRDatePickerView *_brdatePicker;
- }
- /**
- 抽屉对象model
- */
- @property (strong,nonatomic) SideSlipModel *regionModel;
- @end
- @implementation RepairReceiptSearchCell
- /**
- cell
-
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- RepairReceiptSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"RepairReceiptSearchCell" owner:nil options:nil][0];
- cell.receiptOrderNo.delegate = cell;
- cell.txtCustomerName.delegate=cell;
- cell.txtCustomerAddress.delegate=cell;
- cell.txtCustomerTelephone.delegate=cell;
- [cell configureKeyboard];
- return cell;
- }
- /**
- 初始化Cell
-
- @param model <#model description#>
- @param indexPath <#indexPath description#>
- */
- - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
- self.regionModel = *model;
- _strEndDate = @"";
- _strStartDate = @"";
- _strReceiptType = @"";
- [self updateModel];
- }
- /**
- awakeFromNib
- */
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- /**
- 显示开始时间
-
- @param sender <#sender description#>
- */
- - (IBAction)showStartDate:(id)sender {
- _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_brdatePicker configureSelectionBlock:^(NSString *date){
- _strStartDate = date;
- } andCompletionBlock:^(void){
- [_btnStartDate setTitle:_strStartDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
- if([_btnStartDate.titleLabel.text isEqualToString:@"请选择回执开始日期"]){
- _strStartDate = @"";
- }else{
- _strStartDate = _btnStartDate.titleLabel.text;
- }
- [self updateModel];
-
- }];
- [_brdatePicker show];
- }
- /**
- 显示结束时间
-
- @param sender <#sender description#>
- */
- - (IBAction)showEndDate:(id)sender {
- _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_brdatePicker configureSelectionBlock:^(NSString *date){
- _strEndDate = date;
- } andCompletionBlock:^(void){
- [_btnEndDate setTitle:_strEndDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
- if([_btnEndDate.titleLabel.text isEqualToString:@"请选择回执结束日期"]){
- _strEndDate = @"";
- }else{
- _strEndDate = _btnEndDate.titleLabel.text;
- }
- [self updateModel];
- }];
- [_brdatePicker show];
- }
- /**
- 弹出回执状态
-
- @param sender <#sender description#>
- */
- - (IBAction)showReceiptType:(id)sender {
- StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
- tc.sdelegate = self;
- tc.isPresentViewFlag = YES;
- [tc.arrFilter addObjectsFromArray: [self getMutableArray]];
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
- }
- /**
- 状态回调函数
-
- @param s <#s description#>
- */
- - (void)showStatusValue:(StatusInfo*)s{
- [_btnReceiptType setTitle:s.name forState:UIControlStateNormal];
- _strReceiptType = s.statusId;
- [self updateModel];
- }
- /**
- 初始化回执类型
- */
- - (NSMutableArray *)getMutableArray{
- NSMutableArray *arrayStatus = [[NSMutableArray alloc]init];
- StatusInfo *s = [[StatusInfo alloc]init];
- s.statusId = @"0";
- s.name = @"再次安排";
- [arrayStatus addObject:s];
- s = [[StatusInfo alloc]init];
- s.statusId = @"1";
- s.name = @"完成";
- [arrayStatus addObject:s];
- s = [[StatusInfo alloc]init];
- s.statusId = @"2";
- s.name = @"全部";
- [arrayStatus addObject:s];
- return arrayStatus;
- }
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _receiptOrderNo.inputAccessoryView = keyBoardAccessoryView;
- _txtCustomerName.inputAccessoryView=keyBoardAccessoryView;
- _txtCustomerAddress.inputAccessoryView=keyBoardAccessoryView;
- _txtCustomerTelephone.inputAccessoryView=keyBoardAccessoryView;
- }
- /**
- 文本编辑时候 弹出取消完成按钮
-
- @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;
- }
- /**
- 取消文本
- */
- - (void)accessoryButtonBack {
- [self hideKey];
- }
- /**
- 确定文本
- */
- - (void)accessoryButtonDone {
- [self hideKey];
- }
- /**
- * 隐藏键盘
- */
- - (void)hideKey{
- [_receiptOrderNo resignFirstResponder];
- [_txtCustomerName resignFirstResponder ];
- [_txtCustomerAddress resignFirstResponder];
- [_txtCustomerTelephone resignFirstResponder];
- [self.contentView endEditing:YES];
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
- [_receiptOrderNo setText:@""];
- [_txtCustomerName setText:@""];
- [_txtCustomerAddress setText:@""];
- [_txtCustomerTelephone setText:@""];
- }
- /**
- 更新model
- */
- - (void)updateModel{
- ReceiptSearchModel *model = [[ReceiptSearchModel alloc] init];
- model.strReceiptOrderNo = [_receiptOrderNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.customerName=[_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.customerAddress=[_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.customerTelephone=[_txtCustomerTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.strStartDate = _strStartDate;
- model.strEndDate = _strEndDate;
- model.strReceiptType = _strReceiptType;
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:model forKey:RECEIPT_SEARCH_MODEL];
- _regionModel.customDict = [mutDict copy];
- }
- /**
- Identifier
-
- @return
- */
- + (NSString *)cellReuseIdentifier {
- return @"RepairReceiptSearchCell";
- }
- /**
- 高度
-
- @return return value description
- */
- - (CGFloat)cellHeight {
- return 624;
- }
- /**
- 文本编辑结束事件
-
- @param textField <#textField description#>
- */
- - (void)textFieldDidEndEditing:(UITextField *)textField {
- [self updateModel];
- }
- /**
- 触摸事件
-
- @param touches <#touches description#>
- @param event <#event description#>
- */
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self hideKey];
- }
- @end
|