Commit 0fee4195 authored by Steven杜宇's avatar Steven杜宇

// 配偶信息

parent 827ec4a0
......@@ -26,7 +26,8 @@ class YHSpouseBasicInfoVC: YHBaseViewController, YHFamilyMemberProtol {
var spouse:YHFamilyMember?
weak var delegate:YHSpouseInfoVCProtocol?
// 是否显示未填写错误提示
var isNeedShowError = false
var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
lazy var tableView: UITableView = {
......@@ -87,6 +88,7 @@ class YHSpouseBasicInfoVC: YHBaseViewController, YHFamilyMemberProtol {
let item00 = YHFormDetailItem(type: .spouseName)
item00.placeHolder = "请输入".local
item00.value = spouse.subsetName
item00.tips = "请输入配偶姓名".local
let item01 = YHFormDetailItem(type: .everName, isNeed: false)
item01.placeHolder = "选填".local
......@@ -99,7 +101,8 @@ class YHSpouseBasicInfoVC: YHBaseViewController, YHFamilyMemberProtol {
let item03 = YHFormDetailItem(type: .birthday)
item03.placeHolder = "请选择".local
item03.value = spouse.birthday
item03.tips = "请选择出生日期".local
let item04 = YHFormDetailItem(type: .birthNation)
item04.value = String(spouse.isBirthOverSeas())
......@@ -107,9 +110,13 @@ class YHSpouseBasicInfoVC: YHBaseViewController, YHFamilyMemberProtol {
if spouse.isBirthOverSeas() {
item05.value = spouse.birthPlace?.foreign
item05.placeHolder = "请输入".local
item05.tips = "请输入出生城市".local
} else {
item05.value = spouse.birthPlace?.area?.joined(separator: ",")
item05.placeHolder = "请选择".local
item05.tips = "请选择出生城市".local
}
let arr0:[YHFormItemProtocol] = [title0, item00, item01, item02, item03, item04, item05]
......@@ -117,13 +124,16 @@ class YHSpouseBasicInfoVC: YHBaseViewController, YHFamilyMemberProtol {
let title1 = YHFormTitleItem(type: .occupationInfo)
let item10 = YHFormDetailItem(type: .occupation)
item10.value = spouse.occupation
item10.placeHolder = "请输入".local
item10.placeHolder = "请选择".local
item10.tips = "请选择职业".local
var arr1:[YHFormItemProtocol] = [title1, item10]
if spouse.isNowHaveJob() {
let item11 = YHFormDetailItem(type: .occupationName)
item11.value = spouse.occupationName
item11.placeHolder = "请输入".local
item11.tips = "请输入职业名称".local
arr1.append(item11)
}
......@@ -132,6 +142,8 @@ class YHSpouseBasicInfoVC: YHBaseViewController, YHFamilyMemberProtol {
let item20 = YHFormDetailItem(type: .ownDegree)
item20.placeHolder = "请选择".local
item20.value = spouse.haveDegreeName()
item20.tips = "请选择".local
var arr2:[YHFormItemProtocol] = [title2, item20]
if spouse.isHaveDegree() { // 选择了有学位
......@@ -164,11 +176,13 @@ class YHSpouseBasicInfoVC: YHBaseViewController, YHFamilyMemberProtol {
let item31 = YHFormDetailItem(type: .stayHKDate)
item31.placeHolder = "请选择".local
item31.value = spouse.childInHk?.info
item31.tips = "请选择".local
let item32 = YHFormDetailItem(type: .roleInHK)
item32.placeHolder = "请选择".local
item32.value = spouse.hkIdentity
item32.tips = "请选择".local
arr3.append(contentsOf: [item31, item32])
}
......@@ -181,13 +195,71 @@ class YHSpouseBasicInfoVC: YHBaseViewController, YHFamilyMemberProtol {
if spouse.isHaveHKIdentityCard() { // 办理过香港身份证才显示证号
let item41 = YHFormDetailItem(type: .hkIdentityCardNumber)
item41.value = spouse.hkIdentityCard
item41.tips = "请输入正确的香港身份证号码".local
arr4.append(item41)
}
items.append(contentsOf: [arr0, arr1, arr2, arr3, arr4])
tableView.reloadData()
}
// 检查填写信息完整性
func checkIntegrity() -> Bool {
guard let spouse = spouse else { return false}
if isEmptyString(spouse.subsetName) {
return false
}
if isEmptyString(spouse.usedName) {
return false
}
if isEmptyString(spouse.surname) {
return false
}
if isEmptyString(spouse.birthday) {
return false
}
if spouse.isBirthOverSeas() {
if isEmptyString(spouse.birthPlace?.foreign) {
return false
}
} else {
if isEmptyArray(spouse.birthPlace?.area) {
return false
}
}
if isEmptyString(spouse.occupation) {
return false
}
if spouse.isNowHaveJob(), isEmptyString(spouse.occupationName) {
return false
}
if spouse.isHaveDegree() { // 选择了有学位
if let degreeArr = spouse.hasDegreeJson, !degreeArr.isEmpty {
for degreeInfo in degreeArr {
if isEmptyString(degreeInfo.degree) || isEmptyString(degreeInfo.address) {
return false
}
}
}
}
return true
}
func nextStep()->Bool {
guard let spouse = spouse else { return false }
let isChecked = checkIntegrity()
isNeedShowError = !isChecked
self.tableView .reloadData()
if !isChecked {
YHHUD.flash(message: "资料还未填完")
return false
}
return true
}
......@@ -297,7 +369,19 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
cell.title = detailItem.getTitle()
cell.text = detailItem.value
cell.isShowBottomLine = indexPath.row != arr.count-1
if detailItem.type == .hkIdentityCardNumber { // 输入香港身份证号码
let isEmptyValue = isEmptyString(detailItem.value)
var isUnvalidFormat = true
if let value = detailItem.value, value.isHKIdentityCardNumber() {
isUnvalidFormat = false
}
let isNeedShowTips = isEmptyValue || isUnvalidFormat
cell.setTips(detailItem.tips, isShow: isNeedShowError && isNeedShowTips)
} else {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
}
cell.textChange = {
[weak self] (text, isEditEnd) in
guard let self = self else { return }
......@@ -317,6 +401,12 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
if isEditEnd {
self.loadBasicInfo()
if detailItem.type == .hkIdentityCardNumber {
if let text = text, !text.isHKIdentityCardNumber() {
YHHUD.flash(message: "请输入正确的香港身份证号格式")
return
}
}
if let delegate = delegate {
delegate.saveInfo?()
}
......@@ -332,6 +422,7 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
cell.title = detailItem.getTitle()
cell.detail = detailItem.value
cell.isShowBottomLine = indexPath.row != arr.count-1
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
return cell
}
......@@ -554,6 +645,7 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
self.spouse?.occupation = selectType.title
self.loadBasicInfo()
}
} else if detailItem.type == .ownDegree {
let hasDegree = self.spouse?.haveDegreeName() ?? "无学位"
YHFormPickerView.show(type: .ownDegree, selectTitle:hasDegree ) {
......
......@@ -40,7 +40,7 @@ class YHSpouseInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol {
var spouse:YHFamilyMember? {
didSet {
if let spouse = spouse {
initalInfoVC.spouse = spouse
primaryInfoVC.spouse = spouse
certificateVC.familyMember = spouse
basicInfoVC.spouse = spouse
}
......@@ -66,7 +66,7 @@ class YHSpouseInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol {
return YHSaveAndSubmitView.createView()
}()
let initalInfoVC = YHSpousePrimaryInfoVC()
let primaryInfoVC = YHSpousePrimaryInfoVC()
let uploadVC = YHCertificateUploadVC()
let certificateVC = YHCertificateInfoController()
let basicInfoVC = YHSpouseBasicInfoVC()
......@@ -76,17 +76,11 @@ class YHSpouseInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol {
createUI()
}
@objc func tap() {
// let index = (currentIndex+1)%self.children.count
// currentIndex = index
}
func createUI() {
guard let spouse = spouse else { return }
initalInfoVC.delegate = self
primaryInfoVC.delegate = self
certificateVC.delegate = self
basicInfoVC.delegate = self
......@@ -96,9 +90,9 @@ class YHSpouseInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol {
updateStepView()
let tap = UITapGestureRecognizer(target: self, action: #selector(tap))
tap.cancelsTouchesInView = false
self.view.addGestureRecognizer(tap)
bottomView.submitBlock = {
[weak self] in
guard let self = self else { return }
......@@ -137,14 +131,14 @@ class YHSpouseInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol {
if spouse.isFollow() {
stepVCs = [ YHFaimilyStepItem(title:"初始信息".local, vc:initalInfoVC, step:0),
stepVCs = [ YHFaimilyStepItem(title:"初始信息".local, vc:primaryInfoVC, step:0),
YHFaimilyStepItem(title:"证件上传".local, vc:uploadVC, step:1),
YHFaimilyStepItem(title:"证件信息".local, vc:certificateVC, step:2),
YHFaimilyStepItem(title:"基本信息".local, vc:basicInfoVC, step:3)]
} else {
stepVCs = [ YHFaimilyStepItem(title:"初始信息".local, vc:initalInfoVC, step:0),
stepVCs = [ YHFaimilyStepItem(title:"初始信息".local, vc:primaryInfoVC, step:0),
YHFaimilyStepItem(title:"基本信息".local, vc:basicInfoVC, step:3)]
}
......@@ -239,3 +233,10 @@ extension YHSpouseInfoContainerVC {
return nil
}
}
extension YHSpouseInfoContainerVC: UIGestureRecognizerDelegate {
@objc func tap() {
print("点击了parentViewController: YHSpouseInfoContainerVC")
}
}
......@@ -40,8 +40,6 @@ class YHSpousePrimaryInfoVC: YHBaseViewController, YHFamilyMemberProtol {
return tableView
}()
override func viewDidLoad() {
super.viewDidLoad()
gk_navTitle = "配偶信息填写".local
......@@ -115,7 +113,6 @@ class YHSpousePrimaryInfoVC: YHBaseViewController, YHFamilyMemberProtol {
item24.value = String(spouse.isOverSeasOver1Year())
arr2.append(item24)
}
}
}
}
......
......@@ -74,7 +74,7 @@ class YHFormItemInputTextCell: UITableViewCell {
textField.backgroundColor = .clear
textField.placeholder = "请输入"
textField.font = UIFont.PFSC_M(ofSize: 14)
textField.tintColor = UIColor.placeHolderColor
textField.tintColor = UIColor.brandMainColor
textField.textColor = UIColor.mainTextColor
textField.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged)
textField.addTarget(self, action: #selector(textFieldEditEnd(textField:)), for: .editingDidEnd)
......
......@@ -78,6 +78,14 @@ extension String {
return false
}
// MARK: - 是否符合香港身份证号码
func isHKIdentityCardNumber() -> Bool {
let regex = #"^([A-Z]\d{6,10}(\(\w{1}\))?)|([A-Z]\d{6,10}(\\w{1}\))?)$/"#
let predicate = NSPredicate(format: "SELF MATCHES %@", regex)
let isValid = predicate.evaluate(with:self)
print(isValid ? "正确的香港身份证号码格式":"错误的香港身份证号码格式")
return isValid
}
func phoneNumberForUI() -> String {
let phone = self.replacingOccurrences(of: " ", with: "")
......
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