Commit 1e41fe20 authored by Steven杜宇's avatar Steven杜宇

// 获取模版

parent 287ec07c
......@@ -137,6 +137,7 @@
0430E6902C7EC78C000511E2 /* YHCardUploadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430E68F2C7EC78C000511E2 /* YHCardUploadView.swift */; };
0430E6922C7EF08B000511E2 /* YHAdopterOtherCardTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430E6912C7EF08B000511E2 /* YHAdopterOtherCardTableViewCell.swift */; };
0431F8822C942D88003B84F4 /* YHResignMaterialNameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0431F8812C942D88003B84F4 /* YHResignMaterialNameCell.swift */; };
0431F8842C9579F7003B84F4 /* YHResignTemplateSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0431F8832C9579F7003B84F4 /* YHResignTemplateSheetView.swift */; };
04358E042C77322700811928 /* YHHaveGrabbedNumberListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E032C77322700811928 /* YHHaveGrabbedNumberListCell.swift */; };
04358E062C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E052C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift */; };
04358E082C77657000811928 /* YHReAppointViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E072C77657000811928 /* YHReAppointViewController.swift */; };
......@@ -939,6 +940,7 @@
0430E68F2C7EC78C000511E2 /* YHCardUploadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCardUploadView.swift; sourceTree = "<group>"; };
0430E6912C7EF08B000511E2 /* YHAdopterOtherCardTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAdopterOtherCardTableViewCell.swift; sourceTree = "<group>"; };
0431F8812C942D88003B84F4 /* YHResignMaterialNameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignMaterialNameCell.swift; sourceTree = "<group>"; };
0431F8832C9579F7003B84F4 /* YHResignTemplateSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignTemplateSheetView.swift; sourceTree = "<group>"; };
04358E032C77322700811928 /* YHHaveGrabbedNumberListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHaveGrabbedNumberListCell.swift; sourceTree = "<group>"; };
04358E052C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHaveGrabbedNumberInfoView.swift; sourceTree = "<group>"; };
04358E072C77657000811928 /* YHReAppointViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHReAppointViewController.swift; sourceTree = "<group>"; };
......@@ -2062,6 +2064,7 @@
children = (
0449EEED2C8EF8CB00A397FD /* YHResignMaterialCell.swift */,
0431F8812C942D88003B84F4 /* YHResignMaterialNameCell.swift */,
0431F8832C9579F7003B84F4 /* YHResignTemplateSheetView.swift */,
);
path = V;
sourceTree = "<group>";
......@@ -4547,6 +4550,7 @@
04FB01CE2C23DDBD0040115D /* YHPeopleMatchNoDataView.swift in Sources */,
A5ACE9362B4564F7002C94D2 /* YHNetworkStatusManager.swift in Sources */,
048787D52BCE880B0036E221 /* YHServiceOrderListViewController.swift in Sources */,
0431F8842C9579F7003B84F4 /* YHResignTemplateSheetView.swift in Sources */,
A5D0012A2BABC84A001F003C /* YHFileListHeaerView.swift in Sources */,
0430E68C2C786257000511E2 /* YHAdopterIncomeViewModel.swift in Sources */,
044414052BC3B9DE00784A14 /* YHServiceTableFootView.swift in Sources */,
......
......@@ -13,15 +13,14 @@ class YHResignMaterialListVC: YHBaseViewController {
var orderId: Int = 0
var id: Int = 0
var viewModel: YHResignMaterialViewModel = YHResignMaterialViewModel()
var items:[YHResignMaterialInfo] = [] {
didSet {
self.emptyDataTipsView.isHidden = self.items.count > 0
self.tableView.reloadData()
}
}
// 列表是否是展开
var isUnfold = true
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
......@@ -102,17 +101,26 @@ extension YHResignMaterialListVC: UITableViewDelegate, UITableViewDataSource {
cell.templateBlock = {
[weak self] in
guard let self = self else { return }
let model = YHTemplateInfo()
let view = YHCertificateTemplateSheetView.templateView(model)
view.scanTemplateBlock = {
[weak self] path in
YHHUD.show(.progress(message: "加载中..."))
self.viewModel.getTemplateInfo(templateId: item.template_id) {
[weak self] success, error in
YHHUD.hide()
guard let self = self else { return }
if let url = path?.url, !url.isEmpty {
print(url)
self.previewFileTool.openXLSXRemoteFile(urlString:url, fileName:"预览")
if !success {
YHHUD.flash(message: "获取模版失败")
return
}
let view = YHResignTemplateSheetView.templateView(self.viewModel.templateDeail)
view.scanTemplateBlock = {
[weak self] path in
guard let self = self else { return }
if let url = path?.fileUrl, !url.isEmpty {
print(url)
self.previewFileTool.openXLSXRemoteFile(urlString:url, fileName:"预览")
}
}
view.show()
}
view.show()
}
}
}
......
//
// YHResignTemplateAlertView.swift
// galaxy
//
// Created by edy on 2024/9/14.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHResignTemplateSheetView: UIView {
static func templateView(_ model: YHResignTemplateDetail) -> YHResignTemplateSheetView {
let sheetView = YHResignTemplateSheetView(frame:UIScreen.main.bounds)
sheetView.updateModel(model)
return sheetView
}
var templateArr: [YHResignTemplateItemModel] = []
var templateInfo: YHResignTemplateDetail?
var scanTemplateBlock: ((YHResignTemplateItemModel?)->())?
lazy var blackMaskView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x0F1214, alpha: 0.5)
let tap = UITapGestureRecognizer(target: self, action: #selector(dismiss))
view.addGestureRecognizer(tap)
return view
}()
lazy var whiteContentView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
lazy var topView:UIView = {
let view = UIView()
view.addSubview(titleLabel)
view.addSubview(closeBtn)
let line = UIView()
line.backgroundColor = .separatorColor
view.addSubview(line)
titleLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(16)
make.left.equalToSuperview().offset(64)
make.right.equalToSuperview().offset(-64)
make.bottom.equalToSuperview().offset(-12)
}
closeBtn.snp.makeConstraints { make in
make.top.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-20)
make.width.height.equalTo(24)
}
closeBtn.YH_clickEdgeInsets = UIEdgeInsets(top: 15, left: 15, bottom: 15, right: 15)
line.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(1)
make.bottom.equalToSuperview()
}
return view
}()
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.estimatedSectionHeaderHeight = 20.0
tableView.estimatedSectionFooterHeight = 1.0
tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = .white
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHCertificateTemplateCell.self, forCellReuseIdentifier: YHCertificateTemplateCell.cellReuseIdentifier)
return tableView
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.textAlignment = .center
label.font = UIFont.PFSC_B(ofSize:17)
label.numberOfLines = 0
label.text = "示例模版"
return label
}()
lazy var closeBtn: UIButton = {
let btn = UIButton()
btn.setImage(UIImage(named:"my_cer_sheet_close"), for: .normal)
btn.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
return btn
}()
lazy var knowBtn:UIButton = {
let btn = UIButton()
btn.setTitle("知道了".local, for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
btn.setTitleColor(.white, for: .normal)
btn.backgroundColor = UIColor.brandMainColor
btn.layer.cornerRadius = kCornerRadius3
btn.addTarget(self, action: #selector(didClickKnownBtn), for: .touchUpInside)
return btn
}()
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
func updateModel(_ model: YHResignTemplateDetail) {
templateInfo = model
if !model.name.isEmpty {
titleLabel.text = "\(model.name)示例模版"
}
templateArr.removeAll()
templateArr = model.file_url
self.tableView.reloadData()
self.setNeedsLayout()
self.layoutIfNeeded()
}
func createUI() {
self.addSubview(blackMaskView)
self.addSubview(whiteContentView)
whiteContentView.addSubview(topView)
whiteContentView.addSubview(knowBtn)
whiteContentView.addSubview(tableView)
let corner = UIRectCorner(rawValue: UIRectCorner.topLeft.rawValue | UIRectCorner.topRight.rawValue)
let path = UIBezierPath(roundedRect:bounds,byRoundingCorners: corner,cornerRadii:CGSizeMake(kCornerRadius6, kCornerRadius6));
let layer = CAShapeLayer();
layer.frame = whiteContentView.bounds;
layer.path = path.cgPath;
whiteContentView.layer.mask = layer;
blackMaskView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
whiteContentView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(484)
}
topView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
}
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(topView.snp.bottom).offset(20)
make.bottom.equalTo(knowBtn.snp.top).offset(-8)
}
knowBtn.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.height.equalTo(48.0)
make.bottom.equalToSuperview().offset(-8-k_Height_safeAreaInsetsBottom())
}
}
func show() -> YHResignTemplateSheetView {
UIApplication.shared.yhKeyWindow()?.addSubview(self)
return self
}
@objc func dismiss() {
self.removeFromSuperview()
}
@objc func didClickKnownBtn() {
dismiss()
}
}
extension YHResignTemplateSheetView: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return templateArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateTemplateCell.cellReuseIdentifier, for: indexPath) as! YHCertificateTemplateCell
cell.update(bottomMargin: 20)
if 0 <= indexPath.row && indexPath.row < templateArr.count {
cell.templateModel = templateArr[indexPath.row]
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.row && indexPath.row < templateArr.count {
let path = templateArr[indexPath.row]
scanTemplateBlock?(path)
dismiss()
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 82.0
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
if let desc = templateInfo?.remark, !desc.isEmpty {
return UITableView.automaticDimension
}
return 0.0
}
private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat {
return 1.0
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView()
if section == 0, let desc = templateInfo?.remark, !desc.isEmpty {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:14)
label.numberOfLines = 0
label.text = "注意事项:\n\(desc)"
view.addSubview(label)
label.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.bottom.equalToSuperview().offset(-20)
}
}
return view
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
}
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