Commit 4be64f0f authored by Steven杜宇's avatar Steven杜宇

// 预约

parent 9a23bd8f
...@@ -72,31 +72,36 @@ class YHResignAppointContainerViewController: YHBaseViewController { ...@@ -72,31 +72,36 @@ class YHResignAppointContainerViewController: YHBaseViewController {
YHHUD.flash(message: msg) YHHUD.flash(message: msg)
return return
} }
let isNotAppointed = self.viewModel.scheduleInfoList.renewal_List.count <= 0
if isNotAppointed { // 没有预约过 // 请求预约人员列表
// 请求预约人员列表 YHHUD.show(.progress(message: "加载中..."))
YHHUD.show(.progress(message: "加载中...")) self.viewModel.getResignAppointUserlist(renewalId: self.renewalId) {
self.viewModel.getResignAppointUserlist(renewalId: self.renewalId) { [weak self] success2, error2 in
[weak self] success2, error2 in YHHUD.hide()
YHHUD.hide() guard let self = self else { return }
guard let self = self else { return }
if !success2 { if !success2 {
let msg = error2?.errorMsg ?? "服务器未知错误" let msg = error2?.errorMsg ?? "服务器未知错误"
YHHUD.flash(message: msg) YHHUD.flash(message: msg)
return return
} }
let isNotAppointed = self.viewModel.scheduleInfoList.renewal_List.count <= 0
if isNotAppointed { // 没有预约过
self.appointVC.allAppointUsers = self.viewModel.appointUsers self.appointVC.allAppointUsers = self.viewModel.appointUsers
self.appointVC.view.isHidden = false self.appointVC.view.isHidden = false
self.scheduleVC.view.isHidden = true self.scheduleVC.view.isHidden = true
}
} else { // 预约过
} else { // 预约过 self.scheduleVC.allAppointUsers = self.viewModel.appointUsers
self.scheduleVC.result_open = self.viewModel.scheduleInfoList.result_open self.scheduleVC.result_open = self.viewModel.scheduleInfoList.result_open
self.scheduleVC.scheduleArr = self.viewModel.scheduleInfoList.renewal_List self.scheduleVC.scheduleArr = self.viewModel.scheduleInfoList.renewal_List
self.scheduleVC.isTogether = self.viewModel.scheduleInfoList.is_together self.scheduleVC.isTogether = self.viewModel.scheduleInfoList.is_together
self.scheduleVC.view.isHidden = false self.scheduleVC.view.isHidden = false
self.appointVC.view.isHidden = true self.appointVC.view.isHidden = true
scheduleBlock?() scheduleBlock?()
}
} }
} }
} }
......
...@@ -25,6 +25,10 @@ class YHResignAppointScheduleListViewController: YHBaseViewController { ...@@ -25,6 +25,10 @@ class YHResignAppointScheduleListViewController: YHBaseViewController {
self.updateBottomBtnAndMotifyBtnStatus() self.updateBottomBtnAndMotifyBtnStatus()
} }
} }
// 所有未预约人员
var allAppointUsers: [YHResignAppointMember] = []
// 是否隐藏修改按钮 // 是否隐藏修改按钮
var isHiddenModifyBtn: Bool = false var isHiddenModifyBtn: Bool = false
...@@ -216,7 +220,7 @@ class YHResignAppointScheduleListViewController: YHBaseViewController { ...@@ -216,7 +220,7 @@ class YHResignAppointScheduleListViewController: YHBaseViewController {
} }
} }
if isOnlyOneUser || isOnlyOneGroup { // 只有一个人或多人单批 此时scheduleArr只有一个元素 if isOnlyOneUser { // 只有一个人
if scheduleArr.count > 0 { if scheduleArr.count > 0 {
// 先得到所有分批用户的集合 // 先得到所有分批用户的集合
YHHUD.show(.progress(message: "加载中...")) YHHUD.show(.progress(message: "加载中..."))
...@@ -254,6 +258,7 @@ class YHResignAppointScheduleListViewController: YHBaseViewController { ...@@ -254,6 +258,7 @@ class YHResignAppointScheduleListViewController: YHBaseViewController {
} }
let appAppointUsers = self.viewModel.appointUsers let appAppointUsers = self.viewModel.appointUsers
// 组装数据 // 组装数据
// 上一个批次中未选中的用户集合 // 上一个批次中未选中的用户集合
var lastLeftUnselectUsers: [YHResignAppointMember] = appAppointUsers.deepCopy() var lastLeftUnselectUsers: [YHResignAppointMember] = appAppointUsers.deepCopy()
...@@ -339,6 +344,10 @@ class YHResignAppointScheduleListViewController: YHBaseViewController { ...@@ -339,6 +344,10 @@ class YHResignAppointScheduleListViewController: YHBaseViewController {
let modifyVC = YHResignAppointTimeModifyViewController() let modifyVC = YHResignAppointTimeModifyViewController()
modifyVC.renewalId = self.renewalId modifyVC.renewalId = self.renewalId
modifyVC.selectGroupArr = groupArr modifyVC.selectGroupArr = groupArr
modifyVC.allAppointUsers = appAppointUsers.deepCopy()
// 只要有一个已确认在港则不能再编辑是否一起递交
modifyVC.isCanEditTogether = !self.isAtLeastOneHeaveConfirmInHK()
modifyVC.isTogether = (self.isTogether == 1)
self.navigationController?.pushViewController(modifyVC) self.navigationController?.pushViewController(modifyVC)
} }
} }
...@@ -354,6 +363,19 @@ class YHResignAppointScheduleListViewController: YHBaseViewController { ...@@ -354,6 +363,19 @@ class YHResignAppointScheduleListViewController: YHBaseViewController {
return isAllHaveConfirmed return isAllHaveConfirmed
} }
func isAtLeastOneHeaveConfirmInHK() -> Bool { // 至少有一个已确认在港
var isAtLeastOneHaveConfirmed = false
for group in scheduleArr {
let status = group.getConfirmInHKStatus()
if status == .haveConfirmHK {
isAtLeastOneHaveConfirmed = true
}
}
return isAtLeastOneHaveConfirmed
}
func requestConfirmInHK(_ model: YHResignAppointGroup) { func requestConfirmInHK(_ model: YHResignAppointGroup) {
YHHUD.show(.progress(message: "提交中...")) YHHUD.show(.progress(message: "提交中..."))
self.viewModel.submitConfirmInHK(id: model.id, is_edit: model.is_edit) { self.viewModel.submitConfirmInHK(id: model.id, is_edit: model.is_edit) {
......
...@@ -13,8 +13,11 @@ import SwifterSwift ...@@ -13,8 +13,11 @@ import SwifterSwift
class YHResignAppointTimeModifyViewController: YHBaseViewController { class YHResignAppointTimeModifyViewController: YHBaseViewController {
var renewalId: Int = 0 var renewalId: Int = 0
var oneGroupTimeSetting = YHResignAppointTimeSettingModel()
var selectGroupArr: [YHResignAppointTimeSettingModel] = [] var selectGroupArr: [YHResignAppointTimeSettingModel] = []
// 所有未预约人员
var allAppointUsers: [YHResignAppointMember] = []
var isCanEditTogether: Bool = false
let viewModel = YHResignAppointViewModel() let viewModel = YHResignAppointViewModel()
// 是否一起在港递交 // 是否一起在港递交
...@@ -32,8 +35,11 @@ class YHResignAppointTimeModifyViewController: YHBaseViewController { ...@@ -32,8 +35,11 @@ class YHResignAppointTimeModifyViewController: YHBaseViewController {
tableView.backgroundColor = .clear tableView.backgroundColor = .clear
tableView.separatorStyle = .none tableView.separatorStyle = .none
tableView.bounces = false tableView.bounces = false
tableView.register(YHResignAppointOptionCell.self, forCellReuseIdentifier: YHResignAppointOptionCell.cellReuseIdentifier)
tableView.register(YHResignAppointOptionResultCell.self, forCellReuseIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier) tableView.register(YHResignAppointOptionResultCell.self, forCellReuseIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier)
tableView.register(YHResignHaveAppointedApplicantsInfoCell.self, forCellReuseIdentifier: YHResignHaveAppointedApplicantsInfoCell.cellReuseIdentifier) tableView.register(YHResignHaveAppointedApplicantsInfoCell.self, forCellReuseIdentifier: YHResignHaveAppointedApplicantsInfoCell.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
tableView.dataSource = self tableView.dataSource = self
...@@ -99,11 +105,24 @@ class YHResignAppointTimeModifyViewController: YHBaseViewController { ...@@ -99,11 +105,24 @@ class YHResignAppointTimeModifyViewController: YHBaseViewController {
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
make.height.equalTo(98) make.height.equalTo(98)
} }
if let firstUser = self.allAppointUsers.first {
let users = allAppointUsers.deepCopy().map {
let item = $0
item.isSelected = true
return item
}
oneGroupTimeSetting.users = users
oneGroupTimeSetting.isShowUsers = false
}
self.tableView.reloadData()
} }
@objc func didTipsBtnClicked() { @objc func didTipsBtnClicked() {
YHResignAppointSubmitTipsView.alertView().show() YHResignAppointSubmitTipsView.alertView().show()
} }
} }
extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableViewDataSource { extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableViewDataSource {
...@@ -117,6 +136,9 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV ...@@ -117,6 +136,9 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV
return 1 return 1
} }
// 分组section // 分组section
if self.isTogether {
return 1
}
return selectGroupArr.count return selectGroupArr.count
} }
...@@ -124,9 +146,39 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV ...@@ -124,9 +146,39 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV
if indexPath.section == 0 { if indexPath.section == 0 {
// 不能编辑是否一起递交 只展示 // 不能编辑是否一起递交 只展示
let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionResultCell if !self.isCanEditTogether {
cell1.isTogether = self.isTogether let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionResultCell
return cell1 cell1.isTogether = self.isTogether
return cell1
}
// 可编辑是否一起递交
let cell = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionCell
cell.isSelectTogether = self.isTogether
cell.selectBlock = {
[weak self] index in
guard let self = self else { return }
// index == 1 表示否
self.isTogether = (index == 1 ? false : true)
self.tableView.reloadData()
}
return cell
}
if self.isTogether { // 选择是一起递交
let cell2 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointTimeSingleCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointTimeSingleCell
cell2.updateModel(self.oneGroupTimeSetting)
cell2.switchBlock = {
[weak self] isOn in
guard let self = self else { return }
self.oneGroupTimeSetting.notleaveHK = isOn
self.tableView.reloadData()
}
cell2.refreshBlock = {
[weak self] in
guard let self = self else { return }
self.tableView.reloadData()
}
return cell2
} }
if 0 <= indexPath.row && indexPath.row < selectGroupArr.count { if 0 <= indexPath.row && indexPath.row < selectGroupArr.count {
...@@ -136,6 +188,7 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV ...@@ -136,6 +188,7 @@ extension YHResignAppointTimeModifyViewController: UITableViewDelegate, UITableV
cell1.updateModel(model) cell1.updateModel(model)
return cell1 return cell1
} }
// 分批次cell // 分批次cell
let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointTimeMultipleCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointTimeMultipleCell let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointTimeMultipleCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointTimeMultipleCell
cell1.updateModel(model) cell1.updateModel(model)
...@@ -323,52 +376,84 @@ extension YHResignAppointTimeModifyViewController { ...@@ -323,52 +376,84 @@ extension YHResignAppointTimeModifyViewController {
@objc func didSubmitBtnClicked() { @objc func didSubmitBtnClicked() {
// 判断是否有分组没有选择时间 // 判断所有组是否有选择时间
var isNoSelectTime = false var isNoSelectTime = false
for group in self.selectGroupArr {
if !group.isHaveAppointed { if self.isTogether { // 选择一起递交
group.isClickSubmit = true self.oneGroupTimeSetting.isClickSubmit = true
var noSeletTime = false var noSeletTime = false
if group.notleaveHK { if self.oneGroupTimeSetting.notleaveHK {
noSeletTime = group.ready_to_submit_at.isEmpty noSeletTime = self.oneGroupTimeSetting.ready_to_submit_at.isEmpty
} else { } else {
noSeletTime = (group.ready_to_submit_at.isEmpty || group.leave_hk_at.isEmpty) noSeletTime = (self.oneGroupTimeSetting.ready_to_submit_at.isEmpty || self.oneGroupTimeSetting.leave_hk_at.isEmpty)
} }
if noSeletTime { if noSeletTime {
isNoSelectTime = true self.tableView.reloadData()
YHHUD.flash(message: "未选择时间")
return
}
} else { // 非一起递交
for group in self.selectGroupArr {
if !group.isHaveAppointed {
group.isClickSubmit = true
var noSeletTime = false
if group.notleaveHK {
noSeletTime = group.ready_to_submit_at.isEmpty
} else {
noSeletTime = (group.ready_to_submit_at.isEmpty || group.leave_hk_at.isEmpty)
}
if noSeletTime {
isNoSelectTime = true
}
} }
} }
if isNoSelectTime { // 有分组没有选择时间
self.tableView.reloadData()
YHHUD.flash(message: "有分批未选择时间")
return
}
} }
if isNoSelectTime { // 有分组没有选择时间
self.tableView.reloadData()
YHHUD.flash(message: "有分批未选择时间")
return
}
requestSubmit() requestSubmit()
} }
func requestSubmit() { func requestSubmit() {
var batchs: [[String : Any]] = [] var batchs: [[String : Any]] = []
for group in self.selectGroupArr {
group.isClickSubmit = false if self.isTogether {
if !group.isHaveAppointed { // 非已确认在港 才加入集合 let allUserInfoArr = self.allAppointUsers.map {
let selectUser = group.users.filter { let dict = ["member_id" : "\($0.id)"]
let item = $0 return dict
return item.isSelected }
} let dict = ["ready_to_submit_at" : self.oneGroupTimeSetting.getSubmitHKTime(),
let allUserInfoArr = selectUser.map { "leave_hk_at" : self.oneGroupTimeSetting.notleaveHK ? "" : self.oneGroupTimeSetting.getLeaveHKTime(),
let dict = ["member_id" : "\($0.id)"] "users" : allUserInfoArr] as! [String : Any]
return dict batchs.append(dict)
} else {
for group in self.selectGroupArr {
group.isClickSubmit = false
if !group.isHaveAppointed { // 非已确认在港 才加入集合
let selectUser = group.users.filter {
let item = $0
return item.isSelected
}
let allUserInfoArr = selectUser.map {
let dict = ["member_id" : "\($0.id)"]
return dict
}
let dict = ["ready_to_submit_at" : group.getSubmitHKTime(),
"leave_hk_at" : group.notleaveHK ? "" : group.getLeaveHKTime(),
"users" : allUserInfoArr] as! [String : Any]
batchs.append(dict)
} }
let dict = ["ready_to_submit_at" : group.getSubmitHKTime(),
"leave_hk_at" : group.notleaveHK ? "" : group.getLeaveHKTime(),
"users" : allUserInfoArr] as! [String : Any]
batchs.append(dict)
} }
} }
let param: [String : Any] = ["renewal_id" : renewalId, let param: [String : Any] = ["renewal_id" : renewalId,
"is_together" : self.isTogether ? 1 : 2, "is_together" : self.isTogether ? 1 : 2,
"batch" : batchs] "batch" : batchs]
......
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