//
|
// HomeDetailContentVC.swift
|
// BrokerDriver
|
//
|
// Created by 无故事王国 on 2023/4/25.
|
//
|
|
import UIKit
|
import FFPage
|
|
class HomeDetailContentVC: BaseViewController {
|
|
@IBOutlet weak var scrollView: UIScrollView!
|
@IBOutlet weak var cargoTableview: UITableView!
|
@IBOutlet weak var cargoTableHeiCons: NSLayoutConstraint!
|
@IBOutlet weak var label_type: UILabel!
|
@IBOutlet weak var label_id: UILabel!
|
@IBOutlet weak var icon_id: UIImageView!
|
@IBOutlet weak var contentTableView: UITableView!
|
@IBOutlet weak var contentTableHeiCons: NSLayoutConstraint!
|
@IBOutlet weak var label_BLN: UILabel!
|
@IBOutlet weak var label_status: UILabel!
|
|
var adapterViewController:FFAdapterViewController!
|
|
private(set) var orderId:String!
|
private(set) var style:HomePageVC.PageStyle!
|
private var model:OrderDetailModel?{
|
didSet{
|
if let m = model{
|
label_type.text = m.orderType
|
label_id.text = m.orderId
|
icon_id.image = m.status.transImage
|
label_BLN.text = "B/L OR AWB NO.:\(m.tGoods?.containerNumber ?? "")"
|
label_status.text = m.nextStatus.transStr
|
contentTableView.reloadData()
|
cargoTableview.reloadData()
|
|
}
|
}
|
}
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
view.backgroundColor = .color("#F9FAFF")
|
}
|
|
override func setUI() {
|
super.setUI()
|
cargoTableview.delegate = self
|
cargoTableview.dataSource = self
|
contentTableView.delegate = self
|
contentTableView.dataSource = self
|
cargoTableview.isScrollEnabled = false
|
contentTableView.isScrollEnabled = false
|
cargoTableview.separatorStyle = .none
|
contentTableView.separatorStyle = .none
|
scrollView.delegate = self
|
|
contentTableView.register(UINib(nibName: "HomeDetailContentTCell", bundle: nil), forCellReuseIdentifier: "_HomeDetailContentTCell")
|
cargoTableview.register(UINib(nibName: "CargoInfoTCell", bundle: nil), forCellReuseIdentifier: "_CargoInfoTCell")
|
cargoTableview.register(UINib(nibName: "CargoTableHeaderView", bundle: nil), forHeaderFooterViewReuseIdentifier: "_CargoTableHeaderView")
|
cargoTableHeiCons.constant = 55 * 5.0 + 45.0
|
|
// footviewHeiCons.constant = UIDevice.jq_safeEdges.bottom + 44.0
|
|
Services.orderInfo(id: orderId, type:style).subscribe(onNext: { [weak self] data in
|
if let model = data.data{
|
self?.model = model
|
}
|
}) { error in
|
|
}.disposed(by: disposeBag)
|
}
|
|
required init(orderId:String,style:HomePageVC.PageStyle) {
|
super.init(nibName: nil, bundle: nil)
|
self.orderId = orderId
|
self.style = style
|
}
|
|
override func setRx() {
|
|
}
|
|
|
override func viewDidLayoutSubviews() {
|
super.viewDidLayoutSubviews()
|
contentTableView.rx.observe(CGSize.self,"contentSize").subscribe(onNext: {[weak self] contentSize in
|
self?.contentTableHeiCons.constant = contentSize?.height ?? 0
|
}).disposed(by: disposeBag)
|
}
|
|
@IBAction func tapAction(_ sender: UIButton) {
|
//到达码头:提示上传
|
//运输中:上传POD
|
//运回码头:提示上传
|
print("---->")
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
}
|
|
extension HomeDetailContentVC:UIScrollViewDelegate{
|
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
|
|
let totalHeight = adapterViewController.headHeight
|
let offset = totalHeight - scrollView.contentOffset.y
|
let isTop = (offset - topSafeHeight) < 0
|
|
if scrollView.contentOffset.y > 0 && !isTop{
|
adapterViewController.scrollview.contentOffset = scrollView.contentOffset
|
}
|
}
|
}
|
|
extension HomeDetailContentVC:UITableViewDelegate{
|
|
}
|
|
extension HomeDetailContentVC:UITableViewDataSource{
|
|
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
if cargoTableview == tableView{
|
let headView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "_CargoTableHeaderView") as? CargoTableHeaderView
|
return headView
|
}
|
return nil
|
}
|
|
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
if cargoTableview == tableView{
|
return 45.0
|
}
|
return 0.001
|
}
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
if cargoTableview == tableView{
|
return 1
|
}
|
return model?.list.count ?? 0
|
}
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
if cargoTableview == tableView{
|
let cell = tableView.dequeueReusableCell(withIdentifier: "_CargoInfoTCell") as! CargoInfoTCell
|
cell.l1.text = model?.tGoods?.containerNumber ?? ""
|
cell.l2.text = "\(model?.tGoods?.weight ?? 0)"
|
cell.l3.text = model?.tGoods?.size ?? ""
|
cell.l4.text = String(format: "%@\n%@", model?.tGoods?.type ?? "" ,model?.tGoods?.typeClass ?? "")
|
return cell
|
}
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: "_HomeDetailContentTCell") as! HomeDetailContentTCell
|
if let dict = model?.list[indexPath.row]{
|
cell.dicts = dict
|
}
|
|
return cell
|
}
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
if cargoTableview == tableView{
|
return 50
|
}
|
return UITableView.automaticDimension
|
}
|
}
|