List.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <page-list
  3. show-tag-columns
  4. show-tag-filter
  5. :list="list"
  6. :columns="columns"
  7. :group-actions="groupActions"
  8. :single-actions="singleActions"
  9. :showSearchbox="showSearchbox"
  10. :showGroupActions="showGroupActions"
  11. :export-data-options="exportDataOptions"
  12. :ext-tag-params="{ service: 'identity' }" />
  13. </template>
  14. <script>
  15. import { mapGetters } from 'vuex'
  16. import WindowsMixin from '@/mixins/windows'
  17. import ListMixin from '@/mixins/list'
  18. import { getEnabledSwitchActions } from '@/utils/common/tableActions'
  19. import GlobalSearchMixin from '@/mixins/globalSearch'
  20. import { getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  21. import SingleActionsMixin from '../mixins/singleActions'
  22. import ColumnsMixin from '../mixins/columns'
  23. export default {
  24. name: 'DomainList',
  25. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin],
  26. props: {
  27. id: String,
  28. getParams: {
  29. type: Object,
  30. },
  31. },
  32. data () {
  33. return {
  34. list: this.$list.createList(this, {
  35. id: this.id,
  36. resource: 'domains',
  37. apiVersion: 'v1',
  38. getParams: this.getParam,
  39. filterOptions: {
  40. id: {
  41. label: this.$t('table.title.id'),
  42. },
  43. name: {
  44. label: this.$t('system.text_101'),
  45. filter: true,
  46. formatter: val => {
  47. return `name.contains("${val}")`
  48. },
  49. },
  50. description: getDescriptionFilter(),
  51. created_at: getCreatedAtFilter(),
  52. idp_id: {
  53. label: this.$t('dictionary.identity_provider'),
  54. },
  55. },
  56. responseData: this.responseData,
  57. hiddenColumns: ['created_at'],
  58. }),
  59. exportDataOptions: {
  60. items: [
  61. { label: 'ID', key: 'id' },
  62. { label: this.$t('system.text_101'), key: 'name' },
  63. { label: this.$t('system.text_163'), key: 'enabled' },
  64. { label: this.$t('system.text_165'), key: 'idp' },
  65. { label: this.$t('table.title.user_tag'), key: 'user_tags' },
  66. { label: this.$t('common.createdAt'), key: 'created_at' },
  67. ],
  68. },
  69. groupActions: [
  70. {
  71. label: this.$t('system.text_128'),
  72. permission: 'domains_create',
  73. action: () => {
  74. this.$router.push('/domain/create')
  75. },
  76. meta: () => {
  77. return {
  78. buttonType: 'primary',
  79. }
  80. },
  81. },
  82. {
  83. label: this.$t('system.text_166'),
  84. actions: () => {
  85. return [
  86. ...getEnabledSwitchActions(this, undefined, ['domains_perform_enable', 'domains_perform_disable'], {
  87. actions: [
  88. () => {
  89. this.list.batchUpdate(this.list.selectedItems.map(({ id }) => id), {
  90. enabled: true,
  91. })
  92. },
  93. () => {
  94. this.list.batchUpdate(this.list.selectedItems.map(({ id }) => id), {
  95. enabled: false,
  96. })
  97. },
  98. ],
  99. }),
  100. {
  101. label: this.$t('table.action.set_tag'),
  102. permission: 'domains_perform_set_user_metadata',
  103. action: () => {
  104. this.createDialog('SetTagDialog', {
  105. data: this.list.selectedItems,
  106. columns: this.columns,
  107. onManager: this.onManager,
  108. params: {
  109. service: 'identity',
  110. resources: 'domain',
  111. },
  112. mode: 'add',
  113. })
  114. },
  115. },
  116. {
  117. label: this.$t('system.text_129'),
  118. permission: 'domains_delete',
  119. action: (row) => {
  120. this.createDialog('DeleteResDialog', {
  121. vm: this,
  122. data: this.list.selectedItems,
  123. columns: this.columns,
  124. title: this.$t('system.text_129'),
  125. name: this.$t('dictionary.domain'),
  126. onManager: this.onManager,
  127. })
  128. },
  129. meta: () => this.$getDeleteResult(this.list.selectedItems),
  130. },
  131. ]
  132. },
  133. meta: () => {
  134. return {
  135. validate: !!this.list.selectedItems.length,
  136. }
  137. },
  138. },
  139. ],
  140. }
  141. },
  142. computed: mapGetters(['isAdminMode', 'l3PermissionEnable', 'globalConfig']),
  143. created () {
  144. // if (!this.l3PermissionEnable) {
  145. // this.singleActions.splice(0, 1)
  146. // }
  147. this.initSidePageTab('detail')
  148. this.list.fetchData()
  149. this.$bus.$on('SystemDomainsListRefresh', args => {
  150. this.list.refresh()
  151. }, this)
  152. },
  153. methods: {
  154. getParam () {
  155. const ret = {
  156. ...this.getParams,
  157. details: true,
  158. }
  159. return ret
  160. },
  161. handleOpenSidepage (row) {
  162. this.sidePageTriggerHandle(this, 'DomainSidePage', {
  163. id: row.id,
  164. resource: 'domains',
  165. apiVersion: 'v1',
  166. getParams: this.getParam,
  167. }, {
  168. list: this.list,
  169. })
  170. },
  171. },
  172. }
  173. </script>