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

// 预约

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