Detail.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <detail
  3. :onManager="onManager"
  4. :data="data"
  5. :base-info="baseInfo"
  6. :extra-info="extraInfo"
  7. :hiddenKeys="['external_id', 'type', 'project_domain', 'tenant', 'status']"
  8. :show-name="false"
  9. :show-desc="false"
  10. :is-edit-name="!data.is_system"
  11. :is-edit-desc="!data.is_system" />
  12. </template>
  13. <script>
  14. import WindowsMixin from '@/mixins/windows'
  15. import ColumnsMixin from '../mixins/columns'
  16. import { NOTIFY_TOPIC_NAMES_MAP, NOTIFY_TOPIC_TYPES_MAP } from '@IAM/constants'
  17. import { getEnabledTableColumn } from '@/utils/common/tableColumn'
  18. export default {
  19. name: 'TopicDetail',
  20. mixins: [WindowsMixin, ColumnsMixin],
  21. props: {
  22. data: {
  23. type: Object,
  24. required: true,
  25. },
  26. onManager: {
  27. type: Function,
  28. required: true,
  29. },
  30. },
  31. data () {
  32. return {
  33. baseInfo: [
  34. {
  35. field: 'name',
  36. title: this.$t('system.notify.topic.name'),
  37. formatter: ({ row }) => {
  38. return NOTIFY_TOPIC_NAMES_MAP[row.name] || row.name || '-'
  39. },
  40. },
  41. {
  42. field: 'topic-type',
  43. title: this.$t('system.notify.topic.type'),
  44. formatter: ({ row }) => {
  45. return NOTIFY_TOPIC_TYPES_MAP[row.type] ? NOTIFY_TOPIC_TYPES_MAP[row.type].label : '-'
  46. },
  47. },
  48. getEnabledTableColumn(),
  49. ],
  50. extraInfo: [
  51. {
  52. title: this.$t('system.notify.topic.resources'),
  53. items: [
  54. {
  55. field: 'resource_types',
  56. title: this.$t('scope.text_653'),
  57. slots: {
  58. default: ({ row }) => {
  59. if (!row.resource_types) return []
  60. const ret = []
  61. for (const r of row.resource_types) {
  62. ret.push(<div>{this.$t(`dictionary.${r}`)}</div>)
  63. }
  64. return ret
  65. },
  66. },
  67. },
  68. ],
  69. },
  70. {
  71. title: this.$t('iam.notify_time'),
  72. items: [
  73. {
  74. field: 'advance_days',
  75. title: this.$t('iam.notify_time'),
  76. slots: {
  77. default: ({ row }) => {
  78. const { advance_days = [] } = row
  79. if (!advance_days.length) return '-'
  80. const ret = []
  81. if (advance_days.length === 1) {
  82. ret.push(<span>{this.$t('iam.notify_one_day', [this.$t('iam.notify_time.some_day', [advance_days[0]])])}</span>)
  83. } else {
  84. const dayList = []
  85. advance_days.map(day => {
  86. dayList.push(this.$t('iam.notify_time.some_day', [day]))
  87. })
  88. ret.push(<span>{this.$t('iam.notify_some_day', [dayList.join('、')])}</span>)
  89. }
  90. ret.push(<a-icon type='edit' class='edit-icon primary-color ml-2' onclick={this.updateNotifyTime} />)
  91. return ret
  92. },
  93. },
  94. },
  95. ],
  96. hidden: () => !['resource release', 'password expire'].includes(this.data.name),
  97. },
  98. ],
  99. }
  100. },
  101. methods: {
  102. updateNotifyTime () {
  103. this.createDialog('NotifyTopicUpdateTimeDialog', {
  104. onManager: this.onManager,
  105. data: [this.data],
  106. columns: this.columns,
  107. })
  108. },
  109. },
  110. }
  111. </script>
  112. <style scoped>
  113. </style>