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

// 分批修改

parent f2132ce0
...@@ -3549,8 +3549,8 @@ ...@@ -3549,8 +3549,8 @@
children = ( children = (
04912F932CB921C300CC3105 /* YHResignAppointContainerViewController.swift */, 04912F932CB921C300CC3105 /* YHResignAppointContainerViewController.swift */,
04912F6F2CB765FE00CC3105 /* YHResignAppointTimeViewController.swift */, 04912F6F2CB765FE00CC3105 /* YHResignAppointTimeViewController.swift */,
04912F952CB924DA00CC3105 /* YHResignAppointTimeModifyViewController.swift */,
04F4A5272CB8D4270026D469 /* YHResignAppointSubmitScheduleViewController.swift */, 04F4A5272CB8D4270026D469 /* YHResignAppointSubmitScheduleViewController.swift */,
04912F952CB924DA00CC3105 /* YHResignAppointTimeModifyViewController.swift */,
); );
path = C; path = C;
sourceTree = "<group>"; sourceTree = "<group>";
......
...@@ -15,6 +15,7 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -15,6 +15,7 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
var scheduleArr: [YHResignAppointGroup] = [] { var scheduleArr: [YHResignAppointGroup] = [] {
didSet { didSet {
self.tableView.reloadData() self.tableView.reloadData()
self.updateBottomBtnStatus()
} }
} }
...@@ -102,6 +103,7 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -102,6 +103,7 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
make.height.equalTo(98) make.height.equalTo(98)
} }
self.updateBottomBtnStatus()
} }
...@@ -109,6 +111,21 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -109,6 +111,21 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
} }
// 更新底部下一步按钮点击状态
func updateBottomBtnStatus() {
// 是否所有分批都已确认在港
var isAllGroupHaveConfirmInHK = true
for group in scheduleArr {
let confirmHKStatus = group.getConfirmInHKStatus()
if confirmHKStatus != .haveConfirmHK {
isAllGroupHaveConfirmInHK = false
}
}
self.nextBtn.isUserInteractionEnabled = isAllGroupHaveConfirmInHK
self.nextBtn.alpha = isAllGroupHaveConfirmInHK ? 1.0 : 0.3
}
func clickConfirmHKButton(status: YHResignConfirmHKStatus) { func clickConfirmHKButton(status: YHResignConfirmHKStatus) {
if status == .waitConfirmHK { // 待确认在港 if status == .waitConfirmHK { // 待确认在港
// 展示提前到港弹窗 // 展示提前到港弹窗
...@@ -152,6 +169,8 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -152,6 +169,8 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
let vc = YHResignAppointTimeViewController() let vc = YHResignAppointTimeViewController()
if scheduleArr.count > 0 { if scheduleArr.count > 0 {
let group = scheduleArr[0] let group = scheduleArr[0]
vc.defaultSubmitTime = group.ready_to_submit_at
vc.defaultLeaveHKTime = group.leave_hk_at
vc.allAppointUsers = group.user_list.map { vc.allAppointUsers = group.user_list.map {
return $0.transformToMember() return $0.transformToMember()
} }
...@@ -161,7 +180,24 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController { ...@@ -161,7 +180,24 @@ class YHResignAppointSubmitScheduleViewController: YHBaseViewController {
} }
// 多人多批 // 多人多批
var groupArr = [YHResignAppointTimeSettingModel]()
for (index, group) in scheduleArr.enumerated() {
let model = YHResignAppointTimeSettingModel()
let status = group.getConfirmInHKStatus()
model.isHaveAppointed = (status == .haveConfirmHK)
model.ready_to_submit_at = group.ready_to_submit_at
model.leave_hk_at = group.leave_hk_at
model.notleaveHK = group.leave_hk_at.isEmpty
model.itemIndex = index
model.users = group.user_list.map {
return $0.transformToMember()
}
groupArr.append(model)
}
let modifyVC = YHResignAppointTimeModifyViewController()
modifyVC.selectGroupArr = groupArr
self.navigationController?.pushViewController(modifyVC)
} }
} }
......
...@@ -10,16 +10,23 @@ import UIKit ...@@ -10,16 +10,23 @@ import UIKit
import AttributedString import AttributedString
import SwifterSwift import SwifterSwift
// 初始是单人或初始默认为所有人为一批的情况 可用此VC
class YHResignAppointTimeViewController: YHBaseViewController { class YHResignAppointTimeViewController: YHBaseViewController {
var renewalId: Int = 0 var renewalId: Int = 0
// 所有预约人员 // 所有预约人员
var allAppointUsers: [YHResignAppointMember] = [] var allAppointUsers: [YHResignAppointMember] = []
// 预约在港递交时间
var defaultSubmitTime: String = ""
// 预计离港时间
var defaultLeaveHKTime: String = ""
let viewModel = YHResignAppointViewModel() let viewModel = YHResignAppointViewModel()
// 申请人是否在港 // 申请人是否在港
var togetherArr: [YHResignAppointTogetherSetting] = [] var togetherArr: [YHResignAppointTogetherSetting] = []
// 是否一起在港递交
lazy var togetherSetting = { lazy var togetherSetting = {
let model = YHResignAppointTogetherSetting() let model = YHResignAppointTogetherSetting()
model.is_together = 1 model.is_together = 1
...@@ -28,8 +35,6 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -28,8 +35,6 @@ class YHResignAppointTimeViewController: YHBaseViewController {
// 分组信息 // 分组信息
var selectGroupArr: [YHResignAppointTimeSettingModel] = [] var selectGroupArr: [YHResignAppointTimeSettingModel] = []
// 是否一起赴港
var isTogether: Bool = true
// 是否单人 // 是否单人
private var isOnyOne: Bool { private var isOnyOne: Bool {
get { get {
...@@ -126,6 +131,8 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -126,6 +131,8 @@ class YHResignAppointTimeViewController: YHBaseViewController {
if isOnyOne { // 只有一个人 if isOnyOne { // 只有一个人
self.togetherSetting.is_together = 0 self.togetherSetting.is_together = 0
let model1 = YHResignAppointTimeSettingModel() let model1 = YHResignAppointTimeSettingModel()
model1.ready_to_submit_at = defaultSubmitTime
model1.leave_hk_at = defaultLeaveHKTime
selectGroupArr.append(model1) selectGroupArr.append(model1)
self.tableView.reloadData() self.tableView.reloadData()
return return
...@@ -136,6 +143,8 @@ class YHResignAppointTimeViewController: YHBaseViewController { ...@@ -136,6 +143,8 @@ class YHResignAppointTimeViewController: YHBaseViewController {
togetherArr.append(self.togetherSetting) togetherArr.append(self.togetherSetting)
// 分组数据 // 分组数据
let model1 = YHResignAppointTimeSettingModel() let model1 = YHResignAppointTimeSettingModel()
model1.ready_to_submit_at = defaultSubmitTime
model1.leave_hk_at = defaultLeaveHKTime
if self.togetherSetting.is_together == 2 { // 不一起递交 需显示候选人列表 if self.togetherSetting.is_together == 2 { // 不一起递交 需显示候选人列表
// 默认全部选中 // 默认全部选中
let users = allAppointUsers.deepCopy().map { let users = allAppointUsers.deepCopy().map {
......
...@@ -39,6 +39,45 @@ class YHResignAppointGroup: SmartCodable { ...@@ -39,6 +39,45 @@ class YHResignAppointGroup: SmartCodable {
// 自定义 第几批 // 自定义 第几批
var batchIndex: Int = 0 var batchIndex: Int = 0
func getConfirmInHKStatus() -> YHResignConfirmHKStatus {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let nowDateString = dateFormatter.string(from: Date())
var confirmStatus = YHResignConfirmHKStatus.waitConfirmHK
// 是否到了预约递交时间
let isArriveSubmitTime = compareDates(self.ready_to_submit_at, nowDateString)
if !isArriveSubmitTime {
// 待确认在港
confirmStatus = .waitConfirmHK
} else {
confirmStatus = !self.determine_hk_at.isEmpty ? .haveConfirmHK : .canConfirmHK
}
return confirmStatus
}
// dateString1 是否不小于dateString2
func compareDates(_ dateString1: String, _ dateString2: String) -> Bool {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
// 将字符串转换为 Date 对象
guard let date1 = dateFormatter.date(from: dateString1),
let date2 = dateFormatter.date(from: dateString2) else {
print("日期格式错误")
return false
}
// 比较日期
if date1 < date2 {
print("\(dateString1) 小于 \(dateString2)")
return false
}
return true
}
required init() { required init() {
} }
......
...@@ -15,8 +15,9 @@ class YHResignAppointTimeSettingModel: SmartCodable { ...@@ -15,8 +15,9 @@ class YHResignAppointTimeSettingModel: SmartCodable {
var leave_hk_at: String = "" // 预计离港时间 var leave_hk_at: String = "" // 预计离港时间
var notleaveHK: Bool = false // 暂不离港 var notleaveHK: Bool = false // 暂不离港
var users: [YHResignAppointMember] = [] var users: [YHResignAppointMember] = []
var itemIndex: Int = 0 // 第几批 var itemIndex: Int = 0 // 第几批 从0开始
var isClickSubmit: Bool = false var isClickSubmit: Bool = false
var isHaveAppointed: Bool = false
required init() { required init() {
......
...@@ -31,7 +31,7 @@ class YHResignAppointApplicantInfoCell: UITableViewCell { ...@@ -31,7 +31,7 @@ class YHResignAppointApplicantInfoCell: UITableViewCell {
label.numberOfLines = 0 label.numberOfLines = 0
label.font = UIFont.PFSC_M(ofSize: 17) label.font = UIFont.PFSC_M(ofSize: 17)
label.textColor = .mainTextColor label.textColor = .mainTextColor
label.text = "第批赴港递交信息" label.text = "第?批赴港递交信息"
return label return label
}() }()
...@@ -55,7 +55,7 @@ class YHResignAppointApplicantInfoCell: UITableViewCell { ...@@ -55,7 +55,7 @@ class YHResignAppointApplicantInfoCell: UITableViewCell {
label.numberOfLines = 0 label.numberOfLines = 0
label.font = UIFont.PFSC_M(ofSize: 14) label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = .mainTextColor label.textColor = .mainTextColor
label.text = "成员:侯林、张曼玉、刘德华" label.text = "成员:"
return label return label
}() }()
...@@ -82,6 +82,20 @@ class YHResignAppointApplicantInfoCell: UITableViewCell { ...@@ -82,6 +82,20 @@ class YHResignAppointApplicantInfoCell: UITableViewCell {
setupUI() setupUI()
} }
func updateModel(_ model: YHResignAppointTimeSettingModel) {
titleLabel.text = "第\(String.convertNumberToChineseText(model.itemIndex+1))批赴港递交信息"
var names = "成员:"
for (index, user) in model.users.enumerated() {
names += user.apply_name
if index != model.users.count-1 {
names += "、"
}
}
applicantNamesLabel.text = names
submitTimeView.detail = model.ready_to_submit_at
leaveHKTimeView.detail = model.leave_hk_at
}
func setupUI() { func setupUI() {
self.selectionStyle = .none self.selectionStyle = .none
......
...@@ -12,6 +12,12 @@ class YHResignAppointOptionResultCell: UITableViewCell { ...@@ -12,6 +12,12 @@ class YHResignAppointOptionResultCell: UITableViewCell {
static let cellReuseIdentifier = "YHResignAppointOptionResultCell" static let cellReuseIdentifier = "YHResignAppointOptionResultCell"
var isTogether: Bool = false {
didSet {
optionLabel.text = isTogether ? "是" : "否"
}
}
lazy var whiteContentView: UIView = { lazy var whiteContentView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .white view.backgroundColor = .white
......
...@@ -18,7 +18,11 @@ class YHResignAppointShowTimeItemView: UIView { ...@@ -18,7 +18,11 @@ class YHResignAppointShowTimeItemView: UIView {
var detail: String = "" { var detail: String = "" {
didSet { didSet {
detailLabel.text = detail var text = detail
if text.isEmpty {
text = " " // 空字符串不能自适应label高度
}
detailLabel.text = text
} }
} }
......
...@@ -98,26 +98,12 @@ class YHResignAppointedScheduleSingleItemView: UIView { ...@@ -98,26 +98,12 @@ class YHResignAppointedScheduleSingleItemView: UIView {
submitTimeLabel.text = "预约递交时间: " + model.ready_to_submit_at submitTimeLabel.text = "预约递交时间: " + model.ready_to_submit_at
confirmHKTimeLabel.text = "确认在港时间: " + model.determine_hk_at confirmHKTimeLabel.text = "确认在港时间: " + model.determine_hk_at
let dateFormatter = DateFormatter() self.confirmHKStatus = model.getConfirmInHKStatus()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let nowDateString = dateFormatter.string(from: Date())
var confirmStatus = YHResignConfirmHKStatus.waitConfirmHK
// 是否到了预约递交时间
let isArriveSubmitTime = compareDates(model.ready_to_submit_at, nowDateString)
if !isArriveSubmitTime {
// 待确认在港
confirmStatus = .waitConfirmHK
} else {
confirmStatus = !model.determine_hk_at.isEmpty ? .haveConfirmHK : .canConfirmHK
}
self.confirmHKStatus = confirmStatus
haveConfirmInHKLabel.isHidden = (confirmStatus != .haveConfirmHK) haveConfirmInHKLabel.isHidden = (self.confirmHKStatus != .haveConfirmHK)
confirmInHKBtn.isHidden = (confirmStatus == .haveConfirmHK) confirmInHKBtn.isHidden = (self.confirmHKStatus == .haveConfirmHK)
if confirmStatus == .waitConfirmHK { if self.confirmHKStatus == .waitConfirmHK {
confirmInHKBtn.setTitle("待确认在港", for: .normal) confirmInHKBtn.setTitle("待确认在港", for: .normal)
confirmInHKBtn.setTitleColor(.mainTextColor, for: .normal) confirmInHKBtn.setTitleColor(.mainTextColor, for: .normal)
confirmInHKBtn.backgroundColor = .init(hex: 0xF4F6FA) confirmInHKBtn.backgroundColor = .init(hex: 0xF4F6FA)
...@@ -126,7 +112,7 @@ class YHResignAppointedScheduleSingleItemView: UIView { ...@@ -126,7 +112,7 @@ class YHResignAppointedScheduleSingleItemView: UIView {
} }
} else if confirmStatus == .canConfirmHK { } else if self.confirmHKStatus == .canConfirmHK {
confirmInHKBtn.setTitle("确认在港", for: .normal) confirmInHKBtn.setTitle("确认在港", for: .normal)
confirmInHKBtn.setTitleColor(.white, for: .normal) confirmInHKBtn.setTitleColor(.white, for: .normal)
confirmInHKBtn.backgroundColor = .brandMainColor confirmInHKBtn.backgroundColor = .brandMainColor
...@@ -138,7 +124,7 @@ class YHResignAppointedScheduleSingleItemView: UIView { ...@@ -138,7 +124,7 @@ class YHResignAppointedScheduleSingleItemView: UIView {
confirmHKTimeLabel.removeFromSuperview() confirmHKTimeLabel.removeFromSuperview()
confirmHKTimeLabel.snp.removeConstraints() confirmHKTimeLabel.snp.removeConstraints()
if confirmStatus == .haveConfirmHK { // 已确认在港 需要显示确认在港时间 if self.confirmHKStatus == .haveConfirmHK { // 已确认在港 需要显示确认在港时间
self.addSubview(confirmHKTimeLabel) self.addSubview(confirmHKTimeLabel)
confirmHKTimeLabel.snp.remakeConstraints { make in confirmHKTimeLabel.snp.remakeConstraints { make in
make.left.equalTo(18) make.left.equalTo(18)
......
...@@ -118,26 +118,12 @@ class YHResignHaveAppointedMultipleInfoCell: UITableViewCell { ...@@ -118,26 +118,12 @@ class YHResignHaveAppointedMultipleInfoCell: UITableViewCell {
submitTimeLabel.text = "预约递交时间: " + model.ready_to_submit_at submitTimeLabel.text = "预约递交时间: " + model.ready_to_submit_at
confirmHKTimeLabel.text = "确认在港时间: " + model.determine_hk_at confirmHKTimeLabel.text = "确认在港时间: " + model.determine_hk_at
let dateFormatter = DateFormatter() self.confirmHKStatus = model.getConfirmInHKStatus()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let nowDateString = dateFormatter.string(from: Date())
var confirmStatus = YHResignConfirmHKStatus.waitConfirmHK
// 是否到了预约递交时间
let isArriveSubmitTime = compareDates(model.ready_to_submit_at, nowDateString)
if !isArriveSubmitTime {
// 待确认在港
confirmStatus = .waitConfirmHK
} else {
confirmStatus = !model.determine_hk_at.isEmpty ? .haveConfirmHK : .canConfirmHK
}
self.confirmHKStatus = confirmStatus
haveConfirmInHKLabel.isHidden = (confirmStatus != .haveConfirmHK) haveConfirmInHKLabel.isHidden = (self.confirmHKStatus != .haveConfirmHK)
confirmInHKBtn.isHidden = (confirmStatus == .haveConfirmHK) confirmInHKBtn.isHidden = (self.confirmHKStatus == .haveConfirmHK)
if confirmStatus == .waitConfirmHK { if self.confirmHKStatus == .waitConfirmHK {
confirmInHKBtn.setTitle("待确认在港", for: .normal) confirmInHKBtn.setTitle("待确认在港", for: .normal)
confirmInHKBtn.setTitleColor(.mainTextColor, for: .normal) confirmInHKBtn.setTitleColor(.mainTextColor, for: .normal)
confirmInHKBtn.backgroundColor = .init(hex: 0xF4F6FA) confirmInHKBtn.backgroundColor = .init(hex: 0xF4F6FA)
...@@ -146,7 +132,7 @@ class YHResignHaveAppointedMultipleInfoCell: UITableViewCell { ...@@ -146,7 +132,7 @@ class YHResignHaveAppointedMultipleInfoCell: UITableViewCell {
} }
} else if confirmStatus == .canConfirmHK { } else if self.confirmHKStatus == .canConfirmHK {
confirmInHKBtn.setTitle("确认在港", for: .normal) confirmInHKBtn.setTitle("确认在港", for: .normal)
confirmInHKBtn.setTitleColor(.white, for: .normal) confirmInHKBtn.setTitleColor(.white, for: .normal)
confirmInHKBtn.backgroundColor = .brandMainColor confirmInHKBtn.backgroundColor = .brandMainColor
...@@ -158,7 +144,7 @@ class YHResignHaveAppointedMultipleInfoCell: UITableViewCell { ...@@ -158,7 +144,7 @@ class YHResignHaveAppointedMultipleInfoCell: UITableViewCell {
confirmHKTimeLabel.removeFromSuperview() confirmHKTimeLabel.removeFromSuperview()
confirmHKTimeLabel.snp.removeConstraints() confirmHKTimeLabel.snp.removeConstraints()
if confirmStatus == .haveConfirmHK { // 已确认在港 需要显示确认在港时间 if self.confirmHKStatus == .haveConfirmHK { // 已确认在港 需要显示确认在港时间
self.addSubview(confirmHKTimeLabel) self.addSubview(confirmHKTimeLabel)
confirmHKTimeLabel.snp.remakeConstraints { make in confirmHKTimeLabel.snp.remakeConstraints { make in
make.left.equalTo(18) make.left.equalTo(18)
...@@ -190,26 +176,6 @@ class YHResignHaveAppointedMultipleInfoCell: UITableViewCell { ...@@ -190,26 +176,6 @@ class YHResignHaveAppointedMultipleInfoCell: UITableViewCell {
self.layoutIfNeeded() self.layoutIfNeeded()
} }
// dateString1 是否不小于dateString2
func compareDates(_ dateString1: String, _ dateString2: String) -> Bool {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
// 将字符串转换为 Date 对象
guard let date1 = dateFormatter.date(from: dateString1),
let date2 = dateFormatter.date(from: dateString2) else {
print("日期格式错误")
return false
}
// 比较日期
if date1 < date2 {
print("\(dateString1) 小于 \(dateString2)")
return false
}
return true
}
func createUI() { func createUI() {
self.selectionStyle = .none self.selectionStyle = .none
......
...@@ -73,25 +73,7 @@ class YHResignHaveAppointedSingleInfoCell: UITableViewCell { ...@@ -73,25 +73,7 @@ class YHResignHaveAppointedSingleInfoCell: UITableViewCell {
modifyBtnBlock?() modifyBtnBlock?()
} }
// dateString1 是否不小于dateString2
func compareDates(_ dateString1: String, _ dateString2: String) -> Bool {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
// 将字符串转换为 Date 对象
guard let date1 = dateFormatter.date(from: dateString1),
let date2 = dateFormatter.date(from: dateString2) else {
print("日期格式错误")
return false
}
// 比较日期
if date1 < date2 {
print("\(dateString1) 小于 \(dateString2)")
return false
}
return true
}
func setupUI() { func setupUI() {
self.selectionStyle = .none self.selectionStyle = .none
......
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