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
}
}
......@@ -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