OOMeetingAcceptController.swift 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // OOMeetingAcceptController.swift
  3. // o2app
  4. //
  5. // Created by 刘振兴 on 2018/1/22.
  6. // Copyright © 2018年 zone. All rights reserved.
  7. //
  8. import UIKit
  9. import EmptyDataSet_Swift
  10. import CocoaLumberjack
  11. private let meetingIdentifier = "OOMeetingAcceptCell"
  12. class OOMeetingAcceptController: UIViewController,EmptyDataSetSource,EmptyDataSetDelegate {
  13. private lazy var headerView:OOMeetingConfirmHeaderView = {
  14. let view = Bundle.main.loadNibNamed("OOMeetingConfirmHeaderView", owner: self, options: nil)?.first as! OOMeetingConfirmHeaderView
  15. view.frame = CGRect(x: 0, y: 0, width: kScreenW, height: 40)
  16. view.delegate = self
  17. return view
  18. }()
  19. private let viewModel:OOMeetingAcceptViewModel = {
  20. return OOMeetingAcceptViewModel()
  21. }()
  22. private var uIndex: Int = 0
  23. @IBOutlet weak var tableView: UITableView!
  24. override func viewDidLoad() {
  25. super.viewDidLoad()
  26. self.tabBarItem?.selectedImage = O2ThemeManager.image(for: "Icon.icon_zjhy_pro")
  27. tableView.register(UINib.init(nibName: "OOMeetingAcceptCell", bundle: nil), forCellReuseIdentifier: meetingIdentifier)
  28. headerView.autoresizingMask = .flexibleWidth
  29. tableView.tableHeaderView = headerView
  30. tableView.emptyDataSetSource = self
  31. tableView.emptyDataSetDelegate = self
  32. tableView.tableFooterView = UIView()
  33. if #available(iOS 11.0, *) {
  34. //tableView.contentInsetAdjustmentBehavior = .never
  35. }
  36. viewModel.callbackExecutor = {
  37. msg in
  38. self.tableView.reloadData()
  39. }
  40. }
  41. /// 修改后返回会刷新列表
  42. override func viewWillAppear(_ animated: Bool) {
  43. super.viewWillAppear(animated)
  44. viewModel.loadAcceptListByIndex(uIndex)
  45. }
  46. override func didReceiveMemoryWarning() {
  47. super.didReceiveMemoryWarning()
  48. // Dispose of any resources that can be recreated.
  49. }
  50. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  51. if segue.identifier == "showMeetingDetail" {
  52. if let vc = segue.destination as? OOMeetingDetailViewController, let meeting = sender as? OOMeetingInfo {
  53. vc.meetingInfo = meeting
  54. }
  55. }
  56. }
  57. func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? {
  58. let text = "没有待处理的申请"
  59. let titleAttributes = [NSAttributedString.Key.foregroundColor:UIColor(hex:"#CCCCCC"),NSAttributedString.Key.font:UIFont.init(name: "PingFangSC-Regular", size: 18)!]
  60. return NSMutableAttributedString(string: text, attributes: titleAttributes)
  61. }
  62. func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? {
  63. return #imageLiteral(resourceName: "icon_wuyaoqing")
  64. }
  65. func backgroundColor(forEmptyDataSet scrollView: UIScrollView) -> UIColor? {
  66. return UIColor(hex:"#F5F5F5")
  67. }
  68. func emptyDataSetShouldDisplay(_ scrollView: UIScrollView) -> Bool {
  69. return true
  70. }
  71. }
  72. extension OOMeetingAcceptController:UITableViewDelegate,UITableViewDataSource {
  73. func numberOfSections(in tableView: UITableView) -> Int {
  74. return viewModel.numberOfSections()
  75. }
  76. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  77. return viewModel.numberOfRowsInSection(section)
  78. }
  79. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  80. //let cell = t
  81. let cell = tableView.dequeueReusableCell(withIdentifier: meetingIdentifier, for: indexPath)
  82. let uCell = cell as! OOMeetingAcceptCell
  83. uCell.viewModel = viewModel
  84. let item = viewModel.nodeForIndexPath(indexPath)
  85. uCell.config(withItem: item)
  86. if uIndex == 1 {
  87. if item?.status == "wait" && O2AuthSDK.shared.myInfo()?.distinguishedName == item?.applicant {
  88. uCell.editButton.isHidden = false
  89. }else {
  90. uCell.editButton.isHidden = true
  91. }
  92. }else{
  93. uCell.editButton.isHidden = true
  94. }
  95. return cell
  96. }
  97. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  98. let item = viewModel.nodeForIndexPath(indexPath)
  99. self.performSegue(withIdentifier: "showMeetingDetail", sender: item)
  100. }
  101. }
  102. extension OOMeetingAcceptController:OOMeetingConfirmHeaderViewDelegate {
  103. func confirmHeaderView(_ segmentedControlIndex: Int) {
  104. self.uIndex = segmentedControlIndex
  105. viewModel.loadAcceptListByIndex(uIndex)
  106. }
  107. }