| | |
| | | // |
| | | |
| | | import UIKit |
| | | import QMUIKit |
| | | |
| | | class OrderReviewDetailVC: YYViewController { |
| | | |
| | | private var id:Int! |
| | | |
| | | @IBOutlet weak var label_startAddress: UILabel! |
| | | @IBOutlet weak var label_billing: UILabel! |
| | | @IBOutlet weak var label_detailAddress: UILabel! |
| | | @IBOutlet weak var label_payType: UILabel! |
| | | @IBOutlet weak var stack_users: UIStackView! |
| | | @IBOutlet weak var label_reason: UILabel! |
| | | @IBOutlet weak var label_carType: UILabel! |
| | | @IBOutlet weak var label_peopleNum: UILabel! |
| | | @IBOutlet weak var textView_content: QMUITextView! |
| | | @IBOutlet weak var label_textNum: UILabel! |
| | | @IBOutlet weak var view_handle: UIView! |
| | | |
| | | init(id:Int) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.id = id |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "订单审核" |
| | | |
| | | APIManager.shared.provider.rx.request(.approveOrderDetail(id: id)).mapThenValidate(OrderReviewDetailModel.self).subscribe(onSuccess: {[weak self] result in |
| | | guard let weakSelf = self else { return} |
| | | switch result{ |
| | | case .success(let m): |
| | | weakSelf.label_startAddress.text = m?.startAddress ?? "" |
| | | weakSelf.label_detailAddress.text = m?.endAddress ?? "" |
| | | weakSelf.label_billing.text = m?.calType.rawString ?? "" |
| | | weakSelf.label_reason.text = m?.reasonTypeNames ?? "" |
| | | weakSelf.label_carType.text = m?.serverCardName ?? "" |
| | | weakSelf.textView_content.text = m?.auditRemark ?? "" |
| | | weakSelf.label_peopleNum.text = "\(m?.peopleNum ?? 0)" |
| | | weakSelf.label_payType.text = m?.payWay.rawStr ?? "" |
| | | |
| | | weakSelf.stack_users.removeSubviews() |
| | | for v in m!.peopleItems{ |
| | | if v.name.isEmpty && v.phone.isEmpty {continue} |
| | | let label = UILabel(text: String(format: "%@ %@", v.name,v.phone)) |
| | | label.textColor = UIColor(hexString: "#333333") |
| | | label.textAlignment = .left |
| | | label.font = UIFont.systemFont(ofSize: 12, weight: .medium) |
| | | weakSelf.stack_users.addArrangedSubview(label) |
| | | } |
| | | |
| | | switch m?.auditStatus{ |
| | | case .pass,.reject: |
| | | weakSelf.view_handle.isHidden = true |
| | | weakSelf.textView_content.isEditable = false |
| | | case .review: |
| | | weakSelf.view_handle.isHidden = false |
| | | weakSelf.textView_content.isEditable = true |
| | | default:break |
| | | } |
| | | |
| | | case .failure(let error): |
| | | alert(text: error.localizedDescription) |
| | | } |
| | | }) { error in |
| | | alert(text: error.localizedDescription) |
| | | }.disposed(by: disposeBag) |
| | | } |
| | | |
| | | override func bindRx() { |
| | | textView_content.rx.text.orEmpty.subscribe(onNext: { [weak self] text in |
| | | self?.label_textNum.text = "\(text.length) / 50" |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | |
| | | @IBAction func rejectAction(_ sender: UIButton) { |
| | | guard !textView_content.text.isEmpty else { |
| | | alert(text: "请输入拒绝内容");return |
| | | } |
| | | APIManager.shared.provider.rx.request(.approveOrderAudit(id: id, status: 2, auditRemark: textView_content.text)).mapThenValidate(Nothing.self).subscribe(onSuccess: {result in |
| | | switch result{ |
| | | case .success(_): |
| | | alert(text: "已提交") |
| | | self.view_handle.isHidden = true |
| | | NotificationCenter.default.post(name: OrderReviewRefresh_Noti, object: nil) |
| | | case .failure(let error):alert(text: error.localizedDescription) |
| | | } |
| | | }) { error in |
| | | alert(text: error.localizedDescription) |
| | | }.disposed(by: disposeBag) |
| | | |
| | | } |
| | | |
| | | @IBAction func agreenAction(_ sender: UIButton) { |
| | | APIManager.shared.provider.rx.request(.approveOrderAudit(id: id, status: 1)).mapThenValidate(Nothing.self).subscribe(onSuccess: {result in |
| | | switch result{ |
| | | case .success(_): |
| | | alert(text: "已提交") |
| | | self.view_handle.isHidden = true |
| | | NotificationCenter.default.post(name: OrderReviewRefresh_Noti, object: nil) |
| | | case .failure(let error):alert(text: error.localizedDescription) |
| | | } |
| | | }) { error in |
| | | alert(text: error.localizedDescription) |
| | | }.disposed(by: disposeBag) |
| | | } |
| | | } |