List.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div>
  3. <a-alert :message="alertMessage" class="mb-2" type="info" />
  4. <page-list
  5. :list="list"
  6. :columns="columns"
  7. :single-actions="singleActions"
  8. :group-actions="groupActions"
  9. :export-data-options="exportDataOptions" />
  10. </div>
  11. </template>
  12. <script>
  13. import { mapGetters } from 'vuex'
  14. import ColumnsMixin from '../mixins/columns'
  15. import SingleActionsMixin from '../mixins/singleActions'
  16. import ListMixin from '@/mixins/list'
  17. import WindowsMixin from '@/mixins/windows'
  18. import { getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  19. export default {
  20. name: 'SshProxyList',
  21. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  22. props: {
  23. id: String,
  24. hiddenActions: {
  25. type: Array,
  26. default: () => ([]),
  27. },
  28. },
  29. data () {
  30. return {
  31. alertMessage: this.$t('network.ssh-proxy.endpoints.list.tips'),
  32. list: this.$list.createList(this, {
  33. id: this.id,
  34. resource: 'proxy_endpoints',
  35. getParams: this.getParam,
  36. filterOptions: {
  37. name: {
  38. label: this.$t('network.text_21'),
  39. filter: true,
  40. formatter: val => {
  41. return `name.contains(${val})`
  42. },
  43. },
  44. description: getDescriptionFilter(),
  45. ip_addr: {
  46. label: 'IP',
  47. filter: true,
  48. formatter: val => {
  49. return `intranet_ip_addr.contains(${val})`
  50. },
  51. },
  52. created_at: getCreatedAtFilter(),
  53. },
  54. hiddenColumns: ['created_at'],
  55. }),
  56. exportDataOptions: {
  57. items: [
  58. { label: 'ID', key: 'id' },
  59. { label: this.$t('network.text_21'), key: 'name' },
  60. { label: this.$t('common.createdAt'), key: 'created_at' },
  61. ],
  62. },
  63. groupActions: [
  64. {
  65. label: this.$t('network.text_26'),
  66. permission: 'sshproxy_endpoint_create',
  67. action: () => {
  68. this.$router.push({
  69. path: '/ssh-proxy/create',
  70. })
  71. },
  72. meta: () => {
  73. return {
  74. buttonType: 'primary',
  75. validate: !this.cloudEnvEmpty,
  76. tooltip: this.cloudEnvEmpty ? this.$t('common.no_platform_available') : '',
  77. }
  78. },
  79. hidden: () => this.hiddenActions.includes('create'),
  80. },
  81. {
  82. label: this.$t('network.text_200'),
  83. actions: () => {
  84. return [
  85. {
  86. label: this.$t('network.text_349'),
  87. permission: 'proxy_endpoints_update',
  88. action: () => {
  89. this.createDialog('UpdateSSHPortDialog', {
  90. vm: this,
  91. data: this.list.selectedItems,
  92. columns: this.columns,
  93. title: this.$t('network.text_349'),
  94. name: this.$t('network.ssh-proxy.endpoints'),
  95. onManager: this.onManager,
  96. })
  97. },
  98. },
  99. {
  100. label: this.$t('network.text_131'),
  101. permission: 'proxy_endpoints_delete',
  102. action: () => {
  103. this.createDialog('DeleteResDialog', {
  104. vm: this,
  105. data: this.list.selectedItems,
  106. columns: this.columns,
  107. title: this.$t('network.text_131'),
  108. name: this.$t('network.ssh-proxy.endpoints'),
  109. onManager: this.onManager,
  110. })
  111. },
  112. meta: () => {
  113. return {
  114. validate: this.list.allowDelete(),
  115. }
  116. },
  117. },
  118. ]
  119. },
  120. meta: () => {
  121. return {
  122. validate: this.list.selected.length,
  123. }
  124. },
  125. },
  126. ],
  127. }
  128. },
  129. computed: {
  130. ...mapGetters(['isAdminMode', 'isDomainMode', 'isProjectMode', 'userInfo']),
  131. },
  132. created () {
  133. this.initSidePageTab('SshProxy-detail')
  134. this.list.fetchData()
  135. },
  136. methods: {
  137. getParam () {
  138. return {}
  139. },
  140. handleOpenSidepage (row) {
  141. this.sidePageTriggerHandle(this, 'SshProxySidePage', {
  142. id: row.id,
  143. resource: 'proxy_endpoints',
  144. getParams: this.getParam,
  145. }, {
  146. list: this.list,
  147. })
  148. },
  149. },
  150. }
  151. </script>