Commit ec24856c authored by Steven杜宇's avatar Steven杜宇

// 家庭信息确认

parent 98bbaba8
...@@ -72,6 +72,10 @@ class YHFamilyInfoConfirmViewController: YHBaseViewController { ...@@ -72,6 +72,10 @@ class YHFamilyInfoConfirmViewController: YHBaseViewController {
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
make.height.equalTo(98) make.height.equalTo(98)
} }
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
getFamilyInfo() getFamilyInfo()
} }
...@@ -99,7 +103,7 @@ extension YHFamilyInfoConfirmViewController: UITableViewDelegate, UITableViewDat ...@@ -99,7 +103,7 @@ extension YHFamilyInfoConfirmViewController: UITableViewDelegate, UITableViewDat
} }
if indexPath.section == 1 { if indexPath.section == 1 {
let approveCell = tableView.dequeueReusableCell(withIdentifier: YHApproverInfoVerifyCell.cellReuseIdentifier, for: indexPath) as! YHApproverInfoVerifyCell let approveCell = tableView.dequeueReusableCell(withIdentifier: YHApproverInfoVerifyCell.cellReuseIdentifier, for: indexPath) as! YHApproverInfoVerifyCell
approveCell.updateFamilyArr(self.familyArr) approveCell.updateFamilyArr(self.familyArr, familyGroup: self.viewModel.familyInfo)
return approveCell return approveCell
} }
if indexPath.section == 2 { if indexPath.section == 2 {
......
...@@ -18,7 +18,12 @@ enum YHFamilyMemberRelationType: Int { ...@@ -18,7 +18,12 @@ enum YHFamilyMemberRelationType: Int {
class YHFamilyInfoUpdateViewController: YHBaseViewController { class YHFamilyInfoUpdateViewController: YHBaseViewController {
var orderId: Int = 0 var memberId: Int = 0
var familyGroupModel: YHFamilyGroupModel = YHFamilyGroupModel()
let viewModel = YHFamilyInfoConfirmViewModel()
private var detailMember:YHApplicantInfoModel = YHApplicantInfoModel()
var relation:YHFamilyMemberRelationType = .mainApplicant var relation:YHFamilyMemberRelationType = .mainApplicant
var isInfoEditing: Bool = false var isInfoEditing: Bool = false
...@@ -95,7 +100,7 @@ class YHFamilyInfoUpdateViewController: YHBaseViewController { ...@@ -95,7 +100,7 @@ class YHFamilyInfoUpdateViewController: YHBaseViewController {
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
make.height.equalTo(98) make.height.equalTo(98)
} }
self.getData() self.getDetail()
} }
@objc func didCancelBtnClicked() { @objc func didCancelBtnClicked() {
...@@ -103,190 +108,37 @@ class YHFamilyInfoUpdateViewController: YHBaseViewController { ...@@ -103,190 +108,37 @@ class YHFamilyInfoUpdateViewController: YHBaseViewController {
} }
@objc func didConfirmBtnClicked() { @objc func didConfirmBtnClicked() {
self.detailMember.info.isCheck = true
self.tableView.reloadData()
} }
func getData() { func getDetail() {
if self.familyGroupModel.main.info.id == memberId {
items.removeAll() self.detailMember = self.familyGroupModel.main
let isEditMode = self.isInfoEditing
let isShowPreviousInfo = false
// arr1 信息核实
var arr1 = [YHFamilyInfoItem]()
if self.relation == .mainApplicant {
let name = "张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋张全蛋" } else if self.familyGroupModel.spouse.info.id == memberId {
let mainApplicantNameInfo = YHFamilyInfoItem(id: .mainApplicantName, self.detailMember = self.familyGroupModel.spouse
action: .edit,
isMust: true,
title: "主申请人姓名",
value: name,
previousTitle: "原主申人姓名",
previousValue: name,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(mainApplicantNameInfo)
} else if self.relation == .spouse { } else {
let name = "李斯" for child in self.familyGroupModel.children {
let spouseNameInfo = YHFamilyInfoItem(id: .spouseName, if child.info.id == memberId {
action: .edit, self.detailMember = child
isMust: true, break
title: "配偶姓名", }
value: name, }
previousTitle: "原配偶姓名",
previousValue: name,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(spouseNameInfo)
} else if self.relation == .child {
let name = "张晓蛋"
let childNameInfo = YHFamilyInfoItem(id: .childName,
action: .edit,
isMust: true,
title: "子女姓名",
value: name,
previousTitle: "原子女姓名",
previousValue: name,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(childNameInfo)
}
let firsName = "ZH"
let firstNameInfo = YHFamilyInfoItem(id: .firstName,
action: .edit,
isMust: true,
title: "姓(拼音)",
value: firsName,
previousTitle: "原姓(拼音)",
previousValue: firsName,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(firstNameInfo)
let lastName = "ZHANGZ"
let lastNameInfo = YHFamilyInfoItem(id: .lastName,
action: .edit,
isMust: true,
title: "名(拼音)",
value: lastName,
previousTitle: "原名(拼音)",
previousValue: lastName,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(lastNameInfo)
if self.relation != .child { // 子女无婚姻状况一栏
let marriage = "已婚"
let marriageInfo = YHFamilyInfoItem(id: .marriage,
action: .select,
isMust: true,
title: "婚姻状况",
value: marriage,
previousTitle: "原婚姻状况",
previousValue: marriage,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(marriageInfo)
} }
self.getData()
}
func getData() {
let birthNation = "国内" items.removeAll()
let options = [YHFamilyInfoOption(value: "国内", isSelect: true),
YHFamilyInfoOption(value: "国外", isSelect: false)] // arr1 信息核实
let birthNationInfo = YHFamilyInfoItem(id: .birthNation, let arr1 = viewModel.getInfoConfirm(self.detailMember, isEditMode: self.isInfoEditing)
action: .choice,
isMust: true,
title: "出生国家/地区",
value: birthNation,
previousTitle: "原出生国家/地区",
previousValue: birthNation,
options: options,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(birthNationInfo)
let birthPlace = "上海市市辖区"
let birthPlaceInfo = YHFamilyInfoItem(id: .birthPlace,
action: .select,
isMust: true,
title: "出生地",
value: birthPlace,
previousTitle: "原出生地",
previousValue: birthPlace,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(birthPlaceInfo)
let declareNation = "中国-CHINA"
let declareNationInfo = YHFamilyInfoItem(id: .declareNation,
action: .select,
isMust: true,
title: "申报国籍",
value: declareNation,
previousTitle: "原申报国籍",
previousValue: declareNation,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(declareNationInfo)
let occupation = "总监"
let occupationInfo = YHFamilyInfoItem(id: .occupation,
action: .edit,
isMust: true,
title: "职业",
value: occupation,
previousTitle: "原职业",
previousValue: occupation,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(occupationInfo)
let hongkongId = "3231235123512"
let hongkongIdInfo = YHFamilyInfoItem(id: .hongKongId,
action: .edit,
isMust: true,
title: "香港身份证号",
value: hongkongId,
previousTitle: "原香港身份证号",
previousValue: hongkongId,
isEditMode: isEditMode,
isShowPreviousInfo: isShowPreviousInfo)
arr1.append(hongkongIdInfo)
// arr2 递交证件信息 // arr2 递交证件信息
var arr2 = [YHFamilyInfoItem]() let arr2 = viewModel.getCertificateInfo(self.detailMember)
let travelCerType = "港澳通行证"
let travelCerInfo = YHFamilyInfoItem(id: .travelCertificateType,
action: .select,
isMust: true,
title: "申报旅行证件",
value: travelCerType,
previousTitle: "原申报旅行证件",
previousValue: travelCerType,
isEditMode: false,
isShowPreviousInfo: false)
arr2.append(travelCerInfo)
let cerId = "2351235234523542"
let cerIdInfo = YHFamilyInfoItem(id: .travelCertificateId,
action: .edit,
isMust: true,
title: "证件号",
value: cerId,
previousTitle: "原证件号",
previousValue: cerId,
isEditMode: false,
isShowPreviousInfo: false)
arr2.append(cerIdInfo)
// 信息核实 // 信息核实
items.append(arr1) items.append(arr1)
...@@ -297,17 +149,10 @@ class YHFamilyInfoUpdateViewController: YHBaseViewController { ...@@ -297,17 +149,10 @@ class YHFamilyInfoUpdateViewController: YHBaseViewController {
} }
func updateData() { func updateData() {
let isEditMode = self.isInfoEditing
let isShowPreviousInfo = false
if let arr1 = items.first { if let arr1 = items.first {
for item in arr1 { for item in arr1 {
item.isEditMode = isEditMode item.isEditMode = self.isInfoEditing
if !isEditMode, !item.previousValue.isEmpty, item.previousValue != item.value { item.isShowPreviousInfo = (!self.isInfoEditing && !item.previousValue.isEmpty)
item.isShowPreviousInfo = true
} else {
item.isShowPreviousInfo = false
}
} }
} }
self.tableView.reloadData() self.tableView.reloadData()
...@@ -330,6 +175,7 @@ extension YHFamilyInfoUpdateViewController: UITableViewDelegate, UITableViewData ...@@ -330,6 +175,7 @@ extension YHFamilyInfoUpdateViewController: UITableViewDelegate, UITableViewData
cell.titleLabel.attributed.text = title cell.titleLabel.attributed.text = title
cell.modifyBtn.isHidden = false cell.modifyBtn.isHidden = false
cell.isEditState = self.isInfoEditing cell.isEditState = self.isInfoEditing
cell.familyInfo = self.detailMember.info
cell.editBlock = { cell.editBlock = {
[weak self] isEdit in [weak self] isEdit in
guard let self = self else { return } guard let self = self else { return }
......
...@@ -82,6 +82,8 @@ class YHFamilyMemberInfoModel: SmartCodable { ...@@ -82,6 +82,8 @@ class YHFamilyMemberInfoModel: SmartCodable {
// 自定义属性 // 自定义属性
var relation:Int = YHFamilyMemberRelationType.none.rawValue var relation:Int = YHFamilyMemberRelationType.none.rawValue
// 是否检测编辑字段
var isCheck: Bool = false
func getRelation() -> String { func getRelation() -> String {
...@@ -127,6 +129,7 @@ class YHFamilyMemberInfoModel: SmartCodable { ...@@ -127,6 +129,7 @@ class YHFamilyMemberInfoModel: SmartCodable {
} }
init(id: Int, name: String, nameHistory: String, familyName: String, familyNameHistory: String, givenName: String, givenNameHistory: String, married: String, marriedHistory: String, birthPlaceAboard: Int, birthPlaceAboardHistory: Int, birthPlace: YHApplicantBirthPlaceModel, birthPlaceHistory: YHApplicantBirthPlaceModel, nationalityType: Int, nationalityTypeHistory: Int, nationality: String, nationalityHistory: String, hkIdentityid: String, hkIdentityidHistory: String, identity: YHApplicantIdentityModel, occupationName: String, occupationNameHistory: String) { init(id: Int, name: String, nameHistory: String, familyName: String, familyNameHistory: String, givenName: String, givenNameHistory: String, married: String, marriedHistory: String, birthPlaceAboard: Int, birthPlaceAboardHistory: Int, birthPlace: YHApplicantBirthPlaceModel, birthPlaceHistory: YHApplicantBirthPlaceModel, nationalityType: Int, nationalityTypeHistory: Int, nationality: String, nationalityHistory: String, hkIdentityid: String, hkIdentityidHistory: String, identity: YHApplicantIdentityModel, occupationName: String, occupationNameHistory: String) {
self.id = id self.id = id
self.name = name self.name = name
self.nameHistory = nameHistory self.nameHistory = nameHistory
......
...@@ -14,10 +14,13 @@ class YHApproverInfoVerifyCell: UITableViewCell { ...@@ -14,10 +14,13 @@ class YHApproverInfoVerifyCell: UITableViewCell {
static let cellReuseIdentifier = "YHApproverInfoVerifyCell" static let cellReuseIdentifier = "YHApproverInfoVerifyCell"
var familyArr:[YHApplicantInfoModel] = [] var familyArr:[YHApplicantInfoModel] = []
var familyGroupInfo: YHFamilyGroupModel = YHFamilyGroupModel()
let memberRowHeight = 69.0 let memberRowHeight = 69.0
func updateFamilyArr(_ familyArr: [YHApplicantInfoModel]) { func updateFamilyArr(_ familyArr: [YHApplicantInfoModel], familyGroup:YHFamilyGroupModel) {
self.familyArr = familyArr self.familyArr = familyArr
self.familyGroupInfo = familyGroup
tableView.snp.updateConstraints { make in tableView.snp.updateConstraints { make in
make.height.equalTo(memberRowHeight * Double(familyArr.count) + 4.0) make.height.equalTo(memberRowHeight * Double(familyArr.count) + 4.0)
} }
...@@ -128,8 +131,9 @@ extension YHApproverInfoVerifyCell: UITableViewDelegate, UITableViewDataSource { ...@@ -128,8 +131,9 @@ extension YHApproverInfoVerifyCell: UITableViewDelegate, UITableViewDataSource {
if 0 <= indexPath.row && indexPath.row < familyArr.count { if 0 <= indexPath.row && indexPath.row < familyArr.count {
let model = familyArr[indexPath.row] let model = familyArr[indexPath.row]
let vc = YHFamilyInfoConfirmViewController() let vc = YHFamilyInfoUpdateViewController()
vc.orderId = model.info.id vc.memberId = model.info.id
vc.familyGroupModel = self.familyGroupInfo
UIViewController.current?.navigationController?.pushViewController(vc) UIViewController.current?.navigationController?.pushViewController(vc)
} }
} }
......
...@@ -55,6 +55,9 @@ class YHFamilyInfoItem { ...@@ -55,6 +55,9 @@ class YHFamilyInfoItem {
var isEditMode: Bool = false var isEditMode: Bool = false
var isShowPreviousInfo: Bool = false var isShowPreviousInfo: Bool = false
var tips: String = ""
var isCheck: Bool = false
required init() { required init() {
} }
...@@ -76,6 +79,7 @@ class YHFamilyInfoItem { ...@@ -76,6 +79,7 @@ class YHFamilyInfoItem {
class YHIFamilyInfoListCell: UITableViewCell { class YHIFamilyInfoListCell: UITableViewCell {
static let cellReuseIdentifier = "YHIFamilyInfoListCell" static let cellReuseIdentifier = "YHIFamilyInfoListCell"
var familyInfo: YHFamilyMemberInfoModel = YHFamilyMemberInfoModel()
var isEditState: Bool = false { var isEditState: Bool = false {
didSet { didSet {
...@@ -174,11 +178,11 @@ class YHIFamilyInfoListCell: UITableViewCell { ...@@ -174,11 +178,11 @@ class YHIFamilyInfoListCell: UITableViewCell {
} }
if let itemView = itemView as? YHInfoItemView { if let itemView = itemView as? YHInfoItemView {
itemsContentView.addSubview(itemView) itemsContentView.addSubview(itemView)
itemView.updateItem(item) itemView.updateItem(item, familyInfo: familyInfo)
} else if let itemView = itemView as? YHInfoOptionView { } else if let itemView = itemView as? YHInfoOptionView {
itemsContentView.addSubview(itemView) itemsContentView.addSubview(itemView)
itemView.updateItem(item) itemView.updateItem(item, familyInfo: familyInfo)
} }
if let itemView = itemView { if let itemView = itemView {
......
...@@ -14,7 +14,7 @@ import AttributedString ...@@ -14,7 +14,7 @@ import AttributedString
class YHInfoItemView: UIView { class YHInfoItemView: UIView {
var item: YHFamilyInfoItem = YHFamilyInfoItem() var item: YHFamilyInfoItem = YHFamilyInfoItem()
var faimilyInfo: YHFamilyMemberInfoModel = YHFamilyMemberInfoModel()
let rightBtnWidth = 22.0 let rightBtnWidth = 22.0
lazy var lineView: UIView = { lazy var lineView: UIView = {
...@@ -44,6 +44,7 @@ class YHInfoItemView: UIView { ...@@ -44,6 +44,7 @@ class YHInfoItemView: UIView {
tf.textColor = UIColor.mainTextColor tf.textColor = UIColor.mainTextColor
tf.isHidden = true tf.isHidden = true
tf.delegate = self tf.delegate = self
tf.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged)
return tf return tf
}() }()
...@@ -79,6 +80,14 @@ class YHInfoItemView: UIView { ...@@ -79,6 +80,14 @@ class YHInfoItemView: UIView {
return label return label
}() }()
lazy var errorTipsLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 12)
label.textColor = UIColor.failColor
return label
}()
// 拉起弹窗用的一行透明的按钮 // 拉起弹窗用的一行透明的按钮
lazy var clickRowBtn: UIButton = { lazy var clickRowBtn: UIButton = {
let btn = UIButton() let btn = UIButton()
...@@ -104,6 +113,7 @@ class YHInfoItemView: UIView { ...@@ -104,6 +113,7 @@ class YHInfoItemView: UIView {
self.addSubview(textField) self.addSubview(textField)
self.addSubview(rightBtn) self.addSubview(rightBtn)
self.addSubview(previousContentView) self.addSubview(previousContentView)
self.addSubview(errorTipsLabel)
self.addSubview(clickRowBtn) self.addSubview(clickRowBtn)
previousContentView.addSubview(previousTitleLabel) previousContentView.addSubview(previousTitleLabel)
previousContentView.addSubview(previousDetailLabel) previousContentView.addSubview(previousDetailLabel)
...@@ -160,6 +170,14 @@ class YHInfoItemView: UIView { ...@@ -160,6 +170,14 @@ class YHInfoItemView: UIView {
make.top.equalTo(12) make.top.equalTo(12)
make.right.equalTo(-18) make.right.equalTo(-18)
make.bottom.equalTo(-12) make.bottom.equalTo(-12)
make.height.greaterThanOrEqualTo(20)
}
errorTipsLabel.snp.makeConstraints { make in
make.left.equalTo(0)
make.right.equalTo(0)
make.top.equalTo(previousContentView.snp.bottom)
make.bottom.equalTo(-16)
} }
} }
...@@ -168,11 +186,13 @@ class YHInfoItemView: UIView { ...@@ -168,11 +186,13 @@ class YHInfoItemView: UIView {
if isTextEdit { if isTextEdit {
textField.becomeFirstResponder() textField.becomeFirstResponder()
textField.text = "" textField.text = ""
textFieldChanged(textField:textField)
} }
} }
@objc func didSelectSheetBtnClicked() { @objc func didSelectSheetBtnClicked() {
if item.action == .select { if item.action == .select {
self.becomeFirstResponder()
if item.id == .marriage { if item.id == .marriage {
YHSheetPickerView.show(type:.marriage, selectTitle: item.value) { YHSheetPickerView.show(type:.marriage, selectTitle: item.value) {
...@@ -212,8 +232,9 @@ class YHInfoItemView: UIView { ...@@ -212,8 +232,9 @@ class YHInfoItemView: UIView {
} }
} }
func updateItem(_ item: YHFamilyInfoItem) { func updateItem(_ item: YHFamilyInfoItem, familyInfo: YHFamilyMemberInfoModel) {
self.item = item self.item = item
self.faimilyInfo = familyInfo
// 标题 // 标题
var title: ASAttributedString = .init("\(item.title)", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor.mainTextColor)) var title: ASAttributedString = .init("\(item.title)", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor.mainTextColor))
// 是否必填 // 是否必填
...@@ -228,12 +249,14 @@ class YHInfoItemView: UIView { ...@@ -228,12 +249,14 @@ class YHInfoItemView: UIView {
detailLabel.text = item.value detailLabel.text = item.value
detailLabel.isHidden = isTextEdit detailLabel.isHidden = isTextEdit
textField.isHidden = !isTextEdit textField.isHidden = !isTextEdit
textField.placeholder = self.getPlaceHolder()
let isSelectSheet = item.isEditMode && item.action == .select let isSelectSheet = item.isEditMode && item.action == .select
clickRowBtn.isHidden = !isSelectSheet clickRowBtn.isHidden = !isSelectSheet
textField.text = item.value textField.text = item.value
rightBtn.isHidden = !item.isEditMode rightBtn.isHidden = !item.isEditMode
if item.action == .edit { if item.action == .edit {
rightBtn.setImage(UIImage(named: "family_info_del"), for: .normal) rightBtn.setImage(UIImage(named: "family_info_del"), for: .normal)
} else if item.action == .select { } else if item.action == .select {
...@@ -241,7 +264,6 @@ class YHInfoItemView: UIView { ...@@ -241,7 +264,6 @@ class YHInfoItemView: UIView {
} }
previousTitleLabel.text = item.previousTitle previousTitleLabel.text = item.previousTitle
previousDetailLabel.text = item.previousValue previousDetailLabel.text = item.previousValue
previousContentView.isHidden = !item.isShowPreviousInfo
detailLabel.snp.remakeConstraints { make in detailLabel.snp.remakeConstraints { make in
make.top.equalTo(16) make.top.equalTo(16)
...@@ -249,16 +271,32 @@ class YHInfoItemView: UIView { ...@@ -249,16 +271,32 @@ class YHInfoItemView: UIView {
make.right.equalTo(item.isEditMode ? -18.0-rightBtnWidth : 0) make.right.equalTo(item.isEditMode ? -18.0-rightBtnWidth : 0)
if isTextEdit { if isTextEdit {
make.height.equalTo(20) make.height.equalTo(20)
} else {
make.height.greaterThanOrEqualTo(20)
} }
} }
previousContentView.isHidden = !item.isShowPreviousInfo
previousContentView.snp.remakeConstraints { make in previousContentView.snp.remakeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.bottom.equalTo(item.isShowPreviousInfo ? -16 : 0) make.top.equalTo(detailLabel.snp.bottom).offset(item.isShowPreviousInfo ? 16 : 0)
if !item.isShowPreviousInfo { if !item.isShowPreviousInfo {
make.height.equalTo(0) make.height.equalTo(0)
} }
make.top.equalTo(detailLabel.snp.bottom).offset(16) }
let isShowTips = (familyInfo.isCheck && !item.tips.isEmpty)
item.tips = self.getRedTips()
errorTipsLabel.text = item.tips
errorTipsLabel.isHidden = !isShowTips
errorTipsLabel.snp.remakeConstraints { make in
make.left.equalTo(0)
make.right.equalTo(0)
if !isShowTips {
make.height.equalTo(0)
}
make.top.equalTo(previousContentView.snp.bottom).offset(isShowTips ? 6 : 0)
make.bottom.equalTo(-16)
} }
} }
} }
...@@ -274,14 +312,106 @@ extension YHInfoItemView: UITextFieldDelegate { ...@@ -274,14 +312,106 @@ extension YHInfoItemView: UITextFieldDelegate {
// return false // return false
// } // }
printLog("\(newText)") printLog("\(newText)")
self.item.value = newText
return true return true
} }
@objc func textFieldChanged(textField:UITextField) {
if let text = textField.text {
self.updateText(text)
self.faimilyInfo.isCheck = false
} else {
self.updateText("")
}
self.item.tips = self.getRedTips()
self.updateItem(self.item, familyInfo: self.faimilyInfo)
}
func updateText(_ newText: String) {
self.item.value = newText
if self.item.id == .mainApplicantName || self.item.id == .spouseName || self.item.id == .childName {
self.faimilyInfo.name = newText
} else if self.item.id == .firstName {
self.faimilyInfo.familyName = newText
} else if self.item.id == .lastName {
self.faimilyInfo.givenName = newText
} else if self.item.id == .occupation {
self.faimilyInfo.occupationName = newText
} else if self.item.id == .hongKongId {
self.faimilyInfo.hkIdentityid = newText
}
}
func getPlaceHolder() -> String {
if self.item.id == .mainApplicantName {
return "请输入主申请人姓名"
}
if self.item.id == .spouseName {
return "请输入配偶姓名"
}
if self.item.id == .childName {
return "请输入子女姓名"
} else if self.item.id == .firstName {
return "请输入姓(拼音)"
} else if self.item.id == .lastName {
return "请输入名(拼音)"
} else if self.item.id == .occupation {
return "请输入职业"
} else if self.item.id == .hongKongId {
return "请输入香港身份证号"
}
return ""
}
func getRedTips() -> String {
if !self.item.value.isEmpty {
return ""
}
if self.item.id == .mainApplicantName {
return "请输入主申请人姓名"
}
if self.item.id == .spouseName {
return "请输入配偶姓名"
}
if self.item.id == .childName {
return "请输入子女姓名"
} else if self.item.id == .firstName {
return "请输入姓(拼音)"
} else if self.item.id == .lastName {
return "请输入名(拼音)"
} else if self.item.id == .occupation {
return "请输入职业"
} else if self.item.id == .hongKongId {
return "请输入香港身份证号"
}
return ""
}
} }
class YHInfoOptionView: UIView { class YHInfoOptionView: UIView {
var item: YHFamilyInfoItem = YHFamilyInfoItem() var item: YHFamilyInfoItem = YHFamilyInfoItem()
var familyInfo: YHFamilyMemberInfoModel = YHFamilyMemberInfoModel()
let btnBaseTag = 9527 let btnBaseTag = 9527
let btnHeight = 32.0 let btnHeight = 32.0
let btnWidth = 74.0 let btnWidth = 74.0
...@@ -396,12 +526,14 @@ class YHInfoOptionView: UIView { ...@@ -396,12 +526,14 @@ class YHInfoOptionView: UIView {
make.top.equalTo(12) make.top.equalTo(12)
make.right.equalTo(-18) make.right.equalTo(-18)
make.bottom.equalTo(-12) make.bottom.equalTo(-12)
make.height.greaterThanOrEqualTo(20)
} }
} }
func updateItem(_ item: YHFamilyInfoItem) { func updateItem(_ item: YHFamilyInfoItem, familyInfo: YHFamilyMemberInfoModel) {
self.item = item self.item = item
self.familyInfo = familyInfo
// 标题 // 标题
var title: ASAttributedString = .init("\(item.title)", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor.mainTextColor)) var title: ASAttributedString = .init("\(item.title)", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor.mainTextColor))
// 是否必填 // 是否必填
...@@ -439,6 +571,7 @@ class YHInfoOptionView: UIView { ...@@ -439,6 +571,7 @@ class YHInfoOptionView: UIView {
previousTitleLabel.text = item.previousTitle previousTitleLabel.text = item.previousTitle
previousDetailLabel.text = item.previousValue previousDetailLabel.text = item.previousValue
previousContentView.isHidden = !item.isShowPreviousInfo previousContentView.isHidden = !item.isShowPreviousInfo
previousContentView.snp.remakeConstraints { make in previousContentView.snp.remakeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
...@@ -461,7 +594,7 @@ class YHInfoOptionView: UIView { ...@@ -461,7 +594,7 @@ class YHInfoOptionView: UIView {
item.value = option.value item.value = option.value
} }
} }
self.updateItem(item) self.updateItem(item, familyInfo: self.familyInfo)
} }
} }
} }
...@@ -47,4 +47,177 @@ class YHFamilyInfoConfirmViewModel: NSObject { ...@@ -47,4 +47,177 @@ class YHFamilyInfoConfirmViewModel: NSObject {
callback?(false, err) callback?(false, err)
} }
} }
func getInfoConfirm(_ model: YHApplicantInfoModel, isEditMode:Bool) -> [YHFamilyInfoItem] {
var nameTitle = ""
var previousNameTitle = ""
var id = YHFamilyInfoType.none
var resultArr = [YHFamilyInfoItem]()
if model.info.relation == YHFamilyMemberRelationType.mainApplicant.rawValue {
id = .mainApplicantName
nameTitle = "主申请人姓名"
previousNameTitle = "原主申人姓名"
} else if model.info.relation == YHFamilyMemberRelationType.spouse.rawValue {
id = .spouseName
nameTitle = "配偶姓名"
previousNameTitle = "原配偶姓名"
} else if model.info.relation == YHFamilyMemberRelationType.child.rawValue {
id = .childName
nameTitle = "子女姓名"
previousNameTitle = "原子女姓名"
}
// 姓名
let mainApplicantNameInfo = YHFamilyInfoItem(id: id,
action: .edit,
isMust: true,
title: nameTitle,
value: model.info.name,
previousTitle: previousNameTitle,
previousValue: model.info.nameHistory,
isEditMode: isEditMode,
isShowPreviousInfo: !isEditMode && !model.info.nameHistory.isEmpty)
resultArr.append(mainApplicantNameInfo)
// 姓(拼音)
let firstNameInfo = YHFamilyInfoItem(id: .firstName,
action: .edit,
isMust: true,
title: "姓(拼音)",
value: model.info.familyName,
previousTitle: "原姓(拼音)",
previousValue: model.info.familyNameHistory,
isEditMode: isEditMode,
isShowPreviousInfo: !isEditMode && !model.info.familyNameHistory.isEmpty)
resultArr.append(firstNameInfo)
// 名(拼音)
let lastNameInfo = YHFamilyInfoItem(id: .lastName,
action: .edit,
isMust: true,
title: "名(拼音)",
value: model.info.givenName,
previousTitle: "原名(拼音)",
previousValue: model.info.givenNameHistory,
isEditMode: isEditMode,
isShowPreviousInfo: !isEditMode && !model.info.givenNameHistory.isEmpty)
resultArr.append(lastNameInfo)
// 婚姻状况
if model.info.relation != YHFamilyMemberRelationType.child.rawValue { // 子女无婚姻状况一栏
let marriageInfo = YHFamilyInfoItem(id: .marriage,
action: .select,
isMust: true,
title: "婚姻状况",
value: model.info.married,
previousTitle: "原婚姻状况",
previousValue: model.info.marriedHistory,
isEditMode: isEditMode,
isShowPreviousInfo: !isEditMode && !model.info.marriedHistory.isEmpty)
resultArr.append(marriageInfo)
}
// 出生国家/地区
let birthNation = "国内"
let options = [YHFamilyInfoOption(value: "国内", isSelect: true),
YHFamilyInfoOption(value: "国外", isSelect: false)]
let birthNationInfo = YHFamilyInfoItem(id: .birthNation,
action: .choice,
isMust: true,
title: "出生国家/地区",
value: birthNation,
previousTitle: "原出生国家/地区",
previousValue: birthNation,
options: options,
isEditMode: isEditMode,
isShowPreviousInfo: !isEditMode && !birthNation.isEmpty)
resultArr.append(birthNationInfo)
// 出生地
let birthPlace = "上海市市辖区"
let birthPlaceInfo = YHFamilyInfoItem(id: .birthPlace,
action: .select,
isMust: true,
title: "出生地",
value: birthPlace,
previousTitle: "原出生地",
previousValue: birthPlace,
isEditMode: isEditMode,
isShowPreviousInfo: !isEditMode && !birthPlace.isEmpty)
resultArr.append(birthPlaceInfo)
// 申报国籍
let declareNation = "中国"
let declareNationInfo = YHFamilyInfoItem(id: .declareNation,
action: .select,
isMust: true,
title: "申报国籍",
value: declareNation,
previousTitle: "原申报国籍",
previousValue: declareNation,
isEditMode: isEditMode,
isShowPreviousInfo: !isEditMode && !declareNation.isEmpty)
resultArr.append(declareNationInfo)
// 职业
let occupationInfo = YHFamilyInfoItem(id: .occupation,
action: .edit,
isMust: true,
title: "职业",
value: model.info.occupationName,
previousTitle: "原职业",
previousValue: model.info.occupationNameHistory,
isEditMode: isEditMode,
isShowPreviousInfo: !isEditMode && !model.info.occupationNameHistory.isEmpty)
resultArr.append(occupationInfo)
// 香港身份证号
let hongkongIdInfo = YHFamilyInfoItem(id: .hongKongId,
action: .edit,
isMust: true,
title: "香港身份证号",
value: model.info.hkIdentityid,
previousTitle: "原香港身份证号",
previousValue: model.info.hkIdentityidHistory,
isEditMode: isEditMode,
isShowPreviousInfo: !isEditMode && !model.info.hkIdentityidHistory.isEmpty)
resultArr.append(hongkongIdInfo)
return resultArr
}
func getCertificateInfo(_ model: YHApplicantInfoModel) -> [YHFamilyInfoItem] {
// 申报旅行证件
var resultArr = [YHFamilyInfoItem]()
let travelCerInfo = YHFamilyInfoItem(id: .travelCertificateType,
action: .select,
isMust: true,
title: "申报旅行证件",
value: model.info.identity.name,
previousTitle: "原申报旅行证件",
previousValue: model.info.identity.name,
isEditMode: false,
isShowPreviousInfo: false)
resultArr.append(travelCerInfo)
// 证件号
let cerIdInfo = YHFamilyInfoItem(id: .travelCertificateId,
action: .edit,
isMust: true,
title: "证件号",
value: model.info.identity.number,
previousTitle: "原证件号",
previousValue: model.info.identity.number,
isEditMode: false,
isShowPreviousInfo: false)
resultArr.append(cerIdInfo)
return resultArr
}
} }
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