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

// 家庭信息确认

parent 98bbaba8
......@@ -72,6 +72,10 @@ class YHFamilyInfoConfirmViewController: YHBaseViewController {
make.left.right.bottom.equalToSuperview()
make.height.equalTo(98)
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
getFamilyInfo()
}
......@@ -99,7 +103,7 @@ extension YHFamilyInfoConfirmViewController: UITableViewDelegate, UITableViewDat
}
if indexPath.section == 1 {
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
}
if indexPath.section == 2 {
......
......@@ -82,6 +82,8 @@ class YHFamilyMemberInfoModel: SmartCodable {
// 自定义属性
var relation:Int = YHFamilyMemberRelationType.none.rawValue
// 是否检测编辑字段
var isCheck: Bool = false
func getRelation() -> String {
......@@ -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) {
self.id = id
self.name = name
self.nameHistory = nameHistory
......
......@@ -14,10 +14,13 @@ class YHApproverInfoVerifyCell: UITableViewCell {
static let cellReuseIdentifier = "YHApproverInfoVerifyCell"
var familyArr:[YHApplicantInfoModel] = []
var familyGroupInfo: YHFamilyGroupModel = YHFamilyGroupModel()
let memberRowHeight = 69.0
func updateFamilyArr(_ familyArr: [YHApplicantInfoModel]) {
func updateFamilyArr(_ familyArr: [YHApplicantInfoModel], familyGroup:YHFamilyGroupModel) {
self.familyArr = familyArr
self.familyGroupInfo = familyGroup
tableView.snp.updateConstraints { make in
make.height.equalTo(memberRowHeight * Double(familyArr.count) + 4.0)
}
......@@ -128,8 +131,9 @@ extension YHApproverInfoVerifyCell: UITableViewDelegate, UITableViewDataSource {
if 0 <= indexPath.row && indexPath.row < familyArr.count {
let model = familyArr[indexPath.row]
let vc = YHFamilyInfoConfirmViewController()
vc.orderId = model.info.id
let vc = YHFamilyInfoUpdateViewController()
vc.memberId = model.info.id
vc.familyGroupModel = self.familyGroupInfo
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
......
......@@ -55,6 +55,9 @@ class YHFamilyInfoItem {
var isEditMode: Bool = false
var isShowPreviousInfo: Bool = false
var tips: String = ""
var isCheck: Bool = false
required init() {
}
......@@ -76,6 +79,7 @@ class YHFamilyInfoItem {
class YHIFamilyInfoListCell: UITableViewCell {
static let cellReuseIdentifier = "YHIFamilyInfoListCell"
var familyInfo: YHFamilyMemberInfoModel = YHFamilyMemberInfoModel()
var isEditState: Bool = false {
didSet {
......@@ -174,11 +178,11 @@ class YHIFamilyInfoListCell: UITableViewCell {
}
if let itemView = itemView as? YHInfoItemView {
itemsContentView.addSubview(itemView)
itemView.updateItem(item)
itemView.updateItem(item, familyInfo: familyInfo)
} else if let itemView = itemView as? YHInfoOptionView {
itemsContentView.addSubview(itemView)
itemView.updateItem(item)
itemView.updateItem(item, familyInfo: familyInfo)
}
if let itemView = itemView {
......
......@@ -14,7 +14,7 @@ import AttributedString
class YHInfoItemView: UIView {
var item: YHFamilyInfoItem = YHFamilyInfoItem()
var faimilyInfo: YHFamilyMemberInfoModel = YHFamilyMemberInfoModel()
let rightBtnWidth = 22.0
lazy var lineView: UIView = {
......@@ -44,6 +44,7 @@ class YHInfoItemView: UIView {
tf.textColor = UIColor.mainTextColor
tf.isHidden = true
tf.delegate = self
tf.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged)
return tf
}()
......@@ -79,6 +80,14 @@ class YHInfoItemView: UIView {
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 = {
let btn = UIButton()
......@@ -104,6 +113,7 @@ class YHInfoItemView: UIView {
self.addSubview(textField)
self.addSubview(rightBtn)
self.addSubview(previousContentView)
self.addSubview(errorTipsLabel)
self.addSubview(clickRowBtn)
previousContentView.addSubview(previousTitleLabel)
previousContentView.addSubview(previousDetailLabel)
......@@ -160,6 +170,14 @@ class YHInfoItemView: UIView {
make.top.equalTo(12)
make.right.equalTo(-18)
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 {
if isTextEdit {
textField.becomeFirstResponder()
textField.text = ""
textFieldChanged(textField:textField)
}
}
@objc func didSelectSheetBtnClicked() {
if item.action == .select {
self.becomeFirstResponder()
if item.id == .marriage {
YHSheetPickerView.show(type:.marriage, selectTitle: item.value) {
......@@ -212,8 +232,9 @@ class YHInfoItemView: UIView {
}
}
func updateItem(_ item: YHFamilyInfoItem) {
func updateItem(_ item: YHFamilyInfoItem, familyInfo: YHFamilyMemberInfoModel) {
self.item = item
self.faimilyInfo = familyInfo
// 标题
var title: ASAttributedString = .init("\(item.title)", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor.mainTextColor))
// 是否必填
......@@ -228,12 +249,14 @@ class YHInfoItemView: UIView {
detailLabel.text = item.value
detailLabel.isHidden = isTextEdit
textField.isHidden = !isTextEdit
textField.placeholder = self.getPlaceHolder()
let isSelectSheet = item.isEditMode && item.action == .select
clickRowBtn.isHidden = !isSelectSheet
textField.text = item.value
rightBtn.isHidden = !item.isEditMode
if item.action == .edit {
rightBtn.setImage(UIImage(named: "family_info_del"), for: .normal)
} else if item.action == .select {
......@@ -241,7 +264,6 @@ class YHInfoItemView: UIView {
}
previousTitleLabel.text = item.previousTitle
previousDetailLabel.text = item.previousValue
previousContentView.isHidden = !item.isShowPreviousInfo
detailLabel.snp.remakeConstraints { make in
make.top.equalTo(16)
......@@ -249,16 +271,32 @@ class YHInfoItemView: UIView {
make.right.equalTo(item.isEditMode ? -18.0-rightBtnWidth : 0)
if isTextEdit {
make.height.equalTo(20)
} else {
make.height.greaterThanOrEqualTo(20)
}
}
previousContentView.isHidden = !item.isShowPreviousInfo
previousContentView.snp.remakeConstraints { make in
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 {
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 {
// return false
// }
printLog("\(newText)")
self.item.value = newText
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 {
var item: YHFamilyInfoItem = YHFamilyInfoItem()
var familyInfo: YHFamilyMemberInfoModel = YHFamilyMemberInfoModel()
let btnBaseTag = 9527
let btnHeight = 32.0
let btnWidth = 74.0
......@@ -396,12 +526,14 @@ class YHInfoOptionView: UIView {
make.top.equalTo(12)
make.right.equalTo(-18)
make.bottom.equalTo(-12)
make.height.greaterThanOrEqualTo(20)
}
}
func updateItem(_ item: YHFamilyInfoItem) {
func updateItem(_ item: YHFamilyInfoItem, familyInfo: YHFamilyMemberInfoModel) {
self.item = item
self.familyInfo = familyInfo
// 标题
var title: ASAttributedString = .init("\(item.title)", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor.mainTextColor))
// 是否必填
......@@ -439,6 +571,7 @@ class YHInfoOptionView: UIView {
previousTitleLabel.text = item.previousTitle
previousDetailLabel.text = item.previousValue
previousContentView.isHidden = !item.isShowPreviousInfo
previousContentView.snp.remakeConstraints { make in
make.left.right.equalToSuperview()
......@@ -461,7 +594,7 @@ class YHInfoOptionView: UIView {
item.value = option.value
}
}
self.updateItem(item)
self.updateItem(item, familyInfo: self.familyInfo)
}
}
}
......@@ -47,4 +47,177 @@ class YHFamilyInfoConfirmViewModel: NSObject {
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