MeTraineeDetails01Controller.swift 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // MeTraineeDetails01Controller.swift
  3. // JiaPeiManage
  4. //
  5. // Created by Ning.ge on 2023/6/20.
  6. //
  7. import UIKit
  8. import RxSwift
  9. import RxCocoa
  10. final class MeTraineeDetails01Controller: BaseTableViewController {
  11. let cellIdentifier:String = "_MeTraineeDetails01Cell"
  12. // MARK: 服务属性
  13. private let cocahService: CoachServiceType = CoachService(networking: CoachNetworking())
  14. // MARK: UI属性
  15. var groupList:[String : [String:String]] = [:]
  16. var groupColorList:[String:String] = [:]
  17. let keys = ["个人信息","培训信息"]
  18. let keyArray = [["证件类型","证件号码","推荐人","国籍","地区","县区","联系地址","培训车型","是否激活","备案时间","所属机构"],
  19. ["阶段一学时","阶段二学时", "阶段三学时", "阶段四学时", "科一已打/所需学时", "科二已打/所需学时", "科三已打/所需学时","科四已打/所需学时", "科二总里程", "科三总里程", "总里程",]]
  20. // MARK: 数据
  21. var traineeInfoModel:TraineeInfoModel?
  22. // init(info:TraineeInfoModel) {
  23. // super.init()
  24. // self.traineeInfoModel = info
  25. // }
  26. required convenience init?(coder aDecoder: NSCoder) {
  27. fatalError("init(coder:) has not been implemented")
  28. }
  29. override func viewDidLoad() {
  30. super.viewDidLoad()
  31. //绑定
  32. biandView()
  33. }
  34. // MARK: 私有方法
  35. func setInfo(info:TraineeInfoModel){
  36. self.traineeInfoModel = info
  37. groupList["个人信息"] = ["证件类型":"身份证",
  38. "证件号码":info.idcard,
  39. "推荐人":info.source ?? "",
  40. "国籍":info.nationality,
  41. "地区":info.dqmc,
  42. "县区":info.qxmc,
  43. "联系地址":info.address,
  44. "培训车型":info.trainType,
  45. "是否激活":(info.active=="1" ? "是":"否"),
  46. "备案时间":info.recordDate ?? "",
  47. "所属机构":info.schoolName ?? "",]
  48. // let onetime:String = info.trainOneExamStatus=="1" ? "运管已签章"+info.trainOneExamTime.prefix(10):"无"
  49. // let twotime:String = info.trainTwoExamStatus=="1" ? "运管已签章"+info.trainTwoExamTime.prefix(10):"无"
  50. // let threetime:String = info.trainThreeExamStatus=="1" ? "运管已签章"+info.trainThreeExamTime.prefix(10):"无"
  51. // let fourtime:String = info.trainFourExamStatus=="1" ? "运管已签章"+info.trainFourExamTime.prefix(10):"无"
  52. let onetime:String = info.trainOneStatusStr
  53. let twotime:String = info.trainTwoStatusStr
  54. let threetime:String = info.trainThreeStatusStr
  55. let fourtime:String = info.trainFourStatusStr
  56. groupColorList["阶段一学时"] = info.trainOneStatusColor
  57. groupColorList["科一已打/所需学时"] = "#35BF5E"
  58. groupColorList["阶段二学时"] = info.trainTwoStatusColor
  59. groupColorList["科二已打/所需学时"] = "#35BF5E"
  60. groupColorList["阶段三学时"] = info.trainThreeStatusColor
  61. groupColorList["科三已打/所需学时"] = "#35BF5E"
  62. groupColorList["阶段四学时"] = info.trainFourStatusColor
  63. groupColorList["科四已打/所需学时"] = "#35BF5E"
  64. groupList["培训信息"] = ["阶段一学时":onetime,
  65. "阶段二学时":twotime,
  66. "阶段三学时":threetime,
  67. "阶段四学时":fourtime,
  68. "科一已打/所需学时":info.k1+"/"+info.totalKm1,
  69. "科二已打/所需学时":info.k2+"/"+info.totalKm2,
  70. "科三已打/所需学时":info.k3+"/"+info.totalKm3,
  71. "科四已打/所需学时":info.k4+"/"+info.totalKm4,
  72. "科二总里程":info.k2Mileage,
  73. "科三总里程":info.k3Mileage,
  74. "总里程":info.mileage,]
  75. tableView.reloadData()
  76. }
  77. func biandView(){
  78. tableView.delegate = self
  79. tableView.dataSource = self
  80. tableView.separatorStyle = .none //去除分割线
  81. tableView.register(UINib(nibName: "MeTraineeDetails01Cell", bundle: nil), forCellReuseIdentifier: cellIdentifier)
  82. tableView.rowHeight = 40.f
  83. self.isEmptyDisplay = false
  84. self.hideLoadAnimation()
  85. }
  86. }
  87. //数据源
  88. extension MeTraineeDetails01Controller:UITableViewDataSource {
  89. func numberOfSections(in tableView: UITableView) -> Int {
  90. if(groupList.count>0){
  91. return keys.count ?? 0
  92. }
  93. return 0
  94. }
  95. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  96. let count = groupList[keys[section]]!.count
  97. return count
  98. }
  99. func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
  100. let header_view = MeTraineeDetails01HeaderView.loadFromNib()
  101. header_view.traineeInfoModel = self.traineeInfoModel
  102. header_view.title_label.text = keys[section]
  103. if section == 1 {
  104. header_view.estu_log_button.isHidden = false
  105. } else {
  106. header_view.estu_log_button.isHidden = true
  107. }
  108. return header_view
  109. }
  110. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  111. return 50.f
  112. }
  113. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  114. var groupDict = groupList[keys[indexPath.section]]!
  115. let _keys = keyArray[indexPath.section]
  116. let type = _keys[indexPath.row]
  117. let value = groupDict[type]
  118. let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! MeTraineeDetails01Cell
  119. cell.contentView.backgroundColor = ((indexPath.row%2) != 0) ? UIColor("#113357") : UIColor("#0B2B4D")
  120. cell.backgroundColor = ((indexPath.row%2) != 0) ? UIColor("#113357") : UIColor("#0B2B4D")
  121. cell.type_label.text = type
  122. cell.value_label.text = value
  123. if let color = groupColorList[type] {
  124. // key 存在,执行相应的逻辑
  125. cell.value_label.textColor = UIColor(color)
  126. }else {
  127. // key 不存在,执行相应的逻辑
  128. cell.value_label.textColor = .db_fontSelColor
  129. }
  130. return cell
  131. }
  132. }
  133. //事件
  134. extension MeTraineeDetails01Controller:UITableViewDelegate {
  135. }