Detail.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <detail
  3. :data="data"
  4. :base-info="baseInfo"
  5. :extra-info="extraInfo"
  6. :on-manager="onManager"
  7. :hiddenKeys="hiddenKeys"
  8. :nameRules="nameRules"
  9. status-module="commonalert"
  10. :resource="resource" />
  11. </template>
  12. <script>
  13. import { getEnabledTableColumn, getProjectTableColumn } from '@/utils/common/tableColumn'
  14. import {
  15. levelColumn,
  16. strategyColumn,
  17. projectTableColumn,
  18. recipientsColumn,
  19. getResTypeColumn,
  20. getVerifiedContactTypesTableColumn,
  21. robotsColumn,
  22. rolesColumn,
  23. reasonColumn,
  24. } from '../utils'
  25. export default {
  26. name: 'CommonalertDetail',
  27. props: {
  28. data: {
  29. type: Object,
  30. required: true,
  31. },
  32. onManager: {
  33. type: Function,
  34. required: true,
  35. },
  36. resource: String,
  37. },
  38. data () {
  39. return {
  40. baseInfo: [
  41. getResTypeColumn(),
  42. projectTableColumn(),
  43. getEnabledTableColumn(),
  44. levelColumn(),
  45. getProjectTableColumn(),
  46. getVerifiedContactTypesTableColumn({ vm: this }),
  47. {
  48. field: 'disable_notify_recovery',
  49. title: this.$t('monitor.commonalerts.disable_notify_recovery'),
  50. formatter: ({ row }) => {
  51. return row.disable_notify_recovery ? this.$t('common.true') : this.$t('common.false')
  52. },
  53. },
  54. ],
  55. extraInfo: [
  56. {
  57. title: this.$t('monitor.commonalert.alarm_strategy'),
  58. items: [
  59. strategyColumn(),
  60. reasonColumn(),
  61. ],
  62. },
  63. ],
  64. hiddenKeys: ['project_domain', 'tenant'],
  65. nameRules: [{ required: true, message: `${this.$t('common.placeholder')}${this.$t('common.name')}` }],
  66. }
  67. },
  68. created () {
  69. this.getRobots()
  70. this.getRecipients()
  71. this.getRoles()
  72. },
  73. methods: {
  74. async getRecipients () {
  75. try {
  76. const { data: { data: recipientList } } = await new this.$Manager('receivers', 'v1')
  77. .list({
  78. params: {
  79. scope: this.$store.getters.scope,
  80. with_meta: true,
  81. limit: 0,
  82. project_domain_filter: true,
  83. },
  84. })
  85. this.baseInfo.push(recipientsColumn(recipientList))
  86. } catch (error) {
  87. console.error(error)
  88. return []
  89. }
  90. },
  91. async getRobots () {
  92. try {
  93. const { data: { data: robotList } } = await new this.$Manager('robots', 'v1')
  94. .list({
  95. params: {
  96. scope: this.$store.getters.scope,
  97. with_meta: true,
  98. limit: 0,
  99. },
  100. })
  101. this.baseInfo.push(robotsColumn(robotList))
  102. } catch (error) {
  103. console.error(error)
  104. return []
  105. }
  106. },
  107. async getRoles () {
  108. try {
  109. const { data: { data: roleList } } = await new this.$Manager('roles', 'v1')
  110. .list({
  111. params: {
  112. scope: this.$store.getters.scope,
  113. limit: 0,
  114. },
  115. })
  116. this.baseInfo.push(rolesColumn(roleList))
  117. } catch (error) {
  118. console.error(error)
  119. return []
  120. }
  121. },
  122. },
  123. }
  124. </script>