Detail.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <detail
  3. :data="data"
  4. :base-info="baseInfo"
  5. :extra-info="extraInfo"
  6. :on-manager="onManager"
  7. :hiddenKeys="hiddenKeys"
  8. status-module="commonalert"
  9. :resource="resource"
  10. :showName="false" />
  11. </template>
  12. <script>
  13. import WindowsMixin from '@/mixins/windows'
  14. import { getCopyWithContentTableColumn, getBrandTableColumn, getStatusTableColumn } from '@/utils/common/tableColumn'
  15. import { strategyColumn } from '@Monitor/views/commonalert/utils'
  16. export default {
  17. name: 'AlertResourceDetail',
  18. mixins: [WindowsMixin],
  19. props: {
  20. data: {
  21. type: Object,
  22. required: true,
  23. },
  24. onManager: {
  25. type: Function,
  26. required: true,
  27. },
  28. resource: String,
  29. },
  30. data () {
  31. return {
  32. baseInfo: [
  33. // projectTableColumn,
  34. // getProjectTableColumn(),
  35. getCopyWithContentTableColumn(),
  36. getCopyWithContentTableColumn({ field: 'ip', title: 'IP' }),
  37. getBrandTableColumn(),
  38. getCopyWithContentTableColumn({ field: 'cloudregion', title: this.$t('dictionary.cloudregion') }),
  39. getCopyWithContentTableColumn({ field: 'zone', title: this.$t('dictionary.zone') }),
  40. ],
  41. extraInfo: [
  42. {
  43. title: this.$t('monitor.associate_alarm_strategy'),
  44. field: 'strategy',
  45. slots: {
  46. default: ({ row }, h) => {
  47. return [
  48. <vxe-grid class="mb-2" data={ this.alertList } columns={ this.alertColumns } />,
  49. ]
  50. },
  51. },
  52. },
  53. ],
  54. hiddenKeys: ['status'],
  55. alertList: [],
  56. alertColumns: [
  57. getCopyWithContentTableColumn({ field: 'alert_name' }),
  58. strategyColumn('alert_rule'),
  59. getStatusTableColumn({ field: 'alert_state', statusModule: 'alertresource' }),
  60. {
  61. field: 'metric',
  62. title: this.$t('monitor.monitor_metric'),
  63. },
  64. {
  65. field: '_option',
  66. title: this.$t('table.title._action'),
  67. slots: {
  68. default: ({ row }, h) => {
  69. return [<a-button type='link' onClick={e => this.goMonitor(row)}>{ this.$t('monitor.view_monitor')}</a-button>]
  70. },
  71. },
  72. },
  73. ],
  74. }
  75. },
  76. created () {
  77. this.getAlerts()
  78. },
  79. methods: {
  80. async getAlerts () {
  81. try {
  82. const { data: { data: list } } = await new this.$Manager('monitorresourcealerts', 'v1')
  83. .list({
  84. params: {
  85. scope: this.$store.getters.scope,
  86. limit: 0,
  87. all_state: true,
  88. monitor_resource_id: this.data.id,
  89. },
  90. })
  91. this.alertList = list
  92. } catch (error) {
  93. console.error(error)
  94. return []
  95. }
  96. },
  97. goMonitor (data) {
  98. this.createDialog('ViewMonitorDialog', {
  99. vm: this,
  100. title: this.$t('common.view_action', [this.$t('monitor.text_0')]),
  101. columns: this.columns,
  102. onManager: this.onManager,
  103. data: [data],
  104. })
  105. },
  106. },
  107. }
  108. </script>