List.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :export-data-options="exportDataOptions" />
  8. </template>
  9. <script>
  10. import ColumnsMixin from '../mixins/columns'
  11. import SingleActionsMixin from '../mixins/singleActions'
  12. import { getNameFilter, getDomainFilter, getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  13. import WindowsMixin from '@/mixins/windows'
  14. import ListMixin from '@/mixins/list'
  15. import { getSetPublicAction } from '@/utils/common/tableActions'
  16. import { getDisabledProvidersActionMeta } from '@/utils/common/hypervisor'
  17. export default {
  18. name: 'ProxysettingList',
  19. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  20. props: {
  21. id: String,
  22. getParams: {
  23. type: Object,
  24. },
  25. },
  26. data () {
  27. return {
  28. list: this.$list.createList(this, {
  29. id: this.id,
  30. resource: 'proxysettings',
  31. getParams: this.getParams,
  32. filterOptions: {
  33. name: getNameFilter(),
  34. description: getDescriptionFilter(),
  35. project_domains: getDomainFilter(),
  36. created_at: getCreatedAtFilter(),
  37. // https_proxy: {
  38. // label: 'https代理',
  39. // },
  40. // http_proxy: {
  41. // label: 'http代理',
  42. // },
  43. // no_proxy: {
  44. // label: '不走代理地址',
  45. // },
  46. },
  47. hiddenColumns: ['created_at'],
  48. }),
  49. exportDataOptions: {
  50. items: [
  51. { label: 'ID', key: 'id' },
  52. { label: this.$t('cloudenv.text_95'), key: 'name' },
  53. { label: this.$t('cloudenv.text_395'), key: 'https_proxy' },
  54. { label: this.$t('cloudenv.text_398'), key: 'http_proxy' },
  55. { label: this.$t('cloudenv.text_403'), key: 'no_proxy' },
  56. {
  57. label: this.$t('compute.text_505'),
  58. key: 'public_scope',
  59. hidden: () => {
  60. return !this.$store.getters.l3PermissionEnable && (this.$store.getters.scopeResource && this.$store.getters.scopeResource.domain.includes('cloudaccounts'))
  61. },
  62. },
  63. { label: this.$t('common.createdAt'), key: 'created_at' },
  64. ],
  65. },
  66. groupActions: [
  67. {
  68. label: this.$t('cloudenv.text_104'),
  69. permission: 'proxysettings_create',
  70. action: () => {
  71. this.createDialog('ProxysettingCreateDialog', {
  72. onManager: this.onManager,
  73. refresh: this.refresh,
  74. })
  75. },
  76. meta: () => {
  77. return {
  78. buttonType: 'primary',
  79. }
  80. },
  81. },
  82. getSetPublicAction(this, {
  83. name: this.$t('dictionary.proxysetting'),
  84. scope: 'domain',
  85. resource: 'proxysettings',
  86. }, {
  87. permission: 'proxysettings_perform_public',
  88. meta: () => {
  89. const lent = this.list.selectedItems.length
  90. if (lent === 0) {
  91. return {
  92. validate: false,
  93. }
  94. }
  95. for (let i = 0; i < lent; i++) {
  96. const row = this.list.selectedItems[i]
  97. if (row.id === 'DIRECT') {
  98. return {
  99. tooltip: this.$t('cloudenv.text_404'),
  100. validate: false,
  101. }
  102. }
  103. const { isDomainMode, userInfo } = this.$store.getters
  104. if (isDomainMode && (userInfo.projectDomainId !== row.domain_id)) {
  105. return {
  106. validate: false,
  107. tooltip: this.$t('cloudenv.text_405'),
  108. }
  109. }
  110. }
  111. return {
  112. validate: true,
  113. }
  114. },
  115. extraMeta: obj => {
  116. return getDisabledProvidersActionMeta({
  117. rows: this.list.selectedItems,
  118. disabledProviders: ['BingoCloud'],
  119. })
  120. },
  121. }),
  122. {
  123. label: this.$t('cloudenv.text_108'),
  124. permission: 'proxysettings_delete',
  125. action: () => {
  126. this.createDialog('DeleteResDialog', {
  127. data: this.list.selectedItems,
  128. columns: this.columns,
  129. title: this.$t('cloudenv.text_108'),
  130. name: this.$t('dictionary.proxysetting'),
  131. onManager: this.onManager,
  132. })
  133. },
  134. meta: () => {
  135. return {
  136. validate: this.list.allowDelete(),
  137. }
  138. },
  139. extraMeta: obj => {
  140. return getDisabledProvidersActionMeta({
  141. rows: this.list.selectedItems,
  142. disabledProviders: ['BingoCloud'],
  143. })
  144. },
  145. },
  146. ],
  147. }
  148. },
  149. created () {
  150. this.list.fetchData()
  151. },
  152. }
  153. </script>