Commit 33180eaf authored by David黄金龙's avatar David黄金龙

Merge commit 'b3264fb0' into davidhuang

* commit 'b3264fb0':
  配偶信息填写
  配偶信息填写
  配偶信息填写
parents 738f45ac b3264fb0
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import UIKit import UIKit
enum YHFamilyMemberEditType:Int { enum YHFormTitleItemEditType:Int {
case none = 1 case none = 1
case canEdit = 2 case canEdit = 2
case canCancel = 3 case canCancel = 3
...@@ -17,10 +17,10 @@ enum YHFamilyMemberEditType:Int { ...@@ -17,10 +17,10 @@ enum YHFamilyMemberEditType:Int {
class YHFamilyMemberFormVC: YHBaseViewController { class YHFamilyMemberFormVC: YHBaseViewController {
var familyMemberInfo: YHFamilyMemberInfo? var familyMemberInfo: YHFamilyMemberInfo?
var isChildsEditMode: YHFamilyMemberEditType = .none var isChildsEditMode: YHFormTitleItemEditType = .none
var isBrothersEditMode: YHFamilyMemberEditType = .none var isBrothersEditMode: YHFormTitleItemEditType = .none
var items:[[YHFamilyMemberProtocol]] = [] var items:[[YHFormItemProtocol]] = []
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
...@@ -29,6 +29,7 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -29,6 +29,7 @@ class YHFamilyMemberFormVC: YHBaseViewController {
if #available(iOS 11.0, *) { if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never tableView.contentInsetAdjustmentBehavior = .never
} }
tableView.showsVerticalScrollIndicator = false
tableView.backgroundColor = .clear tableView.backgroundColor = .clear
tableView.separatorStyle = .none tableView.separatorStyle = .none
tableView.delegate = self tableView.delegate = self
...@@ -59,7 +60,7 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -59,7 +60,7 @@ class YHFamilyMemberFormVC: YHBaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
self.gk_navTitle = "家庭成员信息填写" self.gk_navTitle = "家庭成员信息填写".local
view.backgroundColor = UIColor(hexString:"#F8F8F8") view.backgroundColor = UIColor(hexString:"#F8F8F8")
createUI() createUI()
loadData() loadData()
...@@ -274,12 +275,12 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -274,12 +275,12 @@ class YHFamilyMemberFormVC: YHBaseViewController {
// 配偶section // 配偶section
if let sponse = familyMemberInfo?.spouse { if let sponse = familyMemberInfo?.spouse {
let sponseArray:[YHFamilyMemberProtocol] = [YHFamilyMemberFormItem(type: .sponse), sponse] let sponseArray:[YHFormItemProtocol] = [YHFormTitleItem(type: .sponse), sponse]
items.append(sponseArray) items.append(sponseArray)
} }
// 父母section // 父母section
var parents = [YHFamilyMemberProtocol]() var parents = [YHFormItemProtocol]()
if let father = familyMemberInfo?.father { if let father = familyMemberInfo?.father {
parents.append(father) parents.append(father)
} }
...@@ -287,20 +288,20 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -287,20 +288,20 @@ class YHFamilyMemberFormVC: YHBaseViewController {
parents.append(mother) parents.append(mother)
} }
if !parents.isEmpty { if !parents.isEmpty {
let item0 = YHFamilyMemberFormItem(type: .parent) let item0 = YHFormTitleItem(type: .parent)
parents.insert(item0, at: 0) parents.insert(item0, at: 0)
items.append(parents) items.append(parents)
} }
// 子女section // 子女section
var childArr:[YHFamilyMemberProtocol] = [YHFamilyMemberFormItem(type: .child), YHFamilyMemberFormItem(type: .addChild)] var childArr:[YHFormItemProtocol] = [YHFormTitleItem(type: .child), YHFormAddItem(type: .addChild)]
if let childs = familyMemberInfo?.child, !childs.isEmpty { if let childs = familyMemberInfo?.child, !childs.isEmpty {
childArr.insert(contentsOf: childs, at:1) childArr.insert(contentsOf: childs, at:1)
} }
items.append(childArr) items.append(childArr)
// 兄妹section // 兄妹section
var brotherArr:[YHFamilyMemberProtocol] = [YHFamilyMemberFormItem(type: .brother), YHFamilyMemberFormItem(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 {
brotherArr.insert(contentsOf: brothers, at:1) brotherArr.insert(contentsOf: brothers, at:1)
} }
...@@ -486,27 +487,14 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -486,27 +487,14 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let arr = items[indexPath.section] let arr = items[indexPath.section]
let item:YHFamilyMemberProtocol = arr[indexPath.row] let item:YHFormItemProtocol = arr[indexPath.row]
if item is YHFamilyMemberFormItem { // 是标题或添加项目 if item is YHFormTitleItem { // 是标题
let formItem = item as! YHFamilyMemberFormItem let formItem = item as! YHFormTitleItem
if formItem.type == .addChild || formItem.type == .addBrother { // 新增子女/兄弟姐妹
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormAddInfoCell.cellReuseIdentifier, for: indexPath) as! YHFormAddInfoCell
createCorner(cell: cell, arr: arr, indexPath: indexPath)
cell.clickBlock = { [weak self] in
if formItem.type == .addBrother {
self?.addBrother()
} else if formItem.type == .addChild {
self?.addChild()
}
}
return cell
}
// 配偶父母子女兄妹title // 配偶父母子女兄妹title
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormTitleCell.cellReuseIdentifier, for: indexPath) as! YHFormTitleCell let cell = tableView.dequeueReusableCell(withIdentifier: YHFormTitleCell.cellReuseIdentifier, for: indexPath) as! YHFormTitleCell
createCorner(cell: cell, arr: arr, indexPath: indexPath)
cell.titleLabel.text = formItem.getTitle() cell.titleLabel.text = formItem.getTitle()
cell.subTitleLabel.text = formItem.getSubTitle() cell.subTitleLabel.text = formItem.getSubTitle()
...@@ -544,7 +532,6 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -544,7 +532,6 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
if item is YHParent || item is YHChild || item is YHSpouse || item is YHBrother { if item is YHParent || item is YHChild || item is YHSpouse || item is YHBrother {
let cell = tableView.dequeueReusableCell(withIdentifier: YHSingleLineSelectCell.cellReuseIdentifier, for: indexPath) as! YHSingleLineSelectCell let cell = tableView.dequeueReusableCell(withIdentifier: YHSingleLineSelectCell.cellReuseIdentifier, for: indexPath) as! YHSingleLineSelectCell
createCorner(cell: cell, arr: arr, indexPath: indexPath)
cell.isShowDeleteBtn = false cell.isShowDeleteBtn = false
cell.deleteBlock = nil cell.deleteBlock = nil
if item is YHChild || item is YHBrother { if item is YHChild || item is YHBrother {
...@@ -559,8 +546,8 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -559,8 +546,8 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
cell.deleteBlock = { [weak self] in cell.deleteBlock = { [weak self] in
if item is YHChild { if item is YHChild {
let childCount = self?.familyMemberInfo?.child?.count ?? 0 let childCount = self?.familyMemberInfo?.child?.count ?? 0
if (indexPath.row < childCount) {
// 因为子女兄妹section第一行都是标题所以row-1 // 因为子女兄妹section第一行都是标题所以row-1
if (indexPath.row-1 < childCount) {
self?.familyMemberInfo?.child?.remove(at: indexPath.row-1) self?.familyMemberInfo?.child?.remove(at: indexPath.row-1)
self?.isChildsEditMode = .none self?.isChildsEditMode = .none
self?.isBrothersEditMode = .none self?.isBrothersEditMode = .none
...@@ -568,8 +555,8 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -568,8 +555,8 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
} else if item is YHBrother { } else if item is YHBrother {
let brotherCount = self?.familyMemberInfo?.brother?.count ?? 0 let brotherCount = self?.familyMemberInfo?.brother?.count ?? 0
if (indexPath.row < brotherCount) {
// 因为子女兄妹section第一行都是标题所以row-1 // 因为子女兄妹section第一行都是标题所以row-1
if (indexPath.row-1 < brotherCount) {
self?.familyMemberInfo?.brother?.remove(at: indexPath.row-1) self?.familyMemberInfo?.brother?.remove(at: indexPath.row-1)
self?.isChildsEditMode = .none self?.isChildsEditMode = .none
self?.isBrothersEditMode = .none self?.isBrothersEditMode = .none
...@@ -582,24 +569,48 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -582,24 +569,48 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
return cell return cell
} }
// 新增子女/兄弟姐妹
if item is YHFormAddItem {
let formItem = item as! YHFormAddItem
if formItem.type == .addChild || formItem.type == .addBrother {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormAddInfoCell.cellReuseIdentifier, for: indexPath) as! YHFormAddInfoCell
cell.clickBlock = { [weak self] in
if formItem.type == .addBrother {
self?.addBrother()
} else if formItem.type == .addChild {
self?.addChild()
}
}
return cell
}
}
let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell", for: indexPath) let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell", for: indexPath)
createCorner(cell: cell, arr: arr, indexPath: indexPath)
return cell return cell
} }
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.section >= items.count { return }
let arr:[YHFormItemProtocol] = items[indexPath.section]
if indexPath.row >= arr.count { return }
createCorner(cell: cell, arr: arr, indexPath: indexPath)
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let arr = items[indexPath.section] let arr = items[indexPath.section]
let item:YHFamilyMemberProtocol = arr[indexPath.row] let item:YHFormItemProtocol = arr[indexPath.row]
if item is YHFamilyMemberFormItem { // 是标题或添加项目 if item is YHFormTitleItem { // 是标题
let titleItem = item as! YHFamilyMemberFormItem
if titleItem.type == .addChild || titleItem.type == .addBrother {
return 77.0
}
return 52.0 return 52.0
} else if item is YHFormAddItem { // 新增子女兄妹
return 70.0
} }
return 64.0 return 50.0
} }
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
...@@ -612,9 +623,13 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -612,9 +623,13 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let spouse = familyMemberInfo?.spouse {
let vc = YHSpouseFormVC() let vc = YHSpouseFormVC()
vc.spouse = spouse
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
}
func createCorner(cell:UITableViewCell, arr:Array<Any>, indexPath:IndexPath) { func createCorner(cell:UITableViewCell, arr:Array<Any>, indexPath:IndexPath) {
// 设置每块section圆角 // 设置每块section圆角
......
...@@ -10,7 +10,9 @@ import UIKit ...@@ -10,7 +10,9 @@ import UIKit
class YHSpouseFormVC: YHBaseViewController { class YHSpouseFormVC: YHBaseViewController {
lazy var items:[YHTableItemInfo] = [YHTableItemInfo]() var spouse:YHSpouse?
lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
...@@ -19,6 +21,7 @@ class YHSpouseFormVC: YHBaseViewController { ...@@ -19,6 +21,7 @@ class YHSpouseFormVC: YHBaseViewController {
if #available(iOS 11.0, *) { if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never tableView.contentInsetAdjustmentBehavior = .never
} }
tableView.showsVerticalScrollIndicator = false
tableView.backgroundColor = .clear tableView.backgroundColor = .clear
tableView.separatorStyle = .none tableView.separatorStyle = .none
tableView.delegate = self tableView.delegate = self
...@@ -58,19 +61,48 @@ class YHSpouseFormVC: YHBaseViewController { ...@@ -58,19 +61,48 @@ class YHSpouseFormVC: YHBaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
gk_navTitle = "配偶信息填写".local
createUI() createUI()
loadData() loadSponseInfo()
}
func loadSponseInfo() {
} guard let spouse = spouse else { return }
items.removeAll()
// 随行
let title0 = YHFormTitleItem(type: .accompany)
let item0 = YHFormDetailItem(type: .accompany)
item0.isAccompany = (spouse.follow == 1)
let arr0:[YHFormItemProtocol] = [title0, item0]
items.append(arr0)
func loadData() { if item0.isAccompany { // 随行才加后面的信息
// 国籍
let title1 = YHFormTitleItem(type: .country)
let item10 = YHFormDetailItem(type: .country)
item10.country = "中国"
let arr1:[YHFormItemProtocol] = [title1, item10]
// 居住信息
let title2 = YHFormTitleItem(type: .liveInfo)
let item20 = YHFormDetailItem(type: .isLiveTother)
let item21 = YHFormDetailItem(type: .liveContry)
let item22 = YHFormDetailItem(type: .liveCity)
let item23 = YHFormDetailItem(type: .detailAddress)
let arr2:[YHFormItemProtocol] = [title2, item20, item21, item22, item23]
// 港澳通信证
let title3 = YHFormTitleItem(type: .hkPassport)
let item30 = YHFormDetailItem(type: .hkPassport)
let arr3:[YHFormItemProtocol] = [title3, item30]
items.append(contentsOf:[arr1, arr2, arr3])
}
let item1 = YHTableItemInfo(type: .accompany)
let item2 = YHTableItemInfo(type: .country)
let item3 = YHTableItemInfo(type: .address)
let item4 = YHTableItemInfo(type: .hongkongMacaouPassport)
items.append(contentsOf: [item1, item2, item3, item4])
tableView.reloadData() tableView.reloadData()
} }
...@@ -126,74 +158,106 @@ extension YHSpouseFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -126,74 +158,106 @@ extension YHSpouseFormVC : UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section >= items.count { return 0 } if section >= items.count { return 0 }
let item:YHTableItemInfo = items[section] let arr = items[section]
return item.getSubItems().count return arr.count
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section >= items.count { return UITableViewCell() } if indexPath.section >= items.count { return createDefaultCell(indexPath) }
let arr:[YHFormItemProtocol] = items[indexPath.section]
if indexPath.row >= arr.count { return createDefaultCell(indexPath) }
let item:YHTableItemInfo = items[indexPath.section]
if indexPath.row >= item.getSubItems().count { return UITableViewCell() }
let item:YHFormItemProtocol = arr[indexPath.row]
let subItem:YHTableSubItemInfo = item.getSubItems()[indexPath.row] if item is YHFormTitleItem { // 标题
switch subItem.type {
case .subTitle:
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormTitleCell.cellReuseIdentifier, for: indexPath) as! YHFormTitleCell let cell = tableView.dequeueReusableCell(withIdentifier: YHFormTitleCell.cellReuseIdentifier, for: indexPath) as! YHFormTitleCell
createCorner(cell: cell, indexPath: indexPath) cell.titleLabel.text = item.getTitle()
cell.titleLabel.text = item.title
return cell return cell
case .subAcompany: } else if item is YHFormDetailItem { // 具体信息
let detailItem = item as! YHFormDetailItem
if detailItem.type == .accompany || detailItem.type == .hkPassport {
let cell = tableView.dequeueReusableCell(withIdentifier: YHDoubleChoiceFormCell.cellReuseIdentifier, for: indexPath) as! YHDoubleChoiceFormCell let cell = tableView.dequeueReusableCell(withIdentifier: YHDoubleChoiceFormCell.cellReuseIdentifier, for: indexPath) as! YHDoubleChoiceFormCell
createCorner(cell: cell, indexPath: indexPath) cell.title = detailItem.getTitle()
cell.question = subItem.title
return cell
case .subCountry: if detailItem.type == .accompany {
let cell = tableView.dequeueReusableCell(withIdentifier: YHSingleLineSelectCell.cellReuseIdentifier, for: indexPath) as! YHSingleLineSelectCell cell.response = detailItem.isAccompany
createCorner(cell: cell, indexPath: indexPath) } else if detailItem.type == .hkPassport {
cell.isMust = subItem.isMust
cell.title = subItem.title }
cell.responseBlock = {
[weak self] choice in
if detailItem.type == .accompany {
self?.spouse?.follow = (choice ? 1 : 0)
self?.loadSponseInfo()
} else if detailItem.type == .hkPassport {
}
}
return cell return cell
case .subIsLiveTogether, .subHongkongMacaouPassport: } else if detailItem.type == .isLiveTother || detailItem.isHongKongMacouPassport {
let cell = tableView.dequeueReusableCell(withIdentifier: YHDoubleChoiceFormCell.cellReuseIdentifier, for: indexPath) as! YHDoubleChoiceFormCell let cell = tableView.dequeueReusableCell(withIdentifier: YHDoubleChoiceFormCell.cellReuseIdentifier, for: indexPath) as! YHDoubleChoiceFormCell
createCorner(cell: cell, indexPath: indexPath) cell.title = detailItem.getTitle()
cell.question = subItem.title
return cell return cell
case .subLiveNation, .subLiveCity, .subDetailAddress: } else if detailItem.type == .country || detailItem.type == .liveContry || detailItem.type == .liveCity || detailItem.type == .detailAddress {
let cell = tableView.dequeueReusableCell(withIdentifier: YHSingleLineSelectCell.cellReuseIdentifier, for: indexPath) as! YHSingleLineSelectCell let cell = tableView.dequeueReusableCell(withIdentifier: YHSingleLineSelectCell.cellReuseIdentifier, for: indexPath) as! YHSingleLineSelectCell
createCorner(cell: cell, indexPath: indexPath) cell.isMust = detailItem.isNeed
cell.isMust = subItem.isMust cell.title = detailItem.getTitle()
cell.title = subItem.title
return cell return cell
}
}
return createDefaultCell(indexPath)
} }
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.section >= items.count { return }
let arr:[YHFormItemProtocol] = items[indexPath.section]
if indexPath.row >= arr.count { return }
createCorner(cell: cell, arr: arr, indexPath: indexPath)
}
func createDefaultCell(_ indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell", for: indexPath) let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell", for: indexPath)
createCorner(cell: cell, indexPath: indexPath)
return cell return cell
} }
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section >= items.count { return 0 } if indexPath.section >= items.count { return 0.0 }
let item:YHTableItemInfo = items[indexPath.section] let arr:[YHFormItemProtocol] = items[indexPath.section]
if indexPath.row >= arr.count { return 0.0 }
if indexPath.row >= item.getSubItems().count { return 0 } let item = arr[indexPath.row]
let subItem = item.getSubItems()[indexPath.row]
if subItem.type == .subIsLiveTogether || if item is YHFormTitleItem { // 标题
subItem.type == .subAcompany || return 52.0
subItem.type == .subHongkongMacaouPassport }
{ return UITableView.automaticDimension }
if item is YHFormDetailItem {
let detailItem = item as! YHFormDetailItem
if detailItem.type == .isLiveTother ||
detailItem.type == .accompany ||
detailItem.type == .hkPassport
{
return UITableView.automaticDimension
}
}
return 52.0 return 52.0
} }
...@@ -210,13 +274,15 @@ extension YHSpouseFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -210,13 +274,15 @@ extension YHSpouseFormVC : UITableViewDelegate, UITableViewDataSource {
} }
func createCorner(cell:UITableViewCell, indexPath:IndexPath) { func createCorner(cell:UITableViewCell, arr:Array<Any>, indexPath:IndexPath) {
// 复用时需清理
cell.layer.mask = nil
// 设置每块section圆角 // 设置每块section圆角
if (indexPath.row == 0) { if (indexPath.row == 0) {
let corner = UIRectCorner(rawValue: UIRectCorner.topLeft.rawValue | UIRectCorner.topRight.rawValue) let corner = UIRectCorner(rawValue: UIRectCorner.topLeft.rawValue | UIRectCorner.topRight.rawValue)
cell.createCorner(CGSizeMake(12.0, 12.0), corner) cell.createCorner(CGSizeMake(12.0, 12.0), corner)
} else if (indexPath.row == 2) { } else if (indexPath.row == arr.count-1) {
let corner = UIRectCorner(rawValue: UIRectCorner.bottomLeft.rawValue | UIRectCorner.bottomRight.rawValue) let corner = UIRectCorner(rawValue: UIRectCorner.bottomLeft.rawValue | UIRectCorner.bottomRight.rawValue)
cell.createCorner(CGSizeMake(12.0, 12.0), corner) cell.createCorner(CGSizeMake(12.0, 12.0), corner)
......
...@@ -108,22 +108,7 @@ class YHTableSubItemInfo { ...@@ -108,22 +108,7 @@ class YHTableSubItemInfo {
// 是否必填 // 是否必填
var isMust:Bool var isMust:Bool
// 是否随行
var isAccompany:Bool = false
// 港澳通信证
var isHongKongMacouPassport:Bool = false
// 国籍
var nation:String? = ""
/** 居住信息 **/
// 是否与主申请人同住
var isLiveTogether:Bool = false
// 现居住国家
var liveContry:String? = ""
// 现居住城市
var liveCity:String? = ""
// 现居住详细地址
var liveAddress:String? = ""
var title:String { var title:String {
return getTitle() return getTitle()
......
...@@ -9,28 +9,75 @@ ...@@ -9,28 +9,75 @@
import UIKit import UIKit
import SmartCodable import SmartCodable
enum YHFamilyMemberItemType:Int { protocol YHFormItemProtocol {
func getTitle() -> String
func getSubTitle() -> String
}
// 表单标题类型
enum YHFormTitleItemType:Int {
case sponse = 1 case sponse = 1
case parent = 2 case parent = 2
case child = 3 case child = 3
case brother = 4 case brother = 4
case addChild = 5
case addBrother = 6 case accompany = 5
case country = 6
case liveInfo = 7
case hkPassport = 8
} }
// 表单添加条目类型
enum YHFormAddItemType:Int {
protocol YHFamilyMemberProtocol { case addChild = 1
case addBrother = 2
}
func getTitle() -> String // 表单具体条目类型
func getSubTitle() -> String enum YHFormDetailItemType:Int {
case accompany = 1
case country = 2
case isLiveTother = 3
case liveContry = 4
case liveCity = 5
case detailAddress = 6
case hkPassport = 7
}
//添加item
class YHFormAddItem : YHFormItemProtocol
{
var type: YHFormAddItemType
init(type: YHFormAddItemType) {
self.type = type
}
func getTitle() -> String {
switch self.type {
case .addChild:
return "新增子女".local
case .addBrother:
return "新增兄弟姐妹".local
}
}
func getSubTitle() -> String {
return ""
}
} }
class YHFamilyMemberFormItem : YHFamilyMemberProtocol {
var type: YHFamilyMemberItemType // 标题item
class YHFormTitleItem : YHFormItemProtocol {
var type: YHFormTitleItemType
init(type: YHFamilyMemberItemType) { init(type: YHFormTitleItemType) {
self.type = type self.type = type
} }
...@@ -44,10 +91,14 @@ class YHFamilyMemberFormItem : YHFamilyMemberProtocol { ...@@ -44,10 +91,14 @@ class YHFamilyMemberFormItem : YHFamilyMemberProtocol {
return "兄弟姐妹".local return "兄弟姐妹".local
case .child: case .child:
return "子女".local return "子女".local
case .addChild: case .accompany:
return "新增子女".local return "随行".local
case .addBrother: case .country:
return "新增兄弟姐妹".local return "国籍".local
case .liveInfo:
return "居住信息".local
case .hkPassport:
return "港澳通行证".local
} }
} }
...@@ -61,14 +112,71 @@ class YHFamilyMemberFormItem : YHFamilyMemberProtocol { ...@@ -61,14 +112,71 @@ class YHFamilyMemberFormItem : YHFamilyMemberProtocol {
return String(format: "(%@)", "如无可不填".local) return String(format: "(%@)", "如无可不填".local)
case .child: case .child:
return String(format: "(%@)", "如无可不填".local) return String(format: "(%@)", "如无可不填".local)
case .addChild: case .accompany:
return "" return "".local
case .addBrother: case .country:
return "" return "".local
case .liveInfo:
return "".local
case .hkPassport:
return "".local
} }
} }
} }
// 具体item
class YHFormDetailItem : YHFormItemProtocol {
var type: YHFormDetailItemType
// 是否是必填项
var isNeed: Bool = true
// 是否随行
var isAccompany:Bool = false
// 港澳通信证
var isHongKongMacouPassport:Bool = false
// 国籍
var country:String? = ""
/** 居住信息 **/
// 是否与主申请人同住
var isLiveTogether:Bool = false
// 现居住国家
var liveContry:String? = ""
// 现居住城市
var liveCity:String? = ""
// 现居住详细地址
var liveAddress:String? = ""
init(type: YHFormDetailItemType) {
self.type = type
}
func getTitle() -> String {
switch type {
case .accompany:
return "是否随行至香港".local
case .country:
return String(format: "%@/%@", "国家".local, "地区".local)
case .isLiveTother:
return "是否与主申请人同住".local
case .liveContry:
return String(format: "%@/%@", "国家".local, "地区".local)
case .liveCity:
return String(format: "%@/%@", "国家".local, "地区".local)
case .detailAddress:
return "详细地址".local
case .hkPassport:
return "是否办理".local
}
}
func getSubTitle() -> String {
return ""
}
}
/* ***** ***** ***** ***** ***** ***** ***** ***** */ /* ***** ***** ***** ***** ***** ***** ***** ***** */
// MARK: - YHWelcome // MARK: - YHWelcome
...@@ -112,7 +220,7 @@ class YHFamilyMemberInfo: SmartCodable { ...@@ -112,7 +220,7 @@ class YHFamilyMemberInfo: SmartCodable {
} }
// MARK: - 子女初始信息 YHChild // MARK: - 子女初始信息 YHChild
class YHChild: SmartCodable, YHFamilyMemberProtocol { class YHChild: SmartCodable, YHFormItemProtocol {
var id: Int = -1 var id: Int = -1
var deceased: Int = -1 var deceased: Int = -1
...@@ -209,7 +317,7 @@ class YHChild: SmartCodable, YHFamilyMemberProtocol { ...@@ -209,7 +317,7 @@ class YHChild: SmartCodable, YHFamilyMemberProtocol {
} }
// MARK: - YHBrother // MARK: - YHBrother
class YHBrother: SmartCodable, YHFamilyMemberProtocol { class YHBrother: SmartCodable, YHFormItemProtocol {
var id: Int? = -1 var id: Int? = -1
var deceased: Int? = -1 var deceased: Int? = -1
var custody: Int? = -1 var custody: Int? = -1
...@@ -354,7 +462,7 @@ class YHSubsetNamePinyin: SmartCodable { ...@@ -354,7 +462,7 @@ class YHSubsetNamePinyin: SmartCodable {
} }
// MARK: - 父母信息 YHParent // MARK: - 父母信息 YHParent
class YHParent: SmartCodable, YHFamilyMemberProtocol { class YHParent: SmartCodable, YHFormItemProtocol {
var id: Int = -1 var id: Int = -1
var deceased: Int = -1 var deceased: Int = -1
var custody: Int = -1 var custody: Int = -1
...@@ -451,7 +559,7 @@ class YHParent: SmartCodable, YHFamilyMemberProtocol { ...@@ -451,7 +559,7 @@ class YHParent: SmartCodable, YHFamilyMemberProtocol {
} }
// MARK: - 配偶 YHSpouse // MARK: - 配偶 YHSpouse
class YHSpouse: SmartCodable, YHFamilyMemberProtocol { class YHSpouse: SmartCodable, YHFormItemProtocol {
var id: Int = -1 var id: Int = -1
var deceased: Int = -1 var deceased: Int = -1
var custody: Int = -1 var custody: Int = -1
......
...@@ -16,13 +16,15 @@ class YHDoubleChoiceFormCell: UITableViewCell { ...@@ -16,13 +16,15 @@ class YHDoubleChoiceFormCell: UITableViewCell {
let btnTitleSelectColor = UIColor(hex: 0x4487F9) let btnTitleSelectColor = UIColor(hex: 0x4487F9)
let btnTitleDefaultColor = UIColor(hex:0x222222) let btnTitleDefaultColor = UIColor(hex:0x222222)
let btnBgColor = UIColor(hex:0xF8F9FB) let btnBgColor = UIColor(hex:0xF8F9FB)
let confirmTag = 9527 let negativeTag = 9527
let negativeTag = 9528 let confirmTag = 9528
var question:String? { var responseBlock:((Bool)->Void)?
var title:String? {
didSet { didSet {
if let question = question { if let question = title {
let str = "*"+question let str = "*"+question
let attributes: [NSAttributedString.Key: Any] = [ let attributes: [NSAttributedString.Key: Any] = [
.font: UIFont.PFSCR(ofSize: 14), .font: UIFont.PFSCR(ofSize: 14),
...@@ -31,13 +33,19 @@ class YHDoubleChoiceFormCell: UITableViewCell { ...@@ -31,13 +33,19 @@ class YHDoubleChoiceFormCell: UITableViewCell {
let questionAttrStr = NSMutableAttributedString(string: str, attributes: attributes) let questionAttrStr = NSMutableAttributedString(string: str, attributes: attributes)
let starRange = NSRange(location: 0, length: 1) let starRange = NSRange(location: 0, length: 1)
questionAttrStr.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor(hex:0xFF3A3A), range: starRange) questionAttrStr.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor(hex:0xFF3A3A), range: starRange)
questionLabel.attributedText = questionAttrStr titleLabel.attributedText = questionAttrStr
} }
} }
} }
lazy var questionLabel: UILabel = { var response:Bool = false {
didSet {
showResponse(response)
}
}
lazy var titleLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.textColor = UIColor(hexString:"#333333") label.textColor = UIColor(hexString:"#333333")
label.textAlignment = .left label.textAlignment = .left
...@@ -82,15 +90,15 @@ class YHDoubleChoiceFormCell: UITableViewCell { ...@@ -82,15 +90,15 @@ class YHDoubleChoiceFormCell: UITableViewCell {
self.selectionStyle = .none self.selectionStyle = .none
question = " 1、是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪? " title = " 1、是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪? "
contentView.addSubview(questionLabel) contentView.addSubview(titleLabel)
contentView.addSubview(negativeBtn) contentView.addSubview(negativeBtn)
contentView.addSubview(confirmBtn) contentView.addSubview(confirmBtn)
// 默认选择否按钮 // 默认选择否按钮
didClickResponseBtn(btn: negativeBtn) response = false
questionLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.top.equalTo(contentView.snp.top).offset(22) make.top.equalTo(contentView.snp.top).offset(22)
make.left.equalToSuperview().offset(16) make.left.equalToSuperview().offset(16)
make.right.equalTo(confirmBtn.snp.left).offset(-8) make.right.equalTo(confirmBtn.snp.left).offset(-8)
...@@ -111,13 +119,16 @@ class YHDoubleChoiceFormCell: UITableViewCell { ...@@ -111,13 +119,16 @@ class YHDoubleChoiceFormCell: UITableViewCell {
} }
@objc func didClickResponseBtn(btn: UIButton) { @objc func didClickResponseBtn(btn: UIButton) {
let isConfirm = (btn.tag == confirmTag) response = (btn.tag == confirmTag)
if let responseBlock = responseBlock {
responseBlock(btn.tag==confirmTag)
}
}
func showResponse(_ isConfirm: Bool) {
confirmBtn.layer.borderColor = (isConfirm ? btnTitleSelectColor : .clear).cgColor confirmBtn.layer.borderColor = (isConfirm ? btnTitleSelectColor : .clear).cgColor
confirmBtn.setTitleColor((isConfirm ? btnTitleSelectColor : btnTitleDefaultColor), for: .normal) confirmBtn.setTitleColor((isConfirm ? btnTitleSelectColor : btnTitleDefaultColor), for: .normal)
negativeBtn.layer.borderColor = (isConfirm ? .clear : btnTitleSelectColor).cgColor negativeBtn.layer.borderColor = (isConfirm ? .clear : btnTitleSelectColor).cgColor
negativeBtn.setTitleColor((isConfirm ? btnTitleDefaultColor: btnTitleSelectColor), for: .normal) negativeBtn.setTitleColor((isConfirm ? btnTitleDefaultColor: btnTitleSelectColor), for: .normal)
} }
} }
...@@ -14,7 +14,7 @@ class YHFormTitleCell: UITableViewCell { ...@@ -14,7 +14,7 @@ class YHFormTitleCell: UITableViewCell {
let editTag = 9527 let editTag = 9527
let cancelTag = 9528 let cancelTag = 9528
var rightClickBlock:((YHFamilyMemberEditType)->Void)? var rightClickBlock:((YHFormTitleItemEditType)->Void)?
lazy var titleLabel: UILabel = { lazy var titleLabel: UILabel = {
...@@ -111,7 +111,7 @@ class YHFormTitleCell: UITableViewCell { ...@@ -111,7 +111,7 @@ class YHFormTitleCell: UITableViewCell {
} }
} }
func showEditType(type: YHFamilyMemberEditType) { func showEditType(type: YHFormTitleItemEditType) {
switch type { switch type {
case .none: case .none:
cancelButton.isHidden = true cancelButton.isHidden = 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