List.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :export-data-options="exportDataOptions"
  6. :group-actions="groupActions"
  7. :showSearchbox="showSearchbox"
  8. :showGroupActions="showGroupActions"
  9. :single-actions="singleActions" />
  10. </template>
  11. <script>
  12. import * as R from 'ramda'
  13. import ListMixin from '@/mixins/list'
  14. import expectStatus from '@/constants/expectStatus'
  15. import { getStatusFilter, getRegionFilter, getBrandFilter, getAccountFilter, getProjectDomainFilter, getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  16. import WindowsMixin from '@/mixins/windows'
  17. import GlobalSearchMixin from '@/mixins/globalSearch'
  18. import ColumnsMixin from '../mixins/columns'
  19. import SingleActionsMixin from '../mixins/singleActions'
  20. export default {
  21. name: 'AccessGroupList',
  22. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin],
  23. props: {
  24. id: String,
  25. getParams: {
  26. type: [Function, Object],
  27. },
  28. hiddenActions: {
  29. type: Array,
  30. default: () => ([]),
  31. },
  32. },
  33. data () {
  34. return {
  35. list: this.$list.createList(this, {
  36. id: this.id,
  37. resource: 'access_groups',
  38. getParams: this.getParam,
  39. steadyStatus: Object.values(expectStatus.accessGroup).flat(),
  40. filterOptions: {
  41. id: {
  42. label: this.$t('table.title.id'),
  43. },
  44. name: {
  45. label: this.$t('storage.text_40'),
  46. filter: true,
  47. formatter: val => {
  48. return `name.contains("${val}")`
  49. },
  50. },
  51. description: getDescriptionFilter(),
  52. status: getStatusFilter('accessGroup'),
  53. project_domains: getProjectDomainFilter(),
  54. created_at: getCreatedAtFilter(),
  55. brand: getBrandFilter('nas_brands'),
  56. cloudaccount: getAccountFilter(),
  57. region: getRegionFilter(),
  58. },
  59. responseData: this.responseData,
  60. hiddenColumns: ['created_at'],
  61. }),
  62. exportDataOptions: {
  63. items: [
  64. { label: 'ID', key: 'id' },
  65. { label: this.$t('storage.text_40'), key: 'name' },
  66. { label: this.$t('storage.text_41'), key: 'status' },
  67. { label: this.$t('storage.created_at'), key: 'created_at' },
  68. {
  69. label: this.$t('storage.text_48'),
  70. key: 'public_scope',
  71. hidden: () => {
  72. return !this.$store.getters.l3PermissionEnable && (this.$store.getters.scopeResource && this.$store.getters.scopeResource.domain.includes('access_groups'))
  73. },
  74. },
  75. { label: this.$t('storage.text_49', [this.$t('dictionary.domain')]), key: 'project_domain' },
  76. ],
  77. },
  78. groupActions: [
  79. {
  80. label: this.$t('storage.text_31'),
  81. permission: 'access_groups_create',
  82. action: () => {
  83. this.createDialog('AccessGroupCreateDialog', {
  84. data: this.data,
  85. refresh: this.refresh,
  86. onManager: this.onManager,
  87. })
  88. },
  89. meta: () => {
  90. return {
  91. buttonType: 'primary',
  92. }
  93. },
  94. hidden: () => this.hiddenActions.includes('create'),
  95. },
  96. {
  97. label: this.$t('storage.text_33'),
  98. actions: (obj) => {
  99. return [
  100. {
  101. label: this.$t('storage.text_36'),
  102. permission: 'access_groups_delete',
  103. action: () => {
  104. this.createDialog('DeleteResDialog', {
  105. vm: this,
  106. data: this.list.selectedItems,
  107. alert: this.$t('storage.text_266'),
  108. columns: this.columns,
  109. title: this.$t('storage.text_36'),
  110. name: this.$t('dictionary.access_group'),
  111. onManager: this.onManager,
  112. })
  113. },
  114. meta: () => {
  115. return {
  116. validate: this.list.allowDelete(),
  117. }
  118. },
  119. },
  120. ]
  121. },
  122. },
  123. ],
  124. }
  125. },
  126. created () {
  127. this.initSidePageTab('access-group-detail')
  128. this.list.fetchData()
  129. this.$bus.$on('access-group-refresh', () => {
  130. this.list.refresh()
  131. })
  132. },
  133. methods: {
  134. getParam () {
  135. const ret = {
  136. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  137. detail: true,
  138. }
  139. return ret
  140. },
  141. handleOpenSidepage (row, tab) {
  142. this.sidePageTriggerHandle(this, 'AccessGroupSidePage', {
  143. id: row.id,
  144. resource: 'access_groups',
  145. getParams: this.getParam,
  146. }, {
  147. list: this.list,
  148. tab,
  149. })
  150. },
  151. },
  152. }
  153. </script>