Commit 7e830669 authored by David黄金龙's avatar David黄金龙

处理 展示 bug

parent 6709bccc
......@@ -23,6 +23,9 @@ class YHHKPlanDoctumentVC: YHBaseViewController {
var status : Int = 0
private var canEditFlag : Bool = false
private var timer : Timer?
override func viewDidLoad() {
super.viewDidLoad()
gk_navTitle = "赴港计划书"
......@@ -38,6 +41,11 @@ class YHHKPlanDoctumentVC: YHBaseViewController {
getData()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
cancelTimer()
}
private var bottomView : UIView = {
let view = UIView()
view.backgroundColor = .white
......@@ -59,6 +67,53 @@ class YHHKPlanDoctumentVC: YHBaseViewController {
}
extension YHHKPlanDoctumentVC {
fileprivate func cancelTimer() {
guard self.timer != nil else {
return
}
self.timer!.invalidate()
self.timer = nil
}
fileprivate func startTimer() {
self.timer = Timer.scheduledTimer(timeInterval: TimeInterval(3), target: self, selector: #selector(self.flipNext(sender:)), userInfo: nil, repeats: false)
RunLoop.current.add(self.timer!, forMode: .common)
}
@objc fileprivate func flipNext(sender: Timer?) {
YHHUD.hide()
YHHUD.flash(message: "提交成功")
getData()
}
func updateUI() {
if status > 3 {
canEditFlag = false
bottomView.isHidden = true
tableView.snp.removeConstraints()
tableView.snp.remakeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalToSuperview()
make.bottom.equalToSuperview()
}
} else {
canEditFlag = true
bottomView.isHidden = false
tableView.snp.removeConstraints()
tableView.snp.remakeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalToSuperview()
make.bottom.equalTo(bottomView.snp.top).offset(-kMargin)
}
}
}
//点击提交按钮
@objc func clickSubmitBtn() {
submitOp()
......@@ -78,9 +133,13 @@ extension YHHKPlanDoctumentVC {
"qualifications_and_awards":viewModel.arrHKPlanData[4].content,
"other":viewModel.arrHKPlanData[5].content,
"content_save":1]
cancelTimer()
startTimer()
YHHUD.show(.progress(message: ""))
viewModel.submitHKPlanDocument(params) { success, error in
YHHUD.hide()
YHHUD.hide()
self.cancelTimer()
self.getData()
if success {
YHHUD.flash(message: "提交成功")
} else {
......@@ -100,10 +159,14 @@ extension YHHKPlanDoctumentVC {
viewModel.requestDocumentsDetail("\(supplement_id)", callBackBlock: {[weak self] success, error in
YHHUD.hide()
guard let self = self else { return }
self.status = viewModel.mainModel?.prospectus.status ?? 0
for item in viewModel.arrHKPlanData {
item.canEditFlag = self.canEditFlag
}
self.updateUI()
self.tableView.isHidden = false
self.tableView.reloadData()
})
......
......@@ -30,6 +30,9 @@ class YHMyDocumentProspectusModel: YHBaseModel {
var tag: String = ""
var tencent_file_id: String = ""
var tencent_docs_url: String = ""
//赴港计划书状态
var status : Int = 0
}
class YHMyDocumentWritingDocumentModel: YHBaseModel {
......
......@@ -181,6 +181,11 @@ private extension YHHKPlanItemView {
myTextView.wrapToContent()
}
numberLabel.text = myTextView.text.count.string + "/100"
if myTextView.text.count > 100 {
numberLabel.textColor = .failColor
} else {
numberLabel.textColor = UIColor.placeHolderColor
}
if model.isLastData {
line.isHidden = true
......@@ -193,6 +198,9 @@ private extension YHHKPlanItemView {
extension YHHKPlanItemView : UITextViewDelegate {
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
if text.isEmpty {
return true
}
let newLength = (textView.text as NSString).length + text.count - range.length
return newLength <= 100
}
......@@ -201,7 +209,11 @@ extension YHHKPlanItemView : UITextViewDelegate {
guard let model = dataMode else { return }
guard let text = textView.text else { return }
model.content = text
numberLabel.text = myTextView.text.count.string + "/100"
if myTextView.text.count > 100 {
numberLabel.textColor = .failColor
} else {
numberLabel.textColor = UIColor.placeHolderColor
}
}
}
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