ExpenseSearchCell.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. //
  2. // ExpenseSearchCell.m
  3. // IBOSS
  4. //
  5. // Created by apple on 2017/7/10.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:费用明细表查询条件单元格
  9. //
  10. #import "ExpenseSearchCell.h"
  11. #import "UIColor+hexColor.h"
  12. #import "ExpenseSearchModel.h"
  13. #import "SideSlipConfig.h"
  14. #import "CustomerAchievementTextVC.h"
  15. @interface ExpenseSearchCell()<CustomerReportTextProtocol>
  16. /**
  17. 抽屉model
  18. */
  19. @property (strong,nonatomic) SideSlipModel *regionModel;
  20. @end
  21. @implementation ExpenseSearchCell
  22. /**
  23. 高度
  24. @return <#return value description#>
  25. */
  26. - (CGFloat)cellHeight {
  27. return 724.0f;
  28. }
  29. /**
  30. cell
  31. @param indexPath <#indexPath description#>
  32. @return <#return value description#>
  33. */
  34. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  35. ExpenseSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"ExpenseSearchCell" owner:nil options:nil][0];
  36. cell.txtCustomerName.delegate = cell;
  37. cell.txtCustomerCode.delegate=cell;
  38. [cell configureKeyboard];
  39. return cell;
  40. }
  41. /**
  42. 键盘配置
  43. */
  44. - (void)configureKeyboard {
  45. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  46. _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
  47. _txtCustomerCode.inputAccessoryView=keyBoardAccessoryView;
  48. }
  49. /**
  50. awakeFromNib
  51. */
  52. - (void)awakeFromNib {
  53. [super awakeFromNib];
  54. }
  55. /**
  56. Identifier
  57. @return <#return value description#>
  58. */
  59. + (NSString *)cellReuseIdentifier {
  60. return @"ExpenseSearchCell";
  61. }
  62. /**
  63. 更新model
  64. 关宏厚2017-7-6
  65. @param model <#model description#>
  66. @param indexPath <#indexPath description#>
  67. */
  68. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  69. self.regionModel = *model;
  70. //为账务开始结束时间、创建开始结束时间赋默认值(2019-05-22)
  71. NSString *startDateStr= [DateFormat getDateBefore:31];
  72. NSString *endDataStr = [DateFormat getCurrentDate];
  73. [_btnAccountDateFrom setTitle:startDateStr forState:UIControlStateNormal];
  74. _accountDateFrom = _btnAccountDateFrom.titleLabel.text;
  75. [_btnAccountDateTo setTitle:endDataStr forState:UIControlStateNormal];
  76. _accountDateTo = _btnAccountDateTo.titleLabel.text;
  77. //创建时间
  78. // [_btnCreateDateFrom setTitle:startDateStr forState:UIControlStateNormal];
  79. // _createDateFrom = _btnCreateDateFrom.titleLabel.text;
  80. // [_btnCreateDateTo setTitle:endDataStr forState:UIControlStateNormal];
  81. // _createDateTo = _btnCreateDateTo.titleLabel.text;
  82. [self updateModel];
  83. }
  84. /**
  85. 更新frame
  86. @param w <#w description#>
  87. */
  88. - (void)updateFrame:(CGFloat)w{
  89. }
  90. /**
  91. 重置按钮 事件
  92. */
  93. - (void)resetData {
  94. NSString *startDateStr= [DateFormat getDateBefore:31];
  95. NSString *endDataStr = [DateFormat getCurrentDate];
  96. [_btnOrg setTitle:@"请选择业务部门" forState:UIControlStateNormal];
  97. _sOrg = @"";
  98. [_btnStaff setTitle:@"请选择业务员" forState:UIControlStateNormal];
  99. _sStaff = @"";
  100. [_btnAccountDateFrom setTitle:startDateStr forState:UIControlStateNormal];
  101. _accountDateFrom = _btnAccountDateFrom.titleLabel.text;
  102. [_btnAccountDateTo setTitle:endDataStr forState:UIControlStateNormal];
  103. _accountDateTo = _btnAccountDateTo.titleLabel.text;
  104. _txtCustomerCode.text=@"";
  105. _txtCustomerName.text=@"";
  106. //创建日期
  107. // [_btnCreateDateFrom setTitle:startDateStr forState:UIControlStateNormal];
  108. // _createDateFrom = _btnCreateDateFrom.titleLabel.text;
  109. // [_btnCreateDateTo setTitle:endDataStr forState:UIControlStateNormal];
  110. // _createDateTo = _btnCreateDateTo.titleLabel.text;
  111. }
  112. /**
  113. 文本编辑时候 弹出取消完成按钮
  114. @return <#return value description#>
  115. */
  116. - (UIView *)createKeyBoardAccessoryView {
  117. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  118. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  119. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  120. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  121. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  122. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  123. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  124. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  125. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  126. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  127. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  128. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  129. [keyBoardAccessoryView addSubview:backButton];
  130. [keyBoardAccessoryView addSubview:doneButton];
  131. return keyBoardAccessoryView;
  132. }
  133. /**
  134. 取消文本
  135. */
  136. - (void)accessoryButtonBack {
  137. [self hideKey];
  138. }
  139. /**
  140. 确定文本
  141. */
  142. - (void)accessoryButtonDone {
  143. [self hideKey];
  144. }
  145. /**
  146. 业务员 业务部门
  147. @param Amodel <#Amodel description#>
  148. @param cr <#cr description#>
  149. */
  150. - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
  151. //返回值
  152. if(cr == ReportAchiementDepartmt){
  153. _sOrg=Amodel.organizationCode;
  154. [self.btnOrg setTitle:Amodel.organizationName forState:UIControlStateNormal];
  155. }
  156. // 业务员
  157. if(cr == ReportAchiementmn){
  158. _sStaff = Amodel.staffName;
  159. [self.btnStaff setTitle:Amodel.staffName forState:UIControlStateNormal];
  160. }
  161. [self updateModel];
  162. }
  163. /**
  164. 组织机构
  165. @param sender <#sender description#>
  166. */
  167. - (IBAction)showOrg:(id)sender {
  168. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  169. tc.cDelegate = self;
  170. tc.flag = YES;
  171. tc.isPresentViewFlag = YES;
  172. tc.showDialogViewTag=ReportAchiementDepartmt;
  173. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  174. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  175. }
  176. }
  177. /**
  178. 业务员
  179. @param sender <#sender description#>
  180. */
  181. - (IBAction)showStaff:(id)sender {
  182. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  183. tc.cDelegate = self;
  184. tc.isPresentViewFlag = YES;
  185. tc.showDialogViewTag=ReportAchiementmn;
  186. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  187. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  188. }
  189. }
  190. /**
  191. 账务开始时间
  192. @param sender <#sender description#>
  193. */
  194. - (IBAction)showAcountDateFrom:(id)sender {
  195. __weak typeof(self) wSelf = self;
  196. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  197. [_brDatePicker configureSelectionBlock:^(NSString *date){
  198. wSelf.accountDateFrom=date;
  199. } andCompletionBlock:^(void){
  200. [sender setTitle:wSelf.accountDateFrom forState:UIControlStateNormal];
  201. [self updateModel];
  202. } andCancelBlock:^(void){
  203. }];
  204. [_brDatePicker show];
  205. }
  206. /**
  207. 账务结束时间
  208. @param sender <#sender description#>
  209. */
  210. - (IBAction)showAccountDateTo:(id)sender {
  211. __weak typeof(self) wSelf = self;
  212. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  213. [_brDatePicker configureSelectionBlock:^(NSString *date){
  214. wSelf.accountDateTo=date;
  215. } andCompletionBlock:^(void){
  216. [sender setTitle:wSelf.accountDateTo forState:UIControlStateNormal];
  217. [self updateModel];
  218. } andCancelBlock:^(void){
  219. }];
  220. [_brDatePicker show];
  221. }
  222. /**
  223. 创建开始时间
  224. @param sender
  225. */
  226. - (IBAction)createDateFrom:(id)sender {
  227. __weak typeof(self) wSelf = self;
  228. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  229. [_brDatePicker configureSelectionBlock:^(NSString *date){
  230. wSelf.createDateFrom=date;
  231. } andCompletionBlock:^(void){
  232. [sender setTitle:wSelf.createDateFrom forState:UIControlStateNormal];
  233. [self updateModel];
  234. } andCancelBlock:^(void){
  235. }];
  236. [_brDatePicker show];
  237. }
  238. /**
  239. 创建结束时间
  240. @param sender
  241. */
  242. - (IBAction)createDateTo:(id)sender {
  243. __weak typeof(self) wSelf = self;
  244. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  245. [_brDatePicker configureSelectionBlock:^(NSString *date){
  246. wSelf.createDateTo=date;
  247. } andCompletionBlock:^(void){
  248. [sender setTitle:wSelf.createDateTo forState:UIControlStateNormal];
  249. [self updateModel];
  250. } andCancelBlock:^(void){
  251. }];
  252. [_brDatePicker show];
  253. }
  254. /**
  255. 触摸事件
  256. @param touches <#touches description#>
  257. @param event <#event description#>
  258. */
  259. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  260. [self hideKey];
  261. [_txtCustomerCode resignFirstResponder];
  262. [_txtCustomerName resignFirstResponder];
  263. }
  264. /**
  265. 长度
  266. @param textField <#textField description#>
  267. @param range <#range description#>
  268. @param string <#string description#>
  269. @return <#return value description#>
  270. */
  271. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  272. return YES;
  273. }
  274. /* 隐藏键盘
  275. */
  276. - (void)hideKey
  277. {
  278. [self.contentView endEditing:YES];
  279. }
  280. /**
  281. 文本编辑结束事件
  282. @param textField <#textField description#>
  283. */
  284. - (void)textFieldDidEndEditing:(UITextField *)textField {
  285. [self updateModel];
  286. }
  287. /**
  288. 更新model
  289. */
  290. - (void)updateModel{
  291. ExpenseSearchModel *model = [[ExpenseSearchModel alloc] init];
  292. model.sOrgCode = _sOrg;
  293. model.sStaffName = _sStaff;
  294. model.accountDateFrom = _accountDateFrom;
  295. model.accountDateTo = _accountDateTo;
  296. model.customerCode = [_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  297. model.customerName= [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  298. //创建时间
  299. // model.createDateFrom = _createDateFrom;
  300. // model.createDateTo = _createDateTo;
  301. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  302. [mutDict setValue:model forKey:EXPENSE_SEARCH_RANGE_MODEL];
  303. _regionModel.customDict = [mutDict copy];
  304. }
  305. @end