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

// 我的证书

parent 047f5a71
......@@ -326,7 +326,7 @@ extension YHCertificateListVC {
guard let self = self else { return }
print(fileUrl)
uploadFile(fileUrl, supplementInfo: supplementInfo) {
// 待上传的进入详情
// 待上传的进入详情
DispatchQueue.main.async {
let vc = YHCertificateUploadContentListVC()
vc.orderId = self.orderId
......@@ -340,7 +340,7 @@ extension YHCertificateListVC {
[weak self] image, imageName in
guard let self = self else { return }
uploadImage(image, imageName: imageName, supplementInfo: supplementInfo) {
// 待上传的进入详情
// 待上传的进入详情
DispatchQueue.main.async {
let vc = YHCertificateUploadContentListVC()
vc.orderId = self.orderId
......
......@@ -245,7 +245,7 @@ extension YHCertificateSearchViewController {
}
}
func uploadImage(_ img: UIImage, imageName:String, supplementInfo:YHSupplementInfo) {
func uploadImage(_ img: UIImage, imageName:String, supplementInfo:YHSupplementInfo, successBlock:(()->())?) {
// 先OSS上传得到URL
YHHUD.show(.progress(message: "上传中..."))
......@@ -268,6 +268,9 @@ extension YHCertificateSearchViewController {
self.viewModel.updateCertificateItem(supplementId:supplementInfo.id, urlModel:model, operation: "add", rename: "") {
success in
self.requestList(keyWord: self.searchBar.textField.text)
if success {
successBlock?()
}
}
return
}
......@@ -280,7 +283,7 @@ extension YHCertificateSearchViewController {
}
}
func uploadFile(_ fileUrl:URL, supplementInfo:YHSupplementInfo) {
func uploadFile(_ fileUrl:URL, supplementInfo:YHSupplementInfo, successBlock:(()->())?) {
if let fileData = try? Data(contentsOf: fileUrl) {
// 将文件数据上传到服务器
let size = String(format: "%.2fM", Double(fileData.count)/(1024.0 * 1024.0))
......@@ -302,6 +305,9 @@ extension YHCertificateSearchViewController {
self.viewModel.updateCertificateItem(supplementId:supplementInfo.id, urlModel:model, operation: "add", rename: "") {
success in
self.requestList(keyWord: self.searchBar.textField.text)
if success {
successBlock?()
}
}
return
}
......@@ -317,10 +323,8 @@ extension YHCertificateSearchViewController {
}
}
func showUploadSheetView(_ supplementInfo: YHSupplementInfo?) {
guard let supplementInfo = supplementInfo else { return }
func showUploadSheetView(_ supplementInfo: YHSupplementInfo) {
let sheetView = YHCertificateUploadSheetView.sheetView()
sheetView.templateInfo = supplementInfo.templateInfo
sheetView.clickTemplateBlock = {
......@@ -328,19 +332,37 @@ extension YHCertificateSearchViewController {
if let url = path?.url, !url.isEmpty {
guard let self = self else { return }
print(url)
self.previewFileTool.openXLSXRemoteFile(urlString:url, fileName:"预览")
self.previewFileTool.openXLSXRemoteFile(urlString:url, fileName: "预览")
}
}
sheetView.uploadFilesBlock = {
[weak self] fileUrl in
guard let self = self else { return }
print(fileUrl)
uploadFile(fileUrl, supplementInfo: supplementInfo)
uploadFile(fileUrl, supplementInfo: supplementInfo) {
// 待上传的进入详情
DispatchQueue.main.async {
let vc = YHCertificateUploadContentListVC()
vc.orderId = self.orderId
vc.categoryInfo = self.categoryInfo
vc.supplementInfo = supplementInfo
self.navigationController?.pushViewController(vc)
}
}
}
sheetView.uploadImageBlock = {
[weak self] image, imageName in
guard let self = self else { return }
uploadImage(image, imageName: imageName, supplementInfo: supplementInfo)
uploadImage(image, imageName: imageName, supplementInfo: supplementInfo) {
// 待上传的进入详情
DispatchQueue.main.async {
let vc = YHCertificateUploadContentListVC()
vc.orderId = self.orderId
vc.categoryInfo = self.categoryInfo
vc.supplementInfo = supplementInfo
self.navigationController?.pushViewController(vc)
}
}
}
sheetView.show()
}
......
......@@ -12,6 +12,7 @@ class YHCertificateSearchBar: UIView {
static let height = 40.0
static let cancelBtnHeight = height-8.0
static let maxWordsCount = 50
var textChange:((String?)->Void)?
var searchBlock:((String?)->Void)?
......@@ -39,6 +40,7 @@ class YHCertificateSearchBar: UIView {
textField.textColor = UIColor.mainTextColor
textField.clearButtonMode = .whileEditing
textField.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged)
textField.delegate = self
return textField
}()
......@@ -115,3 +117,20 @@ class YHCertificateSearchBar: UIView {
}
}
}
extension YHCertificateSearchBar: UITextFieldDelegate {
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if string.isEmpty == true { // 点击删除
return true
}
var newText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
if newText.count > Self.maxWordsCount {
YHHUD.flash(message: "搜索限制最多\(Self.maxWordsCount)个字符")
return false
}
return true
}
}
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