Vpc.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div>
  3. <a-alert type="warning" class="mb-2" :showIcon="false" :message="$t('network.vpc_network.vpc_action_refresh')" banner />
  4. <page-list
  5. :list="list"
  6. :columns="columns"
  7. :group-actions="groupActions"
  8. :single-actions="singleActions" />
  9. </div>
  10. </template>
  11. <script>
  12. import * as R from 'ramda'
  13. import {
  14. getCopyWithContentTableColumn,
  15. getRegionTableColumn,
  16. getBrandTableColumn,
  17. getAccountTableColumn,
  18. } from '@/utils/common/tableColumn'
  19. import {
  20. getRegionFilter,
  21. getAccountFilter,
  22. getCloudProviderFilter,
  23. } from '@/utils/common/tableFilter'
  24. import WindowsMixin from '@/mixins/windows'
  25. export default {
  26. name: 'vpcListForVpcNetworkSidePage',
  27. mixins: [WindowsMixin],
  28. props: {
  29. resId: String,
  30. data: {
  31. type: Object,
  32. required: true,
  33. },
  34. getParams: [Function, Object],
  35. },
  36. data () {
  37. return {
  38. list: this.$list.createList(this, {
  39. id: 'vpcListForVpcNetworkSidePage',
  40. resource: 'vpcs',
  41. getParams: this.getParam,
  42. filterOptions: {
  43. name: {
  44. label: this.$t('network.text_21'),
  45. filter: true,
  46. formatter: val => {
  47. return `name.contains("${val}")`
  48. },
  49. },
  50. cidr_block: {
  51. label: this.$t('network.vpc.cidr_block.ipv4.label'),
  52. },
  53. region: getRegionFilter(),
  54. cloudaccount: getAccountFilter(),
  55. manager: getCloudProviderFilter(),
  56. },
  57. }),
  58. columns: [
  59. getCopyWithContentTableColumn({
  60. field: 'name',
  61. title: this.$t('table.title.name'),
  62. sortable: true,
  63. }),
  64. getCopyWithContentTableColumn({
  65. field: 'cidr_block',
  66. title: this.$t('network.vpc.cidr_block.ipv4.label'),
  67. sortable: true,
  68. }),
  69. getRegionTableColumn(),
  70. getBrandTableColumn(),
  71. getAccountTableColumn(),
  72. ],
  73. groupActions: [
  74. {
  75. label: this.$t('network.text_719'),
  76. permission: 'inter_vpc_networks_perform_addvpc',
  77. action: () => {
  78. this.createDialog('AssociateVpcForVpcNetworkDialog', {
  79. title: this.$t('network.text_719'),
  80. data: [this.data],
  81. resData: this.data,
  82. columns: this.columns,
  83. onManager: this.onManager,
  84. refresh: this.refresh,
  85. })
  86. },
  87. meta: () => {
  88. return {
  89. validate: true,
  90. buttonType: 'primary',
  91. }
  92. },
  93. },
  94. ],
  95. singleActions: [
  96. {
  97. label: this.$t('network.text_219'),
  98. permission: 'inter_vpc_networks_perform_removevpc',
  99. action: (obj) => {
  100. this.createDialog('RemoveVpcForVpcNetworkDialog', {
  101. title: this.$t('network.text_719'),
  102. data: [obj],
  103. resData: this.data,
  104. columns: this.columns,
  105. onManager: this.onManager,
  106. refresh: this.refresh,
  107. })
  108. },
  109. meta: () => {
  110. return {
  111. validate: true,
  112. }
  113. },
  114. },
  115. ],
  116. }
  117. },
  118. created () {
  119. this.initSidePageTab('vpc-detail')
  120. this.list.fetchData()
  121. },
  122. methods: {
  123. refresh (num) {
  124. if (num) {
  125. let refreshNum = 0
  126. if (refreshNum === 0) {
  127. const timer = setInterval(() => {
  128. refreshNum++
  129. this.list.fetchData()
  130. if (refreshNum >= num) {
  131. clearInterval(timer)
  132. }
  133. }, 6000)
  134. }
  135. } else {
  136. this.list.fetchData()
  137. }
  138. },
  139. handleOpenSidepage (row) {
  140. this.sidePageTriggerHandle(this, 'VpcSidePage', {
  141. id: row.id,
  142. resource: 'vpcs',
  143. getParams: this.getParam,
  144. }, {
  145. list: this.list,
  146. })
  147. },
  148. getParam () {
  149. const ret = {
  150. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  151. }
  152. return ret
  153. },
  154. },
  155. }
  156. </script>