List.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <page-list
  3. show-tag-columns
  4. show-tag-filter
  5. :list="list"
  6. :columns="templateListColumns || columns"
  7. :single-actions="singleActions"
  8. :group-actions="groupActions"
  9. :showSearchbox="showSearchbox"
  10. :showGroupActions="showGroupActions"
  11. :export-data-options="exportDataOptions"
  12. :show-single-actions="!isTemplate"
  13. :show-page="!isTemplate" />
  14. </template>
  15. <script>
  16. import * as R from 'ramda'
  17. import ListMixin from '@/mixins/list'
  18. import ResTemplateListMixin from '@/mixins/resTemplateList'
  19. import expectStatus from '@/constants/expectStatus'
  20. import WindowsMixin from '@/mixins/windows'
  21. import {
  22. getStatusFilter,
  23. getBrandFilter,
  24. getDomainFilter,
  25. getAccountFilter,
  26. getCloudProviderFilter,
  27. getDescriptionFilter,
  28. } from '@/utils/common/tableFilter'
  29. import GlobalSearchMixin from '@/mixins/globalSearch'
  30. import SingleActionsMixin from '../mixins/singleActions'
  31. import ColumnsMixin from '../mixins/columns'
  32. export default {
  33. name: 'VpcPeerConnectList',
  34. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
  35. props: {
  36. id: String,
  37. getParams: {
  38. type: Object,
  39. },
  40. },
  41. data () {
  42. return {
  43. list: this.$list.createList(this, {
  44. ctx: this,
  45. id: this.id,
  46. resource: 'vpc_peering_connections',
  47. getParams: this.getParam,
  48. isTemplate: this.isTemplate,
  49. templateLimit: this.templateLimit,
  50. steadyStatus: Object.values(expectStatus.vpcPeerConnect).flat(),
  51. filterOptions: {
  52. id: {
  53. label: this.$t('table.title.id'),
  54. },
  55. name: {
  56. label: this.$t('network.text_21'),
  57. filter: true,
  58. formatter: val => {
  59. return `name.contains("${val}")`
  60. },
  61. },
  62. description: getDescriptionFilter(),
  63. status: getStatusFilter('vpcPeerConnect'),
  64. brand: getBrandFilter('vpc_peer_brands'),
  65. project_domains: getDomainFilter(),
  66. cloudaccount: getAccountFilter(),
  67. manager: getCloudProviderFilter(),
  68. },
  69. }),
  70. exportDataOptions: {
  71. items: [
  72. { label: 'ID', key: 'id' },
  73. { label: this.$t('network.text_21'), key: 'name' },
  74. ],
  75. },
  76. groupActions: [
  77. {
  78. label: this.$t('common.create'),
  79. permission: 'vpc_peering_connections_create',
  80. action: () => {
  81. this.$router.push({
  82. name: 'VpcPeerConnectCreate',
  83. })
  84. },
  85. meta: () => {
  86. return {
  87. buttonType: 'primary',
  88. validate: true,
  89. }
  90. },
  91. },
  92. {
  93. label: this.$t('table.action.set_tag'),
  94. permission: 'vpc_peering_connections_perform_set_user_metadata',
  95. action: () => {
  96. this.createDialog('SetTagDialog', {
  97. data: this.list.selectedItems,
  98. columns: this.columns,
  99. onManager: this.onManager,
  100. mode: 'add',
  101. params: {
  102. resources: 'inter_vpc_networks',
  103. },
  104. tipName: this.$t('dictionary.vpc_network'),
  105. })
  106. },
  107. meta: () => {
  108. return {
  109. validate: this.list.selectedItems.length,
  110. }
  111. },
  112. },
  113. {
  114. label: this.$t('network.text_201'),
  115. permission: 'vpc_peering_connections_perform_syncstatus',
  116. action: () => {
  117. this.onManager('batchPerformAction', {
  118. steadyStatus: ['running', 'ready'],
  119. managerArgs: {
  120. action: 'syncstatus',
  121. },
  122. })
  123. },
  124. meta: () => {
  125. return {
  126. validate: this.list.selectedItems.length,
  127. }
  128. },
  129. },
  130. {
  131. label: this.$t('network.text_131'),
  132. permission: 'vpc_peering_connections_delete',
  133. action: () => {
  134. this.createDialog('DeleteResDialog', {
  135. vm: this,
  136. data: this.list.selectedItems,
  137. columns: this.columns,
  138. title: this.$t('network.text_131'),
  139. name: this.$t('dictionary.vpc_peer_connect'),
  140. onManager: this.onManager,
  141. })
  142. },
  143. meta: () => {
  144. return {
  145. validate: this.list.allowDelete(),
  146. }
  147. },
  148. },
  149. ],
  150. }
  151. },
  152. created () {
  153. // this.initSidePageTab('detail')
  154. this.list.fetchData()
  155. this.$bus.$on('VpcPeerConnectListSingleRefresh', (...arg) => {
  156. this.list.refresh(...arg)
  157. }, false)
  158. },
  159. methods: {
  160. getParam () {
  161. const ret = {
  162. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  163. }
  164. return ret
  165. },
  166. handleOpenSidepage (row, tab) {
  167. this.sidePageTriggerHandle(this, 'VpcPeerConnectSidePage', {
  168. id: row.id,
  169. resource: 'vpc_peering_connections',
  170. getParams: this.getParam,
  171. }, {
  172. list: this.list,
  173. tab,
  174. })
  175. },
  176. },
  177. }
  178. </script>