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

// 上传弹窗UI更改

parent a6b68d29
...@@ -316,15 +316,6 @@ extension YHCertificateListVC { ...@@ -316,15 +316,6 @@ extension YHCertificateListVC {
let sheetView = YHCertificateUploadSheetView.sheetView() let sheetView = YHCertificateUploadSheetView.sheetView()
sheetView.maxSelectCount = 9 sheetView.maxSelectCount = 9
sheetView.templateInfo = supplementInfo.templateInfo
sheetView.clickTemplateBlock = {
[weak self] path in
if let url = path?.url, !url.isEmpty {
guard let self = self else { return }
print(url)
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 }
......
...@@ -330,16 +330,7 @@ extension YHCertificateSearchViewController { ...@@ -330,16 +330,7 @@ extension YHCertificateSearchViewController {
let sheetView = YHCertificateUploadSheetView.sheetView() let sheetView = YHCertificateUploadSheetView.sheetView()
sheetView.maxSelectCount = 9 sheetView.maxSelectCount = 9
sheetView.templateInfo = supplementInfo.templateInfo sheetView.uploadFilesBlock = {
sheetView.clickTemplateBlock = {
[weak self] path in
if let url = path?.url, !url.isEmpty {
guard let self = self else { return }
print(url)
self.previewFileTool.openXLSXRemoteFile(urlString:url, fileName: "预览")
}
}
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)
......
...@@ -138,15 +138,6 @@ class YHCertificateUploadContentListVC: YHBaseViewController { ...@@ -138,15 +138,6 @@ class YHCertificateUploadContentListVC: YHBaseViewController {
let sheetView = YHCertificateUploadSheetView.sheetView() let sheetView = YHCertificateUploadSheetView.sheetView()
sheetView.maxSelectCount = 99-items.count sheetView.maxSelectCount = 99-items.count
sheetView.templateInfo = supplementInfo.templateInfo
sheetView.clickTemplateBlock = {
[weak self] path in
if let url = path?.url, !url.isEmpty {
guard let self = self else { return }
print(url)
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 }
...@@ -474,7 +465,7 @@ extension YHCertificateUploadContentListVC: UITableViewDelegate, UITableViewData ...@@ -474,7 +465,7 @@ extension YHCertificateUploadContentListVC: UITableViewDelegate, UITableViewData
label.font = UIFont.PFSC_R(ofSize:12) label.font = UIFont.PFSC_R(ofSize:12)
let tipsFont = UIFont.PFSC_R(ofSize: 12) let tipsFont = UIFont.PFSC_R(ofSize: 12)
let a: ASAttributedString = .init("*最多上传", .font(tipsFont),.foreground(UIColor.labelTextColor2)) let a: ASAttributedString = .init("*上传", .font(tipsFont),.foreground(UIColor.labelTextColor2))
let b: ASAttributedString = .init(" \(items.count)/99 ", .font(UIFont.PFSC_M(ofSize: 12)), .foreground(UIColor.init(hexString:"#2F2F2F")!)) let b: ASAttributedString = .init(" \(items.count)/99 ", .font(UIFont.PFSC_M(ofSize: 12)), .foreground(UIColor.init(hexString:"#2F2F2F")!))
let c: ASAttributedString = .init("张图片或文件", .font(tipsFont), .foreground(UIColor.labelTextColor2)) let c: ASAttributedString = .init("张图片或文件", .font(tipsFont), .foreground(UIColor.labelTextColor2))
......
...@@ -43,6 +43,7 @@ enum YHCertificateUploadType: Int { ...@@ -43,6 +43,7 @@ enum YHCertificateUploadType: Int {
class YHCertificateUploadSheetView: UIView { class YHCertificateUploadSheetView: UIView {
private var _maxSelectCount: Int = 9 private var _maxSelectCount: Int = 9
let tips = "支持的文件格式为jpg/jpeg、png、doc/docx、pptx、pdf,最多可上传99张图片或文件"
var maxSelectCount = 9 { var maxSelectCount = 9 {
didSet { didSet {
if maxSelectCount >= 9 { if maxSelectCount >= 9 {
...@@ -54,32 +55,6 @@ class YHCertificateUploadSheetView: UIView { ...@@ -54,32 +55,6 @@ class YHCertificateUploadSheetView: UIView {
} }
} }
} }
var templateInfo: YHTemplateInfo? {
didSet {
templateArr.removeAll()
if let templateInfo = templateInfo {
if templateInfo.materialPath.count > 0 {
let template = templateInfo.materialPath[0]
template.type = 0
templateArr.append(template)
}
if templateInfo.guideFilePath.count > 0 {
let guide = templateInfo.guideFilePath[0]
guide.type = 1
templateArr.append(guide)
}
}
let totalHeight = calculateHeight()
whiteContentView.snp.updateConstraints { make in
make.height.equalTo(totalHeight)
}
self.setNeedsLayout()
self.layoutIfNeeded()
self.tableView.reloadData()
}
}
var templateArr: [YHMaterialPath] = []
var uploadTypeArr = [ var uploadTypeArr = [
YHCertificateUploadItem(type:.camera, title:"拍照上传"), YHCertificateUploadItem(type:.camera, title:"拍照上传"),
YHCertificateUploadItem(type:.photo, title:"相册上传"), YHCertificateUploadItem(type:.photo, title:"相册上传"),
...@@ -90,8 +65,6 @@ class YHCertificateUploadSheetView: UIView { ...@@ -90,8 +65,6 @@ class YHCertificateUploadSheetView: UIView {
var uploadFilesBlock:((URL)->())? var uploadFilesBlock:((URL)->())?
// 上传图片 // 上传图片
var uploadImageBlock:(([YHSelectImageItem])->())? var uploadImageBlock:(([YHSelectImageItem])->())?
// 点击模版
var clickTemplateBlock:((YHMaterialPath?)->())?
lazy var blackMaskView: UIView = { lazy var blackMaskView: UIView = {
let view = UIView() let view = UIView()
...@@ -231,9 +204,10 @@ class YHCertificateUploadSheetView: UIView { ...@@ -231,9 +204,10 @@ class YHCertificateUploadSheetView: UIView {
make.edges.equalToSuperview() make.edges.equalToSuperview()
} }
let whiteHeight = calculateHeight()
whiteContentView.snp.makeConstraints { make in whiteContentView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
make.height.equalTo(458.0) make.height.equalTo(whiteHeight)
} }
topView.snp.makeConstraints { make in topView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview() make.top.left.right.equalToSuperview()
...@@ -247,22 +221,19 @@ class YHCertificateUploadSheetView: UIView { ...@@ -247,22 +221,19 @@ class YHCertificateUploadSheetView: UIView {
} }
func calculateHeight() -> CGFloat { func calculateHeight() -> CGFloat {
guard let templateInfo = templateInfo else { return 0.0}
// 注意事项文字高度 // 注意事项文字高度
var descHeight = templateInfo.description.boundingRect(with: CGSize(width:KScreenWidth-40.0 , height:.greatestFiniteMagnitude), var descHeight = tips.boundingRect(with: CGSize(width:KScreenWidth-40.0 , height:.greatestFiniteMagnitude),
options: .usesLineFragmentOrigin, options: .usesLineFragmentOrigin,
attributes: [.font : UIFont.PFSC_R(ofSize:14)], attributes: [.font : UIFont.PFSC_R(ofSize:14)],
context: nil).size.height context: nil).size.height
descHeight = ceil(descHeight)+20
// 所有模版高度之和 descHeight = ceil(descHeight)+21+34
let templatesHeight = 82.0 * Double(templateArr.count)
// 底部四个操作行高度之和 // 底部四个操作行高度之和
let actionsHeight = 52.0 * 4.0 let actionsHeight = 52.0 * 4.0
let tableViewHeight = descHeight+actionsHeight
let tableViewHeight = descHeight+templatesHeight+actionsHeight
// 白色View总高度 // 白色View总高度
var totalHeight = 53.0+20.0+tableViewHeight+k_Height_safeAreaInsetsBottom() var totalHeight = 53.0+tableViewHeight+k_Height_safeAreaInsetsBottom()
if totalHeight > KScreenHeight { if totalHeight > KScreenHeight {
totalHeight = 458 totalHeight = 458
} }
...@@ -284,27 +255,15 @@ extension YHCertificateUploadSheetView { ...@@ -284,27 +255,15 @@ extension YHCertificateUploadSheetView {
extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSource { extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int { func numberOfSections(in tableView: UITableView) -> Int {
return 2 return 1
} }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 0 {
return templateArr.count
}
return uploadTypeArr.count return uploadTypeArr.count
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateTemplateCell.cellReuseIdentifier, for: indexPath) as! YHCertificateTemplateCell
cell.update(bottomMargin:20)
if 0 <= indexPath.row && indexPath.row < templateArr.count {
cell.templatePath = templateArr[indexPath.row]
}
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateUploadTypeCell.cellReuseIdentifier, for: indexPath) as! YHCertificateUploadTypeCell let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateUploadTypeCell.cellReuseIdentifier, for: indexPath) as! YHCertificateUploadTypeCell
if 0 <= indexPath.row && indexPath.row < uploadTypeArr.count { if 0 <= indexPath.row && indexPath.row < uploadTypeArr.count {
cell.item = uploadTypeArr[indexPath.row] cell.item = uploadTypeArr[indexPath.row]
...@@ -313,15 +272,6 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour ...@@ -313,15 +272,6 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section == 0 { // 模版列表
if 0 <= indexPath.row && indexPath.row < templateArr.count {
let path = templateArr[indexPath.row]
clickTemplateBlock?(path)
dismiss()
}
} else if indexPath.section == 1 { // 操作列表
if 0 <= indexPath.row && indexPath.row < uploadTypeArr.count { if 0 <= indexPath.row && indexPath.row < uploadTypeArr.count {
let operationItem = uploadTypeArr[indexPath.row] let operationItem = uploadTypeArr[indexPath.row]
...@@ -339,23 +289,14 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour ...@@ -339,23 +289,14 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour
selectFile() selectFile()
} }
} }
}
} }
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 0 {
return 82.0
}
return 52.0 return 52.0
} }
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat { private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
if section == 0 { return UITableView.automaticDimension
if let desc = templateInfo?.description, !desc.isEmpty {
return UITableView.automaticDimension
}
}
return 1.0
} }
private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat { private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat {
...@@ -366,21 +307,19 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour ...@@ -366,21 +307,19 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView() let view = UIView()
if section == 0, let desc = templateInfo?.description, !desc.isEmpty { let label = UILabel()
let label = UILabel() label.textColor = UIColor.labelTextColor2
label.textColor = UIColor.mainTextColor label.textAlignment = .left
label.textAlignment = .left label.font = UIFont.PFSC_R(ofSize:14)
label.font = UIFont.PFSC_R(ofSize:14) label.numberOfLines = 0
label.numberOfLines = 0 label.text = tips
label.text = "注意事项:\n\(desc)" view.addSubview(label)
view.addSubview(label)
label.snp.makeConstraints { make in
label.snp.makeConstraints { make in make.top.equalToSuperview().offset(21)
make.top.equalToSuperview() make.left.equalToSuperview().offset(20)
make.left.equalToSuperview().offset(20) make.right.equalToSuperview().offset(-20)
make.right.equalToSuperview().offset(-20) make.bottom.equalToSuperview().offset(-34)
make.bottom.equalToSuperview().offset(-20)
}
} }
return view return view
} }
......
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