Detail.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <detail
  3. :onManager="onManager"
  4. :data="data"
  5. :base-info="baseInfo"
  6. :extraInfo="extraInfo"
  7. :hiddenKeys="['project_domain', 'tenant', 'status', 'updated_at']"
  8. :show-desc="false" />
  9. </template>
  10. <script>
  11. import { contactMap } from '@/constants'
  12. import {
  13. getEnabledTableColumn,
  14. } from '@/utils/common/tableColumn'
  15. import {
  16. getMobileTableColumn,
  17. getEmailTableColumn,
  18. } from '../utils/columns'
  19. import { getNote } from '../utils/index'
  20. import ColumnsMixin from '../mixins/columns'
  21. import CommonMixin from '../mixins/common'
  22. export default {
  23. name: 'ContactDetail',
  24. mixins: [CommonMixin, ColumnsMixin],
  25. props: {
  26. data: {
  27. type: Object,
  28. required: true,
  29. },
  30. onManager: {
  31. type: Function,
  32. required: true,
  33. },
  34. },
  35. data () {
  36. return {
  37. contactMap: contactMap,
  38. }
  39. },
  40. computed: {
  41. contactTypes () {
  42. if (this.data && this.data.enabled_contact_types) {
  43. const contactTypes = []
  44. this.data.enabled_contact_types.forEach((type) => {
  45. const item = this.data.verified_infos.find(obj => obj.contact_type === type)
  46. contactTypes.push(item)
  47. })
  48. return contactTypes
  49. }
  50. return []
  51. },
  52. baseInfo () {
  53. return [
  54. getEnabledTableColumn(),
  55. getMobileTableColumn(),
  56. getEmailTableColumn(),
  57. ]
  58. },
  59. extraInfo () {
  60. return [
  61. {
  62. title: this.$t('system.notify_channels'),
  63. slots: {
  64. default: ({ row }, h) => {
  65. const items = this.contactTypes.map((obj) => {
  66. return (
  67. <div key={obj.contact_type} class="col-12">
  68. <div class="row">
  69. <span style="width: 100px" class="mt-2 ml-4 mb-2">{contactMap[obj.contact_type].label}</span>
  70. <span style={ { color: this.getColor(obj) } } class="mt-2 mb-2">
  71. {this.getTitle(obj, obj.contact_type)}
  72. </span>
  73. </div>
  74. </div>
  75. )
  76. })
  77. return (
  78. <div class="row"> { items } </div>
  79. )
  80. },
  81. },
  82. },
  83. ]
  84. },
  85. },
  86. methods: {
  87. getColor (obj) {
  88. if (!obj.verified) {
  89. if (obj.note) {
  90. return '#d9001b'
  91. } else {
  92. return '#F59A23'
  93. }
  94. } else {
  95. return '#70b603'
  96. }
  97. },
  98. handleVerify () {
  99. const r = this.$router.resolve('/user')
  100. window.open(r.href, '_blank')
  101. },
  102. getTitle (obj, type) {
  103. let msg = ''
  104. if (!obj.verified) {
  105. msg = getNote(obj.note)
  106. } else {
  107. msg = obj.verified ? this.$t('status.verified.true') : this.$t('status.verified.false')
  108. }
  109. return msg
  110. },
  111. },
  112. }
  113. </script>