Commit b9f28cd8 authored by Alex朱枝文's avatar Alex朱枝文

收入记录添加未输入提示,以及代码优化

parent 22c42aa0
......@@ -15,11 +15,15 @@ class YHIncomeRecordViewController: YHBaseViewController {
case incomeSummary(_ isEditing: Bool = false, _ isEditEnable: Bool = false)
case incomeItem(_ isEditState: Bool = false, _ company: String, _ money: String, _ timeStr: String, _ incomeId: Int)
case totalIncome(_ money: ASAttributedString)
case consentForHKTravel(_ title: String, _ detail: ASAttributedString, _ question: String, _ isSelectSureBtn: Bool = true)
case consentForHKTravel(_ title: String, _ detail: ASAttributedString, _ question: String)
}
private lazy var datas: [[TableRow]] = []
/// 是否超过
private var isOver100OK = true
private var over100IndexPath: IndexPath?
private lazy var viewModel = YHIncomeRecordViewModel()
private var incomeModel = YHIncomeRecordCompleteModel()
......@@ -113,6 +117,9 @@ extension YHIncomeRecordViewController {
}
@objc private func clickSubmitButton() {
guard checkInput() else {
return
}
updateIncome(.submit)
}
......@@ -158,7 +165,7 @@ 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万元或以上", incomeModel.income_over_100 == YHIncomeOver100.true.rawValue)]
let firstSection: [TableRow] = [.consentForHKTravel("收入情况", detail, "您在前一年,全年收入是否达港币100万元或以上")]
guard incomeModel.income_over_100 == YHIncomeOver100.true.rawValue else {
datas = [firstSection]
tableView.reloadData()
......@@ -167,14 +174,15 @@ extension YHIncomeRecordViewController {
let hkdFormatter = currencyFormat("")
var money: Double = 0
var secondSection: [TableRow] = [.incomeSummary(false, false)]
let rate = self.incomeModel.rate > 0 ? self.incomeModel.rate : 0.92
incomeModel.list.forEach { companyModel in
money += companyModel.income_money
let moneyStr = "约" + (hkdFormatter.string(from: NSNumber(value: companyModel.income_money)) ?? "0") + "港币"
let moneyStr = "约" + (hkdFormatter.string(from: NSNumber(value: companyModel.income_money / rate)) ?? "0") + "港币"
let timeStr: String = companyModel.fill_status ? "已填写" : "有\(companyModel.unfilled_count)项未填写"
let incomeItem: TableRow = .incomeItem(false, companyModel.company_name, moneyStr, timeStr, companyModel.income_id)
secondSection.append(incomeItem)
}
let totalNum = hkdFormatter.string(from: NSNumber(value: money)) ?? "0"
let totalNum = hkdFormatter.string(from: NSNumber(value: money / rate)) ?? "0"
let totalMoney: ASAttributedString = .init(string: "约 ", .font(.PFSC_R(ofSize: 14))) + .init(string: totalNum, .font(UIFont(name: "DINAlternate-Bold", size: 20) ?? UIFont.systemFont(ofSize: 20))) + .init(string: " 港币", .font(.PFSC_R(ofSize: 14)))
secondSection.append(.totalIncome(totalMoney))
datas = [firstSection, secondSection]
......@@ -236,17 +244,37 @@ extension YHIncomeRecordViewController: UITableViewDelegate, UITableViewDataSour
}
return cell
}
case let .consentForHKTravel(title, detail, question, isSelectSureBtn):
case let .consentForHKTravel(title, detail, question):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHInfoConsentForHKTravelCell.cellReuseIdentifier) as? YHInfoConsentForHKTravelCell {
cell.setupCellInfo(title: title, detail: detail, question: question)
over100IndexPath = indexPath
cell.setupCellInfo(title: title, detail: detail, question: question, needShowFailButton: !isOver100OK)
cell.didSelectSureButton = { [weak self] selected in
guard let self = self else {
return
}
self.incomeModel.income_over_100 = selected ? YHIncomeOver100.true.rawValue : YHIncomeOver100.false.rawValue
switch selected {
case .true:
self.incomeModel.income_over_100 = YHIncomeOver100.true.rawValue
isOver100OK = true
case .false:
self.incomeModel.income_over_100 = YHIncomeOver100.false.rawValue
isOver100OK = true
case .unknown:
self.incomeModel.income_over_100 = YHIncomeOver100.unknown.rawValue
isOver100OK = false
}
self.setupData()
}
cell.selectedSureButton = isSelectSureBtn
let over100Type = YHIncomeOver100(rawValue: incomeModel.income_over_100) ?? .unknown
switch over100Type {
case .true:
cell.selectedSureButton = .true
case .false:
cell.selectedSureButton = .false
case .unknown:
cell.selectedSureButton = .unknown
}
return cell
}
......@@ -287,6 +315,18 @@ extension YHIncomeRecordViewController: UITableViewDelegate, UITableViewDataSour
}
extension YHIncomeRecordViewController {
private func checkInput() -> Bool {
if incomeModel.income_over_100 == YHIncomeOver100.unknown.rawValue {
isOver100OK = false
if let over100IndexPath = over100IndexPath, tableView.numberOfSections > over100IndexPath.section, tableView.numberOfRows(inSection: over100IndexPath.section) > over100IndexPath.row {
tableView.reloadRows(at: [over100IndexPath], with: .none)
}
return false
}
isOver100OK = true
return true
}
private func requestData(isNeedLoading: Bool = false) {
if isNeedLoading {
YHHUD.show(.progress(message: "加载中..."))
......@@ -314,10 +354,9 @@ extension YHIncomeRecordViewController {
}
private func updateIncome(_ type: YHIncomeRecordUpdateType) {
let incomeOver100: YHIncomeOver100 = YHIncomeOver100(rawValue: incomeModel.income_over_100) ?? .true
let msg = type == .save ? "保存中..." : "提交中..."
YHHUD.show(.progress(message: msg))
viewModel.incomeUpdate(orderId: orderId, incomeOver100: incomeOver100, type: type) { [weak self] success, error in
viewModel.incomeUpdate(orderId: orderId, incomeOver100: incomeModel.income_over_100, type: type) { [weak self] success, error in
guard let self = self else {
return
}
......@@ -327,6 +366,8 @@ extension YHIncomeRecordViewController {
YHHUD.flash(message: msg)
if type == .submit {
self.navigationController?.popViewController(animated: true)
} else {
self.requestData(isNeedLoading: true)
}
} else if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.flash(message: errorMsg)
......
......@@ -15,6 +15,13 @@ enum YHIncomeRecordHasAllFile: Int {
}
enum YHIncomeOver100: Int {
case unknown = 0
case `true` = 1
case `false` = 2
}
enum YHCheckboxSelectType: Int {
case unknown = 0
case `true` = 1
case `false` = 2
}
......
......@@ -10,13 +10,13 @@ import UIKit
class YHIncomeDocumentationConfirmationCell: YHResignDocumentCell {
static let cellReuseIdentifier = "YHIncomeDocumentationConfirmationCell"
var didSelectSureButton: ((Bool) -> Void)?
var didSelectSureButton: ((YHIncomeRecordHasAllFile) -> Void)?
private var documentationViews: [YHIncomeDocumentationView] = []
private var lastDocuments: [String] = []
var selectedSureButton: Bool = true {
var selectedSureButton: YHIncomeRecordHasAllFile = .unknown {
didSet {
updateButtonState(sureButton, selectedSureButton)
updateButtonState(cancelButton, !selectedSureButton)
updateButtonsState(selectedSureButton)
}
}
......@@ -77,6 +77,14 @@ class YHIncomeDocumentationConfirmationCell: YHResignDocumentCell {
return view
}()
private lazy var infoFailLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textColor = .failColor
label.text = "请选择"
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
......@@ -86,55 +94,92 @@ class YHIncomeDocumentationConfirmationCell: YHResignDocumentCell {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(title: String, question: String, documents: [String]) {
func setupCellInfo(title: String, question: String, documents: [String], needShowFailButton: Bool) {
infoTitleLabel.text = title
infoQuestionLabel.text = question
documentationViews.forEach {
$0.removeFromSuperview()
}
documentationViews.removeAll()
let count = documents.count
documents.enumerated().forEach { [weak self] index, title in
guard let self = self else {
return
if lastDocuments != documents || documentationViews.count != documents.count {
lastDocuments = documents
documentationViews.forEach {
$0.removeFromSuperview()
}
let documentationView = YHIncomeDocumentationView()
documentationView.setupInfo(title)
self.documentationViews.append(documentationView)
self.containerView.addSubview(documentationView)
documentationView.snp.makeConstraints { make in
if index == 0 {
make.top.equalToSuperview().offset(16)
} else {
make.top.equalTo(self.documentationViews[index - 1].snp.bottom).offset(12)
documentationViews.removeAll()
let count = documents.count
documents.enumerated().forEach { [weak self] index, title in
guard let self = self else {
return
}
make.left.equalToSuperview().offset(16)
make.right.lessThanOrEqualToSuperview().offset(-8)
if index == count - 1 {
make.bottom.equalToSuperview().offset(-16)
let documentationView = YHIncomeDocumentationView()
documentationView.setupInfo(title)
self.documentationViews.append(documentationView)
self.containerView.addSubview(documentationView)
documentationView.snp.makeConstraints { make in
if index == 0 {
make.top.equalToSuperview().offset(16)
} else {
make.top.equalTo(self.documentationViews[index - 1].snp.bottom).offset(12)
}
make.left.equalToSuperview().offset(16)
make.right.lessThanOrEqualToSuperview().offset(-8)
if index == count - 1 {
make.bottom.equalToSuperview().offset(-16)
}
}
}
}
updateFailLabel(needShowFailButton)
}
}
extension YHIncomeDocumentationConfirmationCell {
private func updateFailLabel(_ needShowFailButton: Bool) {
if needShowFailButton {
infoFailLabel.isHidden = false
containerView.snp.remakeConstraints { make in
make.left.equalTo(infoTitleLabel.snp.left)
make.right.equalToSuperview().offset(-18)
make.top.equalTo(infoQuestionLabel.snp.bottom).offset(16)
}
infoFailLabel.snp.remakeConstraints { make in
make.top.equalTo(containerView.snp.bottom).offset(6)
make.left.equalTo(containerView)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
} else {
infoFailLabel.isHidden = true
containerView.snp.remakeConstraints { make in
make.left.equalTo(infoTitleLabel.snp.left)
make.right.equalToSuperview().offset(-18)
make.top.equalTo(infoQuestionLabel.snp.bottom).offset(16)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.snp.remakeConstraints { make in
make.left.equalTo(containerView)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
}
}
@objc private func cancelButtonDidClick(_ sender: UIButton) {
guard !sender.isSelected else {
return
}
selectedSureButton = false
didSelectSureButton?(false)
selectedSureButton = .false
didSelectSureButton?(.false)
}
@objc private func sureButtonDidClick(_ sender: UIButton) {
guard !sender.isSelected else {
return
}
selectedSureButton = true
didSelectSureButton?(true)
selectedSureButton = .true
didSelectSureButton?(.true)
}
private func setupUI() {
......@@ -146,6 +191,7 @@ extension YHIncomeDocumentationConfirmationCell {
subContainerView.addSubview(sureButton)
subContainerView.addSubview(cancelButton)
subContainerView.addSubview(containerView)
subContainerView.addSubview(infoFailLabel)
sureButton.setContentCompressionResistancePriority(.required, for: .horizontal)
cancelButton.setContentCompressionResistancePriority(.required, for: .horizontal)
......@@ -198,15 +244,47 @@ extension YHIncomeDocumentationConfirmationCell {
make.top.equalTo(infoQuestionLabel.snp.bottom).offset(16)
make.bottom.equalToSuperview().offset(-16)
}
selectedSureButton = true
infoFailLabel.snp.makeConstraints { make in
make.left.equalTo(containerView)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.isHidden = true
selectedSureButton = .unknown
}
private func updateButtonState(_ button: UIButton, _ isSelected: Bool) {
button.isSelected = isSelected
button.backgroundColor = isSelected ? UIColor(hexString: "#EBF0F9") : .contentBkgColor
button.layer.borderColor = isSelected ? UIColor.brandMainColor.cgColor : nil
button.layer.borderWidth = isSelected ? 1 : 0
private func updateButtonsState(_ state: YHIncomeRecordHasAllFile) {
switch state {
case .unknown:
sureButton.isSelected = false
sureButton.backgroundColor = .contentBkgColor
sureButton.layer.borderColor = nil
sureButton.layer.borderWidth = 0
cancelButton.isSelected = false
cancelButton.backgroundColor = .contentBkgColor
cancelButton.layer.borderColor = nil
cancelButton.layer.borderWidth = 0
case .true:
sureButton.isSelected = true
sureButton.backgroundColor = UIColor(hexString: "#EBF0F9")
sureButton.layer.borderColor = UIColor.brandMainColor.cgColor
sureButton.layer.borderWidth = 1
cancelButton.isSelected = false
cancelButton.backgroundColor = .contentBkgColor
cancelButton.layer.borderColor = nil
cancelButton.layer.borderWidth = 0
case .false:
cancelButton.isSelected = true
cancelButton.backgroundColor = UIColor(hexString: "#EBF0F9")
cancelButton.layer.borderColor = UIColor.brandMainColor.cgColor
cancelButton.layer.borderWidth = 1
sureButton.isSelected = false
sureButton.backgroundColor = .contentBkgColor
sureButton.layer.borderColor = nil
sureButton.layer.borderWidth = 0
}
}
}
......@@ -229,7 +307,6 @@ private class YHIncomeDocumentationView: UIView {
return view
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
......
......@@ -53,6 +53,14 @@ class YHIncomeInputMoneyCell: YHResignDocumentCell {
return view
}()
private lazy var infoFailLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textColor = .failColor
label.text = "请选择"
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
......@@ -62,7 +70,7 @@ class YHIncomeInputMoneyCell: YHResignDocumentCell {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(title: String, detail: String?, inputValue: String?, showBottomLine: Bool = true, showStarIcon: Bool = false) {
func setupCellInfo(title: String, detail: String?, inputValue: String?, showBottomLine: Bool = true, showStarIcon: Bool = false, needShowFailButton: Bool) {
infoTitleLabel.text = title
bottomLineView.isHidden = !showBottomLine
inputTextField.text = inputValue
......@@ -82,12 +90,8 @@ class YHIncomeInputMoneyCell: YHResignDocumentCell {
make.width.lessThanOrEqualTo(102)
}
}
updateDetailText(detail)
}
func updateDetailText(_ text: String?) {
infoDetailLabel.text = text
if let text = text, text.count > 0 {
infoDetailLabel.text = detail
if let detail = detail, detail.count > 0 {
infoDetailLabel.snp.remakeConstraints { make in
make.top.equalTo(inputTextField.snp.bottom).offset(4)
make.bottom.lessThanOrEqualToSuperview().offset(-16)
......@@ -102,6 +106,17 @@ class YHIncomeInputMoneyCell: YHResignDocumentCell {
make.right.lessThanOrEqualToSuperview().offset(-18)
}
}
infoFailLabel.isHidden = !needShowFailButton
infoFailLabel.snp.remakeConstraints { make in
if needShowFailButton {
make.top.equalTo(infoDetailLabel.snp.bottom).offset(6)
}
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
}
}
......@@ -114,6 +129,7 @@ extension YHIncomeInputMoneyCell {
subContainerView.addSubview(inputTextField)
subContainerView.addSubview(infoDetailLabel)
subContainerView.addSubview(bottomLineView)
subContainerView.addSubview(infoFailLabel)
dotIcon.setContentCompressionResistancePriority(.required, for: .horizontal)
infoTitleLabel.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
......@@ -145,6 +161,12 @@ extension YHIncomeInputMoneyCell {
make.left.equalToSuperview().offset(147)
make.right.lessThanOrEqualToSuperview().offset(-18)
}
infoFailLabel.isHidden = true
infoFailLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
bottomLineView.snp.makeConstraints { make in
make.bottom.equalToSuperview()
......
......@@ -44,6 +44,14 @@ class YHIncomeTypeSelectCell: YHResignDocumentCell {
return view
}()
private lazy var infoFailLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textColor = .failColor
label.text = "请选择"
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
......@@ -53,16 +61,49 @@ class YHIncomeTypeSelectCell: YHResignDocumentCell {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(title: String, detail: String = "请选择", isSelectedOne: Bool = false, showBottomLine: Bool = false) {
func setupCellInfo(title: String, detail: String = "请选择", isSelectedOne: Bool = false, showBottomLine: Bool = false, needShowFailButton: Bool) {
infoTitleLabel.text = title
infoDetailLabel.text = detail
infoDetailLabel.isHidden = isSelectedOne
bottomLineView.isHidden = !showBottomLine
updateFailLabel(needShowFailButton)
}
}
extension YHIncomeTypeSelectCell {
private func updateFailLabel(_ needShowFailButton: Bool) {
if needShowFailButton {
infoDetailLabel.snp.remakeConstraints { make in
make.top.equalToSuperview().offset(16)
make.left.equalToSuperview().offset(147)
make.right.lessThanOrEqualTo(rightArrowIcon.snp.left).offset(-18)
}
infoFailLabel.snp.remakeConstraints { make in
make.top.equalTo(infoDetailLabel.snp.bottom).offset(6)
make.left.equalTo(dotIcon)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.isHidden = false
} else {
infoDetailLabel.snp.remakeConstraints { make in
make.top.equalToSuperview().offset(16)
make.bottom.equalToSuperview().offset(-16)
make.left.equalToSuperview().offset(147)
make.right.lessThanOrEqualTo(rightArrowIcon.snp.left).offset(-18)
}
infoFailLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.isHidden = true
}
}
private func setupUI() {
updateCellCorner(.mid)
subContainerView.addSubview(dotIcon)
......@@ -70,6 +111,7 @@ extension YHIncomeTypeSelectCell {
subContainerView.addSubview(infoDetailLabel)
subContainerView.addSubview(rightArrowIcon)
subContainerView.addSubview(bottomLineView)
subContainerView.addSubview(infoFailLabel)
dotIcon.setContentCompressionResistancePriority(.required, for: .horizontal)
infoTitleLabel.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
......@@ -77,18 +119,18 @@ extension YHIncomeTypeSelectCell {
rightArrowIcon.setContentCompressionResistancePriority(.required, for: .horizontal)
dotIcon.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.centerY.equalTo(infoTitleLabel)
make.left.equalToSuperview().offset(18)
make.width.height.equalTo(6)
}
infoTitleLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.top.equalToSuperview().offset(16)
make.left.equalTo(dotIcon.snp.right).offset(2)
}
rightArrowIcon.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.centerY.equalTo(infoTitleLabel)
make.right.equalToSuperview().offset(-18)
make.width.height.equalTo(20)
}
......@@ -100,6 +142,13 @@ extension YHIncomeTypeSelectCell {
make.right.lessThanOrEqualTo(rightArrowIcon.snp.left).offset(-18)
}
infoFailLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.isHidden = true
bottomLineView.snp.makeConstraints { make in
make.bottom.equalToSuperview()
make.left.equalToSuperview().offset(18)
......
......@@ -13,6 +13,7 @@ class YHIncomeTypesCell: YHResignDocumentCell {
var didClickTypeView: ((Int) -> Void)?
private var typeViews: [YHIncomeTypeView] = []
private var lastTypes: [String] = []
private lazy var bottomLineView: UIView = {
let view = UIView()
......@@ -41,6 +42,10 @@ class YHIncomeTypesCell: YHResignDocumentCell {
}
func setupCellInfo(types: [String]) {
guard lastTypes != types || types.count != typeViews.count else {
return
}
lastTypes = types
typeViews.forEach {
$0.removeFromSuperview()
}
......
......@@ -11,12 +11,11 @@ import UIKit
class YHInfoConsentForHKTravelCell: YHResignDocumentCell {
static let cellReuseIdentifier = "YHInfoConsentForHKTravelCell"
var didSelectSureButton: ((Bool) -> Void)?
var didSelectSureButton: ((YHCheckboxSelectType) -> Void)?
var selectedSureButton: Bool = true {
var selectedSureButton: YHCheckboxSelectType = .unknown {
didSet {
updateButtonState(sureButton, selectedSureButton)
updateButtonState(cancelButton, !selectedSureButton)
updateButtonsState(selectedSureButton)
}
}
......@@ -86,6 +85,14 @@ class YHInfoConsentForHKTravelCell: YHResignDocumentCell {
return button
}()
private lazy var infoFailLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textColor = .failColor
label.text = "请选择"
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
......@@ -95,29 +102,62 @@ class YHInfoConsentForHKTravelCell: YHResignDocumentCell {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(title: String, detail: ASAttributedString, question: String, showBottomLine: Bool = false) {
func setupCellInfo(title: String, detail: ASAttributedString, question: String, showBottomLine: Bool = false, needShowFailButton: Bool) {
bottomLineView.isHidden = !showBottomLine
infoTitleLabel.text = title
infoDetailLabel.attributed.text = detail
infoQuestionLabel.text = question
updateFailLabel(needShowFailButton)
}
}
extension YHInfoConsentForHKTravelCell {
private func updateFailLabel(_ needShowFailButton: Bool) {
if needShowFailButton {
infoFailLabel.isHidden = false
infoQuestionLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalTo(infoDetailLabel.snp.bottom).offset(16)
make.height.greaterThanOrEqualTo(40)
make.width.lessThanOrEqualTo(113)
}
infoFailLabel.snp.remakeConstraints { make in
make.top.equalTo(infoQuestionLabel.snp.bottom).offset(6)
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
} else {
infoFailLabel.isHidden = true
infoQuestionLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalTo(infoDetailLabel.snp.bottom).offset(16)
make.height.greaterThanOrEqualTo(40)
make.width.lessThanOrEqualTo(113)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
}
}
@objc private func cancelButtonDidClick(_ sender: UIButton) {
guard !sender.isSelected else {
return
}
selectedSureButton = false
didSelectSureButton?(false)
selectedSureButton = .false
didSelectSureButton?(.false)
}
@objc private func sureButtonDidClick(_ sender: UIButton) {
guard !sender.isSelected else {
return
}
selectedSureButton = true
didSelectSureButton?(true)
selectedSureButton = .true
didSelectSureButton?(.true)
}
private func setupUI() {
......@@ -130,6 +170,7 @@ extension YHInfoConsentForHKTravelCell {
subContainerView.addSubview(infoQuestionLabel)
subContainerView.addSubview(sureButton)
subContainerView.addSubview(cancelButton)
subContainerView.addSubview(infoFailLabel)
sureButton.setContentCompressionResistancePriority(.required, for: .horizontal)
cancelButton.setContentCompressionResistancePriority(.required, for: .horizontal)
......@@ -165,6 +206,7 @@ extension YHInfoConsentForHKTravelCell {
make.top.equalTo(infoDetailLabel.snp.bottom).offset(16)
make.height.greaterThanOrEqualTo(40)
make.width.lessThanOrEqualTo(113)
make.bottom.equalToSuperview().offset(-16)
}
cancelButton.snp.makeConstraints { make in
......@@ -187,15 +229,47 @@ extension YHInfoConsentForHKTravelCell {
make.left.equalToSuperview().offset(18)
make.right.equalToSuperview().offset(-18)
make.height.equalTo(0.5)
make.top.equalTo(infoQuestionLabel.snp.bottom).offset(22)
}
selectedSureButton = true
infoFailLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.isHidden = true
selectedSureButton = .unknown
}
private func updateButtonState(_ button: UIButton, _ isSelected: Bool) {
button.isSelected = isSelected
button.backgroundColor = isSelected ? UIColor(hexString: "#EBF0F9") : .contentBkgColor
button.layer.borderColor = isSelected ? UIColor.brandMainColor.cgColor : nil
button.layer.borderWidth = isSelected ? 1 : 0
private func updateButtonsState(_ state: YHCheckboxSelectType) {
switch state {
case .unknown:
sureButton.isSelected = false
sureButton.backgroundColor = .contentBkgColor
sureButton.layer.borderColor = nil
sureButton.layer.borderWidth = 0
cancelButton.isSelected = false
cancelButton.backgroundColor = .contentBkgColor
cancelButton.layer.borderColor = nil
cancelButton.layer.borderWidth = 0
case .true:
sureButton.isSelected = true
sureButton.backgroundColor = UIColor(hexString: "#EBF0F9")
sureButton.layer.borderColor = UIColor.brandMainColor.cgColor
sureButton.layer.borderWidth = 1
cancelButton.isSelected = false
cancelButton.backgroundColor = .contentBkgColor
cancelButton.layer.borderColor = nil
cancelButton.layer.borderWidth = 0
case .false:
cancelButton.isSelected = true
cancelButton.backgroundColor = UIColor(hexString: "#EBF0F9")
cancelButton.layer.borderColor = UIColor.brandMainColor.cgColor
cancelButton.layer.borderWidth = 1
sureButton.isSelected = false
sureButton.backgroundColor = .contentBkgColor
sureButton.layer.borderColor = nil
sureButton.layer.borderWidth = 0
}
}
}
......@@ -58,12 +58,12 @@ class YHIncomeRecordViewModel: YHBaseViewModel {
}
}
func updateDetail(incomeId: Int, incomeMoney: Double, corporateTurnover: Double, incomeType: [Int], hasAllFile: YHIncomeRecordHasAllFile, callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
func updateDetail(incomeId: Int, incomeMoney: Double, corporateTurnover: Double, incomeType: [Int], hasAllFile: Int, callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
let params: [String: Any] = ["income_id": incomeId,
"income_money": incomeMoney,
"corporate_turnover": corporateTurnover,
"income_type": incomeType,
"has_all_file": hasAllFile.rawValue]
"has_all_file": hasAllFile]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.IncomeRecord.updateDetail
_ = YHNetRequest.postRequest(url: strUrl, params: params) { json, _ in
// 1. json字符串 转 对象
......@@ -79,9 +79,9 @@ class YHIncomeRecordViewModel: YHBaseViewModel {
}
}
func incomeUpdate(orderId: Int, incomeOver100: YHIncomeOver100, type: YHIncomeRecordUpdateType, callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
func incomeUpdate(orderId: Int, incomeOver100: Int, type: YHIncomeRecordUpdateType, callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
let params: [String: Any] = ["order_id": orderId,
"income_over_100": incomeOver100.rawValue,
"income_over_100": incomeOver100,
"type": type.rawValue]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.IncomeRecord.incomeUpdate
_ = YHNetRequest.postRequest(url: strUrl, params: params) { json, _ in
......
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