RouteSet.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions" />
  7. </template>
  8. <script>
  9. import WindowsMixin from '@/mixins/windows'
  10. import ListMixin from '@/mixins/list'
  11. import {
  12. getCopyWithContentTableColumn,
  13. getStatusTableColumn,
  14. } from '@/utils/common/tableColumn'
  15. import {
  16. NEXT_HOP_TYPES_MAP,
  17. TYPES_MAP,
  18. } from '../constants'
  19. export default {
  20. name: 'RouteSetListForRouteTableSidePage',
  21. mixins: [WindowsMixin, ListMixin],
  22. props: {
  23. resId: String,
  24. data: {
  25. type: Object,
  26. required: true,
  27. },
  28. },
  29. data () {
  30. return {
  31. list: this.$list.createList(this, {
  32. id: 'routeSetListForVpcNetworkSidePage',
  33. resource: 'route_table_route_sets',
  34. getParams: { details: true, route_table_id: this.resId },
  35. filterOptions: {
  36. cidr: {
  37. label: this.$t('network.vpc_network.target_address'),
  38. },
  39. },
  40. }),
  41. columns: [
  42. getCopyWithContentTableColumn({
  43. field: 'cidr',
  44. title: this.$t('network.vpc.cidr_block.ipv4.label'),
  45. sortable: true,
  46. }),
  47. getStatusTableColumn({ statusModule: 'routeSet' }),
  48. {
  49. field: 'next_hop_id',
  50. title: this.$t('network.vpc_network.next_hop'),
  51. slots: {
  52. default: ({ row }) => {
  53. return row.next_hop_id || row.ext_next_hop_id
  54. },
  55. },
  56. },
  57. {
  58. field: 'next_hop_type',
  59. title: this.$t('network.next_hop_type'),
  60. slots: {
  61. default: ({ row }) => {
  62. return NEXT_HOP_TYPES_MAP[row.next_hop_type]?.value || row.next_hop_type
  63. },
  64. },
  65. },
  66. {
  67. field: 'type',
  68. title: this.$t('network.text_249'),
  69. slots: {
  70. default: ({ row }) => {
  71. return TYPES_MAP[row.type]?.value || row.type
  72. },
  73. },
  74. },
  75. ],
  76. groupActions: [
  77. {
  78. label: this.$t('common.action.delete'),
  79. action: obj => {
  80. this.createDialog('DeleteResDialog', {
  81. vm: this,
  82. data: this.list.selectedItems,
  83. columns: this.columns,
  84. name: this.$t('network.vpc_network.route'),
  85. title: this.$t('common.action.delete'),
  86. onManager: this.onManager,
  87. success: () => {
  88. this.destroySidePages()
  89. },
  90. })
  91. },
  92. meta: (obj) => {
  93. if (this.list.selectedItems.some(v => v.type !== 'Custom')) {
  94. return {
  95. validate: false,
  96. tooltip: this.$t('network.route_delete_tips'),
  97. }
  98. }
  99. return {
  100. validate: this.list.allowDelete(),
  101. }
  102. },
  103. },
  104. ],
  105. singleActions: [
  106. {
  107. label: this.$t('common.action.delete'),
  108. action: obj => {
  109. this.createDialog('DeleteResDialog', {
  110. vm: this,
  111. data: [obj],
  112. columns: this.columns,
  113. name: this.$t('network.vpc_network.route'),
  114. title: this.$t('common.action.delete'),
  115. onManager: this.onManager,
  116. success: () => {
  117. this.destroySidePages()
  118. },
  119. })
  120. },
  121. meta: (obj) => {
  122. if (obj.type !== 'Custom') {
  123. return {
  124. validate: false,
  125. tooltip: this.$t('network.route_delete_tips'),
  126. }
  127. }
  128. return this.$getDeleteResult(obj)
  129. },
  130. },
  131. ],
  132. }
  133. },
  134. created () {
  135. this.list.fetchData()
  136. },
  137. }
  138. </script>