| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- //
- // SalesSlipSearchCell.m
- // IBOSSmini
- //
- // Created by ssl on 2018/1/26.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "SalesSlipSearchCell.h"
- #import "UIColor+hexColor.h"
- #import "SideSlipConfig.h"
- @interface SalesSlipSearchCell () <UITextFieldDelegate>
- @end
- @implementation SalesSlipSearchCell
- - (IBAction)showEndDate:(id)sender {
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- _tempEndDate=date;
- } andCompletionBlock:^(void){
- weakself.endDate = _tempEndDate;
- [weakself.endDateBtn setTitle:weakself.endDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
-
- }
- - (IBAction)showStartDate:(id)sender {
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- _tempStartDate=date;
- } andCompletionBlock:^(void){
- weakself.startDate = _tempStartDate;
- [weakself.startDateBtn setTitle:weakself.startDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
- }
- /**
- 高度
-
- @return return value description
- */
- - (CGFloat)cellHeight {
- return 668.5;
- }
- /**
- cell
-
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- SalesSlipSearchCell *cell = [[NSBundle mainBundle]
- loadNibNamed:@"SalesSlipSearchCell"
- owner:nil
- options:nil][0];
- cell.sureBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.sureBtn.layer.borderWidth=1;
- cell.sureBtn.tag=0;
- cell.sureBtn.layer.cornerRadius=4;
-
- [ cell.sureBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- [cell.sureBtn addTarget:cell action:@selector(sureStatus) forControlEvents:UIControlEventTouchUpInside];
-
- cell.orderNoTxt.delegate = cell;
- cell.completeBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.completeBtn.layer.borderWidth=1;
- cell.completeBtn.layer.cornerRadius=4;
- [ cell.completeBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- cell.completeBtn.tag=0;
- [ cell.completeBtn addTarget:cell action:@selector(completeStatus)
- forControlEvents:UIControlEventTouchUpInside];
- cell.inCompleteBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.inCompleteBtn.layer.borderWidth=1;
- cell.inCompleteBtn.layer.cornerRadius=4;
- cell.inCompleteBtn.titleLabel.textColor=NavBarUnEnbleItemColor;
- cell.inCompleteBtn.tag=0;
- [ cell.inCompleteBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- [ cell.inCompleteBtn addTarget:cell action:@selector(incompleteStatus)
- forControlEvents:UIControlEventTouchUpInside];
-
-
- cell.correctBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.correctBtn.layer.borderWidth=1;
- cell.correctBtn.layer.cornerRadius=4;
- cell.correctBtn.tag=0;
- [cell.correctBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- [cell.correctBtn addTarget:cell action:@selector(correctStatus)
- forControlEvents:UIControlEventTouchUpInside];
-
- cell.draftBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.draftBtn.layer.borderWidth=1;
- cell.draftBtn.layer.cornerRadius=4;
- cell.draftBtn.titleLabel.textColor=NavBarUnEnbleItemColor;
- cell.draftBtn.tag=0;
- [ cell.draftBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- [ cell.draftBtn addTarget:cell action:@selector(draftStatus)
- forControlEvents:UIControlEventTouchUpInside];
-
- cell.finshSaleBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.finshSaleBtn.hidden = YES;
- cell.finshSaleBtn.layer.borderWidth=1;
- cell.finshSaleBtn.layer.cornerRadius=4;
- cell.finshSaleBtn.titleLabel.textColor=NavBarUnEnbleItemColor;
- cell.finshSaleBtn.tag=0;
- [ cell.finshSaleBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- [ cell.finshSaleBtn addTarget:cell action:@selector(finshSaleStatus)
- forControlEvents:UIControlEventTouchUpInside];
- cell.orderNoTxt.delegate = cell;
- cell.customerNameTxt.delegate=cell;
- cell.productCodeTxt.delegate=cell;
- cell.customerCodeTxt.delegate=cell;
- cell.customerAddressTxt.delegate=cell;
- [cell configureKeyboard];
- return cell;
- }
- /**
- 区分规格
- */
- - (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];
- }
- -(void)sureStatus{
- [self distinguish:_sureBtn];
- }
- -(void)completeStatus{
- [self distinguish:_completeBtn];
- }
- -(void)incompleteStatus{
- [self distinguish:_inCompleteBtn];
-
-
- }
- -(void)draftStatus{
- [self distinguish:_draftBtn];
- }
- -(void)finshSaleStatus{
- [self distinguish:_finshSaleBtn];
-
- }
- -(void)correctStatus{
- [self distinguish:_correctBtn];
- }
- /**
- 更新model
- */
- - (void)updateModel{
- SalesSlipSearchModel *model = [[SalesSlipSearchModel alloc] init];
- NSString *orderNoStr=[_orderNoTxt.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.SalesNo =orderNoStr;
- NSString *customerNameStr=@"";
- customerNameStr= [_customerNameTxt.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.customerName =customerNameStr;
- NSString *startDateStr=@"";
- startDateStr=_startDateBtn.currentTitle;;
- model.startDate =startDateStr ;
- NSString *endDateStr=@"";
- endDateStr=_endDateBtn.currentTitle;
- model.endDate=endDateStr;
- NSString *goodsCodeStr=@"";
- goodsCodeStr= _productCodeTxt.text;
- model.goodsCode=goodsCodeStr;
- NSString *customerCodeStr=@"";
- customerCodeStr=_customerCodeTxt.text;
- model.customerCode=customerCodeStr;
- NSString *customerAddressStr=@"";
- customerAddressStr=_customerAddressTxt.text;
- model.customerAddress=customerAddressStr;
- _invoiceStatus=@"";
- if(_sureBtn.tag==1 ){
- _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"4,"];
- }
-
- if(_completeBtn.tag==1){
- _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"7,"];
-
- }
-
- if(_draftBtn.tag==1){
- _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"11,"];
-
- }
-
- if(_finshSaleBtn.tag==1){
- _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"6,"];
-
- }
-
- if(_inCompleteBtn.tag==1){
- _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"5,"];
- }
- if(_correctBtn.tag==1){
- _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"10,"];
- }
- if(_invoiceStatus.length>0){
- _invoiceStatus= [NSString stringWithFormat:@"%@%@",@",",_invoiceStatus];
- }
- model.invoiceStatus=_invoiceStatus;
-
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:model forKey:ORDER_SEARCH_RANGE_MODEL];
- _regionModel.customDict = [mutDict copy];
- }
- /**
- Identifier
-
- @return <#return value description#>
- */
- + (NSString *)cellReuseIdentifier {
- return @"OrderListSearchCell";
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
-
- [_orderNoTxt setText:@""];
- [_customerNameTxt setText:@""];
- [_startDateBtn setTitle:@"请选择开始账务日期" forState:UIControlStateNormal];
- _startDate = @"";
- [_endDateBtn setTitle:@"请选择结束账务日期" forState:UIControlStateNormal];
- _endDate = @"";
- [_productCodeTxt setText:@""];
- [_customerCodeTxt setText:@""];
- [_customerAddressTxt setText:@""];
- _sureBtn.tag=0;
- _completeBtn.tag=0;
- _inCompleteBtn.tag=0;
- _correctBtn.tag=0;
- _invoiceStatus=@"";
- }
- /**
- 长度
-
- @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];
- }
- /**
- * 隐藏键盘
- */
- -(void)hideKey
- {
- [self.contentView endEditing:YES];
- }
- /**
- 取消文本
- */
- - (void)accessoryButtonBack {
- NSLog(@"accessoryButtonBack");
- [self hideKey];}
- /**
- 确定文本
- */
- - (void)accessoryButtonDone {
- NSLog(@"accessoryButtonDone");
- [_orderNoTxt resignFirstResponder];
- [_customerNameTxt resignFirstResponder];
- [_productCodeTxt resignFirstResponder];
- [_customerCodeTxt resignFirstResponder];
- [_customerAddressTxt resignFirstResponder];
- [self hideKey];
- }
- /**
- 触摸事件
-
- @param touches <#touches description#>
- @param event <#event description#>
- */
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self hideKey];
- [_orderNoTxt resignFirstResponder];
- [_customerNameTxt resignFirstResponder];
- [_productCodeTxt resignFirstResponder];
- [_customerCodeTxt resignFirstResponder];
- [_customerAddressTxt resignFirstResponder];
- }
- /**
- 更新model
-
- @param model <#model description#>
- @param indexPath <#indexPath description#>
- */
- - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
- indexPath:(NSIndexPath *)indexPath{
- self.regionModel = *model;
- }
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _orderNoTxt.inputAccessoryView = keyBoardAccessoryView;
- _customerNameTxt.inputAccessoryView = keyBoardAccessoryView;
- _productCodeTxt.inputAccessoryView = keyBoardAccessoryView;
- _customerCodeTxt.inputAccessoryView = keyBoardAccessoryView;
- _customerAddressTxt.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)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
-
- }
- @end
|