Commit c90615f5 authored by Steven杜宇's avatar Steven杜宇

// 预约

parent 7943af48
...@@ -165,10 +165,13 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -165,10 +165,13 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
} }
} }
if isOnlyOneUser || isOnlyOneGroup { // 只有一个人或只有一批 此时scheduleArr只有一个元素 if isOnlyOneUser || isOnlyOneGroup { // 只有一个人或多人单批 此时scheduleArr只有一个元素
let vc = YHResignAppointTimeViewController() let vc = YHResignAppointTimeViewController()
vc.renewalId = self.renewalId
if scheduleArr.count > 0 { if scheduleArr.count > 0 {
let group = scheduleArr[0] let group = scheduleArr[0]
vc.togetherSetting.isCanEdit = false
vc.togetherSetting.is_together = 1
vc.defaultSubmitTime = group.ready_to_submit_at vc.defaultSubmitTime = group.ready_to_submit_at
vc.defaultLeaveHKTime = group.leave_hk_at vc.defaultLeaveHKTime = group.leave_hk_at
vc.allAppointUsers = group.user_list.map { vc.allAppointUsers = group.user_list.map {
...@@ -179,6 +182,7 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -179,6 +182,7 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
return return
} }
// 以下是多人的情况
// 先得到所有分批用户的集合 // 先得到所有分批用户的集合
var allAppointUsers = [YHResignAppointUser]() var allAppointUsers = [YHResignAppointUser]()
for group in scheduleArr { for group in scheduleArr {
...@@ -195,9 +199,14 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -195,9 +199,14 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
} }
} }
// 多人多批 // 上一个批次中未选中的用户集合
var groupArr = [YHResignAppointTimeSettingModel]() var lastLeftUnselectUsers: [YHResignAppointMember] = uniqueAllAppointUsers.deepCopy().map {
let m = $0.transformToMember()
m.isSelected = false
return m
}
var groupArr = [YHResignAppointTimeSettingModel]()
for (index, group) in scheduleArr.enumerated() { for (index, group) in scheduleArr.enumerated() {
let model = YHResignAppointTimeSettingModel() let model = YHResignAppointTimeSettingModel()
let status = group.getConfirmInHKStatus() let status = group.getConfirmInHKStatus()
...@@ -207,23 +216,40 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -207,23 +216,40 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
model.notleaveHK = group.leave_hk_at.isEmpty model.notleaveHK = group.leave_hk_at.isEmpty
model.itemIndex = index model.itemIndex = index
// 先讲所有需分批用户设置为未选择状态 if status != .haveConfirmHK { // 非已确认在港
let users = uniqueAllAppointUsers.map { // 先讲所有需分批用户设置为未选择状态
let m = $0.transformToMember() let users = lastLeftUnselectUsers.map {
m.isSelected = false let m = $0.copy() as! YHResignAppointMember
return m m.isSelected = false
} return m
// group.user_list 表示当前批已选用户组 更新已选择状态 }
for selectUser in group.user_list {
for user in users { // group.user_list 表示当前批已选用户组 更新已选择状态
if user.id == selectUser.id { for selectUser in group.user_list {
user.isSelected = true for user in users {
break if user.id == selectUser.id {
user.isSelected = true
break
}
} }
} }
model.users = users
groupArr.append(model)
lastLeftUnselectUsers = users.filter {
return $0.isSelected == false
}.deepCopy()
} else { // 已确认在港
lastLeftUnselectUsers = lastLeftUnselectUsers.filter {
for model in group.user_list {
if model.id == $0.id { // 该用户已经选择过
return false
}
}
return false
}.deepCopy()
} }
model.users = users
groupArr.append(model)
} }
let modifyVC = YHResignAppointTimeModifyViewController() let modifyVC = YHResignAppointTimeModifyViewController()
...@@ -231,6 +257,16 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -231,6 +257,16 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
modifyVC.selectGroupArr = groupArr modifyVC.selectGroupArr = groupArr
self.navigationController?.pushViewController(modifyVC) self.navigationController?.pushViewController(modifyVC)
} }
func isAtLeatOneHaveConfirmInHK() -> Bool { // 所有行程安排中是否至少有一个已确认在港
for group in scheduleArr {
let status = group.getConfirmInHKStatus()
if status == .haveConfirmHK {
return true
}
}
return false
}
} }
extension YHResignAppointSubmitScheduleViewController: UITableViewDelegate, UITableViewDataSource { extension YHResignAppointSubmitScheduleViewController: UITableViewDelegate, UITableViewDataSource {
......
...@@ -98,8 +98,9 @@ class YHResignAppointTimeModifyViewController: YHBaseViewController { ...@@ -98,8 +98,9 @@ class YHResignAppointTimeModifyViewController: YHBaseViewController {
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
make.height.equalTo(98) make.height.equalTo(98)
} }
} }
} }
extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableViewDataSource { extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableViewDataSource {
...@@ -119,12 +120,13 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV ...@@ -119,12 +120,13 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 { if indexPath.section == 0 {
// 不能编辑是否一起递交 只展示
let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionResultCell let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionResultCell
cell1.isTogether = self.isTogether cell1.isTogether = self.isTogether
return cell1 return cell1
} }
if 0 <= indexPath.row && indexPath.row < familyArr.count { if 0 <= indexPath.row && indexPath.row < selectGroupArr.count {
let model = selectGroupArr[indexPath.row] let model = selectGroupArr[indexPath.row]
if model.isHaveAppointed { // 已确认在港 只展示信息 if model.isHaveAppointed { // 已确认在港 只展示信息
let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointApplicantInfoCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointApplicantInfoCell let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointApplicantInfoCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointApplicantInfoCell
...@@ -163,8 +165,8 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV ...@@ -163,8 +165,8 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.row && indexPath.row < familyArr.count { if 0 <= indexPath.row && indexPath.row < selectGroupArr.count {
let model = familyArr[indexPath.row] let model = selectGroupArr[indexPath.row]
} }
} }
......
...@@ -60,6 +60,7 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -60,6 +60,7 @@ class YHResignAppointTimeViewController: YHBaseViewController {
tableView.bounces = false tableView.bounces = false
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell") tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHResignAppointOptionCell.self, forCellReuseIdentifier: YHResignAppointOptionCell.cellReuseIdentifier) tableView.register(YHResignAppointOptionCell.self, forCellReuseIdentifier: YHResignAppointOptionCell.cellReuseIdentifier)
tableView.register(YHResignAppointOptionResultCell.self, forCellReuseIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier)
tableView.register(YHResignAppointTimeSingleCell.self, forCellReuseIdentifier: YHResignAppointTimeSingleCell.cellReuseIdentifier) tableView.register(YHResignAppointTimeSingleCell.self, forCellReuseIdentifier: YHResignAppointTimeSingleCell.cellReuseIdentifier)
tableView.register(YHResignAppointTimeMultipleCell.self, forCellReuseIdentifier: YHResignAppointTimeMultipleCell.cellReuseIdentifier) tableView.register(YHResignAppointTimeMultipleCell.self, forCellReuseIdentifier: YHResignAppointTimeMultipleCell.cellReuseIdentifier)
tableView.delegate = self tableView.delegate = self
...@@ -125,6 +126,7 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -125,6 +126,7 @@ class YHResignAppointTimeViewController: YHBaseViewController {
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
make.height.equalTo(98) make.height.equalTo(98)
} }
self.updateUI()
} }
func updateUI() { func updateUI() {
...@@ -133,10 +135,11 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -133,10 +135,11 @@ class YHResignAppointTimeViewController: YHBaseViewController {
selectGroupArr.removeAll() selectGroupArr.removeAll()
if isOnyOne { // 只有一个人 if isOnyOne { // 只有一个人
self.togetherSetting.is_together = 0 // togetherArr 不放元素 则不展示是否一起递交cell
let model1 = YHResignAppointTimeSettingModel() let model1 = YHResignAppointTimeSettingModel()
model1.ready_to_submit_at = defaultSubmitTime model1.ready_to_submit_at = defaultSubmitTime
model1.leave_hk_at = defaultLeaveHKTime model1.leave_hk_at = defaultLeaveHKTime
model1.notleaveHK = !defaultLeaveHKTime.isEmpty
selectGroupArr.append(model1) selectGroupArr.append(model1)
self.tableView.reloadData() self.tableView.reloadData()
return return
...@@ -149,6 +152,7 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -149,6 +152,7 @@ class YHResignAppointTimeViewController: YHBaseViewController {
let model1 = YHResignAppointTimeSettingModel() let model1 = YHResignAppointTimeSettingModel()
model1.ready_to_submit_at = defaultSubmitTime model1.ready_to_submit_at = defaultSubmitTime
model1.leave_hk_at = defaultLeaveHKTime model1.leave_hk_at = defaultLeaveHKTime
model1.notleaveHK = !defaultLeaveHKTime.isEmpty
if self.togetherSetting.is_together == 2 { // 不一起递交 需显示候选人列表 if self.togetherSetting.is_together == 2 { // 不一起递交 需显示候选人列表
// 默认全部选中 // 默认全部选中
let users = allAppointUsers.deepCopy().map { let users = allAppointUsers.deepCopy().map {
...@@ -312,9 +316,8 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -312,9 +316,8 @@ class YHResignAppointTimeViewController: YHBaseViewController {
} }
} }
let param: [String : Any] = ["renewal_id" : renewalId, let param: [String : Any] = ["renewal_id" : renewalId,
"is_together" : self.togetherSetting.is_together, "is_together" : (self.isOnyOne ? 0 : self.togetherSetting.is_together),
"batch" : batchs] "batch" : batchs]
printLog(param) printLog(param)
YHHUD.show(.progress(message: "加载中...")) YHHUD.show(.progress(message: "加载中..."))
...@@ -349,24 +352,30 @@ extension YHResignAppointTimeViewController: UITableViewDelegate, UITableViewDat ...@@ -349,24 +352,30 @@ extension YHResignAppointTimeViewController: UITableViewDelegate, UITableViewDat
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 { // 是否一起在港递交的cell if indexPath.section == 0 { // 是否一起在港递交的cell
let cell = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionCell if self.togetherSetting.isCanEdit {
if self.togetherSetting.is_together == 1 { let cell = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionCell
cell.isSelectTogether = true if self.togetherSetting.is_together == 1 {
cell.isSelectTogether = true
} else if self.togetherSetting.is_together == 2 {
cell.isSelectTogether = false } else if self.togetherSetting.is_together == 2 {
cell.isSelectTogether = false
} else {
cell.isSelectTogether = nil } else {
} cell.isSelectTogether = nil
cell.selectBlock = { }
[weak self] index in cell.selectBlock = {
guard let self = self else { return } [weak self] index in
// index == 1 表示否 guard let self = self else { return }
self.togetherSetting.is_together = (index == 1 ? 2 : 1) // index == 1 表示否
self.updateUI() self.togetherSetting.is_together = (index == 1 ? 2 : 1)
self.updateUI()
}
return cell
} }
return cell // 不能编辑是否一起递交 只展示
let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionResultCell
cell1.isTogether = (self.togetherSetting.is_together == 1)
return cell1
} }
// 时间选择cell // 时间选择cell
......
...@@ -11,7 +11,7 @@ import SmartCodable ...@@ -11,7 +11,7 @@ import SmartCodable
class YHResignAppointTogetherSetting: SmartCodable { class YHResignAppointTogetherSetting: SmartCodable {
var is_together: Int = 0 // 0未选择 1是 2不是 一起赴港 var is_together: Int = 0 // 0未选择 1是 2不是 一起赴港
var isCanEdit: Bool = true // 是否可编辑
required init() { required init() {
} }
......
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