| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- //
- // OrderAuditSearchCell.m
- // IBOSS
- //
- // Created by 关宏厚 on 2018/11/12.
- // Copyright © 2018 elongtian. All rights reserved.
- //
- #import "OrderAuditSearchCell.h"
- @implementation OrderAuditSearchCell
- #pragma mark - 公共函数
- - (void)awakeFromNib {
- [super awakeFromNib];
-
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- #pragma mark - 委托函数
- /**
- 高度
- @return return value description
- */
- - (CGFloat)cellHeight {
- return 754.5f;
- }
- /**
- cell
-
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- OrderAuditSearchCell *cell = [[NSBundle mainBundle]
- loadNibNamed:@"OrderAuditSearchCell"
- owner:nil
- options:nil][0];
-
- cell.txtOrderNo.delegate = cell;
- cell.txtCustomerCode.delegate = cell;
- cell.txtCustomerName.delegate = cell;
- cell.txtTelephone.delegate = cell;
- cell.txtAddress.delegate = cell;
-
- cell.btnGiveUpAudit.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.btnGiveUpAudit.layer.borderWidth=1;
- cell.btnGiveUpAudit.tag=1;
- cell.btnGiveUpAudit.layer.cornerRadius=4;
- cell.btnGiveUpAudit.layer.borderColor = [[UIColor redColor] CGColor];
- [cell.btnGiveUpAudit setTitleColor: [UIColor redColor] forState:UIControlStateNormal];
- cell.btnAudit.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.btnAudit.layer.borderWidth=1;
- cell.btnAudit.tag=0;
- cell.btnAudit.layer.cornerRadius=4;
- [ cell.btnAudit setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
-
-
- cell.btnSure.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.btnSure.layer.borderWidth=1;
- cell.btnSure.tag=0;
- cell.btnSure.layer.cornerRadius=4;
- cell.btnSure.layer.borderColor = [[UIColor redColor] CGColor];
- [cell.btnSure setTitleColor: [UIColor redColor] forState:UIControlStateNormal];
-
- cell.btnInComplete.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.btnInComplete.layer.borderWidth=1;
- cell.btnInComplete.tag=0;
- cell.btnInComplete.layer.cornerRadius=4;
- [ cell.btnInComplete setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
-
- cell.btnComplete.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.btnComplete.layer.borderWidth=1;
- cell.btnComplete.tag=0;
- cell.btnComplete.layer.cornerRadius=4;
- [ cell.btnComplete setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- [cell configureKeyboard];
- return cell;
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
- [_txtOrderNo setText:@""];
- [_txtCustomerCode setText:@""];
- [_txtCustomerName setText:@""];
- [_txtTelephone setText:@""];
- [_txtAddress setText:@""];
-
- [_btnStartDate setTitle:@"请选择账务开始日期" forState:UIControlStateNormal];
-
- [_btnEndDate setTitle:@"请选择账务结束日期" forState:UIControlStateNormal];
- _startDate=@"";
- _endDate=@"";
- _btnGiveUpAudit.tag=0;
- _btnAudit.tag=0;
- _auditStatus=@"0";
- _invoiceStatus=[NSMutableString stringWithFormat:@"%d",4];
- _btnSure.tag=0;
- _btnInComplete.tag=0;
- _btnComplete.tag=0;
-
- }
- /**
- 触摸事件
-
- @param touches <#touches description#>
- @param event <#event description#>
- */
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self hideKey];
- [_txtOrderNo resignFirstResponder];
- [_txtCustomerCode resignFirstResponder];
- [_txtCustomerName resignFirstResponder];
- [_txtTelephone resignFirstResponder];
- [_txtAddress resignFirstResponder];
-
- }
- /**
- 长度
-
- @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];
- }
- /**
- 更新model
-
- @param model <#model description#>
- @param indexPath <#indexPath description#>
- */
- - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
- indexPath:(NSIndexPath *)indexPath{
- self.regionModel = *model;
- }
- /**
- Identifier
-
- @return <#return value description#>
- */
- + (NSString *)cellReuseIdentifier {
-
- return @"OrderAuditSearchCell";
- }
- #pragma mark - 私有函数
- - (IBAction)clickSureAction:(id)sender {
- [self distinguish:_btnSure];
-
- }
- - (IBAction)clickInCompleteAction:(id)sender {
- [self distinguish:_btnInComplete];
- }
- - (IBAction)clickCompleteAction:(id)sender {
- [self distinguish:_btnComplete];
- }
- - (IBAction)clickStartDateAction:(id)sender {
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- self->_tempStartDate=date;
- } andCompletionBlock:^(void){
- weakself.startDate = self->_tempStartDate;
- [weakself.btnStartDate setTitle:weakself.startDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
- }
- - (IBAction)clickEndDateAction:(id)sender {
-
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- self->_tempEndDate=date;
- } andCompletionBlock:^(void){
- weakself.endDate = self->_tempEndDate;
- [weakself.btnEndDate setTitle:weakself.endDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
-
- }
- - (IBAction)clickAuditAction:(id)sender {
- [self distinguish:_btnAudit];
- }
- - (IBAction)clickGiveUpAuditAction:(id)sender {
- [self distinguish:_btnGiveUpAudit];
- }
- /**
- 更新model
- */
- - (void)updateModel{
- OrderAuditSearchModel *model = [[OrderAuditSearchModel alloc] init];
- model.orderNo = [_txtOrderNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.customerCode = [_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
-
- model.customerName = [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.telephone = [_txtTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""];
-
- model.address= [_txtAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
-
- model.startDate = _startDate;
- model.endDate = _endDate;
-
- _auditStatus=@"";
- if((_btnAudit.tag==0&&_btnGiveUpAudit.tag==0)||(_btnAudit.tag==1&&_btnGiveUpAudit.tag==1)){
- _auditStatus=@"2";
- }
- else{
- if(_btnGiveUpAudit.tag==1 ){
- _auditStatus= [NSString stringWithFormat:@"%@%@",_auditStatus,@"0,"];
- }
-
- if(_btnAudit.tag==1){
- _auditStatus= [NSString stringWithFormat:@"%@%@",_auditStatus,@"1,"];
- }
-
- if(_auditStatus.length>0){
-
- _auditStatus= [_auditStatus substringToIndex:_auditStatus.length-1];
- }
-
- }
-
- model.auditFlag=_auditStatus;
-
- _invoiceStatus=[[NSMutableString alloc] init];
- if(_btnSure.tag==1 ){
- [_invoiceStatus appendString:@"4,"];
- }
-
- if(_btnInComplete.tag==1){
-
- [_invoiceStatus appendString:@"5,"];
- }
-
- if(_btnComplete.tag==1){
- [_invoiceStatus appendString:@"7,"];
- }
-
- if(_invoiceStatus.length>0){
- [_invoiceStatus deleteCharactersInRange:NSMakeRange(_invoiceStatus.length-1, 1)];
- }
- model.invoiceStatusId=_invoiceStatus;
-
-
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:model forKey:ORDER_AUDIT_SEARCH_RANGE_MODEL];
- _regionModel.customDict = [mutDict copy];
- }
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _txtOrderNo.inputAccessoryView=keyBoardAccessoryView;
- _txtCustomerCode.inputAccessoryView=keyBoardAccessoryView;
- _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
- _txtTelephone.inputAccessoryView = keyBoardAccessoryView;
- _txtAddress.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 {
- [_txtOrderNo resignFirstResponder];
- [_txtCustomerCode resignFirstResponder];
- [_txtCustomerName resignFirstResponder];
- [_txtTelephone resignFirstResponder];
- [_txtAddress resignFirstResponder];
- [self hideKey];
- }
- /**
- * 隐藏键盘
- */
- - (void)hideKey
- {
- [self.contentView endEditing:YES];
- }
- /**
- 按钮状态切换
- */
- - (void)distinguish:(UIButton *) btn{
- switch (btn.tag) {
- case 0:
- btn.tag = 1;
- btn.layer.borderColor = [[UIColor redColor] CGColor];
- [btn setTitleColor: [UIColor redColor] forState:UIControlStateNormal];
- break;
- case 1:
- btn.tag = 0;
- btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
- [btn setTitleColor: NavBarUnEnbleItemColor forState:UIControlStateNormal];
- break;
- default:
- break;
-
- }
- [self updateModel];
- }
- @end
|