// // SaleInputTopView.m // RealEstateManagement // // Created by Javen on 2016/10/13. // Copyright © 2016年 上海勾芒信息科技. All rights reserved. // #import "SaleInputTopView.h" @interface SaleInputTopView () @property (strong, nonatomic) UIDatePicker *datePicker; @end @implementation SaleInputTopView - (void)awakeFromNib { [super awakeFromNib]; // if (kUser.isTenant) { // self.btnStore.userInteractionEnabled = NO; // self.right1.hidden = YES; // } self.datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, kWidth, 216)]; self.datePicker.maximumDate = [NSDate date]; self.textFieldDate.inputView = self.datePicker; self.textFieldDate.delegate = self; self.datePicker.datePickerMode = UIDatePickerModeDate; self.textFieldDate.text = [self.datePicker.date yearMonthDayString]; } - (void)textFieldDidEndEditing:(UITextField *)textField { self.textFieldDate.text = [self.datePicker.date yearMonthDayString]; self.blockDidChooseDate(); } - (IBAction)actionContract:(id)sender { if (AppGlobal.user.contracts.count == 1) { UserInfo_contracts *contract = AppGlobal.user.contracts[0]; self.contract = [HMSaleInputDetail_contract modelWithDic:contract.toDictionary]; [self.btnStore setTitle:contract.name forState:UIControlStateNormal]; }else{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"选择合同" message:nil preferredStyle:(UIAlertControllerStyleAlert)]; for (UserInfo_contracts *contract in AppGlobal.user.contracts) { UIAlertAction *action = [UIAlertAction actionWithTitle:contract.name style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { self.contract = [HMSaleInputDetail_contract modelWithDic:contract.toDictionary]; [self.btnStore setTitle:contract.name forState:UIControlStateNormal]; }]; [alert addAction:action]; } UIAlertAction *action = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]; [alert addAction:action]; [self.viewController.navigationController presentViewController:alert animated:YES completion:nil]; } } @end