ConvertToTicket.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ $t('monitor.convert_to_ticket') }}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :count="params.data.length" :action="$t('monitor.convert_to_ticket')" :name="$t('monitor.text_17')" />
  6. <dialog-table v-if="params.columns && params.columns.length" :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form-model ref="form" :model="form" :rules="rules" v-bind="formItemLayout">
  8. <a-form-model-item :label="$t('monitor.alert_ticket_type')">
  9. <a-radio-group v-model="form.ticket_type">
  10. <template v-if="params.enabledKeys.includes('alert-event')">
  11. <a-tooltip v-if="!params.activeKeys.includes('alert-event')" :title="$t('monitor.convert_to_ticket.alert_event_disabled_tip')">
  12. <a-radio-button :disabled="true" value="alert-event">{{ $t('monitor.alert_ticket_type.alert_event') }}</a-radio-button>
  13. </a-tooltip>
  14. <a-radio-button v-else value="alert-event">{{ $t('monitor.alert_ticket_type.alert_event') }}</a-radio-button>
  15. </template>
  16. <template v-if="params.enabledKeys.includes('alert-ticket')">
  17. <a-tooltip v-if="!params.activeKeys.includes('alert-ticket')" :title="$t('monitor.convert_to_ticket.alert_ticket_disabled_tip')">
  18. <a-radio-button :disabled="true" value="alert-ticket">{{ $t('monitor.alert_ticket_type.alert_ticket') }}</a-radio-button>
  19. </a-tooltip>
  20. <a-radio-button v-else value="alert-ticket">{{ $t('monitor.alert_ticket_type.alert_ticket') }}</a-radio-button>
  21. </template>
  22. </a-radio-group>
  23. </a-form-model-item>
  24. </a-form-model>
  25. </div>
  26. <div slot="footer">
  27. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t("dialog.ok") }}</a-button>
  28. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  29. </div>
  30. </base-dialog>
  31. </template>
  32. <script>
  33. import DialogMixin from '@/mixins/dialog'
  34. import WindowsMixin from '@/mixins/windows'
  35. export default {
  36. name: 'AlertResourceConvertToTicketDialog',
  37. components: {
  38. },
  39. mixins: [DialogMixin, WindowsMixin],
  40. data () {
  41. return {
  42. loading: false,
  43. formItemLayout: {
  44. wrapperCol: {
  45. span: 20,
  46. },
  47. labelCol: {
  48. span: 4,
  49. },
  50. },
  51. form: {
  52. ticket_type: this.params.activeKeys[0],
  53. },
  54. }
  55. },
  56. computed: {
  57. },
  58. created () {
  59. this.$mT = new this.$Manager('monitorresources')
  60. },
  61. methods: {
  62. async handleConfirm () {
  63. this.loading = true
  64. try {
  65. await this.$mT.performAction({
  66. id: this.params.data[0].monitor_resource_object_id,
  67. action: 'do-action',
  68. data: {
  69. action: 'sync-process-instance',
  70. data: {
  71. definition_key: this.form.ticket_type,
  72. alert_id: this.params.data[0].alert_id,
  73. metric: this.params.data[0].metric,
  74. },
  75. },
  76. })
  77. this.params.refresh()
  78. this.cancelDialog()
  79. } finally {
  80. this.loading = false
  81. }
  82. },
  83. },
  84. }
  85. </script>