//
|
// TroubleListVC.swift
|
// BrokerDriver
|
//
|
// Created by 无故事王国 on 2023/5/5.
|
//
|
|
import UIKit
|
|
class TroubleListVC: BaseViewController {
|
|
private var orderId:String!
|
private var tableView:BaseTableView!
|
private var selectIndex:Int = -1
|
private let items = ["Appointment cancelled","Appointment expired","Terminal closed","Terminal break","Accident","Container not found","Container line hold","Container custom hold","Container TMF hold","Container Pierpass hold"]
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
title = "Trouble"
|
|
let rightBtn = UIBarButtonItem(target: self, action: #selector(historyAction), image: "btn_time", highImage: "btn_time")
|
navigationItem.rightBarButtonItem = rightBtn
|
|
}
|
|
required init(orderId:String) {
|
super.init(nibName: nil, bundle: nil)
|
self.orderId = orderId
|
|
}
|
|
required init?(coder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
|
override func setUI() {
|
super.setUI()
|
tableView = BaseTableView(frame: .zero, style: .plain)
|
tableView.delegate = self
|
tableView.dataSource = self
|
tableView.separatorStyle = .none
|
tableView.register(UINib(nibName: "TroubleTCell", bundle: nil), forCellReuseIdentifier: "_TroubleTCell")
|
view.addSubview(tableView)
|
tableView.snp.makeConstraints { make in
|
make.edges.equalToSuperview().inset(view.safeAreaInsets)
|
}
|
|
let footView = TroubleFootView.jq_loadNibView()
|
footView.submitClouse { [weak self] text in
|
guard let weakSelf = self else { return }
|
guard weakSelf.selectIndex != -1 else {alert(msg: "Please select your problem");return}
|
|
var model = HomeDetailNoteVC.DetailNotModel()
|
model.category = weakSelf.items[weakSelf.selectIndex]
|
model.type = .troble
|
model.orderId = weakSelf.orderId
|
model.describe = text
|
Services.addOrderNote(model: model).subscribe(onNext: {data in
|
if data.code == 200{
|
alert(msg: "Submit successed")
|
DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
|
self?.navigationController?.popViewController()
|
}
|
}else{
|
alert(msg: data.message)
|
}
|
}) { error in
|
alert(msg: error.localizedDescription)
|
}.disposed(by: weakSelf.disposeBag)
|
}
|
tableView.tableFooterView = footView
|
}
|
|
@objc func historyAction(){
|
let vc = TroubleHistoryListVC(orderId: orderId)
|
push(vc: vc)
|
}
|
}
|
|
extension TroubleListVC:UITableViewDelegate{
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
selectIndex = indexPath.row
|
tableView.reloadData()
|
}
|
}
|
|
extension TroubleListVC:UITableViewDataSource{
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
return items.count
|
}
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
let item = items[indexPath.row]
|
let cell = tableView.dequeueReusableCell(withIdentifier: "_TroubleTCell") as! TroubleTCell
|
cell.boxImage.image = UIImage(named: "")
|
cell.label_content.text = item
|
|
if indexPath.row == selectIndex{
|
cell.boxImage.image = UIImage(named: "icon_seletedBox")
|
}else{
|
cell.boxImage.image = UIImage(named: "icon_box")
|
}
|
return cell
|
}
|
}
|