Commit 6fcaec2b authored by Alex朱枝文's avatar Alex朱枝文

在港记录各个列表接口调试

parent c8894731
...@@ -521,6 +521,8 @@ ...@@ -521,6 +521,8 @@
04CC2EF02BC3DDB2000305DD /* YHServiceBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CC2EEF2BC3DDB2000305DD /* YHServiceBannerView.swift */; }; 04CC2EF02BC3DDB2000305DD /* YHServiceBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CC2EEF2BC3DDB2000305DD /* YHServiceBannerView.swift */; };
04CCEDF72CA0FCB10026EA70 /* YHHKImmigrationRecordsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CCEDF62CA0FCB10026EA70 /* YHHKImmigrationRecordsViewModel.swift */; }; 04CCEDF72CA0FCB10026EA70 /* YHHKImmigrationRecordsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CCEDF62CA0FCB10026EA70 /* YHHKImmigrationRecordsViewModel.swift */; };
04CCEDF92CA0FD5F0026EA70 /* YHHKImmigrationRecordsSummaryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CCEDF82CA0FD5F0026EA70 /* YHHKImmigrationRecordsSummaryModel.swift */; }; 04CCEDF92CA0FD5F0026EA70 /* YHHKImmigrationRecordsSummaryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CCEDF82CA0FD5F0026EA70 /* YHHKImmigrationRecordsSummaryModel.swift */; };
04CCEDFB2CA142010026EA70 /* YHHKImmigrationRecordsStatisticsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CCEDFA2CA142010026EA70 /* YHHKImmigrationRecordsStatisticsModel.swift */; };
04CCEDFD2CA150ED0026EA70 /* YHHKImmigrationRecordsSingleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CCEDFC2CA150ED0026EA70 /* YHHKImmigrationRecordsSingleModel.swift */; };
04CE1ACF2C2AD91F001CB80A /* YHActivityViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CE1AB72C2AD91F001CB80A /* YHActivityViewModel.swift */; }; 04CE1ACF2C2AD91F001CB80A /* YHActivityViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CE1AB72C2AD91F001CB80A /* YHActivityViewModel.swift */; };
04CE1AD02C2AD91F001CB80A /* YHActivityListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CE1AB92C2AD91F001CB80A /* YHActivityListModel.swift */; }; 04CE1AD02C2AD91F001CB80A /* YHActivityListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CE1AB92C2AD91F001CB80A /* YHActivityListModel.swift */; };
04CE1AD12C2AD91F001CB80A /* YHActivityTravelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CE1ABA2C2AD91F001CB80A /* YHActivityTravelModel.swift */; }; 04CE1AD12C2AD91F001CB80A /* YHActivityTravelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CE1ABA2C2AD91F001CB80A /* YHActivityTravelModel.swift */; };
...@@ -1372,6 +1374,8 @@ ...@@ -1372,6 +1374,8 @@
04CC2EEF2BC3DDB2000305DD /* YHServiceBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceBannerView.swift; sourceTree = "<group>"; }; 04CC2EEF2BC3DDB2000305DD /* YHServiceBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceBannerView.swift; sourceTree = "<group>"; };
04CCEDF62CA0FCB10026EA70 /* YHHKImmigrationRecordsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKImmigrationRecordsViewModel.swift; sourceTree = "<group>"; }; 04CCEDF62CA0FCB10026EA70 /* YHHKImmigrationRecordsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKImmigrationRecordsViewModel.swift; sourceTree = "<group>"; };
04CCEDF82CA0FD5F0026EA70 /* YHHKImmigrationRecordsSummaryModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKImmigrationRecordsSummaryModel.swift; sourceTree = "<group>"; }; 04CCEDF82CA0FD5F0026EA70 /* YHHKImmigrationRecordsSummaryModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKImmigrationRecordsSummaryModel.swift; sourceTree = "<group>"; };
04CCEDFA2CA142010026EA70 /* YHHKImmigrationRecordsStatisticsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKImmigrationRecordsStatisticsModel.swift; sourceTree = "<group>"; };
04CCEDFC2CA150ED0026EA70 /* YHHKImmigrationRecordsSingleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKImmigrationRecordsSingleModel.swift; sourceTree = "<group>"; };
04CE1AB72C2AD91F001CB80A /* YHActivityViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHActivityViewModel.swift; sourceTree = "<group>"; }; 04CE1AB72C2AD91F001CB80A /* YHActivityViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHActivityViewModel.swift; sourceTree = "<group>"; };
04CE1AB92C2AD91F001CB80A /* YHActivityListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHActivityListModel.swift; sourceTree = "<group>"; }; 04CE1AB92C2AD91F001CB80A /* YHActivityListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHActivityListModel.swift; sourceTree = "<group>"; };
04CE1ABA2C2AD91F001CB80A /* YHActivityTravelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHActivityTravelModel.swift; sourceTree = "<group>"; }; 04CE1ABA2C2AD91F001CB80A /* YHActivityTravelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHActivityTravelModel.swift; sourceTree = "<group>"; };
...@@ -3567,6 +3571,8 @@ ...@@ -3567,6 +3571,8 @@
children = ( children = (
04F243402C9AFBAB00DF2C74 /* YHHKRecordItemDetailType.swift */, 04F243402C9AFBAB00DF2C74 /* YHHKRecordItemDetailType.swift */,
04CCEDF82CA0FD5F0026EA70 /* YHHKImmigrationRecordsSummaryModel.swift */, 04CCEDF82CA0FD5F0026EA70 /* YHHKImmigrationRecordsSummaryModel.swift */,
04CCEDFA2CA142010026EA70 /* YHHKImmigrationRecordsStatisticsModel.swift */,
04CCEDFC2CA150ED0026EA70 /* YHHKImmigrationRecordsSingleModel.swift */,
04F243712C9EC90C00DF2C74 /* YHHKRecordsEditPersonnelModel.swift */, 04F243712C9EC90C00DF2C74 /* YHHKRecordsEditPersonnelModel.swift */,
); );
path = M; path = M;
...@@ -4932,6 +4938,7 @@ ...@@ -4932,6 +4938,7 @@
047AA3DD2C4A6126009C4554 /* YHLifeViewController.swift in Sources */, 047AA3DD2C4A6126009C4554 /* YHLifeViewController.swift in Sources */,
04FD856C2C2153F000BEF9C5 /* YHMyEducationCell.swift in Sources */, 04FD856C2C2153F000BEF9C5 /* YHMyEducationCell.swift in Sources */,
A5DE0D3C2BB9016200976FE1 /* YHEmailInputAlertView.swift in Sources */, A5DE0D3C2BB9016200976FE1 /* YHEmailInputAlertView.swift in Sources */,
04CCEDFD2CA150ED0026EA70 /* YHHKImmigrationRecordsSingleModel.swift in Sources */,
0418922A2C91CB2500B9FB94 /* YHResignDocumentStatus.swift in Sources */, 0418922A2C91CB2500B9FB94 /* YHResignDocumentStatus.swift in Sources */,
04256DE42C72E3FA00A37BA4 /* YHInfoItemOptionView.swift in Sources */, 04256DE42C72E3FA00A37BA4 /* YHInfoItemOptionView.swift in Sources */,
04256DF22C734E7E00A37BA4 /* YHGrabFileCell.swift in Sources */, 04256DF22C734E7E00A37BA4 /* YHGrabFileCell.swift in Sources */,
...@@ -5203,6 +5210,7 @@ ...@@ -5203,6 +5210,7 @@
04C85DE12C3677CB008B20D6 /* YHConsultantQRCodeView.swift in Sources */, 04C85DE12C3677CB008B20D6 /* YHConsultantQRCodeView.swift in Sources */,
A567E5A32BD7643D00D5D5A0 /* YHHomeBannerView.swift in Sources */, A567E5A32BD7643D00D5D5A0 /* YHHomeBannerView.swift in Sources */,
A5ACE9402B4564F7002C94D2 /* String+Extension.swift in Sources */, A5ACE9402B4564F7002C94D2 /* String+Extension.swift in Sources */,
04CCEDFB2CA142010026EA70 /* YHHKImmigrationRecordsStatisticsModel.swift in Sources */,
045EEEE42B9F171A0022A143 /* YHMySignatureDetailModel.swift in Sources */, 045EEEE42B9F171A0022A143 /* YHMySignatureDetailModel.swift in Sources */,
A5DF9C652C78B5A400CE48E6 /* YHUploadCertificateViewModel.swift in Sources */, A5DF9C652C78B5A400CE48E6 /* YHUploadCertificateViewModel.swift in Sources */,
A5EB6C722C69FB9A0081FB6C /* YHOffivialApprovalGuildLineCheckView.swift in Sources */, A5EB6C722C69FB9A0081FB6C /* YHOffivialApprovalGuildLineCheckView.swift in Sources */,
......
...@@ -12,11 +12,11 @@ import JXSegmentedView ...@@ -12,11 +12,11 @@ import JXSegmentedView
class YHHKImmigrationRecordsVC: YHBaseViewController { class YHHKImmigrationRecordsVC: YHBaseViewController {
private lazy var controllerOne: YHHKRecordsSummaryVC = YHHKRecordsSummaryVC(orderId: self.orderId) private lazy var controllerOne: YHHKRecordsSummaryVC = YHHKRecordsSummaryVC(orderId: self.orderId)
private lazy var controllerTwo: YHHKRecordsContentVC = YHHKRecordsContentVC() private lazy var controllerTwo: YHHKRecordsContentVC = YHHKRecordsContentVC(orderId: self.orderId, userType: .main)
private lazy var controllerThree: YHHKRecordsContentVC = YHHKRecordsContentVC() private lazy var controllerThree: YHHKRecordsContentVC = YHHKRecordsContentVC(orderId: self.orderId, userType: .spouse)
private lazy var controllerFour: YHHKRecordsContentVC = YHHKRecordsContentVC() private lazy var controllerFour: YHHKRecordsContentVC = YHHKRecordsContentVC(orderId: self.orderId, userType: .children)
private lazy var arrItemTitles = ["汇总", "主申", "配偶", "子女"] private lazy var arrItemTitles = ["汇总", "主申(0)", "配偶(0)", "子女(0)"]
private lazy var segmentedView: JXSegmentedView = { private lazy var segmentedView: JXSegmentedView = {
let view = JXSegmentedView(frame: CGRect(x: 0, y: k_Height_safeAreaInsetsTop(), width: KScreenWidth, height: 53)) let view = JXSegmentedView(frame: CGRect(x: 0, y: k_Height_safeAreaInsetsTop(), width: KScreenWidth, height: 53))
...@@ -76,9 +76,13 @@ class YHHKImmigrationRecordsVC: YHBaseViewController { ...@@ -76,9 +76,13 @@ class YHHKImmigrationRecordsVC: YHBaseViewController {
return view return view
}() }()
private lazy var viewModel = YHHKImmigrationRecordsViewModel()
private let orderId: Int private let orderId: Int
init(orderId: Int) { init(orderId: Int) {
self.orderId = orderId self.orderId = orderId
// TODO: - 先写死id alex,后续有可以调试账号再改
//self.orderId = 136013
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)
} }
...@@ -90,6 +94,11 @@ class YHHKImmigrationRecordsVC: YHBaseViewController { ...@@ -90,6 +94,11 @@ class YHHKImmigrationRecordsVC: YHBaseViewController {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
} }
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
requestData()
}
} }
extension YHHKImmigrationRecordsVC { extension YHHKImmigrationRecordsVC {
...@@ -131,6 +140,26 @@ extension YHHKImmigrationRecordsVC { ...@@ -131,6 +140,26 @@ extension YHHKImmigrationRecordsVC {
segmentedView.listContainer = listContainerView segmentedView.listContainer = listContainerView
} }
private func requestData() {
viewModel.getStayInHKRecordStatistics(orderId: orderId) { [weak self] recordStatistics, error in
if let recordStatistics = recordStatistics {
self?.updateVC(recordStatistics: recordStatistics)
} else {
printLog("YHHKImmigrationRecordsVC: 请求失败")
if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.show(.error(message: errorMsg))
YHHUD.hide(afterDelay: 1)
}
}
}
}
private func updateVC(recordStatistics: YHHKImmigrationRecordsStatisticsModel) {
arrItemTitles = ["汇总", "主申(\(recordStatistics.main.sum_times))", "配偶(\(recordStatistics.spouse.sum_times))", "子女(\(recordStatistics.children.sum_times))"]
segmentedDataSource.titles = arrItemTitles
segmentedView.reloadDataWithoutListContainer()
}
@objc private func clickAddNewButton() { @objc private func clickAddNewButton() {
let vc = YHHKRecordsEditContentVC(pageType: .add) let vc = YHHKRecordsEditContentVC(pageType: .add)
navigationController?.pushViewController(vc) navigationController?.pushViewController(vc)
......
...@@ -10,6 +10,12 @@ import UIKit ...@@ -10,6 +10,12 @@ import UIKit
import JXSegmentedView import JXSegmentedView
class YHHKRecordsContentVC: YHBaseViewController { class YHHKRecordsContentVC: YHBaseViewController {
enum UserType: Int {
case main = 1
case spouse = 2
case children = 3
}
enum RowType { enum RowType {
case customer(_ title: String, _ detail: String) case customer(_ title: String, _ detail: String)
...@@ -18,8 +24,18 @@ class YHHKRecordsContentVC: YHBaseViewController { ...@@ -18,8 +24,18 @@ class YHHKRecordsContentVC: YHBaseViewController {
case edit(_ title: String) case edit(_ title: String)
} }
private lazy var viewModel = YHHKImmigrationRecordsViewModel()
private var datas: [[RowType]] = [] private var datas: [[RowType]] = []
private lazy var noDataView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无在港记录", kEmptyCommonBgName)
view.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: 164)
view.backgroundColor = .clear
view.isHidden = true
return view
}()
private lazy var tableView: UITableView = { private lazy var tableView: UITableView = {
let view = UITableView(frame:.zero, style:.grouped) let view = UITableView(frame:.zero, style:.grouped)
view.estimatedSectionHeaderHeight = 16.0 view.estimatedSectionHeaderHeight = 16.0
...@@ -41,6 +57,18 @@ class YHHKRecordsContentVC: YHBaseViewController { ...@@ -41,6 +57,18 @@ class YHHKRecordsContentVC: YHBaseViewController {
return view return view
}() }()
private let orderId: Int
private let userType: UserType
init(orderId: Int, userType: UserType) {
self.orderId = orderId
self.userType = userType
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
...@@ -48,7 +76,7 @@ class YHHKRecordsContentVC: YHBaseViewController { ...@@ -48,7 +76,7 @@ class YHHKRecordsContentVC: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
setupData() requestData()
} }
} }
...@@ -58,16 +86,63 @@ extension YHHKRecordsContentVC { ...@@ -58,16 +86,63 @@ extension YHHKRecordsContentVC {
gk_navigationBar.isHidden = true gk_navigationBar.isHidden = true
view.backgroundColor = UIColor.contentBkgColor view.backgroundColor = UIColor.contentBkgColor
view.addSubview(tableView) view.addSubview(tableView)
view.addSubview(noDataView)
tableView.snp.makeConstraints { make in tableView.snp.makeConstraints { make in
make.left.equalToSuperview() make.left.equalToSuperview()
make.right.equalToSuperview() make.right.equalToSuperview()
make.top.bottom.equalToSuperview() make.top.bottom.equalToSuperview()
} }
noDataView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalTo(KScreenWidth)
make.height.equalTo(164)
}
tableView.tableFooterView = UIView(frame: CGRect.init(x: 0, y: 0, width: KScreenWidth, height: kMargin)) tableView.tableFooterView = UIView(frame: CGRect.init(x: 0, y: 0, width: KScreenWidth, height: kMargin))
} }
private func setupData() { private func requestData() {
datas = [[.customer("客户", "2023-12-13 12:00:00"), .info("逗留人员:", "张三丰、章一刀", 18, 9), .info("出入境时间:", "2023-10-04 ~ 2023-12-04", 9, 2), .remark("备注:", "这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息这里是备注信息"), .edit("编辑")], [.customer("客户", "2023-12-13 12:00:00"), .info("逗留人员:", "张三丰、章一刀", 18, 9), .info("出入境时间:", "2023-10-04 ~ 2023-12-04", 9, 18), .edit("编辑")]] viewModel.getHKImmigrationRecordsSingle(orderId: orderId, userType: userType.rawValue) { [weak self] recordsSingleModel, error in
if let recordsSingleModel = recordsSingleModel {
self?.updateVC(recordsSingleModel: recordsSingleModel)
} else {
printLog("YHHKRecordsContentVC: 请求失败")
if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.show(.error(message: errorMsg))
YHHUD.hide(afterDelay: 1)
}
}
}
}
private func updateVC(recordsSingleModel: YHHKImmigrationRecordsSingleModel) {
guard recordsSingleModel.list.count > 0 else {
noDataView.isHidden = false
return
}
var sections: [[RowType]] = []
recordsSingleModel.list.forEach { record in
var section: [RowType] = [.customer("客户", record.updated_at)]
let name = record.users.reduce("") { partialResult, item in
partialResult.count > 0 ? partialResult + "、" + item.user_name : partialResult + item.user_name
}
section.append(.info("逗留人员:", name, 18, 9))
section.append(.info("出入境时间:", "\(record.start_date) ~ \(record.end_date)", 9, 18))
if record.remark.count > 0 {
section.append(.remark("备注:", record.remark))
}
section.append(.edit("编辑"))
sections.append(section)
}
guard sections.count > 0 else {
noDataView.isHidden = false
return
}
datas = sections
noDataView.isHidden = true
tableView.reloadData() tableView.reloadData()
} }
} }
......
...@@ -17,23 +17,11 @@ class YHHKRecordsSummaryVC: YHBaseViewController { ...@@ -17,23 +17,11 @@ class YHHKRecordsSummaryVC: YHBaseViewController {
let view = YHEmptyDataView.createView("暂无在港记录", kEmptyCommonBgName) let view = YHEmptyDataView.createView("暂无在港记录", kEmptyCommonBgName)
view.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: 164) view.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: 164)
view.backgroundColor = .clear view.backgroundColor = .clear
view.isHidden = true
return view return view
}() }()
private lazy var datas: [YHHKRecordSectionType] = { private lazy var datas: [YHHKRecordSectionType] = []
let firstSection = YHHKRecordSectionType.header("在港逗留情况")
let summaryItems1: [YHHKRecordItemDetailType] = [.detailHeader("逗留共300天(2次)"), .lastStay("上次逗留:2024-10-04"), .summaryItem("2024年 270天(2次)"), .summaryItem("2024年 30天(2次)")]
let periodItems1: [YHHKRecordItemDetailType] = [.detailHeader("超90天未在港"), .duration("2023-10-04", "2023-12-04", "60天"), .duration("2024-12-04", "2023-01-04", "60天")]
let expandedSec1 = YHHKRecordsExpandedSection(title: "章一刀", type: .over90, summaryItems: summaryItems1, periodItems: periodItems1)
let secondSection = YHHKRecordSectionType.expandedItem(expandedSec1)
let summaryItems2: [YHHKRecordItemDetailType] = [.detailHeader("逗留共300天(5次)"), .lastStay("上次逗留:2024-10-04"), .summaryItem("2024年 270天(2次)"), .summaryItem("2024年 30天(3次)")]
let periodItems2: [YHHKRecordItemDetailType] = [.detailHeader("超200天未在港"), .duration("2023-10-04", "2023-12-04", "60天"), .duration("2024-12-04", "2023-01-04", "30天")]
let expandedSec2 = YHHKRecordsExpandedSection(title: "李晓梅", type: .over180, summaryItems: summaryItems2, periodItems: periodItems2)
let thirdSection = YHHKRecordSectionType.expandedItem(expandedSec2)
return [firstSection, secondSection, thirdSection]
}()
private lazy var tableView: YHGestureTableView = { private lazy var tableView: YHGestureTableView = {
let view = YHGestureTableView(frame: .zero, style: .plain) let view = YHGestureTableView(frame: .zero, style: .plain)
...@@ -46,13 +34,13 @@ class YHHKRecordsSummaryVC: YHBaseViewController { ...@@ -46,13 +34,13 @@ class YHHKRecordsSummaryVC: YHBaseViewController {
view.dataSource = self view.dataSource = self
view.delegate = self view.delegate = self
view.showsVerticalScrollIndicator = false view.showsVerticalScrollIndicator = false
view.register(cellWithClass: YHHKRecordsHeaderCell.self) view.register(YHHKRecordsHeaderCell.self, forCellReuseIdentifier: YHHKRecordsHeaderCell.cellReuseIdentifier)
view.register(cellWithClass: YHHKRecordsExpandedCell.self) view.register(YHHKRecordsExpandedCell.self, forCellReuseIdentifier: YHHKRecordsExpandedCell.cellReuseIdentifier)
view.register(cellWithClass: YHHKRecordsSectionHeaderCell.self) view.register(YHHKRecordsSectionHeaderCell.self, forCellReuseIdentifier: YHHKRecordsSectionHeaderCell.cellReuseIdentifier)
view.register(cellWithClass: YHHKRecordsLastStayCell.self) view.register(YHHKRecordsLastStayCell.self, forCellReuseIdentifier: YHHKRecordsLastStayCell.cellReuseIdentifier)
view.register(cellWithClass: YHHKRecordsSummaryItemCell.self) view.register(YHHKRecordsSummaryItemCell.self, forCellReuseIdentifier: YHHKRecordsSummaryItemCell.cellReuseIdentifier)
view.register(cellWithClass: YHHKRecordsDurationItemCell.self) view.register(YHHKRecordsDurationItemCell.self, forCellReuseIdentifier: YHHKRecordsDurationItemCell.cellReuseIdentifier)
view.register(cellWithClass: YHHKRecordsOccupyingSpaceCell.self) view.register(YHHKRecordsOccupyingSpaceCell.self, forCellReuseIdentifier: YHHKRecordsOccupyingSpaceCell.cellReuseIdentifier)
return view return view
}() }()
...@@ -70,11 +58,11 @@ class YHHKRecordsSummaryVC: YHBaseViewController { ...@@ -70,11 +58,11 @@ class YHHKRecordsSummaryVC: YHBaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
requestData()
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
requestData()
} }
} }
...@@ -85,12 +73,21 @@ extension YHHKRecordsSummaryVC { ...@@ -85,12 +73,21 @@ extension YHHKRecordsSummaryVC {
gk_navigationBar.isHidden = true gk_navigationBar.isHidden = true
view.backgroundColor = UIColor.contentBkgColor view.backgroundColor = UIColor.contentBkgColor
view.addSubview(tableView) view.addSubview(tableView)
view.addSubview(noDataView)
tableView.snp.makeConstraints { make in tableView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(kMargin).priority(.high) make.left.equalToSuperview().offset(kMargin).priority(.high)
make.right.equalToSuperview().offset(-kMargin).priority(.high) make.right.equalToSuperview().offset(-kMargin).priority(.high)
make.top.equalToSuperview().offset(kMargin) make.top.equalToSuperview().offset(kMargin)
make.bottom.equalToSuperview().offset(-kMargin) make.bottom.equalToSuperview().offset(-kMargin)
} }
noDataView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalTo(KScreenWidth)
make.height.equalTo(164)
}
} }
private func requestData() { private func requestData() {
...@@ -109,15 +106,51 @@ extension YHHKRecordsSummaryVC { ...@@ -109,15 +106,51 @@ extension YHHKRecordsSummaryVC {
private func updateVC(recordsSummary: YHHKImmigrationRecordsSummaryModel) { private func updateVC(recordsSummary: YHHKImmigrationRecordsSummaryModel) {
guard recordsSummary.list.count > 0 else { guard recordsSummary.list.count > 0 else {
noDataView.isHidden = false
return return
} }
// datas = recordsSummary.list.map { record in var sections: [YHHKRecordSectionType] = [.header("在港逗留情况")]
// let firstSection = YHHKRecordSectionType.header("在港逗留情况") // 优先过滤大于等于90 .filter { $0.not_in_hk_days >= 90 }
// let summaryItems1: [YHHKRecordItemDetailType] = [.detailHeader("逗留共300天(2次)"), .lastStay("上次逗留:2024-10-04"), .summaryItem("2024年 270天(2次)"), .summaryItem("2024年 30天(2次)")] recordsSummary.list.forEach { [weak self] record in
// let periodItems1: [YHHKRecordItemDetailType] = [.detailHeader("超90天未在港"), .duration("2023-10-04", "2023-12-04", "60天"), .duration("2024-12-04", "2023-01-04", "60天")] guard let self = self else {
// let expandedSec1 = YHHKRecordsExpandedSection(title: "章一刀", type: .over90, summaryItems: summaryItems1, periodItems: periodItems1) return
// let secondSection = YHHKRecordSectionType.expandedItem(expandedSec1) }
// } var summaryItems: [YHHKRecordItemDetailType] = [.detailHeader("逗留共\(record.sum_days)天(\(record.sum_days)次)"), .lastStay("上次逗留:\(self.getShortDateString(record.last_stay_date))")]
record.statistics.forEach { item in
let summaryItem = YHHKRecordItemDetailType.summaryItem("\(item.year)\(item.sum_days)天(\(item.sum_times)次)")
summaryItems.append(summaryItem)
}
var header = ""
var type: YHHKNonPresenceRecordType = .normal
var periodItems: [YHHKRecordItemDetailType] = []
if record.not_in_hk_days >= 90 && record.not_in_hk_days < 180 {
header = "超90天未在港"
type = .over90
//periodItems.append(.detailHeader(header))
} else if record.not_in_hk_days >= 180 {
header = "超180天未在港"
type = .over180
periodItems.append(.detailHeader(header))
}
// 产品定的显示超过180天的详细记录
if record.not_in_hk_days >= 180 {
record.details.forEach { item in
let duration = YHHKRecordItemDetailType.duration(self.getShortDateString(item.start_date), self.getShortDateString(item.end_date), "\(item.days)天")
periodItems.append(duration)
}
}
let expandedSec1 = YHHKRecordsExpandedSection(title: record.username, type: type, summaryItems: summaryItems, periodItems: periodItems)
let section = YHHKRecordSectionType.expandedItem(expandedSec1)
sections.append(section)
}
guard sections.count > 1 else {
noDataView.isHidden = false
return
}
datas = sections
noDataView.isHidden = true
tableView.reloadData()
} }
private func getSubCellType(model: YHHKRecordsExpandedSection, indexPath: IndexPath, subType: YHHKRecordItemDetailType) -> YHResignRoundCellType { private func getSubCellType(model: YHHKRecordsExpandedSection, indexPath: IndexPath, subType: YHHKRecordItemDetailType) -> YHResignRoundCellType {
...@@ -140,6 +173,19 @@ extension YHHKRecordsSummaryVC { ...@@ -140,6 +173,19 @@ extension YHHKRecordsSummaryVC {
} }
return cellType return cellType
} }
private func getShortDateString(_ dateString: String) -> String {
// 2024-05-20 00:00:00 -> 2024-05-20
let inputFormatter = DateFormatter()
inputFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
if let date = inputFormatter.date(from: dateString) {
let outputFormatter = DateFormatter()
outputFormatter.dateFormat = "yyyy-MM-dd"
let formattedDateString = outputFormatter.string(from: date)
return formattedDateString
}
return dateString
}
} }
extension YHHKRecordsSummaryVC: UITableViewDelegate, UITableViewDataSource { extension YHHKRecordsSummaryVC: UITableViewDelegate, UITableViewDataSource {
...@@ -200,7 +246,7 @@ extension YHHKRecordsSummaryVC: UITableViewDelegate, UITableViewDataSource { ...@@ -200,7 +246,7 @@ extension YHHKRecordsSummaryVC: UITableViewDelegate, UITableViewDataSource {
case let .duration(from, to, total): case let .duration(from, to, total):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHHKRecordsDurationItemCell.cellReuseIdentifier) as? YHHKRecordsDurationItemCell { if let cell = tableView.dequeueReusableCell(withIdentifier: YHHKRecordsDurationItemCell.cellReuseIdentifier) as? YHHKRecordsDurationItemCell {
let cellType = getSubCellType(model: model, indexPath: indexPath, subType: subType) let cellType = getSubCellType(model: model, indexPath: indexPath, subType: subType)
cell.setupCellInfo(title: "\(from)\(to)", detail: total, cellType: cellType) cell.setupCellInfo(title: "\(from)\(to)", detail: total, cellType: cellType)
return cell return cell
} }
case .occupyingSpace: case .occupyingSpace:
......
//
// YHHKImmigrationRecordsSingleModel.swift
// galaxy
//
// Created by alexzzw on 2024/9/23.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
import SmartCodable
class YHHKImmigrationRecordsSingleModel: SmartCodable {
var list: [YHHKRecordsSingleItem] = []
required init() {
}
}
class YHHKRecordsSingleItem: SmartCodable {
var id: Int = 0
var creator_type: Int = 0
var updated_at: String = ""
var start_date: String = ""
var end_date: String = ""
var remark: String = ""
var users: [YHHKRecordsUserItem] = []
required init() {
}
}
class YHHKRecordsUserItem: SmartCodable {
var user_type: Int = 0
var user_id: Int = 0
var user_name: String = ""
required init() {
}
}
//
// YHHKImmigrationRecordsStatisticsModel.swift
// galaxy
//
// Created by alexzzw on 2024/9/23.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
import SmartCodable
class YHHKImmigrationRecordsStatisticsModel: SmartCodable {
var main: YHHKRecordsStatisticsItem = YHHKRecordsStatisticsItem()
var spouse: YHHKRecordsStatisticsItem = YHHKRecordsStatisticsItem()
var children: YHHKRecordsStatisticsItem = YHHKRecordsStatisticsItem()
required init() {
}
}
class YHHKRecordsStatisticsItem: SmartCodable {
var sum_times: Int = 0
required init() {
}
}
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
import Foundation import Foundation
enum YHHKNonPresenceRecordType { enum YHHKNonPresenceRecordType {
case normal
case over90 case over90
case over180 case over180
...@@ -18,6 +19,8 @@ enum YHHKNonPresenceRecordType { ...@@ -18,6 +19,8 @@ enum YHHKNonPresenceRecordType {
return "超90天未在港" return "超90天未在港"
case .over180: case .over180:
return "超180天未在港" return "超180天未在港"
case .normal:
return ""
} }
} }
} }
......
...@@ -63,9 +63,18 @@ class YHHKRecordsExpandedCell: UITableViewCell { ...@@ -63,9 +63,18 @@ class YHHKRecordsExpandedCell: UITableViewCell {
func setupCellInfo(title: String?, status: YHHKNonPresenceRecordType, isExpanded: Bool, isShowBottomLine: Bool = false) { func setupCellInfo(title: String?, status: YHHKNonPresenceRecordType, isExpanded: Bool, isShowBottomLine: Bool = false) {
infoTitleLabel.text = title infoTitleLabel.text = title
statusLabel.text = status.title if status == .normal {
statusLabel.textColor = status.titleColor statusLabel.isHidden = true
statusLabel.backgroundColor = status.bgColor statusLabel.text = nil
statusLabel.textColor = nil
statusLabel.backgroundColor = nil
} else {
statusLabel.isHidden = false
statusLabel.text = status.title
statusLabel.textColor = status.titleColor
statusLabel.backgroundColor = status.bgColor
}
self.isExpanded = isExpanded self.isExpanded = isExpanded
bottomLineView.isHidden = !isShowBottomLine bottomLineView.isHidden = !isShowBottomLine
} }
...@@ -120,21 +129,25 @@ extension YHHKRecordsExpandedCell { ...@@ -120,21 +129,25 @@ extension YHHKRecordsExpandedCell {
} }
private extension YHHKNonPresenceRecordType { private extension YHHKNonPresenceRecordType {
var titleColor: UIColor { var titleColor: UIColor? {
switch self { switch self {
case .over90: case .over90:
return UIColor.yhOrangeColor return UIColor.yhOrangeColor
case .over180: case .over180:
return UIColor.failColor return UIColor.failColor
case .normal:
return nil
} }
} }
var bgColor: UIColor { var bgColor: UIColor? {
switch self { switch self {
case .normal:
return nil
case .over90: case .over90:
return UIColor(hexString: "#FFF5EB")! return UIColor(hexString: "#FFF5EB")
case .over180: case .over180:
return UIColor(hexString: "#FFF2F2")! return UIColor(hexString: "#FFF2F2")
} }
} }
} }
...@@ -10,15 +10,36 @@ import UIKit ...@@ -10,15 +10,36 @@ import UIKit
class YHHKImmigrationRecordsViewModel: YHBaseViewModel { class YHHKImmigrationRecordsViewModel: YHBaseViewModel {
func getStayInHKRecordStatistics(orderId: Int, callback: @escaping (_ recordStatistics: YHHKImmigrationRecordsStatisticsModel?, _ error: YHErrorModel?) -> Void) {
let params = ["order_id": orderId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.HKImmigrationRecords.stayInHKRecordStatistics
_ = YHNetRequest.getRequest(url: strUrl, params: params) { json, code in
// 1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any], let resultModel = YHHKImmigrationRecordsStatisticsModel.deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callback(nil, err)
return
}
callback(resultModel, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callback(nil, err)
}
} failBlock: { err in
callback(nil, err)
}
}
func getHKImmigrationRecordsSummary(orderId: Int, callback: @escaping (_ recordsSummary: YHHKImmigrationRecordsSummaryModel?, _ error: YHErrorModel?) -> ()) { func getHKImmigrationRecordsSummary(orderId: Int, callback: @escaping (_ recordsSummary: YHHKImmigrationRecordsSummaryModel?, _ error: YHErrorModel?) -> ()) {
let params = ["order_id": orderId] let params = ["order_id": orderId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.ResignDocument.resignDocumentList let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.HKImmigrationRecords.stayInHKRecordSummary
let _ = YHNetRequest.getRequest(url: strUrl,params: params) { [weak self] json, code in let _ = YHNetRequest.getRequest(url: strUrl,params: params) { json, code in
//1. json字符串 转 对象 //1. json字符串 转 对象
guard let self = self else { return }
printLog("model 是 ==> \(json)") printLog("model 是 ==> \(json)")
if json.code == 200 { if json.code == 200 {
guard let dic = json.data?.peel as? [String : Any], let resultModel = YHHKImmigrationRecordsSummaryModel.deserialize(from: dic) else { guard let dic = json.data?.peel as? [String : Any], let resultModel = YHHKImmigrationRecordsSummaryModel.deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description()) let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
...@@ -36,5 +57,29 @@ class YHHKImmigrationRecordsViewModel: YHBaseViewModel { ...@@ -36,5 +57,29 @@ class YHHKImmigrationRecordsViewModel: YHBaseViewModel {
callback(nil, err) callback(nil, err)
} }
} }
func getHKImmigrationRecordsSingle(orderId: Int, userType: Int, callback: @escaping (_ recordsSingleModel: YHHKImmigrationRecordsSingleModel?, _ error: YHErrorModel?) -> ()) {
let params = ["order_id": orderId, "user_type": userType]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.HKImmigrationRecords.stayInHKRecordSingle
let _ = YHNetRequest.getRequest(url: strUrl,params: params) { json, code in
//1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let dic = json.data?.peel as? [String : Any], let resultModel = YHHKImmigrationRecordsSingleModel.deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callback(nil, err)
return
}
callback(resultModel, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callback(nil, err)
}
} failBlock: { err in
callback(nil, err)
}
}
} }
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