CNLiveVitaeWorkDetailController.swift
7.23 KB
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
//
// CNLiveVitaeWorkDetailController.swift
// metaCode
//
// Created by zx on 2024/7/31.
// 工作记录页面(工作记录详情)
import Foundation
import SnapKit
import JFHeroBrowser
class CNLiveVitaeWorkDetailController:CNLiveBaseViewController,UITableViewDataSource, UITableViewDelegate{
var jianjieLblHeight:CGFloat = 40
var cellHeights:Array<CGFloat> = Array()
lazy var bgImgView :UIImageView = {
let iconImgView = UIImageView()
iconImgView.image = UIImage(named: "mine_jianli_workBg")
return iconImgView
}()
lazy var yuanmaLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.text = "工作记录"
titleLabel.font = BoldFont_24
titleLabel.adjustsFontSizeToFitWidth=true
return titleLabel
}()
lazy var yuanmaDescLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.text = "共 1 条"
titleLabel.font = Font_16
return titleLabel
}()
let kCNLiveVitaeWorkCellIdentifier = "kCNLiveVitaeWorkCellIdentifier"
lazy var tableView : UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .none
tableView.tableFooterView = UIView.init()
tableView.register(CNLiveVitaeWorkCell.self, forCellReuseIdentifier: kCNLiveVitaeWorkCellIdentifier)
tableView.backgroundColor = .clear
return tableView
}()
lazy var bottomZhiNanWhiteView :UIView = {
let bottomNavView = UIView()
bottomNavView.backgroundColor = .white
return bottomNavView
}()
lazy var addWorkBtn: UIButton = {
let nextBtn = UIButton(type: .custom)
nextBtn.setTitle("添加工作记录", for: .normal)
nextBtn.setTitleColor(.white, for: .normal)
nextBtn.backgroundColor = HexColor("#1961FE")
nextBtn.layer.cornerRadius = 20
nextBtn.clipsToBounds = true
nextBtn.addTarget(self, action: #selector(addWorkBtnAction), for: .touchUpInside)
return nextBtn
}()
lazy var workListArr :Array<CNLiveVitaeWorksModel> = {
let dataArray = Array<CNLiveVitaeWorksModel>()
return dataArray
}()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.getWorkList()
}
override func viewDidLoad() {
super.viewDidLoad()
titleName = "工作记录"
navigationBarHidden = false
self.initUI()
}
deinit {}
func initUI(){
self.view.backgroundColor = HexColor("#F9F9F9")
self.view.addSubview(self.bgImgView)
self.bgImgView.snp.makeConstraints { make in
make.top.equalTo(KNavigationHeight)
make.left.right.equalToSuperview()
make.height.equalTo(KSreenWidth*457/375)
}
self.bgImgView.addSubview(self.yuanmaLabel)
self.yuanmaLabel.snp.makeConstraints { make in
make.top.equalTo(59)
make.left.equalTo(adapt_length(length: 30))
}
self.bgImgView.addSubview(self.yuanmaDescLabel)
self.yuanmaDescLabel.snp.makeConstraints { make in
make.top.equalTo(self.yuanmaLabel.snp.bottom).offset(adapt_length(length: 5))
make.left.equalTo(adapt_length(length: 30))
}
self.view.addSubview(self.tableView)
self.tableView.snp.makeConstraints { make in
make.top.equalTo(150+KNavigationHeight)
make.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(-60)
}
self.view.addSubview(self.bottomZhiNanWhiteView)
self.bottomZhiNanWhiteView.snp.makeConstraints { make in
make.top.equalTo(self.tableView.snp.bottom)
make.bottom.left.right.equalToSuperview()
}
self.bottomZhiNanWhiteView.addSubview(self.addWorkBtn)
self.addWorkBtn.snp.makeConstraints { make in
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
make.top.equalTo(10)
make.height.equalTo(40)
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.workListArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVitaeWorkCellIdentifier) as? CNLiveVitaeWorkCell
else {
let cell = CNLiveVitaeWorkCell()
return cell
}
let model = workListArr[indexPath.row]
cell.workModel = model
cell.vitaeWorkCellChangedBlock = { workCell,jianjieHeight in
let res = self.workListArr
var tempArr = Array<CNLiveVitaeWorksModel>()
let idxPath = tableView.indexPath(for: workCell)
for (idx,mdl) in res.enumerated() {
if idx == idxPath?.row{
let layout = CNLiveViateWorkModelLayout(model: mdl,descH: Float(jianjieHeight))
let newWorkModel = layout.getCellHModel()
tempArr.append(newWorkModel)
}else{
tempArr.append(mdl)
}
}
self.workListArr = Array(tempArr)
self.tableView.reloadData()
}
cell.vitaeWorkPreviewVideoPhotoBlock = { images , index in
self.hero.browserMultiSoures(viewModules: images, initIndex: index) {
[
.enableBlurEffect(false),
.heroView(nil),
.imageDidChangeHandle({ imageIndex in
return nil
})
]
}
}
cell.vitaeWorkListBlock = {
self.getWorkList()
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let model = self.workListArr[indexPath.row]
return CGFloat(model.cellH)
}
@objc func addWorkBtnAction(){
self.navigationController?.pushViewController(CNLiveVitaeAddWorkController(), animated: true)
}
func getWorkList(){
let vsid = UserInfoManager.shared.userInfo.currentUser?.vsid ?? ""
CNLiveVitaeViewModel.getWorkList(vsid: vsid){ result, respStatus in
if respStatus == .success{
if let res = result as? [CNLiveVitaeWorksModel]{
self.workListArr = Array()
for mdl in res {
let layout = CNLiveViateWorkModelLayout(model: mdl,descH: 40.0)
let newWorkModel = layout.getCellHModel()
self.workListArr.append(newWorkModel)
}
self.tableView.reloadData()
self.yuanmaDescLabel.text = "共 \(res.count) 条"
}
}else{
showMessage(message: "数据异常")
}
}
}
}