Commit 61638ff9 authored by Steven杜宇's avatar Steven杜宇

// 预约

parent c644a4a9
...@@ -17,7 +17,12 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -17,7 +17,12 @@ class YHResignAppointTimeViewController: YHBaseViewController {
// 申请人是否在港 // 申请人是否在港
var togetherArr: [YHResignAppointTogetherSetting] = [] var togetherArr: [YHResignAppointTogetherSetting] = []
var togetherSetting = YHResignAppointTogetherSetting() lazy var togetherSetting = {
let model = YHResignAppointTogetherSetting()
// 默认一起递交
model.is_together = 1
return model
}()
// 分组信息 // 分组信息
var selectGroupArr: [YHResignAppointTimeSettingModel] = [] var selectGroupArr: [YHResignAppointTimeSettingModel] = []
...@@ -128,13 +133,15 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -128,13 +133,15 @@ class YHResignAppointTimeViewController: YHBaseViewController {
togetherArr.append(togetherSetting) togetherArr.append(togetherSetting)
// 分组数据 // 分组数据
let model1 = YHResignAppointTimeSettingModel() let model1 = YHResignAppointTimeSettingModel()
// 默认全部选中 if self.togetherSetting.is_together == 2 { // 不一起递交 需显示候选人列表
let users = allAppointUsers.deepCopy().map { // 默认全部选中
let item = $0 let users = allAppointUsers.deepCopy().map {
item.isSelected = true let item = $0
return item item.isSelected = true
return item
}
model1.users = users
} }
model1.users = users
selectGroupArr.append(model1) selectGroupArr.append(model1)
self.tableView.reloadData() self.tableView.reloadData()
} }
...@@ -256,25 +263,53 @@ extension YHResignAppointTimeViewController: UITableViewDelegate, UITableViewDat ...@@ -256,25 +263,53 @@ extension YHResignAppointTimeViewController: UITableViewDelegate, UITableViewDat
if indexPath.section == 0 { // 是否一起在港递交的cell if indexPath.section == 0 { // 是否一起在港递交的cell
let cell = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionCell let cell = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionCell
if self.togetherSetting.is_together == 1 {
cell.isSelectTogether = true
} else if self.togetherSetting.is_together == 2 {
cell.isSelectTogether = false
} else {
cell.isSelectTogether = nil
}
cell.selectBlock = {
[weak self] index in
guard let self = self else { return }
// index == 1 表示否
self.togetherSetting.is_together = (index == 1 ? 2 : 1)
self.updateUI()
}
return cell return cell
} }
// 分组cell // 时间选择cell
if 0 <= indexPath.row && indexPath.row < selectGroupArr.count { if 0 <= indexPath.row && indexPath.row < selectGroupArr.count {
let model = selectGroupArr[indexPath.row] let model = selectGroupArr[indexPath.row]
if model.users.count <= 0 { // 说明是一起在港递交 if model.users.count <= 0 || self.togetherSetting.is_together == 1 { // 不分组选择cell
let cell2 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointTimeSingleCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointTimeSingleCell let cell2 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointTimeSingleCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointTimeSingleCell
cell2.updateModel(model)
cell2.switchBlock = {
[weak self] isOn in
guard let self = self else { return }
model.notleaveHK = isOn
self.tableView.reloadData()
}
return cell2 return cell2
} }
// 分组选择cell
let cell3 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointTimeMultipleCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointTimeMultipleCell let cell3 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointTimeMultipleCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointTimeMultipleCell
cell3.updateModel(model) cell3.updateModel(model)
cell3.selectBlock = { cell3.selectUserBlock = {
[weak self] member, isSelect, groupIndex in [weak self] member, isSelect, groupIndex in
guard let self = self else { return } guard let self = self else { return }
self.selectMember(member, select: isSelect, groupLevel: groupIndex) self.selectMember(member, select: isSelect, groupLevel: groupIndex)
} }
cell3.switchBlock = {
[weak self] isOn in
guard let self = self else { return }
model.notleaveHK = isOn
self.tableView.reloadData()
}
return cell3 return cell3
} }
......
...@@ -12,13 +12,13 @@ import AttributedString ...@@ -12,13 +12,13 @@ import AttributedString
class YHResignAppointOptionCell: UITableViewCell { class YHResignAppointOptionCell: UITableViewCell {
static let cellReuseIdentifier = "YHResignAppointOptionCell" static let cellReuseIdentifier = "YHResignAppointOptionCell"
// 选择是否赴港 // 选择是否一起在港递交
var isSelectGoHK:Bool? { var isSelectTogether:Bool? {
didSet { didSet {
var selectIndex = -1 // 是否都未选择 var selectIndex = -1 // 是否都未选择
if let isGoHK = isSelectGoHK { if let isTogether = isSelectTogether {
selectIndex = isGoHK ? 0 : 1 selectIndex = isTogether ? 0 : 1
} }
optionsView.selectIndex = selectIndex optionsView.selectIndex = selectIndex
} }
...@@ -64,7 +64,7 @@ class YHResignAppointOptionCell: UITableViewCell { ...@@ -64,7 +64,7 @@ class YHResignAppointOptionCell: UITableViewCell {
view.selectBlock = { view.selectBlock = {
[weak self] index in [weak self] index in
guard let self = self else { return } guard let self = self else { return }
self.selectBlock?(index)
} }
return view return view
}() }()
......
...@@ -18,8 +18,10 @@ class YHResignAppointTimeMultipleCell: UITableViewCell { ...@@ -18,8 +18,10 @@ class YHResignAppointTimeMultipleCell: UITableViewCell {
var arr:[YHResignAppointMember] = [] var arr:[YHResignAppointMember] = []
// param 选中的用户 是否选中 选中的用户是第几批 // param 选中的用户 是否选中 选中的用户是第几批
var selectBlock: ((_ member: YHResignAppointMember, _ isSelect: Bool, _ groupIndex: Int)->())? var selectUserBlock: ((_ member: YHResignAppointMember, _ isSelect: Bool, _ groupIndex: Int)->())?
// switch按钮点击事件
var switchBlock: ((Bool)->())?
lazy var whiteContentView: UIView = { lazy var whiteContentView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .white view.backgroundColor = .white
...@@ -115,6 +117,11 @@ class YHResignAppointTimeMultipleCell: UITableViewCell { ...@@ -115,6 +117,11 @@ class YHResignAppointTimeMultipleCell: UITableViewCell {
lazy var leaveHKSwithView: YHResignLeaveHKSwitchItemView = { lazy var leaveHKSwithView: YHResignLeaveHKSwitchItemView = {
let view = YHResignLeaveHKSwitchItemView() let view = YHResignLeaveHKSwitchItemView()
view.title = "暂不离港" view.title = "暂不离港"
view.selectBlock = {
[weak self] on in
guard let self = self else { return }
self.switchBlock?(on)
}
return view return view
}() }()
...@@ -132,10 +139,49 @@ class YHResignAppointTimeMultipleCell: UITableViewCell { ...@@ -132,10 +139,49 @@ class YHResignAppointTimeMultipleCell: UITableViewCell {
self.model = model self.model = model
titleLabel.text = "请确认第\(model.itemIndex+1)批赴港递交信息" titleLabel.text = "请确认第\(model.itemIndex+1)批赴港递交信息"
subTitleLabel.text = "选择第\(model.itemIndex+1)批赴港递交的申请人" subTitleLabel.text = "选择第\(model.itemIndex+1)批赴港递交的申请人"
self.leaveHKSwithView.switchBtn.setOn(self.model.notleaveHK, animated: false)
self.arr.removeAll() self.arr.removeAll()
self.arr.append(contentsOf: model.users) self.arr.append(contentsOf: model.users)
updateUI() // 预计离港时间控件显示逻辑
let isHiddenLeaveHKTime = self.model.notleaveHK
leaveTimeItemView.removeFromSuperview()
leaveTimeItemView.snp.removeConstraints()
if isHiddenLeaveHKTime {
leaveHKSwithView.snp.remakeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(submitTimeItemView.snp.bottom)
make.bottom.equalToSuperview()
}
} else {
whiteContentView.addSubview(leaveTimeItemView)
leaveTimeItemView.snp.remakeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(submitTimeItemView.snp.bottom)
}
leaveHKSwithView.snp.remakeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(leaveTimeItemView.snp.bottom)
make.bottom.equalToSuperview()
}
}
// 申请人选择列表高度显示
collectionView.reloadData()
collectionView.snp.updateConstraints { make in
make.height.equalTo(self.getCollectionViewHeight())
}
self.setNeedsLayout()
self.layoutIfNeeded()
} }
func setupUI() { func setupUI() {
...@@ -202,17 +248,6 @@ class YHResignAppointTimeMultipleCell: UITableViewCell { ...@@ -202,17 +248,6 @@ class YHResignAppointTimeMultipleCell: UITableViewCell {
make.top.equalTo(leaveTimeItemView.snp.bottom) make.top.equalTo(leaveTimeItemView.snp.bottom)
make.bottom.equalToSuperview() make.bottom.equalToSuperview()
} }
updateUI()
}
func updateUI() {
collectionView.reloadData()
collectionView.snp.updateConstraints { make in
make.height.equalTo(self.getCollectionViewHeight())
}
self.setNeedsLayout()
self.layoutIfNeeded()
} }
func getCollectionViewHeight() -> CGFloat { func getCollectionViewHeight() -> CGFloat {
...@@ -268,7 +303,7 @@ extension YHResignAppointTimeMultipleCell: UICollectionViewDelegate, UICollectio ...@@ -268,7 +303,7 @@ extension YHResignAppointTimeMultipleCell: UICollectionViewDelegate, UICollectio
YHHUD.flash(message: "每一批赴港申请人不可为空,请确保每位申请人都在列") YHHUD.flash(message: "每一批赴港申请人不可为空,请确保每位申请人都在列")
return return
} }
selectBlock?(member, !member.isSelected, self.model.itemIndex) selectUserBlock?(member, !member.isSelected, self.model.itemIndex)
} }
} }
} }
...@@ -12,6 +12,9 @@ import AttributedString ...@@ -12,6 +12,9 @@ import AttributedString
class YHResignAppointTimeSingleCell: UITableViewCell { class YHResignAppointTimeSingleCell: UITableViewCell {
static let cellReuseIdentifier = "YHResignAppointTimeSingleCell" static let cellReuseIdentifier = "YHResignAppointTimeSingleCell"
var model = YHResignAppointTimeSettingModel()
var switchBlock: ((Bool)->())?
lazy var whiteContentView: UIView = { lazy var whiteContentView: UIView = {
let view = UIView() let view = UIView()
...@@ -61,6 +64,11 @@ class YHResignAppointTimeSingleCell: UITableViewCell { ...@@ -61,6 +64,11 @@ class YHResignAppointTimeSingleCell: UITableViewCell {
lazy var leaveHKSwithView: YHResignLeaveHKSwitchItemView = { lazy var leaveHKSwithView: YHResignLeaveHKSwitchItemView = {
let view = YHResignLeaveHKSwitchItemView() let view = YHResignLeaveHKSwitchItemView()
view.title = "暂不离港" view.title = "暂不离港"
view.selectBlock = {
[weak self] on in
guard let self = self else { return }
self.switchBlock?(on)
}
return view return view
}() }()
...@@ -73,6 +81,43 @@ class YHResignAppointTimeSingleCell: UITableViewCell { ...@@ -73,6 +81,43 @@ class YHResignAppointTimeSingleCell: UITableViewCell {
setupUI() setupUI()
} }
func updateModel(_ model: YHResignAppointTimeSettingModel) {
self.model = model
self.leaveHKSwithView.switchBtn.setOn(self.model.notleaveHK, animated: false)
let isHiddenLeaveHKTime = self.model.notleaveHK
leaveTimeItemView.removeFromSuperview()
leaveTimeItemView.snp.removeConstraints()
if isHiddenLeaveHKTime {
leaveHKSwithView.snp.remakeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(submitTimeItemView.snp.bottom)
make.bottom.equalToSuperview()
}
} else {
whiteContentView.addSubview(leaveTimeItemView)
leaveTimeItemView.snp.remakeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(submitTimeItemView.snp.bottom)
}
leaveHKSwithView.snp.remakeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(leaveTimeItemView.snp.bottom)
make.bottom.equalToSuperview()
}
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
func setupUI() { func setupUI() {
self.selectionStyle = .none self.selectionStyle = .none
......
...@@ -10,6 +10,8 @@ import UIKit ...@@ -10,6 +10,8 @@ import UIKit
class YHResignLeaveHKSwitchItemView: UIView { class YHResignLeaveHKSwitchItemView: UIView {
var selectBlock:((Bool)->())?
var title: String = "" { var title: String = "" {
didSet { didSet {
titleLabel.text = title titleLabel.text = title
...@@ -83,7 +85,7 @@ class YHResignLeaveHKSwitchItemView: UIView { ...@@ -83,7 +85,7 @@ class YHResignLeaveHKSwitchItemView: UIView {
} }
@objc func switchViewChange() { @objc func switchViewChange() {
// switchBtn.isOn selectBlock?(switchBtn.isOn)
} }
override func layoutSubviews() { override func layoutSubviews() {
......
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