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

Merge branch 'qmas-1130' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into qmas-1130

parents 0b2c25b4 69ce09f6
......@@ -146,8 +146,8 @@ extension YHIncomeRecordViewController {
private func setupData() {
let detail: ASAttributedString = .init(string: "备注:全年收入是指应课税(应纳所得税)的就业或业务收入,包括工资薪金、津贴、股票期权及从其拥有的公司所得的利润。由个人投资所产生的收入不会计算在内。", .font(UIFont.PFSC_R(ofSize: 13)), .foreground(UIColor(hexString: "#8993A2") ?? .gray))
let firstSection: [TableRow] = [.consentForHKTravel("收入情况", detail, "您在前一年,全年收入是否达港币100万元或以上", true)]
let totalMoney: ASAttributedString = .init(string: "约", .font(.PFSC_R(ofSize: 14))) + .init(string: "1,351,517", .font(UIFont(name: "DINAlternate-Bold", size: 16) ?? UIFont.systemFont(ofSize: 16))) + .init(string: "港币", .font(.PFSC_R(ofSize: 14)))
let secondSection: [TableRow] = [.incomeSummary(false, false), .incomeItem(false, "华为有限公司", "约1,234,234港币", "2019.07-至今"), .incomeItem(false, "腾讯有限公司", "约1,234,234港币", "2015.07-2019.06"), .totalIncome(totalMoney)]
let totalMoney: ASAttributedString = .init(string: "约 ", .font(.PFSC_R(ofSize: 14))) + .init(string: "1,351,517", .font(UIFont(name: "DINAlternate-Bold", size: 20) ?? UIFont.systemFont(ofSize: 20))) + .init(string: " 港币", .font(.PFSC_R(ofSize: 14)))
let secondSection: [TableRow] = [.incomeSummary(false, false), .incomeItem(false, "华为有限公司", "约1,234,234港币", "已填写"), .incomeItem(false, "腾讯有限公司", "约1,234,234港币", "有5项未填写"), .totalIncome(totalMoney)]
datas = [firstSection, secondSection]
tableView.reloadData()
}
......@@ -179,7 +179,7 @@ extension YHIncomeRecordViewController: UITableViewDelegate, UITableViewDataSour
case let .incomeSummary(isEditState, isEditEnable):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeRecordSummaryCell.cellReuseIdentifier) as? YHIncomeRecordSummaryCell {
cell.setupCellInfo(isEditState, isEditEnable)
cell.setupCellInfo(isEditState, isEditEnable, showRightButton: false)
return cell
}
case let .incomeItem(isEditState, company, money, timeStr):
......
......@@ -13,15 +13,19 @@ class YHIncomeRecordWorkExperienceViewController: YHBaseViewController {
enum TableRow {
case header(_ title: String)
case incomeFrom(_ title: String, _ detail: String)
case incomeTypeSelect(_ title: String, _ detail: String, _ isSelectedOne: Bool, _ types: [String])
case incomeTypeSelect(_ title: String, _ detail: String, _ isSelectedOne: Bool)
case incomeTypes(_ types: [String])
case inputMoney(_ title: String, _ detail: String?, _ inputStr: String?, _ showBottomLine: Bool, _ showStar: Bool)
case inputRemark(_ detail: String)
case documentComfirm(_ title: String, _ question: String, _ isSelectedSure: Bool, _ docs: [String])
}
private lazy var datas: [[TableRow]] = []
private var selectedTypes: [String] = []
private let currencyRate = 0.92
private lazy var submitButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
......@@ -73,7 +77,7 @@ class YHIncomeRecordWorkExperienceViewController: YHBaseViewController {
setupUI()
setupData()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
IQKeyboardManager.shared.enable = true
......@@ -86,7 +90,6 @@ class YHIncomeRecordWorkExperienceViewController: YHBaseViewController {
}
extension YHIncomeRecordWorkExperienceViewController {
@objc private func clickSubmitButton() {
//
}
......@@ -119,29 +122,80 @@ extension YHIncomeRecordWorkExperienceViewController {
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalTo(bottomView.snp.top)
}
tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 44))
}
private func setupData() {
let selectedTypes = ["工资薪金所得及全年一次性奖金", "个体工商户/合伙企业/独资企业经营所得收入", "其他境外公司收入(持股50%及以上)"]
let firstSection: [TableRow] = [.header("收入信息"), .incomeFrom("收入来源公司", "华为科技有限公司"), .incomeTypeSelect("收入类型(多选)", "请选择", selectedTypes.count > 0, selectedTypes), .incomeTypes(selectedTypes), .inputMoney("公司营业额(近一年)", "约1,000,000港币", "9,999,999", true, false), .inputMoney("收入金额", "约1,000,000港币", "9,999,999", false, true), .inputRemark("注:按1港币≈0.92人民币计算,实际金额按递交时入境处给出的汇率为准")]
selectedTypes = ["工资薪金所得及全年一次性奖金", "个体工商户/合伙企业/独资企业经营所得收入", "其他境外公司收入(持股50%及以上)"]
let firstSection: [TableRow] = [.header("收入信息"), .incomeFrom("收入来源公司", "华为科技有限公司"), .incomeTypeSelect("收入类型(多选)", "请选择", selectedTypes.count > 0), .incomeTypes(selectedTypes), .inputMoney("公司营业额(近一年)", "约10,869,564港币", "¥9,999,999", true, false), .inputMoney("收入金额", "约10,869,564港币", 9,999,999", false, true), .inputRemark("注:按1港币≈0.92人民币计算,实际金额按递交时入境处给出的汇率为准")]
let secondSection: [TableRow] = [.documentComfirm("证件提供确认", "您是否可以提供以下所有证明文件", true, ["验资报告", "审计报告", "绝对实益拥有人声明书", "国家企业信用信息公示系统报告", "企业所得税月(季)度预缴纳税申报表(A类)", "企业所得税完税证明", "企业所得税年度纳税申报表(A类)"])]
datas = [firstSection, secondSection]
tableView.reloadData()
}
private func showSelectIncomeTypePopVC(selectedTypes: [String]) {
let ctl = YHIncomeTypeSelectViewController.init(selectedTypes: selectedTypes)
let ctl = YHIncomeTypeSelectViewController(selectedTypes: selectedTypes)
let bpc = YHBottomPresentationController(presentedViewController: ctl, presenting: self)
bpc.customRadius = 8.0
ctl.transitioningDelegate = bpc
ctl.sureButtonEvent = { selectedTypes in
//
ctl.sureButtonEvent = { [weak self] selectedTypes in
guard let self = self else {
return
}
self.selectedTypes = selectedTypes
self.updateSelectTypes()
}
present(ctl, animated: true, completion: nil)
}
private func updateSelectTypes() {
var incomeTypesIndexPath: IndexPath?
var incomeTypeSelectIndexPath: IndexPath?
datas = datas.enumerated().map { section, sectionArr in
sectionArr.enumerated().map { row, tableRow in
switch tableRow {
case .incomeTypes:
incomeTypesIndexPath = IndexPath(row: row, section: section)
return .incomeTypes(selectedTypes)
case let .incomeTypeSelect(title, detail, _):
incomeTypeSelectIndexPath = IndexPath(row: row, section: section)
return .incomeTypeSelect(title, detail, selectedTypes.count > 0)
default:
return tableRow
}
}
}
guard let incomeTypeSelectIndexPath = incomeTypeSelectIndexPath else {
return
}
if selectedTypes.count > 0 {
if incomeTypesIndexPath == nil {
var sectionArr = datas[incomeTypeSelectIndexPath.section]
sectionArr.insert(.incomeTypes(selectedTypes), at: incomeTypeSelectIndexPath.row + 1)
datas[incomeTypeSelectIndexPath.section] = sectionArr
}
} else {
guard let incomeTypesIndexPath = incomeTypesIndexPath else {
return
}
var sectionArr = datas[incomeTypesIndexPath.section]
sectionArr.remove(at: incomeTypesIndexPath.row)
datas[incomeTypesIndexPath.section] = sectionArr
}
tableView.performBatchUpdates { [weak tableView] in
tableView?.reloadSections(IndexSet(integer: incomeTypeSelectIndexPath.section), with: .automatic)
}
}
private func currencyFormat(_ currencySymbol: String) -> NumberFormatter {
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.currencySymbol = currencySymbol
formatter.maximumFractionDigits = 0
return formatter
}
}
extension YHIncomeRecordWorkExperienceViewController: UITableViewDelegate, UITableViewDataSource {
......@@ -177,7 +231,7 @@ extension YHIncomeRecordWorkExperienceViewController: UITableViewDelegate, UITab
cell.setupCellInfo(title: title, detail: detail, showBottomLine: true)
return cell
}
case let .incomeTypeSelect(title, detail, isSelectedOne, _):
case let .incomeTypeSelect(title, detail, isSelectedOne):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeTypeSelectCell.cellReuseIdentifier) as? YHIncomeTypeSelectCell {
cell.setupCellInfo(title: title, detail: detail, isSelectedOne: isSelectedOne, showBottomLine: !isSelectedOne)
return cell
......@@ -185,11 +239,52 @@ extension YHIncomeRecordWorkExperienceViewController: UITableViewDelegate, UITab
case let .incomeTypes(types):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeTypesCell.cellReuseIdentifier) as? YHIncomeTypesCell {
cell.setupCellInfo(types: types)
cell.didClickTypeView = { [weak self] index in
guard let self = self else {
return
}
self.selectedTypes.remove(at: index)
self.updateSelectTypes()
}
return cell
}
case let .inputMoney(title, detail, inputStr, showBottomLine, showStar):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeInputMoneyCell.cellReuseIdentifier) as? YHIncomeInputMoneyCell {
cell.setupCellInfo(title: title, detail: detail, inputValue: inputStr, showBottomLine: showBottomLine, showStarIcon: showStar)
cell.didBeginEditing = { textField in
var text = textField.text ?? ""
text = text.replacingOccurrences(of: "¥", with: "")
text = text.replacingOccurrences(of: ",", with: "")
textField.text = text
}
cell.didEndEditing = { [weak self] textField in
guard let self = self else {
return
}
guard let text = textField.text else {
return
}
// 转换为数字
let number = Double(text) ?? 0
// 格式化为带货币符号和千分位
let detail = number / self.currencyRate
let rmbFormatter = self.currencyFormat("¥")
let hkdFormatter = self.currencyFormat("")
if let formattedString = rmbFormatter.string(from: NSNumber(value: number)) {
textField.text = formattedString
let detailStr = "约" + (hkdFormatter.string(from: NSNumber(value: detail)) ?? "") + "港币"
if self.datas.count > indexPath.section {
let sectionArr = self.datas[indexPath.section]
if sectionArr.count > indexPath.row {
let currentRow = sectionArr[indexPath.row]
if case let .inputMoney(title, detail, inputStr, showBottomLine, showStar) = currentRow {
self.datas[indexPath.section][indexPath.row] = .inputMoney(title, detailStr, formattedString, showBottomLine, showStar)
self.tableView.reloadRows(at: [indexPath], with: .automatic)
}
}
}
}
}
return cell
}
case let .inputRemark(detail):
......@@ -204,10 +299,10 @@ extension YHIncomeRecordWorkExperienceViewController: UITableViewDelegate, UITab
return cell
}
}
return UITableViewCell()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
......@@ -230,10 +325,8 @@ extension YHIncomeRecordWorkExperienceViewController: UITableViewDelegate, UITab
return
}
let tableRow = sectionArr[indexPath.row]
if case let .incomeTypeSelect(_, _, _, selectedTypes) = tableRow {
if case .incomeTypeSelect = tableRow {
showSelectIncomeTypePopVC(selectedTypes: selectedTypes)
}
}
}
......@@ -12,6 +12,7 @@ class YHIncomeInputMoneyCell: YHResignDocumentCell {
static let cellReuseIdentifier = "YHIncomeInputMoneyCell"
var didBeginEditing: ((UITextField) -> Void)?
var didEndEditing: ((UITextField) -> Void)?
private lazy var dotIcon: UIImageView = {
......@@ -157,6 +158,12 @@ extension YHIncomeInputMoneyCell {
extension YHIncomeInputMoneyCell: UITextFieldDelegate {
// MARK: - UITextFieldDelegate
func textFieldDidBeginEditing(_ textField: UITextField) {
if textField == inputTextField {
didBeginEditing?(textField)
}
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.endEditing(false)
return true
......
......@@ -50,7 +50,8 @@ class YHIncomeRecordSummaryCell: YHResignDocumentCell {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(_ isEditing: Bool, _ isEditEnable: Bool) {
func setupCellInfo(_ isEditing: Bool, _ isEditEnable: Bool, showRightButton: Bool) {
rightButton.isHidden = !showRightButton
rightButton.isEnabled = isEditEnable
updateRightButtonState(isEditing)
}
......
......@@ -23,7 +23,7 @@ class YHTotalIncomeCell: YHResignDocumentCell {
private lazy var infoDetailLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 16)
label.font = .PFSC_R(ofSize: 20)
label.textColor = .brandMainColor
label.lineBreakMode = .byCharWrapping
return label
......@@ -56,7 +56,7 @@ extension YHTotalIncomeCell {
}
private func setupUI() {
updateCellCorner(.mid)
updateCellCorner(.bottom)
subContainerView.addSubview(infoTitleLabel)
subContainerView.addSubview(infoDetailLabel)
subContainerView.addSubview(infoButton)
......
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