CustomerFilingSearchCell.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. //
  2. // CustomerFilingSearchCell.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/8/28.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "CustomerFilingSearchCell.h"
  9. #import "BaseIDAndNameViewController.h"
  10. #import "UIColor+hexColor.h"
  11. #import "CustomerSearchModel.h"
  12. #import "SideSlipConfig.h"
  13. #import "BRDatePickerView.h"
  14. #import "BaseIDAndNameModel.h"
  15. #import "LogCommentVC.h"
  16. #import "LogShareAndCommentModel.h"
  17. @interface CustomerFilingSearchCell () <UITextFieldDelegate,BaseIDAndNameProtocol,CommentDelegate>
  18. // 抽屉model
  19. @property (strong,nonatomic) SideSlipModel *regionModel;
  20. // 日期对象
  21. @property (strong,nonatomic) BRDatePickerView *dealDatePicker;
  22. // 临时开始日期
  23. @property (copy, nonatomic) NSString *tempStartDate;
  24. // 临时结束日期
  25. @property (copy, nonatomic) NSString *tempEndDate;
  26. @end
  27. @implementation CustomerFilingSearchCell
  28. /**
  29. 高度
  30. @return return value description
  31. */
  32. - (CGFloat)cellHeight {
  33. return 920.0f;
  34. }
  35. /**
  36. cell
  37. @param indexPath <#indexPath description#>
  38. @return <#return value description#>
  39. */
  40. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  41. CustomerFilingSearchCell *cell = [[NSBundle mainBundle]
  42. loadNibNamed:@"CustomerFilingSearchCell"
  43. owner:nil
  44. options:nil][0];
  45. cell.txtCustomerName.delegate = cell;
  46. cell.txtTel.delegate = cell;
  47. cell.txtCustomerAddress.delegate = cell;
  48. cell.boolFlagValue = YES;
  49. cell.filedIntermediateCustomers.delegate = cell;
  50. [cell configureKeyboard];
  51. return cell;
  52. }
  53. /**
  54. awakeFromNib
  55. */
  56. - (void)awakeFromNib {
  57. [super awakeFromNib];
  58. }
  59. /**
  60. Identifier
  61. @return <#return value description#>
  62. */
  63. + (NSString *)cellReuseIdentifier {
  64. return @"CustomerFilingSearchCell";
  65. }
  66. /**
  67. 有效无效标识
  68. @return <#return value description#>
  69. */
  70. - (NSMutableArray *)valueFlagArr{
  71. if (_valueFlagArr == nil) {
  72. _valueFlagArr = [[NSMutableArray alloc]init];
  73. BaseIDAndNameModel *m = [BaseIDAndNameModel new];
  74. m.id = @"0";
  75. m.name = @"有效";
  76. [_valueFlagArr addObject:m];
  77. m = [BaseIDAndNameModel new];
  78. m.id = @"1";
  79. m.name = @"无效";
  80. [_valueFlagArr addObject:m];
  81. }
  82. return _valueFlagArr;
  83. }
  84. /**
  85. 键盘配置
  86. */
  87. - (void)configureKeyboard {
  88. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  89. _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
  90. _txtTel.inputAccessoryView = keyBoardAccessoryView;
  91. _txtCustomerAddress.inputAccessoryView = keyBoardAccessoryView;
  92. _filedIntermediateCustomers.inputAccessoryView = keyBoardAccessoryView;
  93. }
  94. /**
  95. 更新model
  96. @param model <#model description#>
  97. @param indexPath <#indexPath description#>
  98. */
  99. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  100. indexPath:(NSIndexPath *)indexPath{
  101. self.regionModel = *model;
  102. _isExistsSceneAttachment=NO;
  103. _isExistsDrawingAttachment=NO;
  104. _btnDrawingAttachment.layer.borderWidth=1;
  105. [ _btnDrawingAttachment setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
  106. _btnDrawingAttachment.layer.borderColor = [UIColor lightGrayColor].CGColor;
  107. _btnSceneAttachment.layer.borderWidth=1;
  108. [ _btnSceneAttachment setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
  109. _btnSceneAttachment.layer.borderColor = [UIColor lightGrayColor].CGColor;
  110. [self updateModel];
  111. }
  112. /**
  113. 更新frame
  114. @param w <#w description#>
  115. */
  116. - (void)updateFrame:(CGFloat)w{
  117. }
  118. /**
  119. 重置按钮 事件
  120. */
  121. - (void)resetData {
  122. [_txtCustomerName setText:@""];
  123. [_txtTel setText:@""];
  124. [_txtCustomerAddress setText:@""];
  125. [_btnFlagValue setTitle:@"请选择有效标识(默认有效)" forState:UIControlStateNormal];
  126. _boolFlagValue = YES;
  127. [_btnStaDate setTitle:@"请选择开始日期" forState:UIControlStateNormal];
  128. _sStartDate = @"";
  129. [_btnEndDate setTitle:@"请选择结束日期" forState:UIControlStateNormal];
  130. _sEndDate = @"";
  131. [_filedIntermediateCustomers setText:@""];
  132. _createUserID = @"";
  133. [_btnCreateUserName setTitle:@"请选择创建人" forState:UIControlStateNormal];
  134. _isExistsDrawingAttachment=NO;
  135. _isExistsSceneAttachment=NO;
  136. [_btnSceneAttachment setTitle:@"全部" forState:UIControlStateNormal];
  137. [_btnDrawingAttachment setTitle:@"全部" forState:UIControlStateNormal];
  138. }
  139. /**
  140. 文本编辑时候 弹出取消完成按钮
  141. @return <#return value description#>
  142. */
  143. - (UIView *)createKeyBoardAccessoryView {
  144. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  145. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  146. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  147. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  148. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  149. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  150. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  151. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  152. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  153. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  154. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  155. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  156. [keyBoardAccessoryView addSubview:backButton];
  157. [keyBoardAccessoryView addSubview:doneButton];
  158. return keyBoardAccessoryView;
  159. }
  160. /**
  161. 长度
  162. @param textField <#textField description#>
  163. @param range <#range description#>
  164. @param string <#string description#>
  165. @return <#return value description#>
  166. */
  167. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  168. return YES;
  169. }
  170. /**
  171. 文本编辑结束事件
  172. @param textField <#textField description#>
  173. */
  174. - (void)textFieldDidEndEditing:(UITextField *)textField {
  175. [self updateModel];
  176. }
  177. - (IBAction)clickSceneAttachmentAction:(id)sender
  178. {
  179. if(_isExistsSceneAttachment){
  180. _isExistsSceneAttachment=NO;
  181. [_btnSceneAttachment setTitle:@"全部" forState:UIControlStateNormal];
  182. _btnSceneAttachment.layer.borderWidth=1;
  183. [ _btnSceneAttachment setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
  184. _btnSceneAttachment.layer.borderColor = [UIColor lightGrayColor].CGColor;
  185. }
  186. else{
  187. _isExistsSceneAttachment=YES;
  188. _btnSceneAttachment.layer.borderWidth=1;
  189. [_btnSceneAttachment setTitle:@"存在" forState:UIControlStateNormal];
  190. [ _btnSceneAttachment setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  191. _btnSceneAttachment.layer.borderColor = [UIColor redColor].CGColor;
  192. }
  193. [self updateModel];
  194. }
  195. - (IBAction)clickDrawingAttachmentAction:(id)sender {
  196. if(_isExistsDrawingAttachment){
  197. _isExistsDrawingAttachment=NO;
  198. [_btnDrawingAttachment setTitle:@"全部" forState:UIControlStateNormal];
  199. _btnDrawingAttachment.layer.borderWidth=1;
  200. [ _btnDrawingAttachment setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
  201. _btnDrawingAttachment.layer.borderColor = [UIColor lightGrayColor].CGColor;
  202. }
  203. else
  204. {
  205. _isExistsDrawingAttachment=YES;
  206. _btnDrawingAttachment.layer.borderWidth=1;
  207. [_btnDrawingAttachment setTitle:@"存在" forState:UIControlStateNormal];
  208. [ _btnDrawingAttachment setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  209. _btnDrawingAttachment.layer.borderColor = [UIColor redColor].CGColor;
  210. }
  211. [self updateModel];
  212. }
  213. /**
  214. 触摸事件
  215. @param touches <#touches description#>
  216. @param event <#event description#>
  217. */
  218. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  219. [self hideKey];
  220. [_txtCustomerName resignFirstResponder];
  221. [_txtCustomerAddress resignFirstResponder];
  222. [_filedIntermediateCustomers resignFirstResponder];
  223. [_txtTel resignFirstResponder];
  224. }
  225. /**
  226. 有效标识
  227. @param model <#model description#>
  228. @param value <#value description#>
  229. */
  230. - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)model
  231. BaseIDAndName:(baseIdAndName)value{
  232. if ([model.id isEqualToString:@"0"]) {
  233. self.boolFlagValue = YES;
  234. }
  235. if ([model.id isEqualToString:@"1"]) {
  236. self.boolFlagValue = NO;
  237. }
  238. [self.btnFlagValue setTitle:model.name forState:UIControlStateNormal];
  239. [self updateModel];
  240. }
  241. /**
  242. 取消文本
  243. */
  244. - (void)accessoryButtonBack {
  245. NSLog(@"accessoryButtonBack");
  246. [self hideKey];}
  247. /**
  248. 确定文本
  249. */
  250. - (void)accessoryButtonDone {
  251. NSLog(@"accessoryButtonDone");
  252. [_txtCustomerName resignFirstResponder];
  253. [self hideKey];
  254. }
  255. /**
  256. * 隐藏键盘
  257. */
  258. - (void)hideKey
  259. {
  260. [self.contentView endEditing:YES];
  261. }
  262. /**
  263. 显示创建人列表
  264. @param sender <#sender description#>
  265. */
  266. - (IBAction)showCreateUserList:(id)sender {
  267. LogCommentVC *tc = [[LogCommentVC alloc] init];
  268. tc.commentDelegate = self;
  269. tc.ispresentView = YES;
  270. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  271. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  272. }
  273. }
  274. /**
  275. 创建人回调
  276. @param model <#model description#>
  277. */
  278. - (void)reCommentData:(LogShareAndCommentInfoModel*)model
  279. {
  280. self.createUserID = model.userId;
  281. [_btnCreateUserName setTitle:model.userName forState:UIControlStateNormal];
  282. [self updateModel];
  283. }
  284. /**
  285. 开始日期
  286. @param sender
  287. */
  288. - (IBAction)showStaDate:(id)sender {
  289. __weak typeof(self) weakself=self;
  290. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  291. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  292. _tempStartDate=date;
  293. } andCompletionBlock:^(void){
  294. weakself.sStartDate = _tempStartDate;
  295. [weakself.btnStaDate setTitle:weakself.sStartDate forState:UIControlStateNormal];
  296. [self updateModel];
  297. } andCancelBlock:^(void){
  298. }];
  299. [_dealDatePicker show];
  300. }
  301. /**
  302. 结束日期
  303. @param sender <#sender description#>
  304. */
  305. - (IBAction)showEndDate:(id)sender {
  306. __weak typeof(self) weakself=self;
  307. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  308. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  309. self->_tempEndDate=date;
  310. } andCompletionBlock:^(void){
  311. weakself.sEndDate = self->_tempEndDate;
  312. [weakself.btnEndDate setTitle:weakself.sEndDate forState:UIControlStateNormal];
  313. [self updateModel];
  314. } andCancelBlock:^(void){
  315. }];
  316. [_dealDatePicker show];
  317. }
  318. /**
  319. 有效标识
  320. @param sender <#sender description#>
  321. */
  322. - (IBAction)showValueFlag:(id)sender {
  323. BaseIDAndNameViewController *tc = [[BaseIDAndNameViewController alloc ]init];
  324. tc.bDelegate = self;
  325. tc.isPresentViewFlg = YES;
  326. tc.arrFilter = self.valueFlagArr;
  327. tc.arrSearch = self.valueFlagArr;
  328. tc.showDialogViewTag = baseIdAndNameValueFlag;
  329. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  330. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  331. }
  332. }
  333. /**
  334. 更新model
  335. */
  336. - (void)updateModel{
  337. CustomerSearchModel *model = [[CustomerSearchModel alloc] init];
  338. model.customerName = [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  339. model.customerTelephone = [_txtTel.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  340. model.customerAddress = [_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  341. model.IntermediateCustomers = [_filedIntermediateCustomers.text stringByReplacingOccurrencesOfString:@" " withString:@""];;
  342. model.createUserID = _createUserID;
  343. model.valueFlag = _boolFlagValue;
  344. model.customerStaDate = _sStartDate;
  345. model.customerEndDate = _sEndDate;
  346. model.isSceneAttachment=_isExistsSceneAttachment;
  347. model.isDrawingAttachment=_isExistsDrawingAttachment;
  348. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  349. [mutDict setValue:model forKey:CUSTOMER_SEARCH_RANGE_MODEL];
  350. _regionModel.customDict = [mutDict copy];
  351. }
  352. @end