MeetingFormSingleUnitPickerCell.swift 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // MeetingFormSingleUnitPickerCell.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2022/3/14.
  6. // Copyright © 2022 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import Eureka
  10. class MeetingFormSingleUnitPickerCell: Cell<String>, CellType {
  11. @IBOutlet weak var unitLabel: UILabel!
  12. override func setup() {
  13. super.setup()
  14. selectionStyle = .none
  15. }
  16. override func update() {
  17. super.update()
  18. if let v = row.value {
  19. var name = ""
  20. if v.contains("@") {
  21. name = v.split("@")[0]
  22. }else {
  23. name = v
  24. }
  25. self.unitLabel.text = name
  26. }
  27. }
  28. override func didSelect() {
  29. // 点击事件
  30. self.pickerUnit()
  31. }
  32. private func setCellValue(person: String) {
  33. self.row.value = person
  34. var name = ""
  35. if person.contains("@") {
  36. name = person.split("@")[0]
  37. }else {
  38. name = person
  39. }
  40. self.unitLabel.text = name
  41. }
  42. private func pickerUnit() {
  43. if let v = ContactPickerViewController.providePickerVC(
  44. pickerModes: [ContactPickerType.unit],
  45. multiple: false,
  46. pickedDelegate: { (result: O2BizContactPickerResult) in
  47. if let depts = result.departments {
  48. if !depts.isEmpty {
  49. self.setCellValue(person: depts[0].distinguishedName ?? "")
  50. }
  51. }
  52. }) {
  53. self.formViewController()?.navigationController?.pushViewController(v, animated: true)
  54. }
  55. }
  56. }
  57. final class MeetingFormSingleUnitPickerRow: Row<MeetingFormSingleUnitPickerCell>, RowType {
  58. required init(tag: String?) {
  59. super.init(tag: tag)
  60. cellProvider = CellProvider<MeetingFormSingleUnitPickerCell>(nibName: "MeetingFormSingleUnitPickerCell")
  61. }
  62. }