| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- //
- // ExpenseSearchCell.m
- // IBOSS
- //
- // Created by apple on 2017/7/10.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:费用明细表查询条件单元格
- //
- #import "ExpenseSearchCell.h"
- #import "UIColor+hexColor.h"
- #import "ExpenseSearchModel.h"
- #import "SideSlipConfig.h"
- #import "CustomerAchievementTextVC.h"
- @interface ExpenseSearchCell()<CustomerReportTextProtocol>
- /**
- 抽屉model
- */
- @property (strong,nonatomic) SideSlipModel *regionModel;
- @end
- @implementation ExpenseSearchCell
- /**
- 高度
-
- @return <#return value description#>
- */
- - (CGFloat)cellHeight {
- return 724.0f;
- }
- /**
- cell
-
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- ExpenseSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"ExpenseSearchCell" owner:nil options:nil][0];
- cell.txtCustomerName.delegate = cell;
- cell.txtCustomerCode.delegate=cell;
- [cell configureKeyboard];
- return cell;
- }
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
- _txtCustomerCode.inputAccessoryView=keyBoardAccessoryView;
- }
- /**
- awakeFromNib
- */
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- /**
- Identifier
-
- @return <#return value description#>
- */
- + (NSString *)cellReuseIdentifier {
-
- return @"ExpenseSearchCell";
- }
- /**
- 更新model
- 关宏厚2017-7-6
- @param model <#model description#>
- @param indexPath <#indexPath description#>
- */
- - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
- self.regionModel = *model;
- //为账务开始结束时间、创建开始结束时间赋默认值(2019-05-22)
- NSString *startDateStr= [DateFormat getDateBefore:31];
- NSString *endDataStr = [DateFormat getCurrentDate];
- [_btnAccountDateFrom setTitle:startDateStr forState:UIControlStateNormal];
- _accountDateFrom = _btnAccountDateFrom.titleLabel.text;
- [_btnAccountDateTo setTitle:endDataStr forState:UIControlStateNormal];
- _accountDateTo = _btnAccountDateTo.titleLabel.text;
- //创建时间
- // [_btnCreateDateFrom setTitle:startDateStr forState:UIControlStateNormal];
- // _createDateFrom = _btnCreateDateFrom.titleLabel.text;
- // [_btnCreateDateTo setTitle:endDataStr forState:UIControlStateNormal];
- // _createDateTo = _btnCreateDateTo.titleLabel.text;
- [self updateModel];
- }
- /**
- 更新frame
-
- @param w <#w description#>
- */
- - (void)updateFrame:(CGFloat)w{
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
- NSString *startDateStr= [DateFormat getDateBefore:31];
- NSString *endDataStr = [DateFormat getCurrentDate];
- [_btnOrg setTitle:@"请选择业务部门" forState:UIControlStateNormal];
- _sOrg = @"";
- [_btnStaff setTitle:@"请选择业务员" forState:UIControlStateNormal];
- _sStaff = @"";
- [_btnAccountDateFrom setTitle:startDateStr forState:UIControlStateNormal];
- _accountDateFrom = _btnAccountDateFrom.titleLabel.text;
- [_btnAccountDateTo setTitle:endDataStr forState:UIControlStateNormal];
- _accountDateTo = _btnAccountDateTo.titleLabel.text;
- _txtCustomerCode.text=@"";
- _txtCustomerName.text=@"";
- //创建日期
- // [_btnCreateDateFrom setTitle:startDateStr forState:UIControlStateNormal];
- // _createDateFrom = _btnCreateDateFrom.titleLabel.text;
- // [_btnCreateDateTo setTitle:endDataStr forState:UIControlStateNormal];
- // _createDateTo = _btnCreateDateTo.titleLabel.text;
- }
- /**
- 文本编辑时候 弹出取消完成按钮
-
- @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];
-
- }
- /**
- 业务员 业务部门
-
- @param Amodel <#Amodel description#>
- @param cr <#cr description#>
- */
- - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
- //返回值
- if(cr == ReportAchiementDepartmt){
- _sOrg=Amodel.organizationCode;
- [self.btnOrg setTitle:Amodel.organizationName forState:UIControlStateNormal];
- }
- // 业务员
- if(cr == ReportAchiementmn){
- _sStaff = Amodel.staffName;
- [self.btnStaff setTitle:Amodel.staffName forState:UIControlStateNormal];
- }
- [self updateModel];
- }
- /**
- 组织机构
-
- @param sender <#sender description#>
- */
- - (IBAction)showOrg:(id)sender {
- CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
- tc.cDelegate = self;
- tc.flag = YES;
- tc.isPresentViewFlag = YES;
- tc.showDialogViewTag=ReportAchiementDepartmt;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
-
- }
- /**
- 业务员
-
- @param sender <#sender description#>
- */
- - (IBAction)showStaff:(id)sender {
- CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
- tc.cDelegate = self;
- tc.isPresentViewFlag = YES;
- tc.showDialogViewTag=ReportAchiementmn;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
-
- }
- /**
- 账务开始时间
- @param sender <#sender description#>
- */
- - (IBAction)showAcountDateFrom:(id)sender {
- __weak typeof(self) wSelf = self;
- _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_brDatePicker configureSelectionBlock:^(NSString *date){
- wSelf.accountDateFrom=date;
-
- } andCompletionBlock:^(void){
- [sender setTitle:wSelf.accountDateFrom forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_brDatePicker show];
- }
- /**
- 账务结束时间
- @param sender <#sender description#>
- */
- - (IBAction)showAccountDateTo:(id)sender {
- __weak typeof(self) wSelf = self;
- _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_brDatePicker configureSelectionBlock:^(NSString *date){
- wSelf.accountDateTo=date;
-
- } andCompletionBlock:^(void){
- [sender setTitle:wSelf.accountDateTo forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_brDatePicker show];
- }
- /**
- 创建开始时间
- @param sender
- */
- - (IBAction)createDateFrom:(id)sender {
- __weak typeof(self) wSelf = self;
- _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_brDatePicker configureSelectionBlock:^(NSString *date){
- wSelf.createDateFrom=date;
-
- } andCompletionBlock:^(void){
- [sender setTitle:wSelf.createDateFrom forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_brDatePicker show];
- }
- /**
- 创建结束时间
- @param sender
- */
- - (IBAction)createDateTo:(id)sender {
- __weak typeof(self) wSelf = self;
- _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_brDatePicker configureSelectionBlock:^(NSString *date){
- wSelf.createDateTo=date;
-
- } andCompletionBlock:^(void){
- [sender setTitle:wSelf.createDateTo forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_brDatePicker show];
- }
- /**
- 触摸事件
-
- @param touches <#touches description#>
- @param event <#event description#>
- */
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self hideKey];
- [_txtCustomerCode resignFirstResponder];
- [_txtCustomerName 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;
- }
- /* 隐藏键盘
- */
- - (void)hideKey
- {
- [self.contentView endEditing:YES];
- }
- /**
- 文本编辑结束事件
-
- @param textField <#textField description#>
- */
- - (void)textFieldDidEndEditing:(UITextField *)textField {
- [self updateModel];
- }
- /**
- 更新model
- */
- - (void)updateModel{
- ExpenseSearchModel *model = [[ExpenseSearchModel alloc] init];
- model.sOrgCode = _sOrg;
- model.sStaffName = _sStaff;
- model.accountDateFrom = _accountDateFrom;
- model.accountDateTo = _accountDateTo;
- model.customerCode = [_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.customerName= [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- //创建时间
- // model.createDateFrom = _createDateFrom;
- // model.createDateTo = _createDateTo;
-
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:model forKey:EXPENSE_SEARCH_RANGE_MODEL];
- _regionModel.customDict = [mutDict copy];
- }
- @end
|