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

// 家庭成员信息model 更新

parent 6b0bd7e5
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHBrotherInfoVC: YHBaseViewController { class YHBrotherInfoVC: YHBaseViewController {
var brotherInfo:YHBrother? var brotherInfo:YHFamilyMember?
var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]() var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHCertificateViewController: YHBaseViewController { class YHCertificateViewController: YHBaseViewController {
var spouse:YHSpouse? var spouse:YHFamilyMember?
var cardInfo: YHCNIdentityCard? var cardInfo: YHCNIdentityCard?
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHChildBasicInfoVC: YHBaseViewController { class YHChildBasicInfoVC: YHBaseViewController {
var child:YHChild? var child:YHFamilyMember?
var cardInfo: YHCNIdentityCard? var cardInfo: YHCNIdentityCard?
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHChildInitialInfoVC: YHBaseViewController { class YHChildInitialInfoVC: YHBaseViewController {
var child:YHChild? var child:YHFamilyMember?
lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]() lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
......
...@@ -17,7 +17,7 @@ enum YHFormTitleItemEditType:Int { ...@@ -17,7 +17,7 @@ enum YHFormTitleItemEditType:Int {
class YHFamilyMemberFormVC: YHBaseViewController { class YHFamilyMemberFormVC: YHBaseViewController {
var familyMemberInfo: YHFamilyMemberInfo? var familyMemberInfo: YHFamilyMemberGroupInfo?
var isChildsEditMode: YHFormTitleItemEditType = .none var isChildsEditMode: YHFormTitleItemEditType = .none
var isBrothersEditMode: YHFormTitleItemEditType = .none var isBrothersEditMode: YHFormTitleItemEditType = .none
...@@ -269,7 +269,7 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -269,7 +269,7 @@ class YHFamilyMemberFormVC: YHBaseViewController {
] ]
] as [String : Any] ] as [String : Any]
familyMemberInfo = YHFamilyMemberInfo.deserialize(dict: dic) familyMemberInfo = YHFamilyMemberGroupInfo.deserialize(dict: dic)
loadFamilyMember() loadFamilyMember()
} }
...@@ -280,6 +280,8 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -280,6 +280,8 @@ class YHFamilyMemberFormVC: YHBaseViewController {
// 配偶section // 配偶section
if let sponse = familyMemberInfo?.spouse { if let sponse = familyMemberInfo?.spouse {
// 信息未填写时服务器返回的relation=0
sponse.relation = String(format: "%d", YHFamilyMemberType.spouse.rawValue)
let sponseArray:[YHFormItemProtocol] = [YHFormTitleItem(type: .sponse), sponse] let sponseArray:[YHFormItemProtocol] = [YHFormTitleItem(type: .sponse), sponse]
items.append(sponseArray) items.append(sponseArray)
} }
...@@ -287,9 +289,13 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -287,9 +289,13 @@ class YHFamilyMemberFormVC: YHBaseViewController {
// 父母section // 父母section
var parents = [YHFormItemProtocol]() var parents = [YHFormItemProtocol]()
if let father = familyMemberInfo?.father { if let father = familyMemberInfo?.father {
// 信息未填写时服务器返回的relation=0
father.relation = String(format: "%d", YHFamilyMemberType.father.rawValue)
parents.append(father) parents.append(father)
} }
if let mother = familyMemberInfo?.mother { if let mother = familyMemberInfo?.mother {
// 信息未填写时服务器返回的relation=0
mother.relation = String(format: "%d", YHFamilyMemberType.mother.rawValue)
parents.append(mother) parents.append(mother)
} }
if !parents.isEmpty { if !parents.isEmpty {
...@@ -308,6 +314,10 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -308,6 +314,10 @@ class YHFamilyMemberFormVC: YHBaseViewController {
// 兄妹section // 兄妹section
var brotherArr:[YHFormItemProtocol] = [YHFormTitleItem(type: .brother), YHFormAddItem(type: .addBrother)] var brotherArr:[YHFormItemProtocol] = [YHFormTitleItem(type: .brother), YHFormAddItem(type: .addBrother)]
if let brothers = familyMemberInfo?.brother, !brothers.isEmpty { if let brothers = familyMemberInfo?.brother, !brothers.isEmpty {
for brother in brothers {
// 信息未填写时服务器返回的relation=0
brother.relation = String(format: "%d", YHFamilyMemberType.brother.rawValue)
}
brotherArr.insert(contentsOf: brothers, at:1) brotherArr.insert(contentsOf: brothers, at:1)
} }
items.append(brotherArr) items.append(brotherArr)
...@@ -391,7 +401,7 @@ extension YHFamilyMemberFormVC { ...@@ -391,7 +401,7 @@ extension YHFamilyMemberFormVC {
"certificates": [] "certificates": []
] as [String : Any] ] as [String : Any]
let brother:YHBrother = YHBrother.deserialize(dict: dict)! let brother:YHFamilyMember = YHFamilyMember.deserialize(dict: dict)!
if var brothers = familyMemberInfo?.brother { if var brothers = familyMemberInfo?.brother {
brothers.append(brother) brothers.append(brother)
...@@ -466,7 +476,7 @@ extension YHFamilyMemberFormVC { ...@@ -466,7 +476,7 @@ extension YHFamilyMemberFormVC {
"certificates":[] "certificates":[]
] as [String : Any] ] as [String : Any]
let child = YHChild.deserialize(dict: dict)! let child = YHFamilyMember.deserialize(dict: dict)!
if var childs = familyMemberInfo?.child { if var childs = familyMemberInfo?.child {
childs.append(child) childs.append(child)
familyMemberInfo!.child = childs familyMemberInfo!.child = childs
...@@ -534,22 +544,24 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -534,22 +544,24 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
} }
// 配偶父母子女兄妹具体条目 // 配偶父母子女兄妹具体条目
if item is YHParent || item is YHChild || item is YHSpouse || item is YHBrother { if item is YHFamilyMember {
let detailItem = item as! YHFamilyMember
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell
cell.isShowDeleteBtn = false cell.isShowDeleteBtn = false
cell.deleteBlock = nil cell.deleteBlock = nil
if item is YHChild || item is YHBrother { if detailItem.relationType == .child || detailItem.relationType == .brother {
if item is YHChild { if detailItem.relationType == .child {
cell.isShowDeleteBtn = (isChildsEditMode == .canCancel) cell.isShowDeleteBtn = (isChildsEditMode == .canCancel)
} else if item is YHBrother {
} else if detailItem.relationType == .brother {
cell.isShowDeleteBtn = (isBrothersEditMode == .canCancel) cell.isShowDeleteBtn = (isBrothersEditMode == .canCancel)
} }
// 删除子女兄妹处理 // 删除子女兄妹处理
cell.deleteBlock = { [weak self] in cell.deleteBlock = { [weak self] in
if item is YHChild { if detailItem.relationType == .child {
let childCount = self?.familyMemberInfo?.child?.count ?? 0 let childCount = self?.familyMemberInfo?.child?.count ?? 0
// 因为子女兄妹section第一行都是标题所以row-1 // 因为子女兄妹section第一行都是标题所以row-1
if (indexPath.row-1 < childCount) { if (indexPath.row-1 < childCount) {
...@@ -557,7 +569,7 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -557,7 +569,7 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
self?.isChildsEditMode = .none self?.isChildsEditMode = .none
self?.isBrothersEditMode = .none self?.isBrothersEditMode = .none
} }
} else if item is YHBrother { } else if detailItem.relationType == .brother {
let brotherCount = self?.familyMemberInfo?.brother?.count ?? 0 let brotherCount = self?.familyMemberInfo?.brother?.count ?? 0
// 因为子女兄妹section第一行都是标题所以row-1 // 因为子女兄妹section第一行都是标题所以row-1
...@@ -629,11 +641,6 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -629,11 +641,6 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
IQKeyboardManager.shared.enable = true
let caseList = YHFormTitleItemType.allCases.map({ "\($0)" }).joined(separator: ", ")
print(caseList)
let arr = items[indexPath.section] let arr = items[indexPath.section]
let item:YHFormItemProtocol = arr[indexPath.row] let item:YHFormItemProtocol = arr[indexPath.row]
...@@ -652,40 +659,40 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -652,40 +659,40 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
} }
return return
} }
// 父母
if item is YHParent {
let parent = item as! YHParent
let vc = YHParentInfoVC()
vc.parentInfo = parent
self.navigationController?.pushViewController(vc)
return
}
// 配偶 if item is YHFamilyMember {
if item is YHSpouse { let detailItem = item as! YHFamilyMember
let spouse = item as! YHSpouse // 父母
let vc = YHSpouseInitialInfoVC() if detailItem.relationType == .father || detailItem.relationType == .mother {
vc.spouse = spouse let vc = YHParentInfoVC()
self.navigationController?.pushViewController(vc) vc.parentInfo = detailItem
return self.navigationController?.pushViewController(vc)
} return
}
// 子女
if item is YHChild { // 配偶
let child = item as! YHChild if detailItem.relationType == .spouse {
let vc = YHChildInitialInfoVC() let vc = YHSpouseInitialInfoVC()
vc.child = child vc.spouse = detailItem
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
return return
} }
// 兄弟姐妹 // 子女
if item is YHBrother { if detailItem.relationType == .child {
let brother = item as! YHBrother let vc = YHChildInitialInfoVC()
let vc = YHBrotherInfoVC() vc.child = detailItem
vc.brotherInfo = brother self.navigationController?.pushViewController(vc)
self.navigationController?.pushViewController(vc) return
return }
// 兄弟姐妹
if detailItem.relationType == .brother {
let vc = YHBrotherInfoVC()
vc.brotherInfo = detailItem
self.navigationController?.pushViewController(vc)
return
}
} }
} }
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHParentInfoVC: YHBaseViewController { class YHParentInfoVC: YHBaseViewController {
var parentInfo: YHParent? var parentInfo: YHFamilyMember?
var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]() var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
...@@ -72,7 +72,7 @@ class YHParentInfoVC: YHBaseViewController { ...@@ -72,7 +72,7 @@ class YHParentInfoVC: YHBaseViewController {
// 父母亲信息 // 父母亲信息
var arr1 = [YHFormItemProtocol]() var arr1 = [YHFormItemProtocol]()
if parentInfo.sex == -1 { // 父亲 if parentInfo.relationType == .father { // 父亲
let title1:YHFormItemProtocol = YHFormTitleItem(type: .fatherInfo) let title1:YHFormItemProtocol = YHFormTitleItem(type: .fatherInfo)
let item10:YHFormItemProtocol = YHFormDetailItem(type: .fatherName) let item10:YHFormItemProtocol = YHFormDetailItem(type: .fatherName)
arr1.append(contentsOf: [title1, item10]) arr1.append(contentsOf: [title1, item10])
......
...@@ -24,7 +24,7 @@ enum HKFormItemCellType: Int { ...@@ -24,7 +24,7 @@ enum HKFormItemCellType: Int {
class YHSpouseBasicInfoVC: YHBaseViewController { class YHSpouseBasicInfoVC: YHBaseViewController {
var spouse:YHSpouse? var spouse:YHFamilyMember?
var cardInfo: YHCNIdentityCard? var cardInfo: YHCNIdentityCard?
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHSpouseInitialInfoVC: YHBaseViewController { class YHSpouseInitialInfoVC: YHBaseViewController {
var spouse:YHSpouse? var spouse:YHFamilyMember?
lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]() lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
......
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