Snat.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :single-actions="singleActions"
  6. :group-actions="groupActions" />
  7. </template>
  8. <script>
  9. import {
  10. getCopyWithContentTableColumn,
  11. getStatusTableColumn,
  12. } from '@/utils/common/tableColumn'
  13. import expectStatus from '@/constants/expectStatus'
  14. import ListMixin from '@/mixins/list'
  15. import DialogMixin from '@/mixins/dialog'
  16. import WindowsMixin from '@/mixins/windows'
  17. import { checkReadOnly } from '../utils'
  18. export default {
  19. name: 'SNatList',
  20. mixins: [DialogMixin, WindowsMixin, ListMixin],
  21. props: {
  22. resId: {
  23. type: String,
  24. required: true,
  25. },
  26. data: {
  27. type: Object,
  28. required: true,
  29. },
  30. },
  31. data () {
  32. const validate = (this.data.status === 'available')
  33. return {
  34. list: this.$list.createList(this, {
  35. id: 'SNatListForNatSidePage',
  36. resource: 'natsentries',
  37. getParams: {
  38. natgateway: this.resId,
  39. },
  40. filterOptions: {
  41. name: {
  42. label: this.$t('network.text_21'),
  43. filter: true,
  44. formatter: val => {
  45. return `name.contains("${val}")`
  46. },
  47. },
  48. },
  49. steadyStatus: Object.values(expectStatus.nat).flat(),
  50. }),
  51. columns: [
  52. getCopyWithContentTableColumn({
  53. field: 'name',
  54. title: this.$t('network.text_564'),
  55. }),
  56. {
  57. field: 'ip',
  58. title: this.$t('network.text_539'),
  59. },
  60. {
  61. field: 'network',
  62. title: this.$t('network.snat.cidr'),
  63. formatter: ({ row }) => {
  64. if (row.network) {
  65. return this.$t('network.text_566', [row.network.name, row.network.guest_ip_start, row.network.guest_ip_end])
  66. }
  67. if (row.source_cidr) {
  68. return row.source_cidr
  69. }
  70. return '-'
  71. },
  72. },
  73. getStatusTableColumn({ statusModule: 'nat' }),
  74. ],
  75. groupActions: [
  76. {
  77. label: this.$t('network.text_26'),
  78. permission: 'natsentry_create',
  79. action: () => {
  80. this.createDialog('SNatCreateDialog', {
  81. title: this.$t('network.text_567'),
  82. data: this.data,
  83. columns: this.columns,
  84. onManager: this.onManager,
  85. })
  86. },
  87. meta: () => {
  88. const ret = checkReadOnly(this.data, this.$t('network.text_26'))
  89. if (!ret.validate) return ret
  90. return {
  91. buttonType: 'primary',
  92. validate,
  93. tooltip: validate ? '' : this.$t('network.nat.status.unavailable.tooltip'),
  94. }
  95. },
  96. },
  97. {
  98. label: this.$t('network.text_131'),
  99. action: () => {
  100. this.createDialog('DeleteResDialog', {
  101. vm: this,
  102. data: this.list.selectedItems,
  103. columns: this.columns,
  104. title: this.$t('network.text_568'),
  105. onManager: this.onManager,
  106. name: this.$t('network.text_569'),
  107. alert: this.$t('network.text_563'),
  108. })
  109. },
  110. meta: () => {
  111. const ret = checkReadOnly(this.data, this.$t('network.text_131'))
  112. if (!ret.validate) return ret
  113. return {
  114. validate: this.list.allowDelete(),
  115. }
  116. },
  117. },
  118. ],
  119. singleActions: [
  120. {
  121. label: this.$t('network.text_131'),
  122. action: (obj) => {
  123. this.createDialog('DeleteResDialog', {
  124. vm: this,
  125. title: this.$t('network.text_568'),
  126. data: [obj],
  127. columns: this.columns,
  128. onManager: this.onManager,
  129. name: this.$t('network.text_569'),
  130. alert: this.$t('network.text_563'),
  131. })
  132. },
  133. meta: (obj) => {
  134. return checkReadOnly(this.data, this.$t('network.text_131'))
  135. },
  136. },
  137. ],
  138. }
  139. },
  140. created () {
  141. this.list.fetchData()
  142. },
  143. }
  144. </script>