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

// 重新预约逻辑

parent ca753822
......@@ -36,7 +36,7 @@ class YHCertificateAppointViewController: YHBaseViewController {
// 需要预约办证人员
var waitAppointMembers:[YHHKMemberModel] = []
let viewModel = YHCerAppointViewModel()
var viewModel = YHCerAppointViewModel()
let bottomViewHeight = 98.0
// 是否赴港办证
......@@ -389,6 +389,12 @@ extension YHCertificateAppointViewController: UITableViewDelegate, UITableViewDa
[weak self] in
guard let self = self else { return }
let vc = YHReAppointViewController()
vc.orderId = self.orderId
vc.waitAppointMembers = self.waitAppointMembers.deepCopy()
vc.viewModel = self.viewModel
vc.updateBlock = {
self.requestData()
}
self.navigationController?.pushViewController(vc)
}
return cell
......@@ -794,6 +800,7 @@ extension YHCertificateAppointViewController {
YHHUD.show(.progress(message: "加载中..."))
viewModel.submitAppoint(params: params) {
[weak self] success, error in
YHHUD.hide()
guard let self = self else { return }
if success {
YHHUD.flash(message: "提交成功")
......
......@@ -14,6 +14,11 @@ class YHReAppointViewController: YHBaseViewController {
var orderId: Int = 0
var items:[YHAppointItem] = []
var waitAppointMembers:[YHHKMemberModel] = []
var viewModel = YHCerAppointViewModel()
var updateBlock:(()->())?
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
tableView.estimatedSectionHeaderHeight = 16.0
......@@ -38,6 +43,30 @@ class YHReAppointViewController: YHBaseViewController {
return tableView
}()
lazy var bottomBtn: UIButton = {
let btn = UIButton()
btn.backgroundColor = .brandMainColor
btn.setTitle("确认提交", for: .normal)
btn.setTitleColor(.white, for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
btn.addTarget(self, action: #selector(didBottomBtnClicked), for: .touchUpInside)
btn.layer.cornerRadius = kCornerRadius3
return btn
}()
lazy var bottomView: UIView = {
let view = UIView()
view.backgroundColor = .white
view.addSubview(bottomBtn)
bottomBtn.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(8)
make.height.equalTo(48)
}
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
createUI()
......@@ -49,10 +78,16 @@ class YHReAppointViewController: YHBaseViewController {
self.gk_navTitle = "赴港办证预约"
self.view.backgroundColor = .white
self.view.addSubview(self.tableView)
self.view.addSubview(bottomView)
self.tableView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalTo(bottomView.snp.top)
}
self.bottomView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(98.0)
}
updateData()
......@@ -65,11 +100,29 @@ class YHReAppointViewController: YHBaseViewController {
items.append(item1)
let item2 = YHAppointItem(type: .confirmGoHKInfo)
item2.itemIndex = 0
let group1 = YHSelectGroupMemberModel()
group1.isAllMembersGoHK = true
group1.arr = waitAppointMembers
item2.model = group1
item2.placeList = self.viewModel.placeList
item2.arrHkHolidays = self.viewModel.dataModelForHkHolidays?.legaldays ?? []
items.append(item2)
self.tableView.reloadData()
}
func getReAppointMemberNameText() -> String {
var text = ""
for (index, user) in self.waitAppointMembers.enumerated() {
text += user.name
if index != self.waitAppointMembers.count-1 {
text += "、"
}
}
text = "成员:\(text)"
return text
}
}
extension YHReAppointViewController: UITableViewDelegate, UITableViewDataSource {
......@@ -93,6 +146,14 @@ extension YHReAppointViewController: UITableViewDelegate, UITableViewDataSource
// 请您确认第X批赴港信息
let cell = tableView.dequeueReusableCell(withIdentifier: YHSelectApplicantGroupCell.cellReuseIdentifier, for: indexPath) as! YHSelectApplicantGroupCell
cell.isShowSelectUserView = false
cell.isShowRepointNameView = true
cell.repointMembersNameLabel.text = self.getReAppointMemberNameText()
cell.dataModel = item
cell.refreshBlock = {
[weak self] in
guard let self = self else { return }
self.tableView.reloadData()
}
return cell
}
}
......@@ -128,3 +189,96 @@ extension YHReAppointViewController: UITableViewDelegate, UITableViewDataSource
}
}
extension YHReAppointViewController {
@objc func didBottomBtnClicked() {
// 检测各批次是否有日期或办证地点未选择
var isOK = true
for item in self.items {
if item.type != .confirmGoHKInfo {
continue
}
if let groupModel = item.model {
if groupModel.dateTye == 0 { // 选择具体日期
if groupModel.detailDateStr.isEmpty {
groupModel.isNeedCheck = true
isOK = false
}
} else { // 选择具体时段
if groupModel.startDateStr.isEmpty || groupModel.endDateStr.isEmpty {
groupModel.isNeedCheck = true
isOK = false
}
}
// 办证地点未选
if groupModel.hkPlace.name.isEmpty {
groupModel.isNeedCheck = true
isOK = false
}
}
}
if !isOK { // 检测各批次是否有日期或办证地点未选择
self.tableView.reloadData()
return
}
var batchs:[[String: Any]] = []
for group in items {
if let model = group.model {
var start_time = ""
var end_time = ""
if model.dateTye == 0 { // 具体时间
start_time = model.detailDateStr
end_time = model.detailDateStr
} else { // 具体时段
start_time = model.startDateStr
end_time = model.endDateStr
}
let selectUsers = model.arr.filter {
return $0.isSelected == true
}
let users = self.waitAppointMembers.map {
let dict = ["id" : $0.id,
"type" : $0.type,
"name" : $0.name] as! [String : Any]
return dict
}
if users.count > 0 {
let batch:[String : Any] = ["start_time" : start_time,
"end_time" : end_time,
"migration_office" : model.hkPlace.name,
"users" : users]
batchs.append(batch)
}
}
}
// 请求参数
let params:[String : Any] = ["order_id": orderId,
"batch": batchs]
printLog("\(params)")
YHHUD.show(.progress(message: "加载中..."))
viewModel.submitAppoint(params: params) {
[weak self] success, error in
YHHUD.hide()
guard let self = self else { return }
if success {
YHHUD.flash(message: "提交成功")
updateBlock?()
self.navigationController?.popViewController()
return
}
let msg = error?.errorMsg ?? ""
YHHUD.flash(message: msg)
}
}
}
......@@ -29,35 +29,53 @@ class YHSelectApplicantGroupCell: UITableViewCell {
didSet {
detailLabel.isHidden = !isShowSelectUserView
selectGroupView.isHidden = !isShowSelectUserView
collectionView.isHidden = !isShowSelectUserView
lineView.isHidden = !isShowSelectUserView
detailLabel.text = isShowSelectUserView ? self.detailText : ""
detailLabel.snp.updateConstraints { make in
make.top.equalTo(lineView.snp.bottom).offset(isShowSelectUserView ? 16 : 0)
selectPanelView.isHidden = !isShowSelectUserView
selectPanelView.snp.remakeConstraints { make in
make.top.equalTo(reAppontNameView.snp.bottom)
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalTo(optionsView.snp.top)
if !isShowSelectUserView {
make.height.equalTo(0)
}
}
selectGroupView.snp.updateConstraints { make in
make.top.equalTo(detailLabel.snp.bottom).offset(isShowSelectUserView ? 12 : 0)
reAppontNameView.snp.remakeConstraints { make in
make.top.equalTo(lineView.snp.bottom)
make.left.equalTo(18)
make.right.equalTo(-18)
if !isShowRepointNameView {
make.height.equalTo(0)
}
}
collectionView.snp.updateConstraints { make in
make.top.equalTo(isShowSelectUserView ? 14 : 0)
make.bottom.equalTo(isShowSelectUserView ? -14 : 0)
make.height.equalTo(isShowSelectUserView ? self.getCollectionViewHeight() : 0)
}
optionsView.snp.updateConstraints { make in
make.top.equalTo(selectGroupView.snp.bottom).offset(isShowSelectUserView ? 16 : 0)
}
optionsView.lineView.isHidden = (!isShowSelectUserView && !isShowRepointNameView)
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
var isShowRepointNameView: Bool = false {
didSet {
reAppontNameView.snp.remakeConstraints { make in
make.top.equalTo(lineView.snp.bottom)
make.left.equalTo(18)
make.right.equalTo(-18)
if !isShowRepointNameView {
make.height.equalTo(0)
}
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
lazy var whiteContentView: UIView = {
let view = UIView()
view.backgroundColor = .white
......@@ -65,12 +83,6 @@ class YHSelectApplicantGroupCell: UITableViewCell {
return view
}()
lazy var lineView: UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
......@@ -80,7 +92,49 @@ class YHSelectApplicantGroupCell: UITableViewCell {
return label
}()
lazy var detailLabel: UILabel = {
lazy var lineView: UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
return view
}()
lazy var selectPanelView: UIView = {
let panelView = UIView()
panelView.addSubview(selecPanelTitleLabel)
let groupBgview = UIView()
groupBgview.backgroundColor = .init(hex: 0xF8F9FB)
groupBgview.layer.cornerRadius = kCornerRadius3
groupBgview.addSubview(collectionView)
panelView.addSubview(groupBgview)
selecPanelTitleLabel.snp.makeConstraints { make in
make.top.equalTo(16)
make.left.equalTo(18)
make.right.equalTo(-18)
}
groupBgview.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(selecPanelTitleLabel.snp.bottom).offset(12)
make.bottom.equalTo(-16)
}
collectionView.snp.makeConstraints { make in
make.left.equalTo(14)
make.right.equalTo(-14)
make.height.equalTo(0)
make.top.equalTo(14)
make.bottom.equalTo(-14)
}
return panelView
}()
lazy var selecPanelTitleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 14)
......@@ -89,13 +143,6 @@ class YHSelectApplicantGroupCell: UITableViewCell {
return label
}()
lazy var selectGroupView: UIView = {
let view = UIView()
view.backgroundColor = .init(hex: 0xF8F9FB)
view.layer.cornerRadius = kCornerRadius3
return view
}()
lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .vertical
......@@ -179,6 +226,45 @@ class YHSelectApplicantGroupCell: UITableViewCell {
return view
}()
lazy var reAppontNameView: UIView = {
let view = UIView()
let lineView = UIView()
lineView.backgroundColor = .separatorColor
view.addSubview(lineView)
let grayView = UIView()
grayView.backgroundColor = .init(hex: 0xF8F9FB)
grayView.addSubview(repointMembersNameLabel)
view.addSubview(grayView)
lineView.snp.makeConstraints { make in
make.left.right.top.equalTo(0)
make.height.equalTo(1)
}
grayView.snp.makeConstraints { make in
make.left.right.equalTo(0)
make.top.equalTo(lineView.snp.bottom).offset(12)
make.bottom.equalTo(-12)
}
repointMembersNameLabel.snp.makeConstraints { make in
make.left.equalTo(14)
make.right.equalTo(-14)
make.top.equalTo(14)
make.bottom.equalTo(-14)
}
return view
}()
lazy var repointMembersNameLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 13)
label.textColor = .mainTextColor
label.text = "成员:"
return label
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
......@@ -196,9 +282,8 @@ class YHSelectApplicantGroupCell: UITableViewCell {
contentView.addSubview(whiteContentView)
whiteContentView.addSubview(titleLabel)
whiteContentView.addSubview(lineView)
whiteContentView.addSubview(detailLabel)
whiteContentView.addSubview(selectGroupView)
selectGroupView.addSubview(collectionView)
whiteContentView.addSubview(reAppontNameView)
whiteContentView.addSubview(selectPanelView)
whiteContentView.addSubview(optionsView)
whiteContentView.addSubview(timeSelectView)
whiteContentView.addSubview(locationSelectView)
......@@ -218,34 +303,28 @@ class YHSelectApplicantGroupCell: UITableViewCell {
lineView.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.left.equalTo(0)
make.right.equalTo(0)
make.height.equalTo(0.5)
}
detailLabel.snp.makeConstraints { make in
make.top.equalTo(lineView.snp.bottom).offset(16)
make.left.equalTo(18)
make.right.equalTo(-18)
}
selectGroupView.snp.makeConstraints { make in
reAppontNameView.snp.makeConstraints { make in
make.top.equalTo(lineView.snp.bottom)
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(detailLabel.snp.bottom).offset(12)
make.height.equalTo(0)
}
collectionView.snp.makeConstraints { make in
make.left.equalTo(14)
make.right.equalTo(-14)
make.height.equalTo(40+16)
make.top.equalTo(14)
make.bottom.equalTo(-14)
selectPanelView.snp.makeConstraints { make in
make.top.equalTo(reAppontNameView.snp.bottom)
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalTo(optionsView.snp.top)
}
optionsView.snp.makeConstraints { make in
make.top.equalTo(selectGroupView.snp.bottom).offset(16)
make.left.equalTo(18)
make.right.equalTo(0)
make.right.equalTo(-18)
}
timeSelectView.snp.makeConstraints { make in
......@@ -322,6 +401,8 @@ private extension YHSelectApplicantGroupCell {
let b: ASAttributedString = .init("请您确认第\(batchNumberText)批赴港信息", .font(UIFont.PFSC_M(ofSize: 17)),.foreground(UIColor.mainTextColor))
titleLabel.attributed.text = a+b
selecPanelTitleLabel.text = "选择第\(batchNumberText)批赴港激活签证的申请人"
collectionView.reloadData()
// 时间选择UI更新
......
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