Commit 1c48dd7d authored by Steven杜宇's avatar Steven杜宇

配偶信息填写

parent 54ab7e63
......@@ -20,7 +20,7 @@ class YHFamilyMemberFormVC: YHBaseViewController {
var isChildsEditMode: YHFamilyMemberEditType = .none
var isBrothersEditMode: YHFamilyMemberEditType = .none
var items:[[YHFamilyMemberProtocol]] = []
var items:[[YHFormItemProtocol]] = []
lazy var tableView: UITableView = {
......@@ -29,6 +29,7 @@ class YHFamilyMemberFormVC: YHBaseViewController {
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.showsVerticalScrollIndicator = false
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.delegate = self
......@@ -59,7 +60,7 @@ class YHFamilyMemberFormVC: YHBaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.gk_navTitle = "家庭成员信息填写"
self.gk_navTitle = "家庭成员信息填写".local
view.backgroundColor = UIColor(hexString:"#F8F8F8")
createUI()
loadData()
......@@ -274,12 +275,12 @@ class YHFamilyMemberFormVC: YHBaseViewController {
// 配偶section
if let sponse = familyMemberInfo?.spouse {
let sponseArray:[YHFamilyMemberProtocol] = [YHFamilyMemberFormItem(type: .sponse), sponse]
let sponseArray:[YHFormItemProtocol] = [YHFormTitleItem(type: .sponse), sponse]
items.append(sponseArray)
}
// 父母section
var parents = [YHFamilyMemberProtocol]()
var parents = [YHFormItemProtocol]()
if let father = familyMemberInfo?.father {
parents.append(father)
}
......@@ -287,20 +288,20 @@ class YHFamilyMemberFormVC: YHBaseViewController {
parents.append(mother)
}
if !parents.isEmpty {
let item0 = YHFamilyMemberFormItem(type: .parent)
let item0 = YHFormTitleItem(type: .parent)
parents.insert(item0, at: 0)
items.append(parents)
}
// 子女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 {
childArr.insert(contentsOf: childs, at:1)
}
items.append(childArr)
// 兄妹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 {
brotherArr.insert(contentsOf: brothers, at:1)
}
......@@ -486,27 +487,14 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
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
if formItem.type == .addChild || formItem.type == .addBrother { // 新增子女/兄弟姐妹
let formItem = item as! YHFormTitleItem
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
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormTitleCell.cellReuseIdentifier, for: indexPath) as! YHFormTitleCell
createCorner(cell: cell, arr: arr, indexPath: indexPath)
cell.titleLabel.text = formItem.getTitle()
cell.subTitleLabel.text = formItem.getSubTitle()
......@@ -544,7 +532,6 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
if item is YHParent || item is YHChild || item is YHSpouse || item is YHBrother {
let cell = tableView.dequeueReusableCell(withIdentifier: YHSingleLineSelectCell.cellReuseIdentifier, for: indexPath) as! YHSingleLineSelectCell
createCorner(cell: cell, arr: arr, indexPath: indexPath)
cell.isShowDeleteBtn = false
cell.deleteBlock = nil
if item is YHChild || item is YHBrother {
......@@ -559,8 +546,8 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
cell.deleteBlock = { [weak self] in
if item is YHChild {
let childCount = self?.familyMemberInfo?.child?.count ?? 0
if (indexPath.row < childCount) {
// 因为子女兄妹section第一行都是标题所以row-1
if (indexPath.row-1 < childCount) {
self?.familyMemberInfo?.child?.remove(at: indexPath.row-1)
self?.isChildsEditMode = .none
self?.isBrothersEditMode = .none
......@@ -568,8 +555,8 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
} else if item is YHBrother {
let brotherCount = self?.familyMemberInfo?.brother?.count ?? 0
if (indexPath.row < brotherCount) {
// 因为子女兄妹section第一行都是标题所以row-1
if (indexPath.row-1 < brotherCount) {
self?.familyMemberInfo?.brother?.remove(at: indexPath.row-1)
self?.isChildsEditMode = .none
self?.isBrothersEditMode = .none
......@@ -582,24 +569,48 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
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)
createCorner(cell: cell, arr: arr, indexPath: indexPath)
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 {
let arr = items[indexPath.section]
let item:YHFamilyMemberProtocol = arr[indexPath.row]
let item:YHFormItemProtocol = arr[indexPath.row]
if item is YHFamilyMemberFormItem { // 是标题或添加项目
let titleItem = item as! YHFamilyMemberFormItem
if titleItem.type == .addChild || titleItem.type == .addBrother {
return 77.0
}
if item is YHFormTitleItem { // 是标题
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? {
......
......@@ -10,7 +10,8 @@ import UIKit
class YHSpouseFormVC: YHBaseViewController {
lazy var items:[YHTableItemInfo] = [YHTableItemInfo]()
var sponseInfo:YHSpouse?
lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
lazy var tableView: UITableView = {
......@@ -19,6 +20,7 @@ class YHSpouseFormVC: YHBaseViewController {
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.showsVerticalScrollIndicator = false
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.delegate = self
......@@ -58,19 +60,18 @@ class YHSpouseFormVC: YHBaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
gk_navTitle = "配偶信息填写".local
createUI()
loadData()
loadSponseInfo()
}
func loadData() {
func loadSponseInfo() {
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])
let arr0:[YHFormItemProtocol] = [YHFormTitleItem(type: .accompany), YHFormDetailItem(type: .accompany)]
let arr1:[YHFormItemProtocol] = [YHFormTitleItem(type: .country), YHFormDetailItem(type: .country)]
let arr2:[YHFormItemProtocol] = [YHFormTitleItem(type: .liveInfo),YHFormDetailItem(type: .isLiveTother),YHFormDetailItem(type: .liveContry),YHFormDetailItem(type: .liveCity),YHFormDetailItem(type: .detailAddress)]
let arr3:[YHFormItemProtocol] = [YHFormTitleItem(type: .hkPassport), YHFormDetailItem(type: .hkPassport)]
items.append(contentsOf:[arr0, arr1, arr2, arr3])
tableView.reloadData()
}
......@@ -126,74 +127,91 @@ extension YHSpouseFormVC : UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section >= items.count { return 0 }
let item:YHTableItemInfo = items[section]
return item.getSubItems().count
let arr = items[section]
return arr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section >= items.count { return UITableViewCell() }
let item:YHTableItemInfo = items[indexPath.section]
if indexPath.row >= item.getSubItems().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 subItem:YHTableSubItemInfo = item.getSubItems()[indexPath.row]
let item:YHFormItemProtocol = arr[indexPath.row]
switch subItem.type {
case .subTitle:
if item is YHFormTitleItem { // 标题
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormTitleCell.cellReuseIdentifier, for: indexPath) as! YHFormTitleCell
createCorner(cell: cell, indexPath: indexPath)
cell.titleLabel.text = item.title
// createCorner(cell: cell, arr: arr, indexPath: indexPath)
cell.titleLabel.text = item.getTitle()
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
createCorner(cell: cell, indexPath: indexPath)
cell.question = subItem.title
// createCorner(cell: cell, arr: arr,indexPath: indexPath)
cell.question = detailItem.getTitle()
return cell
case .subCountry:
let cell = tableView.dequeueReusableCell(withIdentifier: YHSingleLineSelectCell.cellReuseIdentifier, for: indexPath) as! YHSingleLineSelectCell
createCorner(cell: cell, indexPath: indexPath)
cell.isMust = subItem.isMust
cell.title = subItem.title
return cell
} else if detailItem.type == .isLiveTother || detailItem.isHongKongMacouPassport {
case .subIsLiveTogether, .subHongkongMacaouPassport:
let cell = tableView.dequeueReusableCell(withIdentifier: YHDoubleChoiceFormCell.cellReuseIdentifier, for: indexPath) as! YHDoubleChoiceFormCell
createCorner(cell: cell, indexPath: indexPath)
cell.question = subItem.title
// createCorner(cell: cell, arr: arr, indexPath: indexPath)
cell.question = detailItem.getTitle()
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
createCorner(cell: cell, indexPath: indexPath)
cell.isMust = subItem.isMust
cell.title = subItem.title
// createCorner(cell: cell, arr: arr, indexPath: indexPath)
cell.isMust = detailItem.isNeed
cell.title = detailItem.getTitle()
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)
createCorner(cell: cell, indexPath: indexPath)
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section >= items.count { return 0 }
let item:YHTableItemInfo = items[indexPath.section]
if indexPath.section >= items.count { return 0.0 }
let arr:[YHFormItemProtocol] = items[indexPath.section]
if indexPath.row >= arr.count { return 0.0 }
if indexPath.row >= item.getSubItems().count { return 0 }
let subItem = item.getSubItems()[indexPath.row]
let item = arr[indexPath.row]
if subItem.type == .subIsLiveTogether ||
subItem.type == .subAcompany ||
subItem.type == .subHongkongMacaouPassport
{ return UITableView.automaticDimension }
if item is YHFormTitleItem { // 标题
return 52.0
}
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
}
......@@ -210,13 +228,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圆角
if (indexPath.row == 0) {
let corner = UIRectCorner(rawValue: UIRectCorner.topLeft.rawValue | UIRectCorner.topRight.rawValue)
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)
cell.createCorner(CGSizeMake(12.0, 12.0), corner)
......
......@@ -108,22 +108,7 @@ class YHTableSubItemInfo {
// 是否必填
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 {
return getTitle()
......
......@@ -9,28 +9,75 @@
import UIKit
import SmartCodable
enum YHFamilyMemberItemType:Int {
protocol YHFormItemProtocol {
func getTitle() -> String
func getSubTitle() -> String
}
// 表单标题类型
enum YHFormTitleItemType:Int {
case sponse = 1
case parent = 2
case child = 3
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
}
......@@ -44,10 +91,14 @@ class YHFamilyMemberFormItem : YHFamilyMemberProtocol {
return "兄弟姐妹".local
case .child:
return "子女".local
case .addChild:
return "新增子女".local
case .addBrother:
return "新增兄弟姐妹".local
case .accompany:
return "随行".local
case .country:
return "国籍".local
case .liveInfo:
return "居住信息".local
case .hkPassport:
return "港澳通行证".local
}
}
......@@ -61,14 +112,71 @@ class YHFamilyMemberFormItem : YHFamilyMemberProtocol {
return String(format: "(%@)", "如无可不填".local)
case .child:
return String(format: "(%@)", "如无可不填".local)
case .addChild:
return ""
case .addBrother:
return ""
case .accompany:
return "".local
case .country:
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 nation: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
......@@ -112,7 +220,7 @@ class YHFamilyMemberInfo: SmartCodable {
}
// MARK: - 子女初始信息 YHChild
class YHChild: SmartCodable, YHFamilyMemberProtocol {
class YHChild: SmartCodable, YHFormItemProtocol {
var id: Int = -1
var deceased: Int = -1
......@@ -209,7 +317,7 @@ class YHChild: SmartCodable, YHFamilyMemberProtocol {
}
// MARK: - YHBrother
class YHBrother: SmartCodable, YHFamilyMemberProtocol {
class YHBrother: SmartCodable, YHFormItemProtocol {
var id: Int? = -1
var deceased: Int? = -1
var custody: Int? = -1
......@@ -354,7 +462,7 @@ class YHSubsetNamePinyin: SmartCodable {
}
// MARK: - 父母信息 YHParent
class YHParent: SmartCodable, YHFamilyMemberProtocol {
class YHParent: SmartCodable, YHFormItemProtocol {
var id: Int = -1
var deceased: Int = -1
var custody: Int = -1
......@@ -451,7 +559,7 @@ class YHParent: SmartCodable, YHFamilyMemberProtocol {
}
// MARK: - 配偶 YHSpouse
class YHSpouse: SmartCodable, YHFamilyMemberProtocol {
class YHSpouse: SmartCodable, YHFormItemProtocol {
var id: Int = -1
var deceased: Int = -1
var custody: Int = -1
......
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