Commit 6bdecb3c authored by pete谢兆麟's avatar pete谢兆麟

1.工作经验删除逻辑,及显示逻辑

2.项目经验UI修改及至今逻辑添加
3.项目经验列表UI 调整
parent e4613f9f
......@@ -110,7 +110,7 @@ class YHServiceCenterMainViewController: YHBaseViewController {
extension YHServiceCenterMainViewController {
func loadData() {
if model.id != -1 {
if model.id != -1 && self.navigationController?.viewControllers.count != 1 {
noDataView.isHidden = true
nameBgImageView.isHidden = false
segmentedView.isHidden = false
......
......@@ -180,11 +180,31 @@ extension YHWorkExperienceListViewController: UITableViewDelegate, UITableViewDa
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let number = dataSource?.count ?? 0
if number == 0 {
return CGFloat(23 + 216)
} else {
return CGFloat(23 + 154 + 76 * number)
var height = 23 + 154
if let data = dataSource {
for item in data {
if item.company_name == "" {
height = height + 52
} else {
let text = item.company_name // 要显示的文本内容
let font = UIFont.PFSC_B(ofSize: 14) // 字体大小
let maxWidth = 143.0 // 最大宽度限制
// 创建NSAttributedString对象并设置属性
let attributes = [NSAttributedString.Key.font : font] as [NSAttributedString.Key : Any]
_ = NSMutableAttributedString(string: text ?? "", attributes: attributes)
// 根据指定的最大宽度和字体大小计算文本的高度
let size = (text! as NSString).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size
if size.height > 20 {
height = height + 96
} else {
height = height + 76
}
}
}
}
return CGFloat(height)
}
}
......@@ -484,7 +484,7 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
} else if stepView.currentIndex == 3 {
if self.viewModel.mainModel.is_project_introduction == 1 {
let number = introductionDataSource?.count ?? 0
return CGFloat(76 * number + 161)
return CGFloat(76 * number + 150)
} else {
if indexPath.row == 0 {
if self.isShowMessageSelect {
......
......@@ -14,7 +14,10 @@ class YHWorkIntroductionViewController: YHBaseViewController {
var nameTextField: UITextField!
var startTextField: UITextField!
var endTextField: UITextField!
var longTimeButton: UIButton!
var messageTextField: UITextView!
var startButton: UIButton!
var endButton: UIButton!
var promptsLabel: UILabel!
var actionView: YHWorkActionView!
var bottomView: UIView!
......@@ -44,7 +47,7 @@ class YHWorkIntroductionViewController: YHBaseViewController {
func setView() {
view.backgroundColor = .white
let array = ["项目名称", "项目时间", "项目业绩/亮点"]
let array = ["项目名称", "项目开始时间", "项目结束时间", "项目业绩/亮点"]
for i in 0..<array.count {
let label = UILabel()
label.textColor = UIColor.mainTextColor
......@@ -100,10 +103,10 @@ class YHWorkIntroductionViewController: YHBaseViewController {
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 52)
make.left.equalTo(117)
make.height.equalTo(51)
make.width.equalTo(90)
make.right.equalTo(-18)
}
let startButton = {
startButton = {
let button = UIButton(type: .custom)
button.addTarget(self, action: #selector(startClick), for: .touchUpInside)
return button
......@@ -113,7 +116,7 @@ class YHWorkIntroductionViewController: YHBaseViewController {
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 52)
make.left.equalTo(117)
make.height.equalTo(51)
make.width.equalTo(90)
make.right.equalTo(-18)
}
endTextField = {
......@@ -122,39 +125,72 @@ class YHWorkIntroductionViewController: YHBaseViewController {
textField.placeholder = "结束时间"
textField.isEnabled = false
textField.isUserInteractionEnabled = false
textField.text = dataSource.project_end_time
if dataSource.project_end_time != "至今" {
textField.text = dataSource.project_end_time
} else {
textField.text = ""
}
return textField
}()
view.addSubview(endTextField)
endTextField.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 52)
make.right.equalTo(-18)
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 104)
make.left.equalTo(117)
make.height.equalTo(51)
make.width.equalTo(90)
make.right.equalTo(-18)
}
let endButton = {
endButton = {
let button = UIButton(type: .custom)
button.addTarget(self, action: #selector(endClick), for: .touchUpInside)
return button
}()
view.addSubview(endButton)
endButton.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 52)
make.right.equalTo(-18)
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 104)
make.left.equalTo(117)
make.height.equalTo(51)
make.width.equalTo(90)
make.right.equalTo(-18)
}
let lineView = UIView()
lineView.backgroundColor = UIColor.mainTextColor
view.addSubview(lineView)
lineView.snp.makeConstraints { make in
make.centerY.equalTo(startTextField.snp.centerY)
make.height.equalTo(1)
make.width.equalTo(5)
make.centerX.equalToSuperview().offset(40)
longTimeButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "main_time_normal"), for: .normal)
button.setImage(UIImage(named: "login_privacy_agree"), for: .selected)
button.setTitleColor(UIColor.mainTextColor, for: .normal)
button.setTitle("至今", for: .normal)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 14)
button.contentHorizontalAlignment = .right
button.addTarget(self, action: #selector(longTimeButtonClick), for: .touchUpInside)
if dataSource.project_end_time == "至今" {
button.isSelected = true
} else {
button.isSelected = false
}
return button
}()
view.addSubview(longTimeButton)
if dataSource.project_end_time != "至今" {
longTimeButton.snp.makeConstraints { make in
make.right.equalTo(-18)
make.centerY.equalTo(endTextField.snp.centerY)
make.height.equalTo(32)
make.width.equalTo(43)
}
endTextField.isHidden = false
endButton.isHidden = false
} else {
longTimeButton.snp.makeConstraints { make in
make.left.equalTo(117)
make.centerY.equalTo(endTextField.snp.centerY)
make.height.equalTo(32)
make.width.equalTo(43)
}
endTextField.isHidden = true
endButton.isHidden = true
}
longTimeButton.iconInLeft(spacing: 3)
messageTextField = {
let textField = UITextView()
......@@ -169,7 +205,7 @@ class YHWorkIntroductionViewController: YHBaseViewController {
messageTextField.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(156 + k_Height_NavigationtBarAndStatuBar)
make.top.equalTo(208 + k_Height_NavigationtBarAndStatuBar)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 124)
}
......@@ -185,7 +221,7 @@ class YHWorkIntroductionViewController: YHBaseViewController {
promptsLabel.snp.makeConstraints { make in
make.left.equalTo(22)
make.right.equalTo(-22)
make.top.equalTo(161 + k_Height_NavigationtBarAndStatuBar)
make.top.equalTo(220 + k_Height_NavigationtBarAndStatuBar)
}
actionView = {
let view = YHWorkActionView()
......@@ -257,7 +293,33 @@ class YHWorkIntroductionViewController: YHBaseViewController {
}
}
@objc func longTimeButtonClick() {
longTimeButton.isSelected = !longTimeButton.isSelected
if longTimeButton.isSelected {
longTimeButton.snp.remakeConstraints { make in
make.left.equalTo(117)
make.centerY.equalTo(endTextField.snp.centerY)
make.height.equalTo(32)
make.width.equalTo(43)
}
endTextField.isHidden = true
endButton.isHidden = true
} else {
longTimeButton.snp.remakeConstraints { make in
make.right.equalTo(-18)
make.centerY.equalTo(endTextField.snp.centerY)
make.height.equalTo(32)
make.width.equalTo(43)
}
endTextField.isHidden = false
endButton.isHidden = false
}
}
@objc func submit() {
if longTimeButton.isSelected {
dataSource.project_end_time = "至今"
}
guard let _ = dataSource.project_name else {
YHHUD.flash(message: "您还有信息未填写")
return
......@@ -290,7 +352,7 @@ class YHWorkIntroductionViewController: YHBaseViewController {
@objc func startClick() {
view.endEditing(true)
YHDatePickView.show(type: .yyyymmdd, title: "选择开始时间", lastIsTaday: true, currentDay: dataSource.project_start_time ?? "") { date in
if date > self.dataSource.project_end_time ?? "" && self.dataSource.project_end_time?.count ?? 0 > 0 {
if date > self.dataSource.project_end_time ?? "" && self.dataSource.project_end_time?.count ?? 0 > 0 && self.dataSource.project_end_time != "至今" {
YHHUD.flash(message: "开始时间不能晚于结束时间")
} else {
let format = DateFormatter()
......
......@@ -184,17 +184,18 @@ class YHWorkExperienceListTableViewCell: UITableViewCell {
}
return
}
var total = 0
for i in 0 ..< dataSource.count {
let line = UIView()
line.backgroundColor = UIColor.separatorColor
mainItemView.addSubview(line)
line.snp.makeConstraints { make in
make.left.equalTo(18)
make.top.equalTo(76 * i)
make.top.equalTo(total)
make.height.equalTo(1)
make.right.equalTo(-18)
}
total = total + 1
let itemView = YHWorkItemView()
itemView.clickBlock = {[weak self] model in
guard let self = self else { return }
......@@ -209,16 +210,38 @@ class YHWorkExperienceListTableViewCell: UITableViewCell {
block(model)
}
}
let model = dataSource[i]
itemView.tag = 4000 + i
itemView.dataSource = dataSource[i]
itemView.showPrompt = showPrompt
var h = 0
if model.company_name == "" {
h = 51
} else {
let text = model.company_name // 要显示的文本内容
let font = UIFont.PFSC_B(ofSize: 14) // 字体大小
let maxWidth = 143.0 // 最大宽度限制
// 创建NSAttributedString对象并设置属性
let attributes = [NSAttributedString.Key.font : font] as [NSAttributedString.Key : Any]
_ = NSMutableAttributedString(string: text ?? "", attributes: attributes)
// 根据指定的最大宽度和字体大小计算文本的高度
let size = (text! as NSString).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size
if size.height > 20 {
h = 95
} else {
h = 75
}
}
mainItemView.addSubview(itemView)
itemView.snp.makeConstraints { make in
make.left.equalTo(18)
make.top.equalTo(76 * i + 1)
make.height.equalTo(75)
make.top.equalTo(total)
make.height.equalTo(h)
make.right.equalTo(-18)
}
total = total + h
}
}
......
......@@ -108,7 +108,7 @@ class YHWorkIntroductionItemView: UIView {
func updateAllViews() {
guard let dataSource = dataSource else { return }
titleLabel.text = dataSource.project_name
subTitleLabel.text = "\(dataSource.project_start_time ?? "")" + "-" + "\(dataSource.project_end_time ?? "")"
subTitleLabel.text = "\(dataSource.project_start_time ?? "")" + "" + "\(dataSource.project_end_time ?? "")"
}
......
......@@ -122,8 +122,8 @@ class YHWorkIntroductionTableViewCell: UITableViewCell {
centerView.addSubview(mainItemView)
mainItemView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalTo(-65)
make.top.equalTo(85)
make.bottom.equalTo(-79)
make.top.equalTo(63)
}
bottomView = {
......
......@@ -54,6 +54,7 @@ class YHWorkItemView: UIView {
let label = UILabel()
label.font = UIFont.PFSC_B(ofSize: 14)
label.textAlignment = .left
label.numberOfLines = 2
label.textColor = UIColor.mainTextColor
return label
}()
......@@ -61,8 +62,7 @@ class YHWorkItemView: UIView {
titleLabel.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.equalTo(16)
make.width.equalTo(112)
make.height.equalTo(20)
make.width.equalTo(143)
}
subTitleLabel = {
......@@ -76,7 +76,7 @@ class YHWorkItemView: UIView {
subTitleLabel.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(20)
make.top.equalTo(40)
make.bottom.equalTo(-16)
}
explainLabel = {
......@@ -91,7 +91,7 @@ class YHWorkItemView: UIView {
make.right.equalTo(-24)
make.left.equalTo(titleLabel.snp.right)
make.height.equalTo(20)
make.centerY.equalTo(titleLabel.snp.centerY)
make.top.equalTo(16)
}
nextStepImageView = {
......@@ -102,7 +102,7 @@ class YHWorkItemView: UIView {
addSubview(nextStepImageView)
nextStepImageView.snp.makeConstraints { make in
make.right.equalToSuperview()
make.centerY.equalTo(titleLabel.snp.centerY)
make.centerY.equalTo(explainLabel.snp.centerY)
make.height.width.equalTo(20)
}
......@@ -145,7 +145,7 @@ class YHWorkItemView: UIView {
if dataSource.vacant_num != 0 {
explainLabel.text = "有" + "\(dataSource.vacant_num ?? 0)" + "项未填写"
} else {
explainLabel.text = (dataSource.entry_time ?? "") + "-" + (dataSource.departure_time ?? "")
explainLabel.text = (dataSource.entry_time ?? "") + "" + (dataSource.departure_time ?? "")
}
if dataSource.company_name?.count == 0 {
titleLabel.text = "工作经验\(tag - 4000 + 1)"
......@@ -169,9 +169,7 @@ class YHWorkItemView: UIView {
if isShow {
explainLabel.isHidden = true
nextStepImageView.isHidden = true
if index != 0 {
deleteButton.isHidden = false
}
deleteButton.isHidden = false
} else {
explainLabel.isHidden = false
nextStepImageView.isHidden = false
......
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