Dnat.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. getStatusTableColumn,
  11. getCopyWithContentTableColumn,
  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: 'DNatList',
  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: 'DNatListForNatSidePage',
  36. resource: 'natdentries',
  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_557'),
  55. }),
  56. getCopyWithContentTableColumn({
  57. field: 'external_ip',
  58. title: this.$t('network.text_539'),
  59. }),
  60. {
  61. field: 'external_port',
  62. title: this.$t('network.text_544'),
  63. width: 80,
  64. },
  65. getCopyWithContentTableColumn({
  66. field: 'internal_ip',
  67. title: this.$t('network.text_558'),
  68. }),
  69. {
  70. field: 'ip_protocol',
  71. title: this.$t('network.text_547'),
  72. width: 80,
  73. },
  74. {
  75. field: 'internal_port',
  76. title: this.$t('network.text_559'),
  77. width: 80,
  78. },
  79. getStatusTableColumn({ statusModule: 'nat' }),
  80. ],
  81. groupActions: [
  82. {
  83. label: this.$t('network.text_26'),
  84. permission: 'natdentry_create',
  85. action: () => {
  86. this.createDialog('DNatCreateDialog', {
  87. title: this.$t('network.text_560'),
  88. data: this.data,
  89. columns: this.columns,
  90. onManager: this.onManager,
  91. })
  92. },
  93. meta: () => {
  94. const ret = checkReadOnly(this.data, this.$t('network.text_26'))
  95. if (!ret.validate) return ret
  96. return {
  97. buttonType: 'primary',
  98. validate,
  99. tooltip: validate ? '' : this.$t('network.nat.status.unavailable.tooltip'),
  100. }
  101. },
  102. },
  103. {
  104. label: this.$t('network.text_131'),
  105. action: () => {
  106. this.createDialog('DeleteResDialog', {
  107. vm: this,
  108. data: this.list.selectedItems,
  109. columns: this.columns,
  110. title: this.$t('network.text_561'),
  111. onManager: this.onManager,
  112. name: this.$t('network.text_562'),
  113. alert: this.$t('network.text_563'),
  114. })
  115. },
  116. meta: () => {
  117. const ret = checkReadOnly(this.data, this.$t('network.text_131'))
  118. if (!ret.validate) return ret
  119. return {
  120. validate: this.list.allowDelete(),
  121. }
  122. },
  123. },
  124. ],
  125. singleActions: [
  126. {
  127. label: this.$t('network.text_131'),
  128. action: (obj) => {
  129. this.createDialog('DeleteResDialog', {
  130. vm: this,
  131. title: this.$t('network.text_561'),
  132. data: [obj],
  133. columns: this.columns,
  134. onManager: this.onManager,
  135. name: this.$t('network.text_562'),
  136. alert: this.$t('network.text_563'),
  137. })
  138. },
  139. meta: (obj) => {
  140. return checkReadOnly(this.data, this.$t('network.text_131'))
  141. },
  142. },
  143. ],
  144. }
  145. },
  146. created () {
  147. this.list.fetchData()
  148. },
  149. }
  150. </script>