MeTraineeDetails01Controller.swift 7.0 KB

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