| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <template>
- <detail
- :data="data"
- :base-info="baseInfo"
- :extra-info="extraInfo"
- :on-manager="onManager"
- :hiddenKeys="hiddenKeys"
- status-module="commonalert"
- :resource="resource"
- :showName="false" />
- </template>
- <script>
- import WindowsMixin from '@/mixins/windows'
- import { getCopyWithContentTableColumn, getBrandTableColumn, getStatusTableColumn } from '@/utils/common/tableColumn'
- import { strategyColumn } from '@Monitor/views/commonalert/utils'
- export default {
- name: 'AlertResourceDetail',
- mixins: [WindowsMixin],
- props: {
- data: {
- type: Object,
- required: true,
- },
- onManager: {
- type: Function,
- required: true,
- },
- resource: String,
- },
- data () {
- return {
- baseInfo: [
- // projectTableColumn,
- // getProjectTableColumn(),
- getCopyWithContentTableColumn(),
- getCopyWithContentTableColumn({ field: 'ip', title: 'IP' }),
- getBrandTableColumn(),
- getCopyWithContentTableColumn({ field: 'cloudregion', title: this.$t('dictionary.cloudregion') }),
- getCopyWithContentTableColumn({ field: 'zone', title: this.$t('dictionary.zone') }),
- ],
- extraInfo: [
- {
- title: this.$t('monitor.associate_alarm_strategy'),
- field: 'strategy',
- slots: {
- default: ({ row }, h) => {
- return [
- <vxe-grid class="mb-2" data={ this.alertList } columns={ this.alertColumns } />,
- ]
- },
- },
- },
- ],
- hiddenKeys: ['status'],
- alertList: [],
- alertColumns: [
- getCopyWithContentTableColumn({ field: 'alert_name' }),
- strategyColumn('alert_rule'),
- getStatusTableColumn({ field: 'alert_state', statusModule: 'alertresource' }),
- {
- field: 'metric',
- title: this.$t('monitor.monitor_metric'),
- },
- {
- field: '_option',
- title: this.$t('table.title._action'),
- slots: {
- default: ({ row }, h) => {
- return [<a-button type='link' onClick={e => this.goMonitor(row)}>{ this.$t('monitor.view_monitor')}</a-button>]
- },
- },
- },
- ],
- }
- },
- created () {
- this.getAlerts()
- },
- methods: {
- async getAlerts () {
- try {
- const { data: { data: list } } = await new this.$Manager('monitorresourcealerts', 'v1')
- .list({
- params: {
- scope: this.$store.getters.scope,
- limit: 0,
- all_state: true,
- monitor_resource_id: this.data.id,
- },
- })
- this.alertList = list
- } catch (error) {
- console.error(error)
- return []
- }
- },
- goMonitor (data) {
- this.createDialog('ViewMonitorDialog', {
- vm: this,
- title: this.$t('common.view_action', [this.$t('monitor.text_0')]),
- columns: this.columns,
- onManager: this.onManager,
- data: [data],
- })
- },
- },
- }
- </script>
|