MeTraineeDetails01Controller.swift 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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):info.trainOneExamTime.prefix(10)+""
  49. let twotime:String = info.trainTwoExamStatus=="1" ? "运管已签章"+info.trainTwoExamTime.prefix(10):info.trainTwoExamTime.prefix(10)+""
  50. let threetime:String = info.trainThreeExamStatus=="1" ? "运管已签章"+info.trainThreeExamTime.prefix(10):info.trainThreeExamTime.prefix(10)+""
  51. let fourtime:String = info.trainFourExamStatus=="1" ? "运管已签章"+info.trainFourExamTime.prefix(10):info.trainFourExamTime.prefix(10)+""
  52. if (info.trainOneExamStatus=="1"){
  53. groupColorList["阶段一学时"] = "#35BF5E"
  54. groupColorList["科一已打/所需学时"] = "#35BF5E"
  55. }
  56. if(info.trainTwoExamStatus=="1"){
  57. groupColorList["阶段二学时"] = "#35BF5E"
  58. groupColorList["科二已打/所需学时"] = "#35BF5E"
  59. }
  60. if(info.trainThreeExamStatus=="1"){
  61. groupColorList["阶段三学时"] = "#35BF5E"
  62. groupColorList["科三已打/所需学时"] = "#35BF5E"
  63. }
  64. if(info.trainFourExamStatus=="1"){
  65. groupColorList["阶段四学时"] = "#35BF5E"
  66. groupColorList["科四已打/所需学时"] = "#35BF5E"
  67. }
  68. groupList["培训信息"] = ["阶段一学时":onetime,
  69. "阶段二学时":twotime,
  70. "阶段三学时":threetime,
  71. "阶段四学时":fourtime,
  72. "科一已打/所需学时":info.k1+"/"+info.totalKm1,
  73. "科二已打/所需学时":info.k2+"/"+info.totalKm2,
  74. "科三已打/所需学时":info.k3+"/"+info.totalKm3,
  75. "科四已打/所需学时":info.k4+"/"+info.totalKm4,
  76. "科二总里程":info.k2Mileage,
  77. "科三总里程":info.k3Mileage,
  78. "总里程":info.mileage,]
  79. tableView.reloadData()
  80. }
  81. func biandView(){
  82. tableView.delegate = self
  83. tableView.dataSource = self
  84. tableView.separatorStyle = .none //去除分割线
  85. tableView.register(UINib(nibName: "MeTraineeDetails01Cell", bundle: nil), forCellReuseIdentifier: cellIdentifier)
  86. tableView.rowHeight = 40.f
  87. self.isEmptyDisplay = false
  88. self.hideLoadAnimation()
  89. }
  90. }
  91. //数据源
  92. extension MeTraineeDetails01Controller:UITableViewDataSource {
  93. func numberOfSections(in tableView: UITableView) -> Int {
  94. if(groupList.count>0){
  95. return keys.count ?? 0
  96. }
  97. return 0
  98. }
  99. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  100. let count = groupList[keys[section]]!.count
  101. return count
  102. }
  103. func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
  104. let header_view = MeTraineeDetails01HeaderView.loadFromNib()
  105. header_view.title_label.text = keys[section]
  106. return header_view
  107. }
  108. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  109. return 50.f
  110. }
  111. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  112. var groupDict = groupList[keys[indexPath.section]]!
  113. let _keys = keyArray[indexPath.section]
  114. let type = _keys[indexPath.row]
  115. let value = groupDict[type]
  116. let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! MeTraineeDetails01Cell
  117. cell.contentView.backgroundColor = ((indexPath.row%2) != 0) ? UIColor("#113357") : UIColor("#0B2B4D")
  118. cell.backgroundColor = ((indexPath.row%2) != 0) ? UIColor("#113357") : UIColor("#0B2B4D")
  119. cell.type_label.text = type
  120. cell.value_label.text = value
  121. if let color = groupColorList[type] {
  122. // key 存在,执行相应的逻辑
  123. cell.value_label.textColor = UIColor(color)
  124. }else {
  125. // key 不存在,执行相应的逻辑
  126. cell.value_label.textColor = .db_fontSelColor
  127. }
  128. return cell
  129. }
  130. }
  131. //事件
  132. extension MeTraineeDetails01Controller:UITableViewDelegate {
  133. // func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  134. // tableView.deselectRow(at: indexPath, animated: false)
  135. // let rowInfo = self.traineeDataModel?.rows![indexPath.row]
  136. // if rowInfo != nil {
  137. // let context: Int = rowInfo?.id ?? 0
  138. // NYSwRouter.push(NYSwPushType.trainee_info,context: context)
  139. // }
  140. // }
  141. }