List.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. :showSearchbox="showSearchbox"
  9. :showGroupActions="showGroupActions" />
  10. </template>
  11. <script>
  12. import ListMixin from '@/mixins/list'
  13. import WindowsMixin from '@/mixins/windows'
  14. import { getProjectDomainFilter, getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  15. import {
  16. getSetPublicAction,
  17. } from '@/utils/common/tableActions'
  18. import GlobalSearchMixin from '@/mixins/globalSearch'
  19. import SingleActionsMixin from '../mixins/singleActions'
  20. import ColumnsMixin from '../mixins/columns'
  21. export default {
  22. name: 'RoleList',
  23. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin],
  24. props: {
  25. id: String,
  26. getParams: {
  27. type: Object,
  28. },
  29. resource: String,
  30. resId: String,
  31. hiddenActions: {
  32. type: Array,
  33. default: () => ([]),
  34. },
  35. },
  36. data () {
  37. return {
  38. list: this.$list.createList(this, {
  39. id: this.id,
  40. resource: 'roles',
  41. apiVersion: 'v1',
  42. getParams: this.getParam,
  43. filterOptions: {
  44. id: {
  45. label: this.$t('table.title.id'),
  46. },
  47. name: {
  48. label: this.$t('system.text_101'),
  49. filter: true,
  50. formatter: val => {
  51. return `name.contains("${val}")`
  52. },
  53. },
  54. description: getDescriptionFilter(),
  55. project_domains: getProjectDomainFilter(),
  56. created_at: getCreatedAtFilter(),
  57. },
  58. responseData: this.responseData,
  59. hiddenColumns: ['created_at'],
  60. }),
  61. exportDataOptions: {
  62. items: [
  63. { label: 'ID', key: 'id' },
  64. { label: this.$t('system.text_101'), key: 'name' },
  65. { label: this.$t('dictionary.domain'), key: 'project_domain' },
  66. { label: this.$t('common.createdAt'), key: 'created_at' },
  67. ],
  68. },
  69. groupActions: [
  70. {
  71. label: this.$t('system.text_128'),
  72. permission: 'roles_create',
  73. action: () => {
  74. this.createDialog('RoleCreateDialog', {
  75. domain: this.resource === 'domains' ? this.resId : '',
  76. success: () => {
  77. this.refresh()
  78. },
  79. })
  80. },
  81. meta: () => {
  82. return {
  83. buttonType: 'primary',
  84. }
  85. },
  86. hidden: () => this.hiddenActions.includes('create'),
  87. },
  88. getSetPublicAction(this, {
  89. name: this.$t('dictionary.role'),
  90. scope: 'domain',
  91. resource: 'roles',
  92. apiVersion: 'v1',
  93. noCandidateDomains: true,
  94. }, {
  95. permission: 'roles_perform_public',
  96. meta: () => {
  97. return {
  98. validate: this.list.selectedItems.length,
  99. }
  100. },
  101. }),
  102. {
  103. label: this.$t('system.text_129'),
  104. permission: 'roles_delete',
  105. action: () => {
  106. this.createDialog('DeleteResDialog', {
  107. vm: this,
  108. data: this.list.selectedItems,
  109. columns: this.columns,
  110. title: this.$t('system.text_129'),
  111. onManager: this.onManager,
  112. name: this.$t('dictionary.role'),
  113. })
  114. },
  115. meta: () => this.$getDeleteResult(this.list.selectedItems),
  116. },
  117. ],
  118. }
  119. },
  120. created () {
  121. this.initSidePageTab('role-detail')
  122. this.list.fetchData()
  123. },
  124. methods: {
  125. getParam () {
  126. const ret = {
  127. ...this.getParams,
  128. details: true,
  129. }
  130. return ret
  131. },
  132. handleOpenSidepage (row) {
  133. this.sidePageTriggerHandle(this, 'RoleSidePage', {
  134. id: row.id,
  135. resource: 'roles',
  136. apiVersion: 'v1',
  137. getParams: this.getParam,
  138. }, {
  139. list: this.list,
  140. hiddenActions: this.hiddenActions,
  141. })
  142. },
  143. },
  144. }
  145. </script>