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

// 我的证书

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