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

// 预约

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