Commit 9b597a37 authored by Alex朱枝文's avatar Alex朱枝文

高A收入记录增加校验

parent cb14b04d
...@@ -14,7 +14,7 @@ class YHAddIncomeRecordCell: YHResignDocumentCell { ...@@ -14,7 +14,7 @@ class YHAddIncomeRecordCell: YHResignDocumentCell {
private lazy var addItemView: YHWorkItemAddView = { private lazy var addItemView: YHWorkItemAddView = {
let view = YHWorkItemAddView() let view = YHWorkItemAddView()
view.addBtn.setTitle("新增收入信息".local, for: .normal) view.addBtn.setTitle("新增收入/工作信息".local, for: .normal)
view.addBtn.setImage(UIImage(named: "income_item_add"), for: .normal) view.addBtn.setImage(UIImage(named: "income_item_add"), for: .normal)
view.clickBlock = { [weak self] in view.clickBlock = { [weak self] in
guard let self = self else { return } guard let self = self else { return }
...@@ -22,6 +22,14 @@ class YHAddIncomeRecordCell: YHResignDocumentCell { ...@@ -22,6 +22,14 @@ class YHAddIncomeRecordCell: YHResignDocumentCell {
} }
return view return view
}() }()
private lazy var infoFailLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textColor = .failColor
label.text = "请新增"
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
...@@ -31,12 +39,51 @@ class YHAddIncomeRecordCell: YHResignDocumentCell { ...@@ -31,12 +39,51 @@ class YHAddIncomeRecordCell: YHResignDocumentCell {
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
func setupCellInfo(_ addTitle: String, needShowFailButton: Bool) {
addItemView.addBtn.setTitle(addTitle.local, for: .normal)
updateFailLabel(needShowFailButton)
}
} }
extension YHAddIncomeRecordCell { extension YHAddIncomeRecordCell {
private func updateFailLabel(_ needShowFailButton: Bool) {
if needShowFailButton {
infoFailLabel.isHidden = false
addItemView.snp.remakeConstraints { make in
make.top.equalToSuperview().offset(16)
make.left.equalToSuperview().offset(18)
make.right.equalToSuperview().offset(-18)
make.height.equalTo(44)
}
infoFailLabel.snp.remakeConstraints { make in
make.top.equalTo(addItemView.snp.bottom).offset(6)
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
} else {
infoFailLabel.isHidden = true
addItemView.snp.remakeConstraints { make in
make.top.equalToSuperview().offset(16)
make.bottom.equalToSuperview().offset(-16)
make.left.equalToSuperview().offset(18)
make.right.equalToSuperview().offset(-18)
make.height.equalTo(44)
}
infoFailLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
}
}
private func setupUI() { private func setupUI() {
updateCellCorner(.bottom) updateCellCorner(.bottom)
subContainerView.addSubview(addItemView) subContainerView.addSubview(addItemView)
subContainerView.addSubview(infoFailLabel)
addItemView.snp.makeConstraints { make in addItemView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(16) make.top.equalToSuperview().offset(16)
make.bottom.equalToSuperview().offset(-16) make.bottom.equalToSuperview().offset(-16)
...@@ -44,5 +91,10 @@ extension YHAddIncomeRecordCell { ...@@ -44,5 +91,10 @@ extension YHAddIncomeRecordCell {
make.right.equalToSuperview().offset(-18) make.right.equalToSuperview().offset(-18)
make.height.equalTo(44) make.height.equalTo(44)
} }
infoFailLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
} }
} }
...@@ -35,6 +35,14 @@ class YHEmploymentVerificationAvailableCell: YHResignDocumentCell { ...@@ -35,6 +35,14 @@ class YHEmploymentVerificationAvailableCell: YHResignDocumentCell {
return label return label
}() }()
private lazy var infoFailLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textColor = .failColor
label.text = "请选择"
return label
}()
private lazy var rightArrowIcon: UIImageView = { private lazy var rightArrowIcon: UIImageView = {
let imageView = UIImageView(image: UIImage(named: "form_right_arrow")) let imageView = UIImageView(image: UIImage(named: "form_right_arrow"))
return imageView return imageView
...@@ -49,13 +57,42 @@ class YHEmploymentVerificationAvailableCell: YHResignDocumentCell { ...@@ -49,13 +57,42 @@ class YHEmploymentVerificationAvailableCell: YHResignDocumentCell {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
func setupCellInfo(detail: String?) { func setupCellInfo(detail: String?, needShowFailButton: Bool) {
infoDetailLabel.text = detail infoDetailLabel.text = detail
updateContentState((detail?.count ?? 0) > 0) updateContentState((detail?.count ?? 0) > 0)
updateFailLabel(needShowFailButton)
} }
} }
extension YHEmploymentVerificationAvailableCell { extension YHEmploymentVerificationAvailableCell {
private func updateFailLabel(_ needShowFailButton: Bool) {
if needShowFailButton {
infoFailLabel.isHidden = false
infoTitleLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalToSuperview().offset(16)
}
infoFailLabel.snp.remakeConstraints { make in
make.top.equalTo(infoTitleLabel.snp.bottom).offset(6)
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
} else {
infoFailLabel.isHidden = true
infoTitleLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalToSuperview().offset(16)
make.bottom.lessThanOrEqualToSuperview().offset(-16)
}
infoFailLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
}
}
private func updateContentState(_ isNotBlank: Bool) { private func updateContentState(_ isNotBlank: Bool) {
if !isNotBlank { if !isNotBlank {
infoDetailLabel.text = "请选择" infoDetailLabel.text = "请选择"
...@@ -73,6 +110,7 @@ extension YHEmploymentVerificationAvailableCell { ...@@ -73,6 +110,7 @@ extension YHEmploymentVerificationAvailableCell {
subContainerView.addSubview(infoDetailLabel) subContainerView.addSubview(infoDetailLabel)
subContainerView.addSubview(dotIcon) subContainerView.addSubview(dotIcon)
subContainerView.addSubview(rightArrowIcon) subContainerView.addSubview(rightArrowIcon)
subContainerView.addSubview(infoFailLabel)
dotIcon.setContentCompressionResistancePriority(.required, for: .horizontal) dotIcon.setContentCompressionResistancePriority(.required, for: .horizontal)
rightArrowIcon.setContentCompressionResistancePriority(.required, for: .horizontal) rightArrowIcon.setContentCompressionResistancePriority(.required, for: .horizontal)
...@@ -82,13 +120,12 @@ extension YHEmploymentVerificationAvailableCell { ...@@ -82,13 +120,12 @@ extension YHEmploymentVerificationAvailableCell {
dotIcon.snp.makeConstraints { make in dotIcon.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18) make.left.equalToSuperview().offset(18)
make.height.width.equalTo(6) make.height.width.equalTo(6)
make.centerY.equalToSuperview() make.centerY.equalTo(infoTitleLabel)
} }
infoTitleLabel.snp.makeConstraints { make in infoTitleLabel.snp.makeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2) make.left.equalTo(dotIcon.snp.right).offset(2)
make.centerY.equalToSuperview() make.top.equalToSuperview().offset(16)
make.top.greaterThanOrEqualToSuperview().offset(16)
make.bottom.lessThanOrEqualToSuperview().offset(-16) make.bottom.lessThanOrEqualToSuperview().offset(-16)
} }
...@@ -100,11 +137,19 @@ extension YHEmploymentVerificationAvailableCell { ...@@ -100,11 +137,19 @@ extension YHEmploymentVerificationAvailableCell {
infoDetailLabel.snp.makeConstraints { make in infoDetailLabel.snp.makeConstraints { make in
make.left.greaterThanOrEqualTo(infoTitleLabel.snp.right).offset(20) make.left.greaterThanOrEqualTo(infoTitleLabel.snp.right).offset(20)
make.centerY.equalToSuperview() make.centerY.equalTo(infoTitleLabel)
make.right.equalTo(rightArrowIcon.snp.left) make.right.equalTo(rightArrowIcon.snp.left)
make.top.greaterThanOrEqualToSuperview().offset(16) make.top.greaterThanOrEqualToSuperview().offset(16)
make.bottom.lessThanOrEqualToSuperview().offset(-16) make.bottom.lessThanOrEqualToSuperview().offset(-16)
} }
infoFailLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.isHidden = true
updateContentState(false) updateContentState(false)
} }
} }
...@@ -26,6 +26,19 @@ class YHGCIncomeRecordViewController: YHBaseViewController { ...@@ -26,6 +26,19 @@ class YHGCIncomeRecordViewController: YHBaseViewController {
private lazy var datas: [[TableRow]] = [] private lazy var datas: [[TableRow]] = []
private lazy var viewModel = YHGCIncomeRecordViewModel() private lazy var viewModel = YHGCIncomeRecordViewModel()
/// 校验是否提供赴港同意书
private var hasCompanyConsentOK = true
private var hasCompanyConsentIndexPath: IndexPath?
/// 校验可提供的在职公司
private var consentWorkIdOK = true
private var consentWorkIdOKIndexPath: IndexPath?
/// 校验人才中心是提供否赴港同意书
private var hasCenterConsentOK = true
private var hasCenterConsentIndexPath: IndexPath?
/// 校验是否具有工作经历
private var hasWorkListOK = true
private var hasWorkListIndexPath: IndexPath?
private lazy var saveButton: UIButton = { private lazy var saveButton: UIButton = {
let button = UIButton(type: .custom) let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15) button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
...@@ -222,7 +235,7 @@ extension YHGCIncomeRecordViewController { ...@@ -222,7 +235,7 @@ extension YHGCIncomeRecordViewController {
//let id = viewModel.mainModel.consent_work_id > 0 ? viewModel.mainModel.consent_work_id : nil //let id = viewModel.mainModel.consent_work_id > 0 ? viewModel.mainModel.consent_work_id : nil
// thirdSection.append(.employmentVerification(viewModel.listModel, id)) // thirdSection.append(.employmentVerification(viewModel.listModel, id))
thirdSection.append(.employmentVerification) thirdSection.append(.employmentVerification)
} else { } else if viewModel.mainModel.has_company_consent == 2 { //选择否时才显示
thirdSection.append(.questionSelect("人才中心是否可以提供赴港同意书")) thirdSection.append(.questionSelect("人才中心是否可以提供赴港同意书"))
} }
} }
...@@ -320,8 +333,8 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo ...@@ -320,8 +333,8 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo
} }
case let .consentForHKTravel(title, detail, question): case let .consentForHKTravel(title, detail, question):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHInfoConsentForHKTravelCell.cellReuseIdentifier) as? YHInfoConsentForHKTravelCell { if let cell = tableView.dequeueReusableCell(withIdentifier: YHInfoConsentForHKTravelCell.cellReuseIdentifier) as? YHInfoConsentForHKTravelCell {
let isOK = viewModel.mainModel.has_company_consent != 0 hasCompanyConsentIndexPath = indexPath
cell.setupCellInfo(title: title, detail: detail, question: question, needShowFailButton: !isOK) cell.setupCellInfo(title: title, detail: detail, question: question, needShowFailButton: !hasCompanyConsentOK)
cell.didSelectSureButton = { [weak self] selected in cell.didSelectSureButton = { [weak self] selected in
guard let self = self else { guard let self = self else {
return return
...@@ -329,12 +342,15 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo ...@@ -329,12 +342,15 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo
switch selected { switch selected {
case .true: case .true:
self.viewModel.mainModel.has_company_consent = YHCheckboxSelectType.true.rawValue self.viewModel.mainModel.has_company_consent = YHCheckboxSelectType.true.rawValue
self.hasCompanyConsentOK = true
break break
case .false: case .false:
self.viewModel.mainModel.has_company_consent = YHCheckboxSelectType.false.rawValue self.viewModel.mainModel.has_company_consent = YHCheckboxSelectType.false.rawValue
self.hasCompanyConsentOK = true
break break
case .unknown: case .unknown:
self.viewModel.mainModel.has_company_consent = YHCheckboxSelectType.unknown.rawValue self.viewModel.mainModel.has_company_consent = YHCheckboxSelectType.unknown.rawValue
self.hasCompanyConsentOK = false
break break
} }
self.setupData() self.setupData()
...@@ -352,6 +368,8 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo ...@@ -352,6 +368,8 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo
} }
case .addItem: case .addItem:
if let cell = tableView.dequeueReusableCell(withIdentifier: YHAddIncomeRecordCell.cellReuseIdentifier) as? YHAddIncomeRecordCell { if let cell = tableView.dequeueReusableCell(withIdentifier: YHAddIncomeRecordCell.cellReuseIdentifier) as? YHAddIncomeRecordCell {
hasWorkListIndexPath = indexPath
cell.setupCellInfo("新增收入/工作信息", needShowFailButton: !hasWorkListOK)
cell.addButtonClickEvent = { [weak self] in cell.addButtonClickEvent = { [weak self] in
guard let self = self else { guard let self = self else {
return return
...@@ -361,6 +379,7 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo ...@@ -361,6 +379,7 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo
guard let self = self else { guard let self = self else {
return return
} }
self.hasWorkListOK = true
self.requestData(isNeedLoading: true) self.requestData(isNeedLoading: true)
} }
self.navigationController?.pushViewController(ctl, animated: true) self.navigationController?.pushViewController(ctl, animated: true)
...@@ -369,8 +388,9 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo ...@@ -369,8 +388,9 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo
} }
case let .questionSelect(question): case let .questionSelect(question):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHInfoQuestionSelectionCell.cellReuseIdentifier) as? YHInfoQuestionSelectionCell { if let cell = tableView.dequeueReusableCell(withIdentifier: YHInfoQuestionSelectionCell.cellReuseIdentifier) as? YHInfoQuestionSelectionCell {
let isOK = viewModel.mainModel.has_center_consent != 0 hasCenterConsentIndexPath = indexPath
cell.setupCellInfo(question: question, needShowFailButton: !isOK)
cell.setupCellInfo(question: question, needShowFailButton: !hasCenterConsentOK)
cell.didSelectSureButton = { [weak self] selected in cell.didSelectSureButton = { [weak self] selected in
guard let self = self else { guard let self = self else {
return return
...@@ -378,10 +398,13 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo ...@@ -378,10 +398,13 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo
switch selected { switch selected {
case .true: case .true:
self.viewModel.mainModel.has_center_consent = YHCheckboxSelectType.true.rawValue self.viewModel.mainModel.has_center_consent = YHCheckboxSelectType.true.rawValue
self.hasCenterConsentOK = true
case .false: case .false:
self.viewModel.mainModel.has_center_consent = YHCheckboxSelectType.false.rawValue self.viewModel.mainModel.has_center_consent = YHCheckboxSelectType.false.rawValue
self.hasCenterConsentOK = true
case .unknown: case .unknown:
self.viewModel.mainModel.has_center_consent = YHCheckboxSelectType.unknown.rawValue self.viewModel.mainModel.has_center_consent = YHCheckboxSelectType.unknown.rawValue
self.hasCenterConsentOK = false
} }
self.setupData() self.setupData()
} }
...@@ -400,6 +423,7 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo ...@@ -400,6 +423,7 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo
case .employmentVerification://(employments, selectedId): case .employmentVerification://(employments, selectedId):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHEmploymentVerificationAvailableCell.cellReuseIdentifier) as? YHEmploymentVerificationAvailableCell { if let cell = tableView.dequeueReusableCell(withIdentifier: YHEmploymentVerificationAvailableCell.cellReuseIdentifier) as? YHEmploymentVerificationAvailableCell {
consentWorkIdOKIndexPath = indexPath
let employments = viewModel.listModel let employments = viewModel.listModel
let selectedId = viewModel.mainModel.consent_work_id > 0 ? viewModel.mainModel.consent_work_id : nil let selectedId = viewModel.mainModel.consent_work_id > 0 ? viewModel.mainModel.consent_work_id : nil
let selectedEmployment = employments.first { model in let selectedEmployment = employments.first { model in
...@@ -410,7 +434,7 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo ...@@ -410,7 +434,7 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo
// selectedEmployment = employments.first // selectedEmployment = employments.first
// viewModel.mainModel.consent_work_id = selectedEmployment?.id ?? 0 // viewModel.mainModel.consent_work_id = selectedEmployment?.id ?? 0
// } // }
cell.setupCellInfo(detail: selectedEmployment?.company_name) cell.setupCellInfo(detail: selectedEmployment?.company_name, needShowFailButton: !consentWorkIdOK)
return cell return cell
} }
case let .workingHoursStatement(placeholder, tips): case let .workingHoursStatement(placeholder, tips):
...@@ -483,6 +507,7 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo ...@@ -483,6 +507,7 @@ extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSo
} }
self.viewModel.mainModel.consent_work_id = employments[index].id ?? 0 self.viewModel.mainModel.consent_work_id = employments[index].id ?? 0
self.tableView.reloadRows(at: [indexPath], with: .automatic) self.tableView.reloadRows(at: [indexPath], with: .automatic)
self.consentWorkIdOK = true
} }
} }
} }
...@@ -503,14 +528,40 @@ extension YHGCIncomeRecordViewController { ...@@ -503,14 +528,40 @@ extension YHGCIncomeRecordViewController {
} }
private func checkInput() -> Bool { private func checkInput() -> Bool {
// if incomeModel.income_over_100 == YHIncomeOver100.unknown.rawValue { if viewModel.listModel.count == 0 {
// isOver100OK = false hasWorkListOK = false
// if let over100IndexPath = over100IndexPath, tableView.numberOfSections > over100IndexPath.section, tableView.numberOfRows(inSection: over100IndexPath.section) > over100IndexPath.row { if let hasWorkListIndexPath = hasWorkListIndexPath, tableView.numberOfSections > hasWorkListIndexPath.section, tableView.numberOfRows(inSection: hasWorkListIndexPath.section) > hasWorkListIndexPath.row {
// tableView.reloadRows(at: [over100IndexPath], with: .none) tableView.reloadRows(at: [hasWorkListIndexPath], with: .none)
// } }
// return false return false
// } }
// isOver100OK = true hasWorkListOK = true
if viewModel.mainModel.has_company_consent == YHCheckboxSelectType.unknown.rawValue {
hasCompanyConsentOK = false
if let hasCompanyConsentIndexPath = hasCompanyConsentIndexPath, tableView.numberOfSections > hasCompanyConsentIndexPath.section, tableView.numberOfRows(inSection: hasCompanyConsentIndexPath.section) > hasCompanyConsentIndexPath.row {
tableView.reloadRows(at: [hasCompanyConsentIndexPath], with: .none)
}
return false
}
hasCompanyConsentOK = true
if viewModel.mainModel.has_company_consent == YHCheckboxSelectType.true.rawValue, viewModel.mainModel.consent_work_id == 0 {
consentWorkIdOK = false
if let consentWorkIdOKIndexPath = consentWorkIdOKIndexPath, tableView.numberOfSections > consentWorkIdOKIndexPath.section, tableView.numberOfRows(inSection: consentWorkIdOKIndexPath.section) > consentWorkIdOKIndexPath.row {
tableView.reloadRows(at: [consentWorkIdOKIndexPath], with: .none)
}
return false
}
consentWorkIdOK = true
if viewModel.mainModel.has_company_consent == YHCheckboxSelectType.false.rawValue, viewModel.mainModel.has_center_consent == YHCheckboxSelectType.unknown.rawValue {
hasCenterConsentOK = false
if let hasCenterConsentIndexPath = hasCenterConsentIndexPath, tableView.numberOfSections > hasCenterConsentIndexPath.section, tableView.numberOfRows(inSection: hasCenterConsentIndexPath.section) > hasCenterConsentIndexPath.row {
tableView.reloadRows(at: [hasCenterConsentIndexPath], with: .none)
}
return false
}
hasCenterConsentOK = true
return true return true
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment