SPSBTransferImformationView.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. //
  2. // SPSBTransferImformationView.m
  3. // 我的社保
  4. //
  5. // Created by shanp on 2021/6/4.
  6. //
  7. #import "SPSBTransferImformationView.h"
  8. #import "SPSBUIGeneralHeader.h"
  9. #import "SPSBTextField.h"
  10. #import "SPSBVerificationProfile.h"
  11. #import "SPSBTitleAndContentTableViewCell.h"
  12. @interface SPSBTransferImformationView ()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate> {
  13. SPSBTextField *_nameTextField;
  14. SPSBTextField *_remarksTextField;
  15. }
  16. @end
  17. @implementation SPSBTransferImformationView
  18. - (instancetype)init {
  19. self = [super initWithFrame:CGRectZero style:UITableViewStylePlain];
  20. if (!self) return nil;
  21. [self setupTableView];
  22. return self;
  23. }
  24. #pragma mark - Action
  25. - (NSString *)spsb_name {
  26. NSString *name = _nameTextField.text;
  27. if (!name) {
  28. name = @"";
  29. }
  30. return name;
  31. }
  32. - (NSString *)spsb_remark {
  33. NSString *remark = _remarksTextField.text;
  34. if (!remark) {
  35. remark = @"";
  36. }
  37. return remark;
  38. }
  39. #pragma mark - UITextFieldDelegate
  40. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  41. jxh_endEdit();
  42. return true;
  43. }
  44. #pragma mark - Delegate & DataSource
  45. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  46. NSArray *titleArray = @[@"转移项目", @"办理人", @"转出城市", @"", @"转入城市", @"", @"说明"];
  47. if (indexPath.section < 3 && indexPath.row == 0) {
  48. SPSBTitleAndContentTableViewCell *cell = [SPSBTitleAndContentTableViewCell createSelectCellWithTitle:titleArray[indexPath.section * 2 + indexPath.row] content:_spsb_data[indexPath.section * 2 + indexPath.row]];
  49. if ([_spsb_data[indexPath.section * 2 + indexPath.row] isEqualToString:@"请选择"]) {
  50. cell.spsb_contentLabel.textColor = spsb_CCCCCC_color();
  51. } else {
  52. cell.spsb_contentLabel.textColor = spsb_666666_color();
  53. }
  54. return cell;
  55. } else {
  56. SPSBTitleAndContentTableViewCell *cell = [SPSBTitleAndContentTableViewCell createSingleDisplayTitleCellWithTitle:titleArray[indexPath.section * 2 + indexPath.row]];
  57. cell.userInteractionEnabled = true;
  58. if (indexPath.section == 0) {
  59. [cell.contentView addSubview:_nameTextField];
  60. [_nameTextField makeConstraints:^(JXHConstraintMaker *make) {
  61. make.trailing.equalTo(-15);
  62. make.centerY.equalTo(0);
  63. make.leading.equalTo(100);
  64. }];
  65. } else {
  66. [cell.contentView addSubview:_remarksTextField];
  67. [_remarksTextField makeConstraints:^(JXHConstraintMaker *make) {
  68. make.trailing.equalTo(-15);
  69. make.centerY.equalTo(0);
  70. make.leading.equalTo(100);
  71. }];
  72. [cell.spsb_bottomLine makeConstraints:^(JXHConstraintMaker *make) {
  73. make.leading.update(0);
  74. }];
  75. }
  76. return cell;
  77. }
  78. return [[UITableViewCell alloc] init];
  79. }
  80. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  81. return _spsb_sectionNumberArray.count;
  82. }
  83. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  84. return [_spsb_sectionNumberArray[section] floatValue];
  85. }
  86. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  87. [tableView deselectRowAtIndexPath:indexPath animated:false];
  88. if (_spsb_selectRow) {
  89. _spsb_selectRow(indexPath);
  90. }
  91. }
  92. #pragma mark - UI
  93. - (void)setupTableView {
  94. self.rowHeight = 50;
  95. self.delaysContentTouches = false;
  96. self.backgroundColor = spsb_F5F5F5_color();
  97. self.separatorStyle = UITableViewCellSeparatorStyleNone;
  98. self.showsHorizontalScrollIndicator = false;
  99. self.showsVerticalScrollIndicator = false;
  100. self.delegate = self;
  101. self.dataSource = self;
  102. self.scrollEnabled = false;
  103. self.tableFooterView = [[UIView alloc] initWithFrame:(CGRect){0, 0, jxh_screenWidth(), 10}];
  104. _nameTextField = [self creatTextFieldWithPlaceholder:@"请输入办理人姓名" maxCount:SPSBMaxNameLength];
  105. _remarksTextField = [self creatTextFieldWithPlaceholder:@"请输入说明信息" maxCount:50];
  106. }
  107. - (SPSBTextField *)creatTextFieldWithPlaceholder:(NSString *)placeholder maxCount:(NSInteger)maxCount {
  108. SPSBTextField *textField = [SPSBTextField convenienceWithFont:spsb_font(15) placeholder:placeholder placeholderColor:spsb_CCCCCC_color() textColor:spsb_666666_color() clearButtonMode:UITextFieldViewModeWhileEditing returnType:UIReturnKeyDone delegate:self];
  109. textField.textAlignment = NSTextAlignmentRight;
  110. textField.spsb_maxCount = maxCount;
  111. return textField;
  112. }
  113. - (BOOL)touchesShouldCancelInContentView:(UIView *)view {
  114. [super touchesShouldCancelInContentView:view];
  115. return true;
  116. }
  117. @end