CNLiveVitaeWorkDetailController.swift
9.87 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
//
// 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()
var workAwardType:CNLiveViateWorkAwardType = .work
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<Any> = {
let dataArray = Array<Any>()
return dataArray
}()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.getWorkList()
}
override func viewDidLoad() {
super.viewDidLoad()
navigationBarHidden = false
self.initUI()
if self.workAwardType == .work{
titleName = "工作记录"
self.bgImgView.image = UIImage(named: "mine_jianli_workBg")
self.yuanmaLabel.text = "工作记录"
self.addWorkBtn.setTitle("添加工作记录", for: .normal)
}else{
titleName = "获奖情况"
self.bgImgView.image = UIImage(named: "mine_jianli_awardBg")
self.yuanmaLabel.text = "获奖情况"
self.addWorkBtn.setTitle("添加获奖记录", for: .normal)
}
}
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
}
if self.workAwardType == .work{
let model = workListArr[indexPath.row] as! CNLiveVitaeWorksModel
cell.workModel = model
}else{
let model = workListArr[indexPath.row] as! CNLiveVitaeAwardsModel
cell.awardModel = model
}
cell.vitaeWorkCellChangedBlock = { workCell,jianjieHeight,isExpand in
let res = self.workListArr
var tempArr = Array<Any>()
let idxPath = tableView.indexPath(for: workCell)
for (idx,mdl) in res.enumerated() {
if idx == idxPath?.row{
if self.workAwardType == .work{
let model = mdl as! CNLiveVitaeWorksModel
let layout = CNLiveViateWorkModelLayout(model: model,descH: Float(jianjieHeight),isPreview: false, isExpand: isExpand, isShowExpand: true)
let newWorkModel = layout.getCellHModel()
tempArr.append(newWorkModel)
}else{
let model = mdl as! CNLiveVitaeAwardsModel
let layout = CNLiveViateAwardModelLayout(model: model,descH: Float(jianjieHeight), isPreview: false, isExpand: isExpand, isShowExpand: true)
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 {
if self.workAwardType == .work{
let model = self.workListArr[indexPath.row] as! CNLiveVitaeWorksModel
return CGFloat(model.cellH)
}else{
let model = self.workListArr[indexPath.row] as! CNLiveVitaeAwardsModel
return CGFloat(model.cellH)
}
}
@objc func addWorkBtnAction(){
let vc = CNLiveVitaeAddWorkController()
vc.workAwardType = self.workAwardType
// vc.isAddWorkAward = true
self.navigationController?.pushViewController(vc, animated: true)
}
func getWorkList(){
let vsid = UserInfoManager.shared.userInfo.currentUser?.vsid ?? ""
if self.workAwardType == .work{
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,isPreview: false, isExpand: false, isShowExpand: true)
let newWorkModel = layout.getCellHModel()
self.workListArr.append(newWorkModel)
}
self.tableView.reloadData()
self.yuanmaDescLabel.text = "共 \(res.count) 条"
}
}else{
showMessage(message: "数据异常")
}
}
}else{
CNLiveVitaeViewModel.getAwardList(vsid: vsid){ result, respStatus in
if respStatus == .success{
if let res = result as? [CNLiveVitaeAwardsModel]{
self.workListArr = Array()
for mdl in res {
let layout = CNLiveViateAwardModelLayout(model: mdl,descH: 40.0, isPreview: false, isExpand: false, isShowExpand: true)
let newWorkModel = layout.getCellHModel()
self.workListArr.append(newWorkModel)
}
self.tableView.reloadData()
self.yuanmaDescLabel.text = "共 \(res.count) 条"
}
}else{
showMessage(message: "数据异常")
}
}
}
}
}