OOMeetingDetailViewController.swift 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // OOMeetingDetailViewController.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2020/11/18.
  6. // Copyright © 2020 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import Eureka
  10. import QuickLook
  11. class OOMeetingDetailViewController: FormViewController {
  12. private lazy var viewModel:OOMeetingCreateViewModel = {
  13. return OOMeetingCreateViewModel()
  14. }()
  15. //预览文件
  16. private lazy var previewVC: CloudFilePreviewController = {
  17. return CloudFilePreviewController()
  18. }()
  19. var meetingInfo: OOMeetingInfo? //需要传入会议对象
  20. override func viewDidLoad() {
  21. super.viewDidLoad()
  22. self.title = self.meetingInfo?.subject ?? "会议详情"
  23. if self.meetingInfo?.status == "wait" && self.meetingInfo?.applicant == O2AuthSDK.shared.myInfo()?.distinguishedName {
  24. self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "修改", style: .plain, target: self, action: #selector(toUpdateMeeting))
  25. }
  26. self.loadForm()
  27. }
  28. func loadForm() {
  29. var time = ""
  30. if let start = self.meetingInfo?.startTime,
  31. let startTime = Date.date(start, formatter: "yyyy-MM-dd HH:mm:ss"),
  32. let end = self.meetingInfo?.completedTime, let endTime = Date.date(end, formatter: "yyyy-MM-dd HH:mm:ss") {
  33. time = startTime.toString("HH:mm") + " 至 " + endTime.toString("HH:mm")
  34. }
  35. form +++ Section()
  36. <<< LabelRow(){ row in
  37. row.title = "申请人"
  38. row.value = self.meetingInfo?.applicant?.split("@").first
  39. }
  40. <<< LabelRow(){ row in
  41. row.title = "会议标题"
  42. row.value = self.meetingInfo?.subject
  43. }
  44. <<< LabelRow(){ row in
  45. row.title = "会议日期"
  46. row.value = self.meetingInfo?.startTime?.subString(from: 0, to: 10)
  47. }
  48. <<< LabelRow(){ row in
  49. row.title = "会议时间"
  50. row.value = time
  51. }
  52. <<< LabelRow(){ row in
  53. row.title = "会议室"
  54. row.value = self.meetingInfo?.woRoom?.name
  55. }
  56. <<< PersonListRow(){ row in
  57. row.cell.viewModel = self.viewModel
  58. row.cell.delegate = self
  59. row.title = "参会人员"
  60. row.value = self.meetingInfo
  61. }
  62. <<< LabelRow(){ row in
  63. row.title = "会议描述"
  64. row.value = self.meetingInfo?.summary
  65. }
  66. <<< MeetingFormAttachmentCellRow("attachmentList") { row in
  67. row.cell.openFileAction = { atta in
  68. self.downloadFile(atta: atta)
  69. }
  70. row.value = self.meetingInfo?.attachmentList
  71. }
  72. }
  73. private func downloadFile(atta: OOMeetingAttachmentList) {
  74. self.showLoading()
  75. self.viewModel.downloadMeetingFile(file: atta) { (err, filePath) in
  76. self.hideLoading()
  77. if let path = filePath {
  78. self.previewFile(path: path)
  79. } else if let msg = err {
  80. self.showError(title: msg)
  81. }
  82. }
  83. }
  84. private func previewFile(path: URL) {
  85. let currentURL = NSURL(fileURLWithPath: path.path)
  86. print(currentURL.description)
  87. print(path.path)
  88. if QLPreviewController.canPreview(currentURL) {
  89. self.previewVC.currentFileURLS.removeAll()
  90. self.previewVC.currentFileURLS.append(currentURL)
  91. self.previewVC.reloadData()
  92. self.pushVC(self.previewVC)
  93. }else {
  94. self.showError(title: "当前文件类型不支持预览!")
  95. }
  96. }
  97. @objc private func toUpdateMeeting() {
  98. if let meeting = self.meetingInfo {
  99. self.performSegue(withIdentifier: "showEditMeetingNew", sender: meeting)
  100. }
  101. }
  102. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  103. if segue.identifier == "showEditMeetingNew" {
  104. if let vc = segue.destination as? OOMeetingFormViewController {
  105. if let meeting = sender as? OOMeetingInfo {
  106. vc.meetingInfo = meeting
  107. vc.fromDetail = true
  108. }
  109. }
  110. }
  111. }
  112. }
  113. extension OOMeetingDetailViewController: PersonListCellDelegate {
  114. func clickAccept(_ completedBlock: @escaping () -> Void) {
  115. if let meeting = self.meetingInfo {
  116. self.viewModel.acceptMeeting(meetingId: meeting.id!) { (err) in
  117. if let message = err {
  118. self.showError(title: message)
  119. }else {
  120. completedBlock()
  121. }
  122. }
  123. }
  124. }
  125. func clickReject(_ completedBlock: @escaping () -> Void) {
  126. if let meeting = self.meetingInfo {
  127. self.showDefaultConfirm(title: "提示", message: "确定要拒绝当前会议邀请?") { (action) in
  128. self.viewModel.rejectMeeting(meetingId: meeting.id!) { (err) in
  129. if let message = err {
  130. self.showError(title: message)
  131. }else {
  132. completedBlock()
  133. }
  134. }
  135. }
  136. }
  137. }
  138. }