宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
//  LineOfCreditDetailVC.swift
//  OKProject
//
//  Created by 无故事王国 on 2023/4/10.
//  Copyright © 2023 yangwang. All rights reserved.
//
 
import UIKit
import QMUIKit
 
class LineOfCreditDetailVC: YYViewController {
 
    @IBOutlet weak var label_name: UILabel!
    @IBOutlet weak var label_phone: UILabel!
    @IBOutlet weak var label_applyQuota: UILabel!
    @IBOutlet weak var textView_reason: QMUITextView!
    @IBOutlet weak var stackView_handle: UIStackView!
    @IBOutlet weak var btn_reject: UIButton!
    @IBOutlet weak var btn_agreen: UIButton!
    @IBOutlet weak var label_textLen: UILabel!
 
    let viewModel = EnterpriseViewModel()
    private var id:Int!
 
    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 = "申请详情"
        textView_reason.isEditable = false
 
        viewModel.getCompanyLimitDetail(id: id) { [weak self] status in
            guard let weakSelf = self else { return }
            switch status {
                case .success(let m):
                    weakSelf.label_name.text = m?.staffName ?? ""
                    weakSelf.label_phone.text = m?.phone ?? ""
                    weakSelf.label_applyQuota.text = m?.applyQuota.remain2Digits() ?? ""
                    weakSelf.textView_reason.text = m?.applyReason ?? ""
                    weakSelf.label_textLen.text = String(format: "%ld/50", m?.applyReason.length ?? 0)
                    weakSelf.stackView_handle.isHidden = (m?.status == .pass || m?.status == .reject)
                case .error(let error):
                    alert(text: error.localizedDescription)
            }
        }
    }
 
 
    @IBAction func agreenAction(_ sender: UIButton) {
        viewModel.companyLimitApprove(id: id, status: 1) { status in
            switch status {
                case .success(_):
                    alert(text: "审核成功")
                    self.stackView_handle.isHidden = true
                    NotificationCenter.default.post(name: RefreshLineOfCredit_Noti, object: nil)
                case .error(let error):
                    alert(text: error.localizedDescription)
            }
        }
    }
 
    @IBAction func rejectAction(_ sender: UIButton) {
        RejectReasonView.show { [weak self] text in
            guard let weakSelf = self else { return }
            weakSelf.viewModel.companyLimitApprove(id: weakSelf.id,remark: text, status: 2) { status in
                switch status {
                    case .success(_):
                        alert(text: "审核成功")
                        weakSelf.stackView_handle.isHidden = true
                        NotificationCenter.default.post(name: RefreshLineOfCredit_Noti, object: nil)
                    case .error(let error):
                        alert(text: error.localizedDescription)
                }
            }
        }
    }
}