Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
9795615a
Commit
9795615a
authored
Nov 13, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 子女
parent
048c4131
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1292 additions
and
29 deletions
+1292
-29
YHGCChildBasicInfoVC.swift
...ilyMember(家庭成员信息表)/C/Child(子女)/YHGCChildBasicInfoVC.swift
+504
-9
YHGCChildInfoContainerVC.swift
...ember(家庭成员信息表)/C/Child(子女)/YHGCChildInfoContainerVC.swift
+284
-10
YHGCChildPrimaryInfoVC.swift
...yMember(家庭成员信息表)/C/Child(子女)/YHGCChildPrimaryInfoVC.swift
+504
-10
No files found.
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/TTPS(高才)/ServiceProcess(我的信息流程)/FamilyMember(家庭成员信息表)/C/Child(子女)/YHGCChildBasicInfoVC.swift
View file @
9795615a
...
...
@@ -8,23 +8,518 @@
import
UIKit
class
YHGCChildBasicInfoVC
:
YHBaseViewController
{
class
YHGCChildBasicInfoVC
:
YHBaseViewController
,
YHFamilyMemberProtol
{
var
child
:
YHFamilyMember
?
weak
var
delegate
:
YHSpouseInfoVCProtocol
?
var
isNeedShowError
=
false
// 是否随行能编辑
var
isFollowCanEdit
=
true
lazy
var
items
:[[
YHFormItemProtocol
]]
=
[[
YHFormItemProtocol
]]()
lazy
var
tableView
:
UITableView
=
{
let
tableView
=
UITableView
(
frame
:
.
zero
,
style
:
.
grouped
)
if
#available(iOS 11.0, *)
{
tableView
.
contentInsetAdjustmentBehavior
=
.
never
}
tableView
.
estimatedSectionHeaderHeight
=
14.0
tableView
.
estimatedSectionFooterHeight
=
1.0
tableView
.
showsVerticalScrollIndicator
=
false
tableView
.
backgroundColor
=
UIColor
(
hexString
:
"#F8F8F8"
)
tableView
.
separatorStyle
=
.
none
tableView
.
delegate
=
self
tableView
.
dataSource
=
self
tableView
.
register
(
UITableViewCell
.
self
,
forCellReuseIdentifier
:
"UITableViewCell"
)
tableView
.
register
(
YHFormItemDoubleChoiceCell
.
self
,
forCellReuseIdentifier
:
YHFormItemDoubleChoiceCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemInputTextCell
.
self
,
forCellReuseIdentifier
:
YHFormItemInputTextCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemEnterDetailCell
.
self
,
forCellReuseIdentifier
:
YHFormItemEnterDetailCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemTitleCell
.
self
,
forCellReuseIdentifier
:
YHFormItemTitleCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemAddCell
.
self
,
forCellReuseIdentifier
:
YHFormItemAddCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemSelectSheetCell
.
self
,
forCellReuseIdentifier
:
YHFormItemSelectSheetCell
.
cellReuseIdentifier
)
return
tableView
}()
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
gk_navigationBar
.
isHidden
=
true
view
.
backgroundColor
=
UIColor
(
hexString
:
"#F8F8F8"
)
createUI
()
loadInfo
()
}
func
loadInfo
()
{
guard
let
child
=
child
else
{
return
}
items
.
removeAll
()
isFollowCanEdit
=
!
child
.
is18YearsOld
()
// 随行
let
title0
=
YHFormTitleItem
(
type
:
.
accompany
)
let
item00
=
YHFormDetailItem
(
type
:
.
ownCustody
,
value
:
String
(
child
.
isOwnCustody
()))
let
item01
=
YHFormDetailItem
(
type
:
.
birthday
,
value
:
child
.
birthday
,
tips
:
"请选择出生日期"
.
local
)
let
item02
=
YHFormDetailItem
(
type
:
.
isAccompanyToHK
,
value
:
String
(
child
.
isFollow
()))
let
arr0
:[
YHFormItemProtocol
]
=
[
title0
,
item00
,
item01
,
item02
]
items
.
append
(
arr0
)
if
child
.
isFollow
()
{
// 随行才加后面的信息
// 国籍
let
title1
=
YHFormTitleItem
(
type
:
.
nationality
)
let
item10
=
YHFormDetailItem
(
type
:
.
nationOrArea
,
value
:
child
.
nationality
,
tips
:
"请选择国籍"
.
local
)
let
arr1
:[
YHFormItemProtocol
]
=
[
title1
,
item10
]
// 居住信息
let
title2
=
YHFormTitleItem
(
type
:
.
liveInfo
)
let
item20
=
YHFormDetailItem
(
type
:
.
isLiveTother
,
value
:
String
(
child
.
isLiveTother
()))
var
arr2
:
[
YHFormItemProtocol
]
=
[
title2
,
item20
]
if
!
child
.
isLiveTother
()
{
// 不同住 才需填写国家/地区
let
item21
=
YHFormDetailItem
(
type
:
.
nationOrArea
,
value
:
child
.
address
.
country
,
tips
:
"请选择国家/地区"
.
local
)
arr2
.
append
(
item21
)
// 国家/地区已填写 才显示现居住城市和详细地址两行
if
!
child
.
address
.
country
.
isEmpty
{
// 居住信息中选择中国才会显示现居住城市
let
isLiveInChina
=
child
.
address
.
country
.
contains
(
"中国"
.
local
)
if
isLiveInChina
{
var
value
=
""
if
!
child
.
address
.
area
.
isEmpty
{
value
=
child
.
address
.
area
.
joined
(
separator
:
","
)
}
let
item22
=
YHFormDetailItem
(
type
:
.
liveCity
,
value
:
value
,
tips
:
"请选择现居住城市"
.
local
)
arr2
.
append
(
item22
)
}
let
placeHolder
=
(
isLiveInChina
?
"请填写小区、楼栋、单元室等"
.
local
:
"请填写国外居住地"
.
local
)
let
detailAddress
=
isLiveInChina
?
child
.
address
.
details
:
child
.
address
.
foreign
let
item23
=
YHFormDetailItem
(
type
:
.
detailAddress
,
value
:
detailAddress
,
placeHolder
:
placeHolder
,
tips
:
placeHolder
)
arr2
.
append
(
item23
)
if
!
isLiveInChina
{
// 在国外
// 是否在海外居住满1年及以上
let
item24
=
YHFormDetailItem
(
type
:
.
isLiveOverSeasMore1Year
,
value
:
String
(
child
.
isOverSeasOver1Year
()))
arr2
.
append
(
item24
)
}
}
}
// 港澳通信证
let
title3
=
YHFormTitleItem
(
type
:
.
hkAndMacaoPassport
)
let
item30
=
YHFormDetailItem
(
type
:
.
isHandleHKPassPort
,
value
:
String
(
child
.
isNeedHandleHKPassPort
()))
let
arr3
:[
YHFormItemProtocol
]
=
[
title3
,
item30
]
items
.
append
(
contentsOf
:[
arr1
,
arr2
,
arr3
])
}
tableView
.
reloadData
()
}
func
createUI
()
{
view
.
addSubview
(
tableView
);
let
topHeight
=
k_Height_NavigationtBarAndStatuBar
+
YHStepView
.
height
let
bottomHeight
=
YHSaveAndSubmitView
.
height
tableView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
offset
(
16
)
make
.
right
.
equalToSuperview
()
.
offset
(
-
16
)
make
.
height
.
equalTo
(
KScreenHeight
-
topHeight
-
bottomHeight
)
}
}
func
getCellType
(
_
item
:
Any
)
->
HKFormItemCellType
{
if
item
is
YHFormTitleItem
{
return
.
title
}
if
item
is
YHFormDetailItem
{
let
detailItem
=
item
as!
YHFormDetailItem
if
detailItem
.
type
==
.
birthCity
{
var
isBirthOverSeas
=
false
if
let
child
=
child
{
isBirthOverSeas
=
child
.
isBirthOverSeas
()
}
if
isBirthOverSeas
{
return
.
inputText
}
else
{
return
.
selectSheet
}
}
if
detailItem
.
type
==
.
detailAddress
{
return
.
inputText
}
if
detailItem
.
type
==
.
nationOrArea
||
detailItem
.
type
==
.
nationOrArea
||
detailItem
.
type
==
.
liveCity
||
detailItem
.
type
==
.
birthday
{
return
.
selectSheet
}
if
detailItem
.
type
==
.
isAccompanyToHK
||
detailItem
.
type
==
.
isHandleHKPassPort
||
detailItem
.
type
==
.
ownCustody
||
detailItem
.
type
==
.
isLiveTother
||
detailItem
.
type
==
.
isLiveOverSeasMore1Year
{
return
.
twoChoice
}
}
return
.
defaultType
}
}
extension
YHGCChildBasicInfoVC
:
UITableViewDelegate
,
UITableViewDataSource
{
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
return
items
.
count
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
if
section
>=
items
.
count
{
return
0
}
let
arr
=
items
[
section
]
return
arr
.
count
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
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
:
YHFormItemProtocol
=
arr
[
indexPath
.
row
]
if
item
is
YHFormTitleItem
{
// 标题
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHFormItemTitleCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHFormItemTitleCell
cell
.
setTitleAndSubTitle
(
title
:
item
.
getTitle
())
return
cell
}
else
if
item
is
YHFormDetailItem
{
// 具体信息
let
detailItem
=
item
as!
YHFormDetailItem
let
cellType
=
self
.
getCellType
(
detailItem
)
if
cellType
==
.
twoChoice
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHFormItemDoubleChoiceCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHFormItemDoubleChoiceCell
cell
.
isMust
=
detailItem
.
isNeed
cell
.
title
=
detailItem
.
getTitle
()
cell
.
enableEdit
=
true
cell
.
disableEditTips
=
nil
var
select
=
false
if
let
value
=
detailItem
.
value
{
select
=
Bool
(
value
)
!
}
if
detailItem
.
type
==
.
isAccompanyToHK
,
let
child
=
child
,
child
.
is18YearsOld
()
{
// 是否随行至香港
// 年满18岁不能随行 随行按钮不可编辑固定为否
cell
.
enableEdit
=
isFollowCanEdit
cell
.
disableEditTips
=
"年满十八岁的子女不能随行至香港"
}
let
answers
=
[
YHFormChoiceItem
(
title
:
"是"
.
local
,
isSelect
:
select
),
YHFormChoiceItem
(
title
:
"否"
.
local
,
isSelect
:
!
select
)]
cell
.
answerArr
=
answers
cell
.
answerBlock
=
{
[
weak
self
]
(
arr
,
selectIndex
)
in
let
selectItem
:
YHFormChoiceItem
=
arr
[
selectIndex
]
let
option
=
(
selectItem
.
title
==
"是"
.
local
?
true
:
false
)
guard
let
self
=
self
else
{
return
}
if
detailItem
.
type
==
.
isAccompanyToHK
{
// 是否随行
self
.
child
?
.
setFollow
(
option
)
if
let
delegate
=
delegate
,
delegate
.
responds
(
to
:
#selector(
YHSpouseInfoVCProtocol.updateStepView
)
)
{
delegate
.
updateStepView
()
}
}
else
if
detailItem
.
type
==
.
isHandleHKPassPort
{
// 是否办理港澳通行证
self
.
child
?
.
setNeedHandleHKPassPort
(
option
)
}
else
if
detailItem
.
type
==
.
isLiveTother
{
// 是否与主申请人同住
self
.
child
?
.
setLiveTother
(
option
)
if
option
{
self
.
child
?
.
address
.
clearAddress
()
}
}
else
if
detailItem
.
type
==
.
isLiveOverSeasMore1Year
{
// 是否在海外居住满1年及以上
self
.
child
?
.
setOverSearsOver1Year
(
option
)
}
else
if
detailItem
.
type
==
.
ownCustody
{
// 抚养权
self
.
child
?
.
setOwnCustody
(
option
)
}
self
.
loadInfo
()
save
()
}
return
cell
}
else
if
cellType
==
.
selectSheet
{
// 选择列表面板
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHFormItemSelectSheetCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHFormItemSelectSheetCell
cell
.
isMust
=
detailItem
.
isNeed
cell
.
title
=
detailItem
.
getTitle
()
cell
.
detail
=
detailItem
.
value
cell
.
setTips
(
detailItem
.
tips
,
isShow
:
isNeedShowError
&&
detailItem
.
isShowTips
)
return
cell
}
else
if
cellType
==
.
inputText
{
// 输入文字cell
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHFormItemInputTextCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHFormItemInputTextCell
cell
.
isMust
=
detailItem
.
isNeed
cell
.
placeHolder
=
detailItem
.
placeHolder
cell
.
title
=
detailItem
.
getTitle
()
cell
.
text
=
detailItem
.
value
cell
.
setTips
(
detailItem
.
tips
,
isShow
:
isNeedShowError
&&
detailItem
.
isShowTips
)
cell
.
textInputCondtion
=
{
textField
in
if
let
textStr
=
textField
.
text
{
let
max
=
100
textField
.
text
=
textStr
.
count
>
max
?
textStr
[
safe
:
..<
max
]
:
textStr
}
return
true
}
cell
.
textChange
=
{
[
weak
self
]
(
text
,
isEditEnd
)
in
guard
let
self
=
self
else
{
return
}
guard
let
child
=
child
else
{
return
}
if
detailItem
.
type
==
.
detailAddress
{
if
child
.
isLiveInChina
()
{
child
.
address
.
details
=
text
??
""
}
else
{
child
.
address
.
foreign
=
text
??
""
}
}
if
isEditEnd
{
self
.
loadInfo
()
save
()
}
}
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
}
// Do any additional setup after loading the view.
createCorner
(
cell
:
cell
,
arr
:
arr
,
indexPath
:
indexPath
)
}
func
createDefaultCell
(
_
indexPath
:
IndexPath
)
->
UITableViewCell
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"UITableViewCell"
,
for
:
indexPath
)
return
cell
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
UITableView
.
automaticDimension
}
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
return
UIView
()
}
/*
// MARK: - Navigation
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
return
UIView
()
}
private
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
CGFloat
{
return
14.0
}
private
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
CGFloat
{
if
section
==
items
.
count
-
1
{
return
14.0
}
return
1.0
}
*/
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
!
(
0
..<
items
.
count
)
.
contains
(
indexPath
.
section
)
{
return
}
let
arr
:[
YHFormItemProtocol
]
=
items
[
indexPath
.
section
]
if
!
(
0
..<
arr
.
count
)
.
contains
(
indexPath
.
row
)
{
return
}
let
item
=
arr
[
indexPath
.
row
]
if
item
is
YHFormDetailItem
{
let
detailItem
=
item
as!
YHFormDetailItem
// 选国籍/现居住城市/详细地址
if
detailItem
.
type
==
.
nationOrArea
{
let
vc
=
YHSelectCountryViewController
()
vc
.
backLocationStringController
=
{
[
weak
self
]
country
in
guard
let
self
=
self
else
{
return
}
let
title
=
arr
[
0
]
as!
YHFormTitleItem
if
title
.
type
==
.
nationality
{
// 选国籍
self
.
child
?
.
nationality
=
country
}
else
if
title
.
type
==
.
liveInfo
{
// // 居住信息选国家地区
self
.
child
?
.
address
.
country
=
country
// 选择国家地区后需清空城市
self
.
child
?
.
address
.
area
=
[]
}
self
.
loadInfo
()
save
()
}
self
.
navigationController
?
.
pushViewController
(
vc
)
}
else
if
detailItem
.
type
==
.
liveCity
{
var
provice
=
""
if
let
country
=
self
.
child
?
.
address
.
country
{
if
country
.
contains
(
"台湾"
)
{
provice
=
"台湾省"
}
if
country
.
contains
(
"香港"
)
{
provice
=
"香港特别行政区"
}
if
country
.
contains
(
"澳门"
)
{
provice
=
"澳门特别行政区"
}
}
let
addressPicker
=
YHAddressViewController
(
selectProvince
:
provice
)
addressPicker
.
backLocationStringController
=
{
[
weak
self
]
(
address
,
province
,
city
,
area
)
in
guard
let
self
=
self
else
{
return
}
print
(
"
\(
address
)\n\(
province
)\n\(
city
)\n\(
area
)
"
)
var
citys
:[
String
]
=
[]
if
!
isEmptyString
(
province
)
{
citys
.
append
(
province
)
}
if
!
isEmptyString
(
city
)
{
citys
.
append
(
city
)
}
self
.
child
?
.
address
.
area
=
citys
self
.
loadInfo
()
save
()
}
UIViewController
.
current
?
.
present
(
addressPicker
,
animated
:
true
,
completion
:
nil
)
}
else
if
detailItem
.
type
==
.
birthday
{
// 出生日期
// 子女选择年满18岁则【是否随行至香港】默认选择否,不可修改
// 如果未年满18岁则【是否随行至香港】可选择【是/否】,可修改
YHDatePickView
.
show
(
type
:
.
yyyymmdd
,
title
:
"选择出生日期"
.
local
,
lastIsTaday
:
true
,
currentDay
:
child
?
.
birthday
??
""
)
{
[
weak
self
]
date
in
guard
let
self
=
self
else
{
return
}
if
detailItem
.
type
==
.
birthday
{
guard
let
child
=
child
else
{
return
}
child
.
birthday
=
date
isFollowCanEdit
=
!
child
.
is18YearsOld
()
if
child
.
is18YearsOld
()
{
child
.
setFollow
(
false
)
}
if
let
delegate
=
delegate
,
delegate
.
responds
(
to
:
#selector(
YHSpouseInfoVCProtocol.updateStepView
)
)
{
delegate
.
updateStepView
()
}
}
self
.
loadInfo
()
save
()
}
}
}
}
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
==
arr
.
count
-
1
)
{
let
corner
=
UIRectCorner
(
rawValue
:
UIRectCorner
.
bottomLeft
.
rawValue
|
UIRectCorner
.
bottomRight
.
rawValue
)
cell
.
createCorner
(
CGSizeMake
(
12.0
,
12.0
),
corner
)
}
else
{
cell
.
layer
.
mask
=
nil
}
}
}
extension
YHGCChildBasicInfoVC
{
// 检查填写信息完整性
func
checkIntegrity
()
->
Bool
{
guard
let
child
=
child
else
{
return
false
}
if
!
child
.
isFollow
()
{
if
isEmptyString
(
child
.
birthday
)
{
return
false
}
return
true
}
if
isEmptyString
(
child
.
birthday
)
{
return
false
}
if
isEmptyString
(
child
.
nationality
)
{
return
false
}
if
!
child
.
isLiveTother
()
{
// 没有与主申请人同住
if
isEmptyString
(
child
.
address
.
country
)
{
return
false
}
if
child
.
isLiveInChina
()
{
if
isEmptyArray
(
child
.
address
.
area
)
{
return
false
}
if
isEmptyString
(
child
.
address
.
details
)
{
return
false
}
}
else
{
// 住在国外
if
isEmptyString
(
child
.
address
.
foreign
)
{
return
false
}
}
}
return
true
}
func
nextStep
()
->
Bool
{
let
isChecked
=
checkIntegrity
()
isNeedShowError
=
!
isChecked
loadInfo
()
if
!
isChecked
{
YHHUD
.
flash
(
message
:
"资料还未填完"
)
return
false
}
return
true
}
func
save
()
{
if
let
delegate
=
delegate
,
delegate
.
responds
(
to
:
#selector(
YHSpouseInfoVCProtocol.saveInfoSilent
)
)
{
delegate
.
saveInfoSilent
()
}
}
}
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/TTPS(高才)/ServiceProcess(我的信息流程)/FamilyMember(家庭成员信息表)/C/Child(子女)/YHGCChildInfoContainerVC.swift
View file @
9795615a
...
...
@@ -5,26 +5,300 @@
// Created by edy on 2024/11/9.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import
UIKit
class
YHGCChildInfoContainerVC
:
YHBaseViewController
{
class
YHGCChildInfoContainerVC
:
YHBaseViewController
,
YHSpouseInfoVCProtocol
{
let
familyRequest
:
YHFamilyRequestViewModel
=
YHFamilyRequestViewModel
()
var
orderId
:
Int
=
0
var
child
:
YHFamilyMember
?
{
didSet
{
primaryInfoVC
.
child
=
child
uploadVC
.
familyMember
=
child
certificateVC
.
familyMember
=
child
basicInfoVC
.
child
=
child
}
}
var
stepVCs
:[
YHFaimilyStepItem
]
=
[]
var
_currentStep
=
0
var
currentStep
:
Int
{
get
{
return
_currentStep
}
set
{
if
let
child
=
child
,
!
child
.
isFollow
(),
newValue
>
0
{
_currentStep
=
3
}
else
{
_currentStep
=
newValue
}
let
index
=
getArrayIndexOfCurrentStep
()
if
let
index
=
index
{
stepView
.
currentIndex
=
index
bottomView
.
changeRightBtnTitle
(
index
==
stepVCs
.
count
-
1
?
"提交"
.
local
:
"下一步"
.
local
)
}
for
vcItem
in
stepVCs
{
vcItem
.
vc
.
view
.
isHidden
=
(
vcItem
.
step
!=
currentStep
)
if
vcItem
.
step
==
currentStep
{
// 刷新
if
vcItem
.
vc
.
responds
(
to
:
#selector(
YHFamilyMemberProtol.loadInfo
)
)
{
vcItem
.
vc
.
loadInfo
()
}
}
}
}
}
var
stepView
:
YHStepView
=
{
let
step
=
YHStepView
()
return
step
}()
var
bottomView
:
YHSaveAndSubmitView
=
{
let
view
=
YHSaveAndSubmitView
.
createView
()
view
.
changeRightBtnTitle
(
"下一步"
)
return
view
}()
let
primaryInfoVC
=
YHGCChildPrimaryInfoVC
()
let
uploadVC
=
YHGCCertificateUploadVC
()
let
certificateVC
=
YHGCCertificateInfoController
()
let
basicInfoVC
=
YHGCChildBasicInfoVC
()
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
gk_navTitle
=
"子女信息填写"
.
local
gk_navigationBar
.
backgroundColor
=
.
white
view
.
backgroundColor
=
UIColor
(
hexString
:
"#F8F8F8"
)
createUI
()
}
func
createUI
()
{
guard
let
child
=
child
else
{
return
}
primaryInfoVC
.
delegate
=
self
uploadVC
.
delegate
=
self
certificateVC
.
delegate
=
self
basicInfoVC
.
delegate
=
self
updateStepView
()
print
(
"step:
\(
child
.
step
)
"
)
currentStep
=
child
.
step
stepView
.
maxIndex
=
getArrayIndexOfCurrentStep
()
??
stepVCs
.
count
-
1
view
.
addSubview
(
stepView
)
view
.
addSubview
(
bottomView
)
// Do any additional setup after loading the view.
bottomView
.
submitBlock
=
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
submit
()
}
bottomView
.
saveBlock
=
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
self
.
saveInfo
(
isSubmit
:
false
,
isShowSubmitMsg
:
false
,
isShowLoading
:
true
,
callBack
:
nil
)
}
stepView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
k_Height_NavigationtBarAndStatuBar
)
make
.
left
.
right
.
equalTo
(
view
)
make
.
height
.
equalTo
(
YHStepView
.
height
)
}
bottomView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
make
.
bottom
.
equalToSuperview
()
make
.
height
.
equalTo
(
YHSaveAndSubmitView
.
height
)
}
}
/*
// MARK: - Navigation
func
updateStepView
()
{
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
guard
let
child
=
child
else
{
return
}
for
vc
in
self
.
children
{
vc
.
willMove
(
toParent
:
nil
)
vc
.
removeFromParent
()
vc
.
view
.
removeFromSuperview
()
}
print
(
self
.
children
)
if
child
.
isFollow
()
{
stepVCs
=
[
YHFaimilyStepItem
(
title
:
"初始信息"
.
local
,
vc
:
primaryInfoVC
,
step
:
0
),
YHFaimilyStepItem
(
title
:
"证件上传"
.
local
,
vc
:
uploadVC
,
step
:
1
),
YHFaimilyStepItem
(
title
:
"证件信息"
.
local
,
vc
:
certificateVC
,
step
:
2
),
YHFaimilyStepItem
(
title
:
"基本信息"
.
local
,
vc
:
basicInfoVC
,
step
:
3
)]
}
else
{
stepVCs
=
[
YHFaimilyStepItem
(
title
:
"初始信息"
.
local
,
vc
:
primaryInfoVC
,
step
:
0
),
YHFaimilyStepItem
(
title
:
"基本信息"
.
local
,
vc
:
basicInfoVC
,
step
:
3
)]
}
var
titles
:[
String
]
=
[]
for
vcItem
in
stepVCs
{
let
topHeight
=
k_Height_NavigationtBarAndStatuBar
+
YHStepView
.
height
let
bottomHeight
=
YHSaveAndSubmitView
.
height
vcItem
.
vc
.
view
.
frame
=
CGRectMake
(
0
,
topHeight
,
KScreenWidth
,
KScreenHeight
-
topHeight
-
bottomHeight
)
self
.
addChild
(
vcItem
.
vc
)
self
.
view
.
addSubview
(
vcItem
.
vc
.
view
)
titles
.
append
(
vcItem
.
title
)
}
stepView
.
dataSource
=
titles
let
step
=
currentStep
currentStep
=
step
stepView
.
block
=
{
[
weak
self
]
index
in
guard
let
self
=
self
else
{
return
}
if
let
targetStep
=
getStepForArrayIndex
(
index
)
{
currentStep
=
targetStep
}
requestDetail
()
print
(
"index:
\(
index
)
"
)
}
*/
self
.
view
.
bringSubviewToFront
(
stepView
)
self
.
view
.
bringSubviewToFront
(
bottomView
)
}
func
submit
()
{
if
let
targetVC
=
getCurrentStepViewController
()
{
if
targetVC
.
nextStep
()
{
var
isShowSubmitMsg
=
false
let
index
=
getArrayIndexOfCurrentStep
()
if
let
index
=
index
,
index
==
stepVCs
.
count
-
1
{
// 最后一步
isShowSubmitMsg
=
true
}
saveInfo
(
isSubmit
:
true
,
isShowSubmitMsg
:
isShowSubmitMsg
,
isShowLoading
:
true
)
{
[
weak
self
]
success
in
guard
let
self
=
self
else
{
return
}
if
success
{
// 当前步骤已是最后一步
if
let
vc
=
stepVCs
.
last
,
vc
.
step
==
currentStep
{
self
.
navigationController
?
.
popViewController
()
return
}
requestDetail
()
if
let
cur
=
getArrayIndexOfCurrentStep
(),
let
item
=
stepVCs
[
safe
:
cur
+
1
]
{
currentStep
=
item
.
step
if
cur
+
1
>
stepView
.
maxIndex
{
stepView
.
maxIndex
=
cur
+
1
}
}
print
(
"currentIndex:
\(
currentStep
)
"
)
}
}
}
}
}
// 【WARNING!】步骤step和在数组中的下标有时候并不是一一对应
func
getArrayIndexOfCurrentStep
()
->
Int
?
{
for
(
i
,
item
)
in
stepVCs
.
enumerated
()
{
if
item
.
step
==
currentStep
{
return
i
}
}
return
nil
}
// 【WARNING!】步骤step和在数组中的下标有时候并不是一一对应
func
getStepForArrayIndex
(
_
index
:
Int
)
->
Int
?
{
if
let
targetVCItem
=
stepVCs
[
safe
:
index
]
{
return
targetVCItem
.
step
}
return
nil
}
func
getCurrentStepViewController
()
->
(
UIViewController
&
YHFamilyMemberProtol
)?
{
for
vcItem
in
stepVCs
{
if
vcItem
.
step
==
currentStep
{
return
vcItem
.
vc
}
}
return
nil
}
}
extension
YHGCChildInfoContainerVC
{
// @param isSubmit:是否为提交 false为保存 true为提交
// @param isShowLoading: 是否展示loading和toast
//
func
saveInfo
(
isSubmit
:
Bool
,
isShowSubmitMsg
:
Bool
,
isShowLoading
:
Bool
,
callBack
:((
Bool
)
->
Void
)?)
{
guard
let
child
=
child
else
{
return
}
guard
let
info
=
child
.
toDictionary
()
else
{
return
}
let
dict
:[
String
:
Any
]
=
[
"order_id"
:
child
.
orderId
,
"relation"
:
child
.
relation
,
"step"
:
currentStep
,
"next"
:
isSubmit
,
"info"
:
info
]
self
.
familyRequest
.
addOrSaveFamilyMember
(
params
:
dict
,
isShowLoading
:
isShowLoading
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
if
isShowLoading
{
if
success
{
YHHUD
.
flash
(
message
:
isSubmit
&&
isShowSubmitMsg
?
"提交成功"
:
"保存成功"
)
}
else
{
var
msg
=
isSubmit
&&
isShowSubmitMsg
?
"提交失败"
:
"保存失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
errorMsg
.
count
>
0
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
}
if
let
callBack
=
callBack
{
callBack
(
success
)
}
}
}
func
requestDetail
()
{
guard
let
child
=
child
else
{
return
}
if
orderId
<=
0
||
child
.
detailId
<=
0
{
print
(
"订单号或成员ID不存在"
)
return
}
self
.
familyRequest
.
requestFamilyMemberInfo
(
orderId
:
orderId
,
detailId
:
child
.
detailId
)
{
[
weak
self
]
detail
,
error
in
guard
let
self
=
self
else
{
return
}
if
let
detail
=
detail
{
self
.
child
=
detail
for
vcItem
in
stepVCs
{
vcItem
.
vc
.
loadInfo
()
}
}
}
}
func
saveInfoSilent
()
{
saveInfo
(
isSubmit
:
false
,
isShowSubmitMsg
:
false
,
isShowLoading
:
false
,
callBack
:
nil
)
}
}
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/TTPS(高才)/ServiceProcess(我的信息流程)/FamilyMember(家庭成员信息表)/C/Child(子女)/YHGCChildPrimaryInfoVC.swift
View file @
9795615a
...
...
@@ -5,26 +5,520 @@
// Created by edy on 2024/11/9.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import
UIKit
class
YHGCChildPrimaryInfoVC
:
YHBaseViewController
{
class
YHGCChildPrimaryInfoVC
:
YHBaseViewController
,
YHFamilyMemberProtol
{
var
child
:
YHFamilyMember
?
weak
var
delegate
:
YHSpouseInfoVCProtocol
?
var
isNeedShowError
=
false
// 是否随行能编辑
var
isFollowCanEdit
=
true
lazy
var
items
:[[
YHFormItemProtocol
]]
=
[[
YHFormItemProtocol
]]()
lazy
var
tableView
:
UITableView
=
{
let
tableView
=
UITableView
(
frame
:
.
zero
,
style
:
.
grouped
)
if
#available(iOS 11.0, *)
{
tableView
.
contentInsetAdjustmentBehavior
=
.
never
}
tableView
.
estimatedSectionHeaderHeight
=
14.0
tableView
.
estimatedSectionFooterHeight
=
1.0
tableView
.
showsVerticalScrollIndicator
=
false
tableView
.
backgroundColor
=
UIColor
(
hexString
:
"#F8F8F8"
)
tableView
.
separatorStyle
=
.
none
tableView
.
delegate
=
self
tableView
.
dataSource
=
self
tableView
.
register
(
UITableViewCell
.
self
,
forCellReuseIdentifier
:
"UITableViewCell"
)
tableView
.
register
(
YHFormItemDoubleChoiceCell
.
self
,
forCellReuseIdentifier
:
YHFormItemDoubleChoiceCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemInputTextCell
.
self
,
forCellReuseIdentifier
:
YHFormItemInputTextCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemEnterDetailCell
.
self
,
forCellReuseIdentifier
:
YHFormItemEnterDetailCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemTitleCell
.
self
,
forCellReuseIdentifier
:
YHFormItemTitleCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemAddCell
.
self
,
forCellReuseIdentifier
:
YHFormItemAddCell
.
cellReuseIdentifier
)
tableView
.
register
(
YHFormItemSelectSheetCell
.
self
,
forCellReuseIdentifier
:
YHFormItemSelectSheetCell
.
cellReuseIdentifier
)
return
tableView
}()
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
gk_navigationBar
.
isHidden
=
true
view
.
backgroundColor
=
UIColor
(
hexString
:
"#F8F8F8"
)
createUI
()
loadInfo
()
}
func
loadInfo
()
{
guard
let
child
=
child
else
{
return
}
// Do any additional setup after loading the view.
items
.
removeAll
()
isFollowCanEdit
=
!
child
.
is18YearsOld
()
// 随行
let
title0
=
YHFormTitleItem
(
type
:
.
accompany
)
let
item00
=
YHFormDetailItem
(
type
:
.
ownCustody
,
value
:
String
(
child
.
isOwnCustody
()))
let
item01
=
YHFormDetailItem
(
type
:
.
birthday
,
value
:
child
.
birthday
,
tips
:
"请选择出生日期"
.
local
)
let
item02
=
YHFormDetailItem
(
type
:
.
isAccompanyToHK
,
value
:
String
(
child
.
isFollow
()))
let
arr0
:[
YHFormItemProtocol
]
=
[
title0
,
item00
,
item01
,
item02
]
items
.
append
(
arr0
)
if
child
.
isFollow
()
{
// 随行才加后面的信息
// 国籍
let
title1
=
YHFormTitleItem
(
type
:
.
nationality
)
let
item10
=
YHFormDetailItem
(
type
:
.
nationOrArea
,
value
:
child
.
nationality
,
tips
:
"请选择国籍"
.
local
)
let
arr1
:[
YHFormItemProtocol
]
=
[
title1
,
item10
]
// 居住信息
let
title2
=
YHFormTitleItem
(
type
:
.
liveInfo
)
let
item20
=
YHFormDetailItem
(
type
:
.
isLiveTother
,
value
:
String
(
child
.
isLiveTother
()))
var
arr2
:
[
YHFormItemProtocol
]
=
[
title2
,
item20
]
if
!
child
.
isLiveTother
()
{
// 不同住 才需填写国家/地区
let
item21
=
YHFormDetailItem
(
type
:
.
nationOrArea
,
value
:
child
.
address
.
country
,
tips
:
"请选择国家/地区"
.
local
)
arr2
.
append
(
item21
)
// 国家/地区已填写 才显示现居住城市和详细地址两行
if
!
child
.
address
.
country
.
isEmpty
{
// 居住信息中选择中国才会显示现居住城市
let
isLiveInChina
=
child
.
address
.
country
.
contains
(
"中国"
.
local
)
if
isLiveInChina
{
var
value
=
""
if
!
child
.
address
.
area
.
isEmpty
{
value
=
child
.
address
.
area
.
joined
(
separator
:
","
)
}
let
item22
=
YHFormDetailItem
(
type
:
.
liveCity
,
value
:
value
,
tips
:
"请选择现居住城市"
.
local
)
arr2
.
append
(
item22
)
}
let
placeHolder
=
(
isLiveInChina
?
"请填写小区、楼栋、单元室等"
.
local
:
"请填写国外居住地"
.
local
)
let
detailAddress
=
isLiveInChina
?
child
.
address
.
details
:
child
.
address
.
foreign
let
item23
=
YHFormDetailItem
(
type
:
.
detailAddress
,
value
:
detailAddress
,
placeHolder
:
placeHolder
,
tips
:
placeHolder
)
arr2
.
append
(
item23
)
if
!
isLiveInChina
{
// 在国外
// 是否在海外居住满1年及以上
let
item24
=
YHFormDetailItem
(
type
:
.
isLiveOverSeasMore1Year
,
value
:
String
(
child
.
isOverSeasOver1Year
()))
arr2
.
append
(
item24
)
}
}
}
/*
// MARK: - Navigation
// 港澳通信证
let
title3
=
YHFormTitleItem
(
type
:
.
hkAndMacaoPassport
)
let
item30
=
YHFormDetailItem
(
type
:
.
isHandleHKPassPort
,
value
:
String
(
child
.
isNeedHandleHKPassPort
()))
let
arr3
:[
YHFormItemProtocol
]
=
[
title3
,
item30
]
items
.
append
(
contentsOf
:[
arr1
,
arr2
,
arr3
])
}
tableView
.
reloadData
()
}
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
func
createUI
()
{
view
.
addSubview
(
tableView
);
let
topHeight
=
k_Height_NavigationtBarAndStatuBar
+
YHStepView
.
height
let
bottomHeight
=
YHSaveAndSubmitView
.
height
tableView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
offset
(
16
)
make
.
right
.
equalToSuperview
()
.
offset
(
-
16
)
make
.
height
.
equalTo
(
KScreenHeight
-
topHeight
-
bottomHeight
)
}
}
*/
func
getCellType
(
_
item
:
Any
)
->
HKFormItemCellType
{
if
item
is
YHFormTitleItem
{
return
.
title
}
if
item
is
YHFormDetailItem
{
let
detailItem
=
item
as!
YHFormDetailItem
if
detailItem
.
type
==
.
birthCity
{
var
isBirthOverSeas
=
false
if
let
child
=
child
{
isBirthOverSeas
=
child
.
isBirthOverSeas
()
}
if
isBirthOverSeas
{
return
.
inputText
}
else
{
return
.
selectSheet
}
}
if
detailItem
.
type
==
.
detailAddress
{
return
.
inputText
}
if
detailItem
.
type
==
.
nationOrArea
||
detailItem
.
type
==
.
nationOrArea
||
detailItem
.
type
==
.
liveCity
||
detailItem
.
type
==
.
birthday
{
return
.
selectSheet
}
if
detailItem
.
type
==
.
isAccompanyToHK
||
detailItem
.
type
==
.
isHandleHKPassPort
||
detailItem
.
type
==
.
ownCustody
||
detailItem
.
type
==
.
isLiveTother
||
detailItem
.
type
==
.
isLiveOverSeasMore1Year
{
return
.
twoChoice
}
}
return
.
defaultType
}
}
extension
YHGCChildPrimaryInfoVC
:
UITableViewDelegate
,
UITableViewDataSource
{
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
return
items
.
count
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
if
section
>=
items
.
count
{
return
0
}
let
arr
=
items
[
section
]
return
arr
.
count
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
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
:
YHFormItemProtocol
=
arr
[
indexPath
.
row
]
if
item
is
YHFormTitleItem
{
// 标题
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHFormItemTitleCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHFormItemTitleCell
cell
.
setTitleAndSubTitle
(
title
:
item
.
getTitle
())
return
cell
}
else
if
item
is
YHFormDetailItem
{
// 具体信息
let
detailItem
=
item
as!
YHFormDetailItem
let
cellType
=
self
.
getCellType
(
detailItem
)
if
cellType
==
.
twoChoice
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHFormItemDoubleChoiceCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHFormItemDoubleChoiceCell
cell
.
isMust
=
detailItem
.
isNeed
cell
.
title
=
detailItem
.
getTitle
()
cell
.
enableEdit
=
true
cell
.
disableEditTips
=
nil
var
select
=
false
if
let
value
=
detailItem
.
value
{
select
=
Bool
(
value
)
!
}
if
detailItem
.
type
==
.
isAccompanyToHK
,
let
child
=
child
,
child
.
is18YearsOld
()
{
// 是否随行至香港
// 年满18岁不能随行 随行按钮不可编辑固定为否
cell
.
enableEdit
=
isFollowCanEdit
cell
.
disableEditTips
=
"年满十八岁的子女不能随行至香港"
}
let
answers
=
[
YHFormChoiceItem
(
title
:
"是"
.
local
,
isSelect
:
select
),
YHFormChoiceItem
(
title
:
"否"
.
local
,
isSelect
:
!
select
)]
cell
.
answerArr
=
answers
cell
.
answerBlock
=
{
[
weak
self
]
(
arr
,
selectIndex
)
in
let
selectItem
:
YHFormChoiceItem
=
arr
[
selectIndex
]
let
option
=
(
selectItem
.
title
==
"是"
.
local
?
true
:
false
)
guard
let
self
=
self
else
{
return
}
if
detailItem
.
type
==
.
isAccompanyToHK
{
// 是否随行
self
.
child
?
.
setFollow
(
option
)
if
let
delegate
=
delegate
,
delegate
.
responds
(
to
:
#selector(
YHSpouseInfoVCProtocol.updateStepView
)
)
{
delegate
.
updateStepView
()
}
}
else
if
detailItem
.
type
==
.
isHandleHKPassPort
{
// 是否办理港澳通行证
self
.
child
?
.
setNeedHandleHKPassPort
(
option
)
}
else
if
detailItem
.
type
==
.
isLiveTother
{
// 是否与主申请人同住
self
.
child
?
.
setLiveTother
(
option
)
if
option
{
self
.
child
?
.
address
.
clearAddress
()
}
}
else
if
detailItem
.
type
==
.
isLiveOverSeasMore1Year
{
// 是否在海外居住满1年及以上
self
.
child
?
.
setOverSearsOver1Year
(
option
)
}
else
if
detailItem
.
type
==
.
ownCustody
{
// 抚养权
self
.
child
?
.
setOwnCustody
(
option
)
}
self
.
loadInfo
()
save
()
}
return
cell
}
else
if
cellType
==
.
selectSheet
{
// 选择列表面板
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHFormItemSelectSheetCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHFormItemSelectSheetCell
cell
.
isMust
=
detailItem
.
isNeed
cell
.
title
=
detailItem
.
getTitle
()
cell
.
detail
=
detailItem
.
value
cell
.
setTips
(
detailItem
.
tips
,
isShow
:
isNeedShowError
&&
detailItem
.
isShowTips
)
return
cell
}
else
if
cellType
==
.
inputText
{
// 输入文字cell
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHFormItemInputTextCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHFormItemInputTextCell
cell
.
isMust
=
detailItem
.
isNeed
cell
.
placeHolder
=
detailItem
.
placeHolder
cell
.
title
=
detailItem
.
getTitle
()
cell
.
text
=
detailItem
.
value
cell
.
setTips
(
detailItem
.
tips
,
isShow
:
isNeedShowError
&&
detailItem
.
isShowTips
)
cell
.
textInputCondtion
=
{
textField
in
if
let
textStr
=
textField
.
text
{
let
max
=
100
textField
.
text
=
textStr
.
count
>
max
?
textStr
[
safe
:
..<
max
]
:
textStr
}
return
true
}
cell
.
textChange
=
{
[
weak
self
]
(
text
,
isEditEnd
)
in
guard
let
self
=
self
else
{
return
}
guard
let
child
=
child
else
{
return
}
if
detailItem
.
type
==
.
detailAddress
{
if
child
.
isLiveInChina
()
{
child
.
address
.
details
=
text
??
""
}
else
{
child
.
address
.
foreign
=
text
??
""
}
}
if
isEditEnd
{
self
.
loadInfo
()
save
()
}
}
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
)
return
cell
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
UITableView
.
automaticDimension
}
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
return
UIView
()
}
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
return
UIView
()
}
private
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
CGFloat
{
return
14.0
}
private
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
CGFloat
{
if
section
==
items
.
count
-
1
{
return
14.0
}
return
1.0
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
!
(
0
..<
items
.
count
)
.
contains
(
indexPath
.
section
)
{
return
}
let
arr
:[
YHFormItemProtocol
]
=
items
[
indexPath
.
section
]
if
!
(
0
..<
arr
.
count
)
.
contains
(
indexPath
.
row
)
{
return
}
let
item
=
arr
[
indexPath
.
row
]
if
item
is
YHFormDetailItem
{
let
detailItem
=
item
as!
YHFormDetailItem
// 选国籍/现居住城市/详细地址
if
detailItem
.
type
==
.
nationOrArea
{
let
vc
=
YHSelectCountryViewController
()
vc
.
backLocationStringController
=
{
[
weak
self
]
country
in
guard
let
self
=
self
else
{
return
}
let
title
=
arr
[
0
]
as!
YHFormTitleItem
if
title
.
type
==
.
nationality
{
// 选国籍
self
.
child
?
.
nationality
=
country
}
else
if
title
.
type
==
.
liveInfo
{
// // 居住信息选国家地区
self
.
child
?
.
address
.
country
=
country
// 选择国家地区后需清空城市
self
.
child
?
.
address
.
area
=
[]
}
self
.
loadInfo
()
save
()
}
self
.
navigationController
?
.
pushViewController
(
vc
)
}
else
if
detailItem
.
type
==
.
liveCity
{
var
provice
=
""
if
let
country
=
self
.
child
?
.
address
.
country
{
if
country
.
contains
(
"台湾"
)
{
provice
=
"台湾省"
}
if
country
.
contains
(
"香港"
)
{
provice
=
"香港特别行政区"
}
if
country
.
contains
(
"澳门"
)
{
provice
=
"澳门特别行政区"
}
}
let
addressPicker
=
YHAddressViewController
(
selectProvince
:
provice
)
addressPicker
.
backLocationStringController
=
{
[
weak
self
]
(
address
,
province
,
city
,
area
)
in
guard
let
self
=
self
else
{
return
}
print
(
"
\(
address
)\n\(
province
)\n\(
city
)\n\(
area
)
"
)
var
citys
:[
String
]
=
[]
if
!
isEmptyString
(
province
)
{
citys
.
append
(
province
)
}
if
!
isEmptyString
(
city
)
{
citys
.
append
(
city
)
}
self
.
child
?
.
address
.
area
=
citys
self
.
loadInfo
()
save
()
}
UIViewController
.
current
?
.
present
(
addressPicker
,
animated
:
true
,
completion
:
nil
)
}
else
if
detailItem
.
type
==
.
birthday
{
// 出生日期
// 子女选择年满18岁则【是否随行至香港】默认选择否,不可修改
// 如果未年满18岁则【是否随行至香港】可选择【是/否】,可修改
YHDatePickView
.
show
(
type
:
.
yyyymmdd
,
title
:
"选择出生日期"
.
local
,
lastIsTaday
:
true
,
currentDay
:
child
?
.
birthday
??
""
)
{
[
weak
self
]
date
in
guard
let
self
=
self
else
{
return
}
if
detailItem
.
type
==
.
birthday
{
guard
let
child
=
child
else
{
return
}
child
.
birthday
=
date
isFollowCanEdit
=
!
child
.
is18YearsOld
()
if
child
.
is18YearsOld
()
{
child
.
setFollow
(
false
)
}
if
let
delegate
=
delegate
,
delegate
.
responds
(
to
:
#selector(
YHSpouseInfoVCProtocol.updateStepView
)
)
{
delegate
.
updateStepView
()
}
}
self
.
loadInfo
()
save
()
}
}
}
}
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
==
arr
.
count
-
1
)
{
let
corner
=
UIRectCorner
(
rawValue
:
UIRectCorner
.
bottomLeft
.
rawValue
|
UIRectCorner
.
bottomRight
.
rawValue
)
cell
.
createCorner
(
CGSizeMake
(
12.0
,
12.0
),
corner
)
}
else
{
cell
.
layer
.
mask
=
nil
}
}
}
extension
YHGCChildPrimaryInfoVC
{
// 检查填写信息完整性
func
checkIntegrity
()
->
Bool
{
guard
let
child
=
child
else
{
return
false
}
if
!
child
.
isFollow
()
{
if
isEmptyString
(
child
.
birthday
)
{
return
false
}
return
true
}
if
isEmptyString
(
child
.
birthday
)
{
return
false
}
if
isEmptyString
(
child
.
nationality
)
{
return
false
}
if
!
child
.
isLiveTother
()
{
// 没有与主申请人同住
if
isEmptyString
(
child
.
address
.
country
)
{
return
false
}
if
child
.
isLiveInChina
()
{
if
isEmptyArray
(
child
.
address
.
area
)
{
return
false
}
if
isEmptyString
(
child
.
address
.
details
)
{
return
false
}
}
else
{
// 住在国外
if
isEmptyString
(
child
.
address
.
foreign
)
{
return
false
}
}
}
return
true
}
func
nextStep
()
->
Bool
{
let
isChecked
=
checkIntegrity
()
isNeedShowError
=
!
isChecked
loadInfo
()
if
!
isChecked
{
YHHUD
.
flash
(
message
:
"资料还未填完"
)
return
false
}
return
true
}
func
save
()
{
if
let
delegate
=
delegate
,
delegate
.
responds
(
to
:
#selector(
YHSpouseInfoVCProtocol.saveInfoSilent
)
)
{
delegate
.
saveInfoSilent
()
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment