List.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :showSearchbox="showSearchbox"
  8. :showGroupActions="showGroupActions"
  9. :export-data-options="exportDataOptions" />
  10. </template>
  11. <script>
  12. import { mapGetters } from 'vuex'
  13. import ListMixin from '@/mixins/list'
  14. import WindowsMixin from '@/mixins/windows'
  15. import { getProjectDomainFilter, getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  16. import GlobalSearchMixin from '@/mixins/globalSearch'
  17. import SingleActionsMixin from '../mixins/singleActions'
  18. import ColumnsMixin from '../mixins/columns'
  19. export default {
  20. name: 'GroupList',
  21. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin],
  22. props: {
  23. id: String,
  24. getParams: {
  25. type: Object,
  26. },
  27. },
  28. data () {
  29. return {
  30. list: this.$list.createList(this, {
  31. id: this.id,
  32. resource: 'groups',
  33. apiVersion: 'v1',
  34. getParams: this.getParam,
  35. filterOptions: {
  36. id: {
  37. label: this.$t('table.title.id'),
  38. },
  39. name: {
  40. label: this.$t('system.text_101'),
  41. filter: true,
  42. formatter: val => {
  43. return `name.contains("${val}")`
  44. },
  45. },
  46. description: getDescriptionFilter(),
  47. project_domain: getProjectDomainFilter(),
  48. created_at: getCreatedAtFilter(),
  49. idp_id: {
  50. label: this.$t('dictionary.identity_provider'),
  51. },
  52. },
  53. responseData: this.responseData,
  54. hiddenColumns: ['created_at'],
  55. }),
  56. exportDataOptions: {
  57. items: [
  58. { label: 'ID', key: 'id' },
  59. { label: this.$t('system.text_101'), key: 'name' },
  60. { label: this.$t('dictionary.domain'), key: 'project_domain' },
  61. { label: this.$t('common.createdAt'), key: 'created_at' },
  62. ],
  63. },
  64. groupActions: [
  65. {
  66. label: this.$t('system.text_128'),
  67. permission: 'groups_create',
  68. action: () => {
  69. this.createDialog('GroupCreateDialog', {
  70. success: () => {
  71. this.refresh()
  72. },
  73. })
  74. },
  75. meta: () => {
  76. return {
  77. buttonType: 'primary',
  78. }
  79. },
  80. },
  81. {
  82. label: this.$t('system.text_129'),
  83. permission: 'groupss_delete',
  84. action: () => {
  85. this.createDialog('DeleteResDialog', {
  86. vm: this,
  87. data: this.list.selectedItems,
  88. columns: this.columns,
  89. title: this.$t('system.text_129'),
  90. onManager: this.onManager,
  91. name: this.$t('dictionary.group'),
  92. })
  93. },
  94. meta: () => {
  95. return {
  96. validate: this.list.selectedItems.length > 0 && this.list.selectedItems.every(item => item.can_delete),
  97. }
  98. },
  99. },
  100. ],
  101. }
  102. },
  103. computed: mapGetters(['isAdminMode', 'l3PermissionEnable']),
  104. created () {
  105. this.initSidePageTab('group-detail')
  106. this.list.fetchData()
  107. },
  108. methods: {
  109. getParam () {
  110. const ret = {
  111. ...this.getParams,
  112. details: true,
  113. }
  114. return ret
  115. },
  116. handleOpenSidepage (row, tab) {
  117. this.sidePageTriggerHandle(this, 'GroupSidePage', {
  118. id: row.id,
  119. resource: 'groups',
  120. apiVersion: 'v1',
  121. getParams: this.getParam,
  122. }, {
  123. list: this.list,
  124. tab,
  125. })
  126. },
  127. },
  128. }
  129. </script>