MeTraineeDetails01Controller.swift 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. let keys = ["个人信息","培训信息"]
  17. let keyArray = [["证件类型","证件号码","推荐人","国籍","地区","县区","联系地址","培训车型","是否激活","备案时间","所属机构"],
  18. ["阶段一学时","阶段二学时", "阶段三学时", "阶段四学时", "科一已打/所需学时", "科二已打/所需学时", "科三已打/所需学时","科四已打/所需学时", "科二总里程", "科三总里程", "总里程",]]
  19. // MARK: 数据
  20. var traineeInfoModel:TraineeInfoModel?
  21. // init(info:TraineeInfoModel) {
  22. // super.init()
  23. // self.traineeInfoModel = info
  24. // }
  25. required convenience init?(coder aDecoder: NSCoder) {
  26. fatalError("init(coder:) has not been implemented")
  27. }
  28. override func viewDidLoad() {
  29. super.viewDidLoad()
  30. //绑定
  31. biandView()
  32. }
  33. // MARK: 私有方法
  34. func setInfo(info:TraineeInfoModel){
  35. self.traineeInfoModel = info
  36. groupList["个人信息"] = ["证件类型":"身份证",
  37. "证件号码":info.idcard,
  38. "推荐人":info.source,
  39. "国籍":info.nationality,
  40. "地区":info.dqmc,
  41. "县区":info.qxmc,
  42. "联系地址":info.address,
  43. "培训车型":info.trainType,
  44. "是否激活":(info.active=="1" ? "是":"否"),
  45. "备案时间":info.recordDate,
  46. "所属机构":info.schoolName,]
  47. let onetime:String = info.trainOneExamStatus=="1" ? "运管已签章\(info.trainOneExamTime)":info.trainOneExamTime
  48. let twotime:String = info.trainTwoExamStatus=="1" ? "运管已签章\(info.trainTwoExamTime)":info.trainTwoExamTime
  49. let threetime:String = info.trainThreeExamTime=="1" ? "运管已签章\(info.trainThreeExamTime)":info.trainThreeExamTime
  50. let fourtime:String = info.trainFourExamStatus=="1" ? "运管已签章\(info.trainFourExamTime)":info.trainFourExamTime
  51. groupList["培训信息"] = ["阶段一学时":onetime,
  52. "阶段二学时":twotime,
  53. "阶段三学时":threetime,
  54. "阶段四学时":fourtime,
  55. "科一已打/所需学时":info.k1+"/"+info.totalKm1,
  56. "科二已打/所需学时":info.k2+"/"+info.totalKm2,
  57. "科三已打/所需学时":info.k3+"/"+info.totalKm3,
  58. "科四已打/所需学时":info.k4+"/"+info.totalKm4,
  59. "科二总里程":info.k2Mileage,
  60. "科三总里程":info.k3Mileage,
  61. "总里程":info.mileage,]
  62. tableView.reloadData()
  63. }
  64. func biandView(){
  65. tableView.delegate = self
  66. tableView.dataSource = self
  67. tableView.separatorStyle = .none //去除分割线
  68. tableView.register(UINib(nibName: "MeTraineeDetails01Cell", bundle: nil), forCellReuseIdentifier: cellIdentifier)
  69. tableView.rowHeight = 40.f
  70. self.isEmptyDisplay = false
  71. self.hideLoadAnimation()
  72. }
  73. }
  74. //数据源
  75. extension MeTraineeDetails01Controller:UITableViewDataSource {
  76. func numberOfSections(in tableView: UITableView) -> Int {
  77. if(groupList.count>0){
  78. return keys.count ?? 0
  79. }
  80. return 0
  81. }
  82. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  83. let count = groupList[keys[section]]!.count
  84. return count
  85. }
  86. func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
  87. let header_view = MeTraineeDetails01HeaderView.loadFromNib()
  88. header_view.title_label.text = keys[section]
  89. return header_view
  90. }
  91. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  92. return 50.f
  93. }
  94. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  95. var groupDict = groupList[keys[indexPath.section]]!
  96. let _keys = keyArray[indexPath.section]
  97. let type = _keys[indexPath.row]
  98. let value = groupDict[type]
  99. let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! MeTraineeDetails01Cell
  100. cell.contentView.backgroundColor = ((indexPath.row%2) != 0) ? UIColor("#113357") : UIColor("#0B2B4D")
  101. cell.backgroundColor = ((indexPath.row%2) != 0) ? UIColor("#113357") : UIColor("#0B2B4D")
  102. cell.type_label.text = type
  103. cell.value_label.text = value
  104. return cell
  105. }
  106. }
  107. //事件
  108. extension MeTraineeDetails01Controller:UITableViewDelegate {
  109. // func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  110. // tableView.deselectRow(at: indexPath, animated: false)
  111. // let rowInfo = self.traineeDataModel?.rows![indexPath.row]
  112. // if rowInfo != nil {
  113. // let context: Int = rowInfo?.id ?? 0
  114. // NYSwRouter.push(NYSwPushType.trainee_info,context: context)
  115. // }
  116. // }
  117. }