宽窄优行-由【嘉易行】项目成品而来
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
//
//  MinePublishSaleDetailMoreVC.swift
//  OKProject
//
//  Created by 无故事王国 on 2022/5/9.
//  Copyright © 2022 yangwang. All rights reserved.
//
 
import UIKit
 
class MinePublishSaleDetailMoreVC: YYViewController {
 
    private let cellW:Double = (ScreenWidth - 30.0)/2.0
    private let cellH:Double = 36
 
    @IBOutlet weak var scrollView: UIScrollView!
    @IBOutlet weak var stackView: UIStackView!
    @IBOutlet weak var deployItemCollectionView: UICollectionView!
    @IBOutlet weak var deployItemCollectionHeiCons: NSLayoutConstraint!
 
    @IBOutlet weak var brandNameL: UILabel!
    @IBOutlet weak var mileageL: UILabel!
    @IBOutlet weak var displacementL: UILabel!
    @IBOutlet weak var transmissionCaseL: UILabel!
    @IBOutlet weak var locationOfLicensePlateL: UILabel!
    @IBOutlet weak var transferTimesL: UILabel!
    @IBOutlet weak var levelL: UILabel!
    @IBOutlet weak var remainingOperationTimeView: UIView!
    @IBOutlet weak var remainingOperationTimeL: UILabel!
    @IBOutlet weak var operationUpdateTimeView: UIView!
    @IBOutlet weak var operationUpdateTimeL: UILabel!
    @IBOutlet weak var licensingTimeL: UILabel!
    @IBOutlet weak var dueTimeOfCompulsoryInsuranceL: UILabel!
    @IBOutlet weak var expirationTimeOfAnnualInspectionL: UILabel!
    @IBOutlet weak var maturityTimeOfCommercialInsuranceL: UILabel!
    @IBOutlet weak var havePledgeBtn: UIButton! //有抵押
    @IBOutlet weak var notHavePledgeBtn: UIButton! //无抵押
 
    var carSellModel:CarSellModel?
    var sellCarReqModel:SellCarReqModel?
    var config = ConfigModel.localConfig()
    var containConfig = [String]()
 
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationItem.title = "车辆档案信息"
 
 
        if let m = carSellModel{
 
 
            brandNameL.text = m.brandName
            mileageL.text = String(format: "%.2lf万", m.mileage)
            displacementL.text = m.displacement
            transmissionCaseL.text = m.transmissionCase
            locationOfLicensePlateL.text = m.locationOfLicensePlate
            transferTimesL.text = String(format: "%@次", m.transferTimes)
            levelL.text = m.level
            remainingOperationTimeL.text = m.remainingOperationTime
            operationUpdateTimeL.text = m.operationUpdateTime
            licensingTimeL.text = m.licensingTime
            dueTimeOfCompulsoryInsuranceL.text = m.dueTimeOfCompulsoryInsurance
            expirationTimeOfAnnualInspectionL.text = m.expirationTimeOfAnnualInspection
            maturityTimeOfCommercialInsuranceL.text = m.maturityTimeOfCommercialInsurance
            containConfig = m.installationConfiguration.components(separatedBy: ",").filter({!$0.isEmpty})
 
            if m.mortgage == 1{
                havePledgeBtn.backgroundColor = UIColor(hexString: "#00BF30")
                notHavePledgeBtn.backgroundColor = .white
                havePledgeBtn.isSelected = true
                notHavePledgeBtn.isSelected = false
            }else{
                notHavePledgeBtn.backgroundColor = UIColor(hexString: "#00BF30")
                havePledgeBtn.backgroundColor = .white
                havePledgeBtn.isSelected = false
                notHavePledgeBtn.isSelected = true
            }
            //73507 【买车】列表-进入详情:数据显示不对
            remainingOperationTimeView.isHidden = m.userType == .user ? true:false
            operationUpdateTimeView.isHidden = m.userType == .user ? true:false
            deployItemCollectionView.reloadData()
            calHei()
        }
 
        if let m1 = sellCarReqModel{
            brandNameL.text = m1.brandName
            mileageL.text = String(format: "%.2lf", m1.mileage ?? 0)
            displacementL.text = m1.displacement
            transmissionCaseL.text = m1.transmissionCase
            locationOfLicensePlateL.text = m1.locationOfLicensePlate
            transferTimesL.text = String(format: "%ld", m1.transferTimes ?? 0)
            levelL.text = m1.level
            remainingOperationTimeL.text = m1.remainingOperationTime
            operationUpdateTimeL.text = m1.operationUpdateTime
            licensingTimeL.text = m1.licensingTime
            dueTimeOfCompulsoryInsuranceL.text = m1.dueTimeOfCompulsoryInsurance
            expirationTimeOfAnnualInspectionL.text = m1.expirationTimeOfAnnualInspection
            maturityTimeOfCommercialInsuranceL.text = m1.maturityTimeOfCommercialInsurance
 
            if m1.mortgage == 1{
                havePledgeBtn.backgroundColor = UIColor(hexString: "#00BF30")
                notHavePledgeBtn.backgroundColor = .white
                havePledgeBtn.isSelected = true
                notHavePledgeBtn.isSelected = false
            }else{
                notHavePledgeBtn.backgroundColor = UIColor(hexString: "#00BF30")
                havePledgeBtn.backgroundColor = .white
                havePledgeBtn.isSelected = false
                notHavePledgeBtn.isSelected = true
            }
 
            deployItemCollectionView.reloadData()
            calHei()
        }
    }
 
    override func setupViews() {
        super.setupViews()
        view.backgroundColor = UIColor(hexString: "#F3F4F5")
        scrollView.contentInset = UIEdgeInsets(top: 21, left: 0, bottom: 10, right: 0)
        stackView.backgroundColor = .white
        stackView.cornerRadius = 4
        stackView.maskToBounds = true
 
        deployItemCollectionView.delegate = self
        deployItemCollectionView.dataSource = self
        deployItemCollectionView.register(UINib(nibName: "CheckItemTCell", bundle: nil), forCellWithReuseIdentifier: "_CheckItemTCell")
        deployItemCollectionView.isScrollEnabled = false
        calHei()
 
        notHavePledgeBtn.borderWidth = 1
        havePledgeBtn.borderWidth = 1
        notHavePledgeBtn.borderColor = UIColor(hexString: "#00BF30")!
        havePledgeBtn.borderColor = UIColor(hexString: "#00BF30")!
    }
 
    private func calHei(){
        if let m = carSellModel{
            let h = ceil(Double(config.count) / 2.0) * cellH
            deployItemCollectionHeiCons.constant = h
        }
 
        if let m1 = sellCarReqModel{
            let items = m1.installationConfiguration!.components(separatedBy: ",")
            let h = ceil(Double(items.count) / 2.0) * cellH
            deployItemCollectionHeiCons.constant = h
        }
    }
}
 
extension MinePublishSaleDetailMoreVC:UICollectionViewDelegate{
 
}
 
extension MinePublishSaleDetailMoreVC:UICollectionViewDataSource{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        if let _ = carSellModel{
            return config.count
        }
 
        if let m1 = sellCarReqModel{
            return m1.installationConfiguration!.components(separatedBy: ",").filter({$0.isEmpty == false}).count
        }
        return 0
    }
 
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
 
        var items = [String]()
        if let _ = carSellModel{
            items = config.map({$0.name})
        }
 
        if let m1 = sellCarReqModel{
            items = m1.installationConfiguration!.components(separatedBy: ",").filter({$0.isEmpty == false})
        }
 
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_CheckItemTCell", for: indexPath) as! CheckItemTCell
        cell.checkBtn.isSelected = true
        cell.itemL.text = items[indexPath.row]
 
        if containConfig.count != 0{
            if !containConfig.contains(items[indexPath.row]){
                cell.checkBtn.isSelected = false
            }
        }
 
        return cell
    }
}
 
extension MinePublishSaleDetailMoreVC:UICollectionViewDelegateFlowLayout{
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
        return 0.01
    }
 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
        return 0.01
    }
 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: cellW, height: cellH)
    }
}