Groups.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions" />
  7. </template>
  8. <script>
  9. import {
  10. getNameDescriptionTableColumn,
  11. getEnabledTableColumn,
  12. getProjectDomainTableColumn,
  13. } from '@/utils/common/tableColumn'
  14. import i18n from '@/locales'
  15. import WindowsMixin from '@/mixins/windows'
  16. import ListMixin from '@/mixins/list'
  17. export default {
  18. name: 'UserSidepageAllProjects',
  19. mixins: [WindowsMixin, ListMixin],
  20. props: {
  21. id: String,
  22. data: {
  23. type: Object,
  24. required: true,
  25. },
  26. },
  27. data () {
  28. return {
  29. list: this.$list.createList(this, {
  30. id: this.id,
  31. resource: this.getList,
  32. apiVersion: 'v1',
  33. }),
  34. columns: [
  35. {
  36. title: this.$t('dictionary.group'),
  37. field: 'name',
  38. slots: {
  39. default: ({ row }) => {
  40. return [
  41. <list-body-cell-wrap copy row={row} field='name' title={row.name} message={row.name} hideField={true}>
  42. <side-page-trigger permission='groups_get' name='GroupSidePage' id={row.id} vm={this}>{ row.name }</side-page-trigger>
  43. </list-body-cell-wrap>,
  44. ]
  45. },
  46. },
  47. },
  48. {
  49. title: this.$t('dictionary.domain'),
  50. field: 'project_domain',
  51. },
  52. ],
  53. groupActions: [
  54. {
  55. label: this.$t('system.text_195', [this.$t('dictionary.group')]),
  56. permission: 'users_perform_join',
  57. action: () => {
  58. this.createDialog('UserGroupJoinDialog', {
  59. onManager: this.onManager,
  60. data: [this.data],
  61. resItem: this.data,
  62. title: this.$t('system.text_195', [this.$t('dictionary.group')]),
  63. columns: [
  64. getNameDescriptionTableColumn({
  65. hideField: true,
  66. formRules: [
  67. { required: true, message: i18n.t('system.text_168') },
  68. ],
  69. edit: row => row.idp_driver !== 'ldap',
  70. slotCallback: row => {
  71. return (
  72. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row) }>{ row.name }</side-page-trigger>
  73. )
  74. },
  75. }),
  76. getProjectDomainTableColumn(),
  77. getEnabledTableColumn(),
  78. ],
  79. refresh: this.refresh,
  80. })
  81. },
  82. meta: () => {
  83. return {
  84. validate: !this.isldap,
  85. tooltip: this.isldap && this.$t('system.text_521'),
  86. }
  87. },
  88. },
  89. {
  90. label: this.$t('system.text_525'),
  91. permission: 'users_perform_leave',
  92. action: () => {
  93. this.createDialog('UserGroupLeaveDialog', {
  94. title: this.$t('system.text_525'),
  95. onManager: this.lionManagerst,
  96. data: this.list.selectedItems,
  97. resItem: this.data,
  98. columns: this.columns,
  99. refresh: this.refresh,
  100. })
  101. },
  102. meta: () => {
  103. if (this.list.selectedItems <= 0) {
  104. return {
  105. validate: false,
  106. }
  107. }
  108. return {
  109. validate: !this.isldap,
  110. tooltip: this.isldap && this.$t('system.text_521'),
  111. }
  112. },
  113. },
  114. ],
  115. singleActions: [
  116. {
  117. label: this.$t('system.text_525'),
  118. permission: 'users_perform_leave',
  119. action: (obj) => {
  120. this.createDialog('UserGroupLeaveDialog', {
  121. title: this.$t('system.text_525'),
  122. onManager: this.lionManagerst,
  123. data: [obj],
  124. resItem: this.data,
  125. columns: this.columns,
  126. refresh: this.refresh,
  127. })
  128. },
  129. meta: (obj) => {
  130. return {
  131. validate: !this.isldap,
  132. tooltip: this.isldap && this.$t('system.text_521'),
  133. }
  134. },
  135. },
  136. ],
  137. }
  138. },
  139. computed: {
  140. isldap () {
  141. return this.data.idp_driver === 'ldap'
  142. },
  143. },
  144. created () {
  145. this.list.fetchData()
  146. },
  147. methods: {
  148. getList (params) {
  149. return new this.$Manager('groups', 'v1').list({
  150. params: params,
  151. ctx: [['users', this.data.id]],
  152. })
  153. },
  154. },
  155. }
  156. </script>