Commit 113055e0 authored by David黄金龙's avatar David黄金龙

基本资料 校验 及 UI展示

parent aac3d3b9
......@@ -55,9 +55,6 @@ extension YHBasicInfoFillViewController {
bottomView.block = { tag in
if tag == 0 {
//点击了保存按钮
// let arr = self.basicInfoVM.arrBasicInfoSessionDataForEdit
// printLog(arr)
printLog("点击了保存按钮")
self.saveData()
} else {
......@@ -97,12 +94,36 @@ extension YHBasicInfoFillViewController {
private func saveData() {
//保存
submitAndSaveDataOp(isSaveFlag: true)
}
private func submitData() {
//提交
submitAndSaveDataOp(isSaveFlag: false)
//1.校验
if dataIsOK() == true {
//提交数据
submitAndSaveDataOp(isSaveFlag: false)
} else {
homeTableView.reloadData()
YHHUD.flash(message: "请完善信息")
}
}
//检查数据是否合法
private func dataIsOK() -> Bool {
var returnValue : Bool = true
let arr = basicInfoVM.arrBasicInfoSessionDataForEdit
for item in arr {
for (_,item0) in item.arrQuestionItem.enumerated() {
if (item0.answer == "Y" && item0.info.count < 1) || item0.answer == "" {
item0.needCheckFlag = true
returnValue = returnValue && false
}
}
}
return returnValue
}
private func submitAndSaveDataOp(isSaveFlag : Bool) {
......@@ -164,7 +185,6 @@ extension YHBasicInfoFillViewController {
arr = tArr
}
var applicant : [String : Any] = [:]
for (index0,item0) in item.arrQuestionItem.enumerated() {
if index0 == 0 {
......@@ -182,7 +202,6 @@ extension YHBasicInfoFillViewController {
applicant.updateValue(item.model?.subset_name ?? "", forKey: "subset_name")
arr.append(applicant)
param.updateValue(arr, forKey: "child")
} else if item.sessionTitle == "家庭背景" {
var applicant : [String : Any] = [:]
......@@ -194,8 +213,6 @@ extension YHBasicInfoFillViewController {
printLog("其他数据没有处理")
}
}
applicant.updateValue(basicInfoVM.dataModelForBasicInfo?.spouse?.id ?? 0, forKey: "id")
applicant.updateValue(basicInfoVM.dataModelForBasicInfo?.spouse?.subset_name ?? 0, forKey: "subset_name")
param.updateValue(applicant, forKey: "background")
} else {
......@@ -204,9 +221,15 @@ extension YHBasicInfoFillViewController {
printLog(param)
basicInfoVM.saveBasicInfo(params: param) { success, error in
self.basicInfoVM.saveBasicInfo(params: param) {[weak self] success, error in
if success == true {
YHHUD.flash(message: "操作成功")
if isSaveFlag == false {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
self?.navigationController?.popViewController(animated: true)
}
}
} else {
let msg = error?.errorMsg ?? "操作失败"
YHHUD.flash(message: msg)
......
......@@ -13,12 +13,16 @@ class YHBasicInfoCellModel {
var answer : String = ""
var info : String = ""
var needCheckFlag : Bool = false
var model : backgroundModel?
var type : Int = 0 //0- 输入型 1-选择型
init(question: String, answer: String, info: String, type : Int = 0) {
init(question: String, answer: String, info: String, type : Int = 0, needCheckFlag : Bool = false) {
self.question = question
self.answer = answer
self.info = info
self.type = type
self.needCheckFlag = needCheckFlag
}
}
......@@ -133,6 +133,22 @@ class YHBasicInfoFillView: UIView, UITextViewDelegate {
private var arrCheckBtns : [UIButton] = []
private let kTipsString : String = "如选择“是”,请详细说明"
private lazy var noChoiceTipsLable: UILabel = {
let label = UILabel()
label.textColor = .failColor
label.font = UIFont.PFSC_R(ofSize: 12)
label.text = "请选择"
return label
}()
private lazy var noTextTipsLable: UILabel = {
let label = UILabel()
label.textColor = .failColor
label.font = UIFont.PFSC_R(ofSize: 12)
label.text = "请补充详细说明"
return label
}()
}
......@@ -201,6 +217,22 @@ private extension YHBasicInfoFillView {
mutilChoiceHoldView.snp.makeConstraints { make in
make.edges.equalTo(0)
}
addSubview(noChoiceTipsLable)
noChoiceTipsLable.isHidden = true
noChoiceTipsLable.snp.makeConstraints { make in
make.top.right.left.equalToSuperview()
make.height.equalTo(20)
}
addSubview(noTextTipsLable)
noTextTipsLable.isHidden = true
noTextTipsLable.snp.makeConstraints { make in
make.top.right.left.equalToSuperview()
make.height.equalTo(20)
}
}
@objc func didClickResponseBtn(btn: UIButton) {
......@@ -215,66 +247,15 @@ private extension YHBasicInfoFillView {
btn.isSelected = true
updateAnswerButton(btn, true)
if btn == answer1Btn {
answer2Btn.isSelected = false
updateAnswerButton(answer2Btn, false)
additionHoldView.snp.removeConstraints()
mutilChoiceHoldView.snp.removeConstraints()
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
additionHoldView.isHidden = true
bottomLine.isHidden = false
mutilChoiceHoldView.isHidden = true
model?.answer = "N"
layoutForNO()
} else {
answer1Btn.isSelected = false
updateAnswerButton(answer1Btn, false)
bottomLine.snp.removeConstraints()
if model?.type == 0 {
additionHoldView.snp.removeConstraints()
additionHoldView.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.height.equalTo(78)
make.bottom.equalToSuperview().offset(-18)
}
model?.answer = "Y"
additionHoldView.isHidden = false
bottomLine.isHidden = true
mutilChoiceHoldView.isHidden = true
} else {
mutilChoiceHoldView.snp.removeConstraints()
mutilChoiceHoldView.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(-18)
}
model?.answer = "Y"
additionHoldView.isHidden = true
bottomLine.isHidden = true
mutilChoiceHoldView.isHidden = false
}
layoutForYES()
}
......@@ -326,27 +307,12 @@ private extension YHBasicInfoFillView {
title = model.question
if model.answer == "Y" {
didClickResponseBtn(btn: answer2Btn)
mutilChoiceHoldView.isHidden = false
} else {
if model.answer == "N" {
didClickResponseBtn(btn: answer1Btn)
} else {
answer2Btn.isSelected = false
updateAnswerButton(answer2Btn, false)
additionHoldView.snp.removeConstraints()
mutilChoiceHoldView.snp.removeConstraints()
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
additionHoldView.isHidden = true
bottomLine.isHidden = false
mutilChoiceHoldView.isHidden = true
layoutForMakeNoChoice()
}
}
return
......@@ -405,40 +371,26 @@ private extension YHBasicInfoFillView {
title = model.question
if model.answer == "Y" {
didClickResponseBtn(btn: answer2Btn)
mutilChoiceHoldView.isHidden = false
} else {
if model.answer == "N" {
didClickResponseBtn(btn: answer1Btn)
} else {
answer2Btn.isSelected = false
updateAnswerButton(answer2Btn, false)
additionHoldView.snp.removeConstraints()
mutilChoiceHoldView.snp.removeConstraints()
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
additionHoldView.isHidden = true
bottomLine.isHidden = false
mutilChoiceHoldView.isHidden = true
layoutForMakeNoChoice()
}
}
} else {
additionHoldView.isHidden = false
mutilChoiceHoldView.isHidden = true
}
else {
title = model.question
if model.answer == "Y" {
didClickResponseBtn(btn: answer2Btn)
myTextView.text = model.info.count > 0 ? model.info : kTipsString
didClickResponseBtn(btn: answer2Btn)
} else {
if model.answer == "N" {
didClickResponseBtn(btn: answer1Btn)
} else {
//没有做选择的情况下
layoutForMakeNoChoice()
}
}
}
......@@ -494,6 +446,7 @@ extension YHBasicInfoFillView : UITextFieldDelegate {
}
textView.textColor = UIColor.mainTextColor
layoutForYES()
}
......@@ -507,6 +460,231 @@ extension YHBasicInfoFillView : UITextFieldDelegate {
sender.isSelected = true
model?.info = String(sender.tag)
}
layoutForYES()
}
}
//各种情况下的布局
private extension YHBasicInfoFillView {
//选择 是 的布局
func layoutForYES() {
guard let model = model else {
printLog("error : 有问题 需要处理。。。。")
return
}
model.answer = "Y"
additionHoldView.isHidden = true
bottomLine.isHidden = true
mutilChoiceHoldView.isHidden = true
noChoiceTipsLable.isHidden = true
noTextTipsLable.isHidden = true
additionHoldView.snp.removeConstraints()
bottomLine.snp.removeConstraints()
mutilChoiceHoldView.snp.removeConstraints()
noChoiceTipsLable.snp.removeConstraints()
additionHoldView.snp.removeConstraints()
noTextTipsLable.snp.removeConstraints()
if model.needCheckFlag == false {
//不需要展示 提示的情况
if model.type == 0 {
additionHoldView.isHidden = false
bottomLine.isHidden = false
additionHoldView.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.height.equalTo(78)
}
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(additionHoldView.snp.bottom).offset(kMargin)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
} else {
bottomLine.isHidden = false
mutilChoiceHoldView.isHidden = false
mutilChoiceHoldView.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
}
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(mutilChoiceHoldView.snp.bottom).offset(kMargin)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
}
}
else {
//需要展示提示的情况
if model.type == 0 {
additionHoldView.isHidden = false
bottomLine.isHidden = false
additionHoldView.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.height.equalTo(78)
}
if model.info.count < 1 {
noTextTipsLable.isHidden = false
noTextTipsLable.snp.remakeConstraints { make in
make.top.equalTo(additionHoldView.snp.bottom).offset(6)
make.left.right.equalToSuperview()
make.height.equalTo(20)
}
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(noTextTipsLable.snp.bottom).offset(kMargin)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
} else {
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(additionHoldView.snp.bottom).offset(kMargin)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
}
} else {
mutilChoiceHoldView.isHidden = false
bottomLine.isHidden = false
mutilChoiceHoldView.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
}
if model.info.count < 1 {
noChoiceTipsLable.isHidden = false
noChoiceTipsLable.snp.remakeConstraints { make in
make.top.equalTo(mutilChoiceHoldView.snp.bottom).offset(6)
make.left.right.equalToSuperview()
make.height.equalTo(20)
}
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(noChoiceTipsLable.snp.bottom).offset(kMargin)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
} else {
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(mutilChoiceHoldView.snp.bottom).offset(kMargin)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
}
}
}
}
//选择 否 的布局
func layoutForNO() {
guard model != nil else {
printLog("error : 有问题 需要处理。。。。")
return
}
//隐藏提示
bottomLine.isHidden = false
noChoiceTipsLable.isHidden = true
additionHoldView.isHidden = true
mutilChoiceHoldView.isHidden = true
noTextTipsLable.isHidden = true
additionHoldView.snp.removeConstraints()
mutilChoiceHoldView.snp.removeConstraints()
noChoiceTipsLable.snp.removeConstraints()
noTextTipsLable.snp.removeConstraints()
bottomLine.snp.removeConstraints()
bottomLine.snp.makeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(kMargin)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
}
//没有选择 是和否的情况
func layoutForMakeNoChoice() {
guard let model = model else {
printLog("error : 有问题 需要处理。。。。")
return
}
if model.needCheckFlag == true {
//展示提示
bottomLine.isHidden = false
noChoiceTipsLable.isHidden = false
additionHoldView.isHidden = true
mutilChoiceHoldView.isHidden = true
noTextTipsLable.isHidden = true
additionHoldView.snp.removeConstraints()
mutilChoiceHoldView.snp.removeConstraints()
noChoiceTipsLable.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(18)
make.left.right.equalToSuperview()
make.height.equalTo(20)
}
bottomLine.snp.removeConstraints()
bottomLine.snp.makeConstraints { make in
make.top.equalTo(noChoiceTipsLable.snp.bottom).offset(kMargin)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
} else {
//隐藏提示
bottomLine.isHidden = false
noChoiceTipsLable.isHidden = true
additionHoldView.isHidden = true
mutilChoiceHoldView.isHidden = true
noTextTipsLable.isHidden = true
additionHoldView.snp.removeConstraints()
mutilChoiceHoldView.snp.removeConstraints()
noChoiceTipsLable.snp.removeConstraints()
bottomLine.snp.removeConstraints()
bottomLine.snp.makeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(kMargin)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
make.bottom.equalToSuperview()
}
}
}
}
......@@ -131,7 +131,6 @@ extension YHBasicInfoFillViewModel {
do {
//家庭背景
if let model = dataModelForBasicInfo.background {
let model1 = YHBasicInfoCellModel(question:"1、至少一名直系家庭成员(已婚配偶、父母、兄弟姊妹、子女)是现居于香港的香港永久性居民", answer: model.background_member?.has ?? "", info: model.background_member?.info ?? "",type: 1)
model1.model = model
......
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