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

// 学历/专业资格

parent dc428ae0
......@@ -8,8 +8,10 @@
import UIKit
import SwifterSwift
import Toast_Swift
class YHEducationDetailVC: YHBaseViewController {
//【WARNING!】新添加 传orderId 已有信息传detailId
// 订单ID
var orderId: Int = 0
// 学历ID
......@@ -82,9 +84,9 @@ class YHEducationDetailVC: YHBaseViewController {
}
loadInfo()
if self.detailId != 0 { // 有学历ID则有历史学历
if self.detailId != 0 { // 有学历ID则该学历已存在
getDetailInfo()
} else {
} else { // 该学历是新添加的
detailInfo.orderId = orderId
}
}
......@@ -136,7 +138,7 @@ class YHEducationDetailVC: YHBaseViewController {
item08.tips = "请输入城市".local
} else {
item08.value = detailInfo.schoolAddress?.area?.joined(separator: ",")
item08.value = detailInfo.schoolAddress?.area.joined(separator: ",")
item08.placeHolder = "请选择出生城市".local
item08.tips = "请选择出生城市".local
}
......@@ -190,7 +192,11 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return }
// 只有国外城市才需输入,国内城市使用的是选择器
if detailItem.type == .educationCity {
detailInfo.schoolAddress?.foreign = text
if let text = text, !text.isEmpty {
detailInfo.schoolAddress?.foreign = text
} else {
detailInfo.schoolAddress?.foreign = ""
}
} else if detailItem.type == .educationMajor {
detailInfo.professional = text
......@@ -386,7 +392,9 @@ extension YHEducationDetailVC {
[weak self] success, error in
guard let self = self else { return }
if success {
detailInfo = self.educationRequest.educationDetailInfo!
if let educationDetailInfo = self.educationRequest.educationDetailInfo {
detailInfo = educationDetailInfo
}
loadInfo()
}
}
......@@ -394,7 +402,7 @@ extension YHEducationDetailVC {
func saveDetailInfo() {
// detailInfo.toDictionary() 对于值为空的字段不会添加 而后台需要 所以如下处理
// detailInfo.toDictionary() 对于值为空的字段不会添加 而后台需要 所以如下处理
let dict:[String : Any] = ["verify": 0,
"id": detailInfo.id,
"order_id": detailInfo.orderId,
......@@ -405,7 +413,7 @@ extension YHEducationDetailVC {
"graduate_time": detailInfo.graduateTime ?? "",
"professional": detailInfo.professional ?? "",
"school_address_aboard": "",
"type": "",
"type": detailInfo.type ?? "",
"school_address": ["country": detailInfo.schoolAddress?.country ?? "",
"area": detailInfo.schoolAddress?.area ?? "",
"foreign": detailInfo.schoolAddress?.foreign ?? ""],
......@@ -415,9 +423,13 @@ extension YHEducationDetailVC {
[weak self] success, error in
guard let self = self else { return }
if success {
// YHHUD.show(.success(message: "保存成功"))
self.view.makeToast("保存成功", duration: 1.0, position:ToastPosition.center)
} else {
// YHHUD.show(.error(message: "保存失败"))
self.view.makeToast("保存失败", duration: 1.0, position:ToastPosition.center)
}
DispatchQueue.main.asyncAfter(deadline:.now()+1.0) {
self.view.hideToast()
}
}
}
......
......@@ -7,17 +7,21 @@
//
import UIKit
import Toast_Swift
class YHEducationalQualificationVC: YHBaseViewController {
var orderId:Int = 0
let educationRequest:YHEducationRequestViewModel = YHEducationRequestViewModel()
var familyMemberInfo: YHFamilyMemberGroupInfo?
var isChildsEditMode: YHFormTitleItemEditType = .none
var isBrothersEditMode: YHFormTitleItemEditType = .none
// 学历编辑模式
var isDegreeEditMode: YHFormTitleItemEditType = .none
// 专业编辑模式
var isQualificationEditMode: YHFormTitleItemEditType = .none
var educationInfo: YHEducationListInfo?
var items:[[YHFormItemProtocol]] = []
// 是否显示未填写错误提示
var isNeedShowError = false
lazy var tableView: UITableView = {
......@@ -63,6 +67,19 @@ class YHEducationalQualificationVC: YHBaseViewController {
view.addSubview(tableView);
view.addSubview(bottomView)
bottomView.saveBlock = {
[weak self] in
guard let self = self else { return }
saveInfo()
self.navigationController?.popViewController(animated: true)
}
bottomView.submitBlock = {
[weak self] in
guard let self = self else { return }
submitInfo()
}
bottomView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(-k_Height_safeAreaInsetsBottom())
......@@ -93,6 +110,16 @@ class YHEducationalQualificationVC: YHBaseViewController {
let item = YHFormDetailItem(type: .educationInfo)
arr0.append(item)
}
// 多学历可编辑删除状态
if eduList.count <= 0 {
isDegreeEditMode = .none
} else {
if isDegreeEditMode == .none {
isDegreeEditMode = .canEdit
}
}
} else {
isDegreeEditMode = .none
}
// 新增学历信息
arr0.append(YHFormAddItem(type: .addEducation))
......@@ -106,7 +133,18 @@ class YHEducationalQualificationVC: YHBaseViewController {
let item = YHFormDetailItem(type: .certificateInfo)
arr1.append(item)
}
// 多专业可编辑删除状态
if quaList.count <= 0 {
isQualificationEditMode = .none
} else {
if isQualificationEditMode == .none {
isQualificationEditMode = .canEdit
}
}
} else {
isQualificationEditMode = .none
}
// 新增学历信息
arr1.append(YHFormAddItem(type: .addCertificateInfo))
items.append(arr1)
......@@ -126,6 +164,8 @@ class YHEducationalQualificationVC: YHBaseViewController {
arr2.append(questionInfo)
}
items.append(arr2)
self.tableView.reloadData()
}
}
......@@ -159,17 +199,34 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
// 决定右边按钮显示样式
cell.showEditType(type: .none)
// if formItem.type == .child {
// cell.showEditType(type: isChildsEditMode)
//
// } else if formItem.type == .brother {
// cell.showEditType(type: isBrothersEditMode)
// }
if formItem.type == .mainApplicantEducation { // 学历
cell.showEditType(type: isDegreeEditMode)
} else if formItem.type == .mainApplicantProfessionalQualification { // 专业
cell.showEditType(type: isQualificationEditMode)
}
// 右边按钮点击事件处理
cell.rightClickBlock = { [weak self] type in
cell.rightClickBlock = {
[weak self] type in
guard let self = self else { return }
if formItem.type == .mainApplicantEducation { // 学历
if self.isDegreeEditMode == .canCancel {
self.isDegreeEditMode = .canEdit
} else if self.isDegreeEditMode == .canEdit {
self.isDegreeEditMode = .canCancel
}
}
if formItem.type == .mainApplicantProfessionalQualification { // 专业
if self.isQualificationEditMode == .canCancel {
self.isQualificationEditMode = .canEdit
} else if self.isQualificationEditMode == .canEdit {
self.isQualificationEditMode = .canCancel
}
}
loadInfo()
}
return cell
}
......@@ -199,6 +256,7 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
} else if detailItem.type == .addCertificateInfo { // 证书
let vc = YHProfessionalQualificationVC()
vc.orderId = String(self.orderId)
self.navigationController?.pushViewController(vc)
}
return
......@@ -245,11 +303,11 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
if item is YHFormDetailItem {
let detailItem = item as! YHFormDetailItem
if detailItem.type == .educationInfo {
if let eduList = educationInfo?.eduList {
if let eduList = educationInfo?.eduList, eduList.count > 0 {
// 第一行是标题
let eduInfo:YHEducationInfo = eduList[indexPath.row-1]
if eduInfo.vacantNum > 0 {
if eduInfo.vacantNum > 0 { // 有未填项
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell
if let college = eduInfo.college, !college.isEmpty {
cell.title = eduInfo.college
......@@ -257,9 +315,17 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
cell.title = "学历标题".local
}
cell.detailLabel.text = String(format: "有%d项未填", eduInfo.vacantNum)
cell.isShowDeleteBtn = (isDegreeEditMode == .canCancel)
cell.detailLabel.textColor = (isNeedShowError && eduInfo.vacantNum > 0 ? .failColor : .labelTextColor2)
cell.deleteBlock = {
[weak self] in
guard let self = self else { return }
isDegreeEditMode = .none
deleteEducationInfo(id:eduInfo.id)
}
return cell
} else {
} else { // 数据已填满
let cell = tableView.dequeueReusableCell(withIdentifier: YHEducationInfoCell.cellReuseIdentifier, for: indexPath) as! YHEducationInfoCell
cell.titleLabel.text = eduInfo.college
......@@ -271,12 +337,19 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
if let admissionTime = eduInfo.admissionTime, let graduateTime = eduInfo.graduateTime {
cell.timeLabel.text = String("\(admissionTime)-\(graduateTime)")
}
cell.isShowDeleteBtn = (isDegreeEditMode == .canCancel)
cell.deleteBlock = {
[weak self] in
guard let self = self else { return }
isDegreeEditMode = .none
deleteEducationInfo(id:eduInfo.id)
}
return cell
}
}
}
if detailItem.type == .certificateInfo {
if let quaList = educationInfo?.quaList {
if let quaList = educationInfo?.quaList, quaList.count > 0 {
// 第一行是标题
let quaInfo:YHQualificationInfo = quaList[indexPath.row-1]
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell
......@@ -289,6 +362,14 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
} else {
cell.detailLabel.text = "已填完".local
}
cell.detailLabel.textColor = (isNeedShowError && quaInfo.vacantNum > 0 ? .failColor : .labelTextColor2)
cell.isShowDeleteBtn = (isQualificationEditMode == .canCancel)
cell.deleteBlock = {
[weak self] in
guard let self = self else { return }
isQualificationEditMode = .none
deleteQualificationInfo(id:quaInfo.id)
}
return cell
}
}
......@@ -356,6 +437,10 @@ extension YHEducationalQualificationVC : UITableViewDelegate, UITableViewDataSou
}
if detailItem.type == .certificateInfo { // 证书
let vc = YHProfessionalQualificationVC()
if let quaList = educationInfo?.quaList, indexPath.row-1 < quaList.count {
let quaInfo = quaList[indexPath.row-1]
vc.detailId = String(quaInfo.id)
}
self.navigationController?.pushViewController(vc)
return
}
......@@ -397,6 +482,93 @@ extension YHEducationalQualificationVC {
}
}
}
// 删除学历信息
func deleteEducationInfo(id:Int) {
self.educationRequest.deleteEducationInfo(id: id) {
[weak self] success, error in
guard let self = self else { return }
if success {
requestEducationInfo()
}
}
}
// 删除证书信息
func deleteQualificationInfo(id:Int) {
self.educationRequest.deleteQualificationInfo(id: id) {
[weak self] success, error in
guard let self = self else { return }
if success {
requestEducationInfo()
}
}
}
// 保存
func saveInfo() {
let params = ["go_next": 0,
"graduate": educationInfo?.graduate ?? 0,
"order_id": self.orderId,
"qualification": educationInfo?.qualification ?? 0]
self.educationRequest.saveAllEducationInfo(params: params) {
[weak self] success, error in
guard let self = self else { return }
if success {
requestEducationInfo()
}
}
}
func submitInfo() {
let isChecked = checkIntegrity()
isNeedShowError = !isChecked
self.tableView .reloadData()
if !isChecked {
ToastManager.shared.isTapToDismissEnabled = false
self.view.makeToast("资料还未填完", duration: 1.0, position:ToastPosition.center)
DispatchQueue.main.asyncAfter(deadline:.now()+1.0) {
self.view.hideToast()
}
return
}
saveInfo()
}
// 检查填写信息完整性
func checkIntegrity() -> Bool {
guard let educationInfo = educationInfo else { return false }
// 检查所有学历信息是否有未填项
if let eduList = educationInfo.eduList, eduList.count > 0 {
for eduInfo in eduList {
if eduInfo.vacantNum > 0 {
return false
}
}
}
// 检查所有证书信息是否有未填项
if let quaList = educationInfo.quaList, quaList.count > 0 {
for quaInfo in quaList {
if quaInfo.vacantNum > 0 {
return false
}
}
}
// 检查所有问题是否有未答项
if educationInfo.qualification == 0 || educationInfo.graduate == 0 {
return false
}
return true
}
}
......@@ -7,11 +7,18 @@
//
import UIKit
import Toast_Swift
class YHProfessionalQualificationVC: YHBaseViewController {
let familyRequest:YHFamilyRequestViewModel = YHFamilyRequestViewModel()
var familyMemberInfo: YHFamilyMemberGroupInfo?
//【WARNING!】新添加 传orderId 已有信息传detailId
// 订单ID
var orderId: String = ""
// 专业ID
var detailId: String = ""
let educationRequest:YHEducationRequestViewModel = YHEducationRequestViewModel()
// 专业详情信息
var detailInfo = YHQualificationDetailInfo()
var isChildsEditMode: YHFormTitleItemEditType = .none
var isBrothersEditMode: YHFormTitleItemEditType = .none
......@@ -44,7 +51,7 @@ class YHProfessionalQualificationVC: YHBaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.gk_navTitle = "学历X".local
self.gk_navTitle = "专业资格及会员资格".local
view.backgroundColor = UIColor(hexString:"#F8F8F8")
createUI()
}
......@@ -57,6 +64,11 @@ class YHProfessionalQualificationVC: 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()
......@@ -72,23 +84,41 @@ class YHProfessionalQualificationVC: YHBaseViewController {
}
loadInfo()
if !self.detailId.isEmpty { // 有专业ID则该专业已存在
reqeustDetailInfo()
} else { // 该专业是新添加的
detailInfo.orderId = orderId
}
}
func loadInfo() {
items.removeAll()
let title0 = YHFormTitleItem(type: .mainApplicantEducation)
let item00 = YHFormDetailItem(type: .qualificationCertificateName)
item00.placeHolder = "请选择资格证书名称".local
item00.value = detailInfo.qualification
let item01 = YHFormDetailItem(type: .conferAgencyFullName)
item01.placeHolder = "请输入颁授机构全称".local
item01.value = detailInfo.college
let item02 = YHFormDetailItem(type: .conferTime)
item02.placeHolder = "请选择颁授年份".local
item02.value = detailInfo.promulgation
let item03 = YHFormDetailItem(type: .conferCountry)
item03.placeHolder = "请选择颁授国家/地区".local
item03.value = detailInfo.collegeAddress.country
let item04 = YHFormDetailItem(type: .conferCity)
item04.placeHolder = "请选择颁授城市".local
if detailInfo.isCollegeInAboard() {
item04.value = detailInfo.collegeAddress.foreign
} else {
item04.value = detailInfo.collegeAddress.area.joined(separator: ",")
}
let arr0:[YHFormItemProtocol] = [title0, item00, item01, item02, item03, item04]
items.append(arr0)
......@@ -136,14 +166,34 @@ extension YHProfessionalQualificationVC : UITableViewDelegate, UITableViewDataSo
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 == .conferCity {
if let text = text, !text.isEmpty {
detailInfo.collegeAddress.foreign = text
} else {
detailInfo.collegeAddress.foreign = ""
}
}
if isEditEnd {
loadInfo()
// saveDetailInfo()
}
}
return cell
} else if cellType == .selectSheet {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemSelectSheetCell.cellReuseIdentifier, for: indexPath) as! YHFormItemSelectSheetCell
cell.placeHolder = detailItem.placeHolder
cell.isMust = detailItem.isNeed
cell.title = detailItem.getTitle()
cell.detail = ""
cell.detail = detailItem.value
return cell
}
}
......@@ -186,8 +236,6 @@ extension YHProfessionalQualificationVC : UITableViewDelegate, UITableViewDataSo
let arr = items[indexPath.section]
let item:YHFormItemProtocol = arr[indexPath.row]
// 标题
if item is YHFormTitleItem {
return
......@@ -200,7 +248,9 @@ extension YHProfessionalQualificationVC : UITableViewDelegate, UITableViewDataSo
[weak self] selectType in
guard let self = self else { return }
detailInfo.qualification = selectType.title
loadInfo()
saveDetailInfo()
}
} else if detailItem.type == .conferTime { // 授权年份
......@@ -208,7 +258,9 @@ extension YHProfessionalQualificationVC : UITableViewDelegate, UITableViewDataSo
YHDatePickView.show(type: .yyyy) {
[weak self] date in
guard let self = self else { return }
detailInfo.promulgation = date
loadInfo()
saveDetailInfo()
}
} else if detailItem.type == .conferCountry { // 授权国家/地区
......@@ -217,15 +269,23 @@ extension YHProfessionalQualificationVC : UITableViewDelegate, UITableViewDataSo
vc.backLocationStringController = {
[weak self] country in
guard let self = self else { return }
detailInfo.collegeAddress.country = country
loadInfo()
saveDetailInfo()
}
self.navigationController?.pushViewController(vc)
} else if detailItem.type == .conferCity { // 授权城市
if detailInfo.isCollegeInAboard() { return }
let vc = YHAddressViewController()
vc.backLocationStringController = {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
detailInfo.collegeAddress.area = [string1, string2, string3, string4]
loadInfo()
saveDetailInfo()
}
self.present(vc, animated: true)
}
......@@ -272,7 +332,56 @@ extension YHProfessionalQualificationVC : UITableViewDelegate, UITableViewDataSo
}
return .defaultType
}
}
extension YHProfessionalQualificationVC {
func reqeustDetailInfo() {
self.educationRequest.getQualificationDetailInfo(id:self.detailId) {
[weak self] success, error in
guard let self = self else { return }
if success {
if let qualificationDetailInfo = self.educationRequest.qualificationDetailInfo {
detailInfo = qualificationDetailInfo
}
loadInfo()
}
}
}
func saveDetailInfo() {
var dict:[String : Any] = [:]
if detailId.isEmpty { // 新增数据
dict = ["verify" : 0,
"college":detailInfo.college,
"college_address_aboard":"",
"id":"",
"order_id" : detailInfo.orderId,
"promulgation" : detailInfo.promulgation,
"qualification" : detailInfo.qualification,
"college_address":["area":[],
"country":"",
"details":"",
"foreign":""]]
} else { // 已有数据
dict = detailInfo.toDictionary() ?? [:]
dict["verify"] = 0
}
print(dict)
self.educationRequest.saveQualificationInfo(params: dict) {
[weak self] success, error in
guard let self = self else { return }
if success {
YHHUD.flash(message: "保存成功")
} else {
YHHUD.flash(message: "保存失败")
}
}
}
}
......@@ -34,8 +34,8 @@ class YHEducationListInfo: SmartCodable {
}
class YHEducationInfo: SmartCodable {
var id: Int = -1
var orderId: Int = -1
var id: Int = 0
var orderId: Int = 0
var college: String?
var background: String?
var professional: String?
......@@ -60,8 +60,8 @@ class YHEducationInfo: SmartCodable {
}
class YHQualificationInfo: SmartCodable {
var id: Int = -1
var orderId: Int = -1
var id: Int = 0
var orderId: Int = 0
var qualification: String?
var vacantNum: Int = 0
......@@ -92,7 +92,7 @@ class YHEducationDetailInfo: SmartCodable {
var degreeType: String?
var remark: String?
var average: String?
var schoolAddress: YHSchoolAddress?
var schoolAddress: YHCollegeAddress?
var schoolAddressAboard: Int = 0
var oldId: Int = 0
var createdAt: String?
......@@ -142,29 +142,89 @@ class YHEducationDetailInfo: SmartCodable {
// 学校是否在国外 默认是在国内
func isSchoolInAboard() -> Bool {
guard let schoolAddress = schoolAddress else { return false }
guard let country = schoolAddress.country else { return false }
if country.contains("中国") {
if schoolAddress.country.isEmpty { return false }
if schoolAddress.country.contains("中国") {
return false
}
return true
}
}
class YHSchoolAddress: Codable {
var area: [String]?
var country: String?
var foreign: String?
class YHCollegeAddress: Codable {
var area: [String] = []
var country: String = ""
var details: String = ""
var foreign: String = ""
enum CodingKeys: String, CodingKey {
case area = "area"
case country = "country"
case details = "details"
case foreign = "foreign"
}
required init(area: [String]?, country: String?, foreign: String?) {
self.area = area
self.country = country
self.foreign = foreign
required init() {
}
}
class YHQualificationDetailInfo: SmartCodable {
var id: String = ""
var orderId: String = ""
var college: String = ""
var collegeAddress: YHCollegeAddress = YHCollegeAddress()
var collegeAddressAboard: Int = 0
var promulgation: String = ""
var qualification: String = ""
var remark: String = ""
var oldId: Int = 0
var createdAt: String = ""
var updatedAt: String = ""
var deletedAt: String = ""
var operatorName: String = ""
var operatorEnglishName: String = ""
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 collegeAddress = "college_address"
case collegeAddressAboard = "college_address_aboard"
case promulgation = "promulgation"
case qualification = "qualification"
case remark = "remark"
case oldId = "old_id"
case createdAt = "created_at"
case updatedAt = "updated_at"
case deletedAt = "deleted_at"
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"
}
// 学校是否在国外 默认是在国内
func isCollegeInAboard() -> Bool {
if collegeAddress.country.isEmpty { return false }
if collegeAddress.country.contains("中国") {
return false
}
return true
}
required init() {
}
}
......@@ -12,7 +12,9 @@ class YHEducationRequestViewModel {
// 学历和专业信息
var educationInfo: YHEducationListInfo?
// 学历详情信息
var educationDetailInfo:YHEducationDetailInfo?
var educationDetailInfo: YHEducationDetailInfo?
// 专业详情信息
var qualificationDetailInfo: YHQualificationDetailInfo?
// 请求学历和专业证书信息
func requestEducationInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
......@@ -104,4 +106,148 @@ class YHEducationRequestViewModel {
}
}
// 删除学历
func deleteEducationInfo(id:Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.deleteEducationInfoApi
let _ = YHNetRequest.postRequest(url: strUrl, params:["id" : id]) {[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)
}
}
// 删除专业
func deleteQualificationInfo(id:Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Qualification.deleteQualificationInfoApi
let _ = YHNetRequest.postRequest(url: strUrl, params:["id" : id]) {[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)
}
}
// 保存所有
func saveAllEducationInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.saveAllEduAndQuaInfoApi
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)
}
}
// 获取专业详情
func getQualificationDetailInfo(id:String, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Qualification.getQualificationDetailInfoApi
let _ = YHNetRequest.getRequest(url: strUrl, params:["id" : id]) {[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 = YHQualificationDetailInfo.deserialize(dict: dic as? [AnyHashable : Any]) else {
callBackBlock(false,nil)
return
}
qualificationDetailInfo = resultModel
callBackBlock(true,nil)
} failBlock: { err in
callBackBlock(false,err)
}
}
// 保存专业信息
func saveQualificationInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Qualification.saveQualificationInfoApi
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)
}
}
}
......@@ -12,6 +12,14 @@ class YHEducationInfoCell: UITableViewCell {
static let cellReuseIdentifier = "YHEducationInfoCell"
let horizonalGap = 18.0
var deleteBlock:(()->Void)?
var isShowDeleteBtn:Bool = false {
didSet {
deleteButton.isHidden = !isShowDeleteBtn
timeLabel.isHidden = isShowDeleteBtn
arrowImgView.isHidden = isShowDeleteBtn
}
}
lazy var titleLabel: UILabel = {
let label = UILabel()
......@@ -38,6 +46,17 @@ class YHEducationInfoCell: UITableViewCell {
return label
}()
private lazy var deleteButton: UIButton = {
let btn = UIButton()
btn.setTitle("删除".local, for: .normal)
btn.titleLabel?.font = UIFont.PFSC_R(ofSize: 14)
btn.setTitleColor(.failColor, for: .normal)
btn.addTarget(self, action: #selector(didClickDeleteBtn(btn:)), for: .touchUpInside)
btn.isHidden = true
return btn
}()
private lazy var arrowImgView: UIImageView = {
let imgView = UIImageView(image: UIImage(named: "form_right_arrow"))
return imgView
......@@ -66,6 +85,13 @@ class YHEducationInfoCell: UITableViewCell {
setupUI()
}
@objc func didClickDeleteBtn(btn:UIButton) {
if let deleteBlock = deleteBlock {
deleteBlock()
}
}
func setupUI() {
self.selectionStyle = .none
......@@ -74,6 +100,7 @@ class YHEducationInfoCell: UITableViewCell {
contentView.addSubview(timeLabel)
contentView.addSubview(arrowImgView)
contentView.addSubview(bottomLine)
contentView.addSubview(deleteButton)
titleLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
......@@ -88,6 +115,12 @@ class YHEducationInfoCell: UITableViewCell {
make.centerY.equalTo(titleLabel)
}
deleteButton.snp.makeConstraints { make in
make.size.equalTo(CGSizeMake(64, 40))
make.centerY.equalTo(titleLabel)
make.right.equalToSuperview()
}
arrowImgView.snp.makeConstraints { make in
make.width.height.equalTo(20.0)
make.centerY.equalTo(titleLabel)
......
......@@ -49,6 +49,20 @@ class YHAllApiName {
static let getEducationDetailInfoApi = "frontend/education/detail"
// 保存学历信息
static let saveEducationInfoApi = "frontend/education/save"
// 删除学历
static let deleteEducationInfoApi = "frontend/education/del"
// 保存所有信息
static let saveAllEduAndQuaInfoApi = "frontend/education/save_all"
}
struct Qualification {
// 获取学历详情信息
static let getQualificationDetailInfoApi = "frontend/qualification/detail"
// 删除专业
static let deleteQualificationInfoApi = "frontend/qualification/del"
// 保存专业
static let saveQualificationInfoApi = "frontend/qualification/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