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

// 学历信息

parent cfbb8cdc
......@@ -335,7 +335,7 @@ extension YHInformationPerfectListVC : UITableViewDelegate,UITableViewDataSource
} else if indexPath.row == 3 {
//学历/专业资格
let vc = YHEducationalQualificationVC()
vc.orderId = orderId
// vc.orderId = orderId
vc.orderId = 133971
navigationController?.pushViewController(vc)
......
......@@ -14,7 +14,7 @@ class YHFamilyRequestViewModel {
//请求所有家庭成员信息
func getFamilyInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Order.familyInfoApi
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Family.familyInfoApi
YHHUD.show(.progress(message: "数据加载中..."))
......@@ -82,7 +82,7 @@ if let brother = dic["brother"], brother is [[String: Any]] {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Order.familyInfoApi
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Family.familyInfoApi
let _ = YHNetRequest.postRequest(url: strUrl, params:params) {[weak self] json, code in
......@@ -109,7 +109,7 @@ if let brother = dic["brother"], brother is [[String: Any]] {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Order.familyMemberDeleteApi
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Family.familyMemberDeleteApi
let _ = YHNetRequest.postRequest(url: strUrl, params:params) { json, code in
YHHUD.hide()
......
......@@ -21,7 +21,11 @@
print(selectType.title)
}
// 【扩展新类型】
1)先增加一个YHFormPickerViewType类型
2)再扩展其关联类型 YHFormPickerViewSubType
3)补充新增类型后的方法 YHFormPickerView的getSubType方法 YHFormPickerViewSubType的title和index方法
4)填充数据源 详情见 属性 dataDict 懒加载方法
*/
......@@ -209,7 +213,7 @@ class YHFormPickerView: UIView {
[YHFormPickerViewItem(type: .degreeLocation(.domestic)),
YHFormPickerViewItem(type: .degreeLocation(.forgin))],
// 专业证书
.professionCertificate:
[YHFormPickerViewItem(type: .professionCertificate(.CFA)),
YHFormPickerViewItem(type: .professionCertificate(.CFP)),
......
......@@ -7,11 +7,15 @@
//
import UIKit
import SwifterSwift
class YHEducationDetailVC: YHBaseViewController {
let familyRequest:YHFamilyRequestViewModel = YHFamilyRequestViewModel()
var familyMemberInfo: YHFamilyMemberGroupInfo?
// 订单ID
var orderId: Int = 0
// 学历ID
var detailId: Int = 0
let educationRequest:YHEducationRequestViewModel = YHEducationRequestViewModel()
var detailInfo: YHEducationDetailInfo = YHEducationDetailInfo()
var isChildsEditMode: YHFormTitleItemEditType = .none
var isBrothersEditMode: YHFormTitleItemEditType = .none
......@@ -44,7 +48,7 @@ class YHEducationDetailVC: YHBaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.gk_navTitle = "学历X".local
self.gk_navTitle = "学历".local
view.backgroundColor = UIColor(hexString:"#F8F8F8")
createUI()
}
......@@ -58,6 +62,12 @@ class YHEducationDetailVC: YHBaseViewController {
view.addSubview(tableView);
view.addSubview(bottomView)
bottomView.saveBlock = {
[weak self] in
guard let self = self else { return }
saveDetailInfo()
}
bottomView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(-k_Height_safeAreaInsetsBottom())
......@@ -72,6 +82,11 @@ class YHEducationDetailVC: YHBaseViewController {
}
loadInfo()
if self.detailId != 0 { // 有学历ID则有历史学历
getDetailInfo()
} else {
detailInfo.orderId = orderId
}
}
func loadInfo() {
......@@ -81,23 +96,51 @@ class YHEducationDetailVC: YHBaseViewController {
let title0 = YHFormTitleItem(type: .mainApplicantEducation)
let item00 = YHFormDetailItem(type: .universityFullName)
item00.placeHolder = "请输入学校全称,例:清华,需填全称“清华大学".local
item00.value = detailInfo.college
let item01 = YHFormDetailItem(type: .educationStyle)
item01.placeHolder = "请选择授课形式".local
item01.value = detailInfo.type
let item02 = YHFormDetailItem(type: .educationTime)
item02.placeHolder = "请选择年月".local
item02.value = detailInfo.admissionTime
let item03 = YHFormDetailItem(type: .graduateTime)
item03.placeHolder = "请选择年月".local
item03.value = detailInfo.graduateTime
let item04 = YHFormDetailItem(type: .educationMajor)
item04.placeHolder = "请输入专业".local
item04.value = detailInfo.professional
let item05 = YHFormDetailItem(type: .educationDegree)
item05.placeHolder = "请选择学位".local
item05.value = detailInfo.background
let item06 = YHFormDetailItem(type: .degreeType)
item06.placeHolder = "请输入学位类型,如管理学".local
item06.value = detailInfo.degreeType
let item07 = YHFormDetailItem(type: .educationCountry)
item07.placeHolder = "请输入国家及地区".local
item07.value = detailInfo.schoolAddress?.country
let item08 = YHFormDetailItem(type: .educationCity)
item08.placeHolder = "请选择城市".local
if detailInfo.isSchoolInAboard() {
item08.value = detailInfo.schoolAddress?.foreign
item08.placeHolder = "请输入城市".local
item08.tips = "请输入城市".local
} else {
item08.value = detailInfo.schoolAddress?.area?.joined(separator: ",")
item08.placeHolder = "请选择出生城市".local
item08.tips = "请选择出生城市".local
}
let arr0:[YHFormItemProtocol] = [title0, item00, item01, item02, item03, item04, item05, item06, item07, item08]
items.append(arr0)
self.tableView.reloadData()
......@@ -126,8 +169,6 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
if item is YHFormTitleItem { // 是标题
let formItem = item as! YHFormTitleItem
// 配偶父母子女兄妹title
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemTitleCell.cellReuseIdentifier, for: indexPath) as! YHFormItemTitleCell
cell.titleLabel.text = formItem.getTitle()
cell.subTitleLabel.text = formItem.getSubTitle()
......@@ -143,6 +184,22 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
cell.placeHolder = detailItem.placeHolder
cell.isMust = detailItem.isNeed
cell.title = detailItem.getTitle()
cell.text = detailItem.value
cell.textChange = {
[weak self] (text, isEditEnd) in
guard let self = self else { return }
// 只有国外城市才需输入,国内城市使用的是选择器
if detailItem.type == .educationCity {
detailInfo.schoolAddress?.foreign = text
} else if detailItem.type == .educationMajor {
detailInfo.professional = text
}
if isEditEnd {
loadInfo()
saveDetailInfo()
}
}
return cell
} else if cellType == .selectSheet {
......@@ -150,7 +207,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
cell.placeHolder = detailItem.placeHolder
cell.isMust = detailItem.isNeed
cell.title = detailItem.getTitle()
cell.detail = ""
cell.detail = detailItem.value
return cell
}
}
......@@ -190,11 +247,6 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = YHProfessionalQualificationVC()
self.navigationController?.pushViewController(vc)
return
/*
let arr = items[indexPath.section]
let item:YHFormItemProtocol = arr[indexPath.row]
......@@ -204,11 +256,16 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
}
if item is YHFormDetailItem {
let detailItem = item as! YHFormDetailItem
if detailItem.type == .educationStyle { // 授课形式
if detailItem.type == .universityFullName { // 选择大学名称
} else if detailItem.type == .educationStyle { // 授课形式
YHFormPickerView.show(type: .edution, selectType: .education(.fullTime)) {
[weak self] selectType in
guard let self = self else { return }
detailInfo.type = selectType.title
loadInfo()
saveDetailInfo()
}
} else if detailItem.type == .educationTime || detailItem.type == .graduateTime { // 入学及毕业年月
......@@ -216,36 +273,56 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
YHDatePickView.show(type: .yyyymm) {
[weak self] date in
guard let self = self else { return }
if detailItem.type == .educationTime {
detailInfo.admissionTime = date
} else if detailItem.type == .graduateTime {
detailInfo.graduateTime = date
}
loadInfo()
saveDetailInfo()
}
} else if detailItem.type == .educationDegree { // 学位
YHFormPickerView.show(type: .degree, selectType: .degree(.bachelor)) {
[weak self] selectType in
guard let self = self else { return }
detailInfo.background = selectType.title
loadInfo()
saveDetailInfo()
}
} else if detailItem.type == .degreeType { // 学位类型
} else if detailItem.type == .educationCountry { // 上课国家/地区
let vc = YHSelectCountryViewController()
vc.backLocationStringController = {
[weak self] country in
guard let self = self else { return }
detailInfo.schoolAddress?.country = country
loadInfo()
saveDetailInfo()
}
self.navigationController?.pushViewController(vc)
} else if detailItem.type == .educationCity { // 上课城市
if detailInfo.isSchoolInAboard() { return }
let vc = YHAddressViewController()
vc.backLocationStringController = {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
detailInfo.schoolAddress?.area = [string1, string2, string3, string4]
loadInfo()
saveDetailInfo()
}
self.present(vc, animated: true)
}
}
*/
}
func createDefaultCell(_ indexPath: IndexPath) -> UITableViewCell {
......@@ -275,23 +352,73 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
if item is YHFormDetailItem {
let detailItem = item as! YHFormDetailItem
if detailItem.type == .universityFullName
|| detailItem.type == .degreeType
|| detailItem.type == .educationMajor {
if detailItem.type == .educationCity {
if detailInfo.isSchoolInAboard() {
return .inputText
}
return .selectSheet
}
if detailItem.type == .educationMajor
{
return .inputText
}
if detailItem.type == .educationStyle
if detailItem.type == .universityFullName
|| detailItem.type == .educationStyle
|| detailItem.type == .educationTime
|| detailItem.type == .graduateTime
|| detailItem.type == .educationDegree
|| detailItem.type == .degreeType
|| detailItem.type == .educationCountry
|| detailItem.type == .educationCity {
{
return .selectSheet
}
}
return .defaultType
}
}
extension YHEducationDetailVC {
func getDetailInfo() {
self.educationRequest.getEducationDetailInfo(params: ["id": self.detailId]) {
[weak self] success, error in
guard let self = self else { return }
if success {
detailInfo = self.educationRequest.educationDetailInfo!
loadInfo()
}
}
}
func saveDetailInfo() {
// detailInfo.toDictionary() 对于值为空的字段不会添加 而后台需要 所以如下处理
let dict:[String : Any] = ["verify": 0,
"id": detailInfo.id,
"order_id": detailInfo.orderId,
"admission_time": detailInfo.admissionTime ?? "",
"background": detailInfo.background ?? "",
"college": detailInfo.college ?? "",
"degree_type": detailInfo.degreeType ?? "",
"graduate_time": detailInfo.graduateTime ?? "",
"professional": detailInfo.professional ?? "",
"school_address_aboard": "",
"type": "",
"school_address": ["country": detailInfo.schoolAddress?.country ?? "",
"area": detailInfo.schoolAddress?.area ?? "",
"foreign": detailInfo.schoolAddress?.foreign ?? ""],
]
self.educationRequest.saveEducationInfo(params: dict) {
[weak self] success, error in
guard let self = self else { return }
if success {
// YHHUD.show(.success(message: "保存成功"))
} else {
// YHHUD.show(.error(message: "保存失败"))
}
}
}
}
......@@ -11,7 +11,7 @@ import UIKit
class YHEducationalQualificationVC: YHBaseViewController {
var orderId:Int?
var orderId:Int = 0
let educationRequest:YHEducationRequestViewModel = YHEducationRequestViewModel()
var familyMemberInfo: YHFamilyMemberGroupInfo?
var isChildsEditMode: YHFormTitleItemEditType = .none
......@@ -55,6 +55,7 @@ class YHEducationalQualificationVC: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
requestEducationInfo()
}
func createUI() {
......@@ -76,7 +77,6 @@ class YHEducationalQualificationVC: YHBaseViewController {
}
loadInfo()
requestEducationInfo()
}
func loadInfo() {
......@@ -186,6 +186,23 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
} else {
cell.title = ""
}
cell.clickBlock = {
[weak self] in
guard let self = self else { return }
if detailItem.type == .addEducation { // 学历
let vc = YHEducationDetailVC()
vc.orderId = self.orderId
self.navigationController?.pushViewController(vc)
} else if detailItem.type == .addCertificateInfo { // 证书
let vc = YHProfessionalQualificationVC()
self.navigationController?.pushViewController(vc)
}
return
}
return cell
}
......@@ -207,6 +224,21 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
let answers = [YHFormChoiceItem(title: "是".local, isSelect: select0),YHFormChoiceItem(title: "否".local, isSelect: select1)]
cell.answerArr = answers
cell.answerBlock = {
[weak self] (arr, selectIndex) in
guard let self = self else { return }
let selectItem:YHFormChoiceItem = arr[selectIndex]
let option = (selectItem.title == "是".local ? 1 : 2)
if detailItem.key == "qualification" {
self.educationInfo?.qualification = option
} else if detailItem.key == "graduate" {
self.educationInfo?.graduate = option
}
loadInfo()
}
return cell
}
......@@ -308,15 +340,6 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
}
if item is YHFormAddItem {
let detailItem = item as! YHFormAddItem
if detailItem.type == .addEducation {
let vc = YHEducationDetailVC()
self.navigationController?.pushViewController(vc)
} else if detailItem.type == .addCertificateInfo {
let vc = YHProfessionalQualificationVC()
self.navigationController?.pushViewController(vc)
}
return
}
......@@ -324,6 +347,10 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
let detailItem = item as! YHFormDetailItem
if detailItem.type == .educationInfo { // 学历
let vc = YHEducationDetailVC()
if let eduList = educationInfo?.eduList, indexPath.row-1 < eduList.count {
let eduInfo = eduList[indexPath.row-1]
vc.detailId = eduInfo.id
}
self.navigationController?.pushViewController(vc)
return
}
......@@ -333,9 +360,6 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
return
}
}
let vc = YHEducationDetailVC()
self.navigationController?.pushViewController(vc)
}
func createDefaultCell(_ indexPath: IndexPath) -> UITableViewCell {
......@@ -364,7 +388,7 @@ extension YHEducationalQualificationVC {
// 请求家庭成员信息
func requestEducationInfo() {
self.educationRequest.requestEducationInfo(params: ["order_id": self.orderId!]) {
self.educationRequest.requestEducationInfo(params: ["order_id": self.orderId]) {
[weak self] success, error in
guard let self = self else { return }
if success {
......
......@@ -9,7 +9,7 @@
import UIKit
import SmartCodable
class YHEducationListInfo:SmartCodable {
class YHEducationListInfo: SmartCodable {
var eduList: [YHEducationInfo]?
var eduCount: Int = 0
var quaList: [YHQualificationInfo]?
......@@ -76,3 +76,95 @@ class YHQualificationInfo: SmartCodable {
}
}
class YHEducationDetailInfo: SmartCodable {
var id: Int = 0
var orderId: Int = 0
var college: String?
var isTop: Int = 0
var type: String?
var admissionTime: String?
var graduateTime: String?
var background: String?
var professional: String?
var degreeType: String?
var remark: String?
var average: String?
var schoolAddress: YHSchoolAddress?
var schoolAddressAboard: Int = 0
var oldId: Int = 0
var createdAt: String?
var updatedAt: String?
var deletedAt: SmartAny?
var isShow: Int = 0
var operatorName: SmartAny?
var operatorEnglishName: SmartAny?
var operatorId: Int = 0
var matchListing: Int = 0
var createFromAppid: Int = 0
var updateFromAppid: Int = 0
var customerCenterId: Int = 0
enum CodingKeys: String, CodingKey {
case id = "id"
case orderId = "order_id"
case college = "college"
case isTop = "is_top"
case type = "type"
case admissionTime = "admission_time"
case graduateTime = "graduate_time"
case background = "background"
case professional = "professional"
case degreeType = "degree_type"
case remark = "remark"
case average = "average"
case schoolAddress = "school_address"
case schoolAddressAboard = "school_address_aboard"
case oldId = "old_id"
case createdAt = "created_at"
case updatedAt = "updated_at"
case deletedAt = "deleted_at"
case isShow = "is_show"
case operatorName = "operator_name"
case operatorEnglishName = "operator_english_name"
case operatorId = "operator_id"
case matchListing = "match_listing"
case createFromAppid = "create_from_appid"
case updateFromAppid = "update_from_appid"
case customerCenterId = "customer_center_id"
}
required init() {
}
// 学校是否在国外 默认是在国内
func isSchoolInAboard() -> Bool {
guard let schoolAddress = schoolAddress else { return false }
guard let country = schoolAddress.country else { return false }
if country.contains("中国") {
return false
}
return true
}
}
class YHSchoolAddress: Codable {
var area: [String]?
var country: String?
var foreign: String?
enum CodingKeys: String, CodingKey {
case area = "area"
case country = "country"
case foreign = "foreign"
}
required init(area: [String]?, country: String?, foreign: String?) {
self.area = area
self.country = country
self.foreign = foreign
}
}
......@@ -9,14 +9,17 @@
import UIKit
class YHEducationRequestViewModel {
// 学历和专业信息
var educationInfo: YHEducationListInfo?
// 学历详情信息
var educationDetailInfo:YHEducationDetailInfo?
// 添加家庭成员
// 请求学历和专业证书信息
func requestEducationInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.educationInfoApi
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.getEducationAndQulificationInfoApi
let _ = YHNetRequest.getRequest(url: strUrl, params:params) {[weak self] json, code in
......@@ -41,4 +44,64 @@ class YHEducationRequestViewModel {
callBackBlock(false,err)
}
}
// 获取学历详情
func getEducationDetailInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.getEducationDetailInfoApi
let _ = YHNetRequest.getRequest(url: strUrl, params:params) {[weak self] json, code in
YHHUD.hide()
guard let self = self else { return }
guard let model = NetBaseModel.deserialize(dict: json) else {
let error : YHErrorModel = YHErrorModel(errorCode:YHErrorCode.dictParseError.rawValue,errorMsg: YHErrorCode.dictParseError.description())
callBackBlock(false,error)
return
}
printLog("model 是 ==> \(model)")
let dic = model.data?.peel as? [AnyHashable : Any]
guard let resultModel = YHEducationDetailInfo.deserialize(dict: dic as? [AnyHashable : Any]) else {
callBackBlock(false,nil)
return
}
educationDetailInfo = resultModel
callBackBlock(true,nil)
} failBlock: { err in
callBackBlock(false,err)
}
}
// 保存学历
func saveEducationInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.saveEducationInfoApi
let _ = YHNetRequest.postRequest(url: strUrl, params:params) {[weak self] json, code in
YHHUD.hide()
guard let self = self else { return }
guard let model = NetBaseModel.deserialize(dict: json) else {
let error : YHErrorModel = YHErrorModel(errorCode:YHErrorCode.dictParseError.rawValue,errorMsg: YHErrorCode.dictParseError.description())
callBackBlock(false,error)
return
}
printLog("model 是 ==> \(model)")
if model.code == NetWorkCode.success.rawValue {
callBackBlock(true,nil)
} else {
callBackBlock(false, nil)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
}
......@@ -32,19 +32,23 @@ class YHAllApiName {
//保存其他资料信息
static let updateOtherInfoApi = "frontend/order/updateOrderOtherInformation"
}
struct Family {
// 获取家庭成员信息 添加家庭成员也用这个
static let familyInfoApi = "frontend/order/information/family"
// 删除家庭成员信息
static let familyMemberDeleteApi = "frontend/order/information/family/delete"
}
struct Education {
// 获取学历及证书相关信息
static let educationInfoApi = "frontend/education/list"
static let getEducationAndQulificationInfoApi = "frontend/education/list"
// 获取学历详情信息
static let getEducationDetailInfoApi = "frontend/education/detail"
// 保存学历信息
static let saveEducationInfoApi = "frontend/education/save"
}
//Users
......
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