singleActions.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. import { typeClouds } from '@/utils/common/hypervisor'
  2. import i18n from '@/locales'
  3. const supportChangeBandwidth = ['huawei', 'baidu', 'aliyun', 'ucloud', 'qcloud', 'ctyun']
  4. export default {
  5. created () {
  6. this.singleActions = [
  7. {
  8. label: i18n.t('network.text_220'),
  9. permission: 'eips_perform_change_bandwidth',
  10. action: (obj) => {
  11. this.createDialog('EipUpdateDialog', {
  12. data: [obj],
  13. columns: this.columns,
  14. onManager: this.onManager,
  15. })
  16. },
  17. meta: (obj) => {
  18. if (!obj.associate_name) {
  19. return {
  20. validate: false,
  21. tooltip: i18n.t('network.text_222'),
  22. }
  23. }
  24. const { brand } = obj
  25. if (brand && !supportChangeBandwidth.includes(brand.toLowerCase())) {
  26. return {
  27. validate: false,
  28. tooltip: i18n.t('network.text_223', [typeClouds.getHosttype()[brand.toLowerCase()].label]),
  29. }
  30. }
  31. return {
  32. validate: true,
  33. }
  34. },
  35. },
  36. {
  37. label: i18n.t('network.text_129'),
  38. actions: obj => {
  39. return [
  40. {
  41. label: i18n.t('network.text_202'),
  42. permission: 'eips_perform_associate',
  43. action: () => {
  44. this.createDialog('EipBindServerDialog', {
  45. data: [obj],
  46. columns: this.columns,
  47. onManager: this.onManager,
  48. refresh: this.refresh,
  49. })
  50. },
  51. meta: () => {
  52. return {
  53. validate: !obj.associate_id && obj.status === 'ready',
  54. }
  55. },
  56. },
  57. {
  58. label: i18n.t('network.text_219'),
  59. permission: 'eips_perform_dissociate',
  60. action: () => {
  61. this.createDialog('EipUntieServerDialog', {
  62. data: [obj],
  63. columns: this.columns,
  64. onManager: this.onManager,
  65. refresh: this.refresh,
  66. })
  67. },
  68. meta: () => {
  69. if (obj.brand === 'Aws' && obj.associate_type === 'natgateway') {
  70. return {
  71. validate: false,
  72. tooltip: this.$t('common.check_readonly', ['Aws', i18n.t('network.unbind_net_gateway')]),
  73. }
  74. }
  75. if (obj.mode === 'public_ip' && obj.associate_id) {
  76. }
  77. if (obj.associate_id) {
  78. if (obj.mode === 'public_ip') {
  79. return {
  80. validate: false,
  81. tooltip: this.$t('network.public_ip_donot_disassociate'),
  82. }
  83. }
  84. return {
  85. validate: true,
  86. }
  87. }
  88. return {
  89. validate: false,
  90. }
  91. },
  92. },
  93. {
  94. label: i18n.t('network.text_201'),
  95. permission: 'eips_perform_syncstatus',
  96. action: () => {
  97. this.onManager('performAction', {
  98. steadyStatus: ['running', 'ready'],
  99. id: obj.id,
  100. managerArgs: {
  101. action: 'syncstatus',
  102. },
  103. })
  104. },
  105. meta: () => ({
  106. validate: true,
  107. }),
  108. },
  109. {
  110. label: i18n.t('network.text_225', [i18n.t('dictionary.project')]),
  111. permission: 'eips_perform_change_owner',
  112. action: () => {
  113. this.createDialog('ChangeOwenrDialog', {
  114. data: [obj],
  115. columns: this.columns,
  116. name: this.$t('dictionary.eip'),
  117. onManager: this.onManager,
  118. resource: 'eips',
  119. refresh: this.refresh,
  120. })
  121. },
  122. meta: () => {
  123. const ret = {
  124. validate: false,
  125. tooltip: '',
  126. }
  127. if (this.isProjectMode) {
  128. ret.tooltip = i18n.t('common_601')
  129. return ret
  130. }
  131. return {
  132. validate: true,
  133. }
  134. },
  135. },
  136. {
  137. label: i18n.t('network.text_131'),
  138. permission: 'eips_delete',
  139. action: () => {
  140. this.createDialog('DeleteResDialog', {
  141. vm: this,
  142. data: [obj],
  143. columns: this.columns,
  144. title: i18n.t('network.text_131'),
  145. name: this.$t('dictionary.eip'),
  146. onManager: this.onManager,
  147. })
  148. },
  149. meta: () => this.$getDeleteResult(obj),
  150. },
  151. ]
  152. },
  153. },
  154. ]
  155. },
  156. }