singleActions.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import { mapGetters } from 'vuex'
  2. import { isCE } from '@/utils/utils'
  3. export default {
  4. computed: {
  5. ...mapGetters(['workflow']),
  6. },
  7. created () {
  8. this.singleActions = [
  9. {
  10. label: this.$t('monitor.convert_to_ticket'),
  11. action: (obj) => {
  12. const activeKeys = []
  13. const enabledKeys = []
  14. if ((this.workflow.enabledKeys || []).includes('alert-event')) {
  15. enabledKeys.push('alert-event')
  16. if (!obj.alert_event_instance_id) {
  17. activeKeys.push('alert-event')
  18. }
  19. }
  20. if ((this.workflow.enabledKeys || []).includes('alert-ticket')) {
  21. enabledKeys.push('alert-ticket')
  22. if (!obj.alert_ticket_instance_id) {
  23. activeKeys.push('alert-ticket')
  24. }
  25. }
  26. this.createDialog('AlertResourceConvertToTicketDialog', {
  27. vm: this,
  28. data: [obj],
  29. columns: this.columns,
  30. onManager: this.onManager,
  31. activeKeys,
  32. enabledKeys,
  33. refresh: this.refresh,
  34. })
  35. },
  36. meta: (obj) => {
  37. const activeKeys = []
  38. const enabledKeys = []
  39. if ((this.workflow.enabledKeys || []).includes('alert-event')) {
  40. enabledKeys.push('alert-event')
  41. if (!obj.alert_event_instance_id) {
  42. activeKeys.push('alert-event')
  43. }
  44. }
  45. if ((this.workflow.enabledKeys || []).includes('alert-ticket')) {
  46. enabledKeys.push('alert-ticket')
  47. if (!obj.alert_ticket_instance_id) {
  48. activeKeys.push('alert-ticket')
  49. }
  50. }
  51. return {
  52. validate: activeKeys.length !== 0,
  53. tooltip: this.$t('monitor.converted_ticket'),
  54. }
  55. },
  56. hidden: (obj) => {
  57. if (isCE() || this.$store.getters.isSysCE) return true
  58. if (!(this.workflow.enabledKeys || []).includes('alert-event') && !(this.workflow.enabledKeys || []).includes('alert-ticket')) return true
  59. return false
  60. },
  61. },
  62. {
  63. label: this.$t('common.view_action', [this.$t('monitor.text_0')]),
  64. action: (obj) => {
  65. if (obj.data) {
  66. obj.eval_data = [obj.data]
  67. }
  68. this.createDialog('ViewMonitorDialog', {
  69. vm: this,
  70. title: this.$t('common.view_action', [this.$t('monitor.text_0')]),
  71. columns: this.columns,
  72. onManager: this.onManager,
  73. data: [obj],
  74. })
  75. },
  76. },
  77. {
  78. label: this.$t('monitor.alerts.shield.shield'),
  79. permission: 'alertrecordshields_create',
  80. action: (obj) => {
  81. this.createDialog('ShieldAlertrecord', {
  82. vm: this,
  83. columns: this.columns,
  84. onManager: this.onManager,
  85. refresh: this.refresh,
  86. data: [obj],
  87. })
  88. },
  89. meta: (obj) => {
  90. const ret = {
  91. validate: true,
  92. }
  93. if (obj.is_set_shield === true) {
  94. return {
  95. validate: false,
  96. tooltip: this.$t('monitor.alerts.shield.tips2'),
  97. }
  98. }
  99. return ret
  100. },
  101. },
  102. ]
  103. },
  104. }