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

高A收入记录增加校验

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