CellViewModel.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // CellViewModel.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 16/7/13.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import Foundation
  9. import ObjectMapper
  10. enum ContactDataType {
  11. case company(AnyObject)
  12. case depart(AnyObject)
  13. case group(AnyObject)
  14. case person(AnyObject)
  15. case identity(AnyObject)
  16. case title(AnyObject)
  17. }
  18. class CellViewModel {
  19. var name:String?
  20. var openFlag = true
  21. var dataType:ContactDataType
  22. init(name:String?,sourceObject:AnyObject){
  23. self.name = name
  24. if sourceObject.isKind(of: Company.self) {
  25. self.dataType = .company(sourceObject)
  26. }else if sourceObject.isKind(of: Department.self){
  27. self.dataType = .depart(sourceObject)
  28. }else if sourceObject.isKind(of: OrgUnit.self) {
  29. self.dataType = .depart(sourceObject)
  30. let unit = sourceObject as! OrgUnit
  31. if (unit.subDirectUnitCount + unit.subDirectIdentityCount) == 0 {
  32. openFlag = false
  33. }
  34. }else if sourceObject.isKind(of: Person.self) {
  35. self.dataType = .person(sourceObject)
  36. }else if sourceObject.isKind(of: PersonV2.self) {
  37. self.dataType = .person(sourceObject)
  38. }else if sourceObject.isKind(of: Identity.self) {
  39. self.dataType = .identity(sourceObject)
  40. }else if sourceObject.isKind(of: IdentityV2.self) {
  41. self.dataType = .identity(sourceObject)
  42. }else if sourceObject.isKind(of: HeadTitle.self) {
  43. self.dataType = .title(sourceObject)
  44. openFlag = false
  45. }else{
  46. self.dataType = .group(sourceObject)
  47. }
  48. }
  49. }