ClouduserList.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :single-actions="singleActions"
  6. :group-actions="groupActions"
  7. :export-data-options="exportDataOptions" />
  8. </template>
  9. <script>
  10. import * as R from 'ramda'
  11. import WindowsMixin from '@/mixins/windows'
  12. import ListMixin from '@/mixins/list'
  13. import ColumnsMixin from '@Cloudenv/views/clouduser/mixins/columns'
  14. export default {
  15. name: 'ClouduserListForCloudgroupSidepage',
  16. mixins: [WindowsMixin, ListMixin, ColumnsMixin],
  17. props: {
  18. id: String,
  19. getParams: {
  20. type: Object,
  21. default: () => ({}),
  22. },
  23. resId: String,
  24. data: Object,
  25. },
  26. data () {
  27. return {
  28. list: this.$list.createList(this, {
  29. id: this.id,
  30. resource: 'cloudusers',
  31. apiVersion: 'v1',
  32. getParams: this.getParam,
  33. filterOptions: {
  34. name: {
  35. label: this.$t('cloudenv.clouduser_list_t1'),
  36. },
  37. owner_name: {
  38. label: this.$t('cloudenv.clouduser_list_t4'),
  39. },
  40. },
  41. }),
  42. exportDataOptions: {
  43. items: [
  44. { label: 'ID', key: 'id' },
  45. { label: this.$t('table.title.name'), key: 'name' },
  46. { label: this.$t('cloudenv.clouduser_list_t5'), key: 'is_console_login' },
  47. { label: this.$t('cloudenv.text_98'), key: 'status' },
  48. { label: this.$t('cloudenv.clouduser_list_t3'), key: 'iam_login_url' },
  49. { label: this.$t('cloudenv.clouduser_list_t4'), key: 'owner_name' },
  50. { label: this.$t('table.title.brand'), key: 'brand' },
  51. { label: this.$t('common.text00108'), key: 'cloudaccount' },
  52. ],
  53. },
  54. groupActions: [
  55. {
  56. label: this.$t('common.remove'),
  57. permission: 'clouduser_perform_leave_group',
  58. action: () => {
  59. this.createDialog('DeleteResDialog', {
  60. vm: this,
  61. data: this.list.selectedItems,
  62. columns: this.columns,
  63. title: this.$t('common.remove'),
  64. name: this.$t('cloudenv.coludgroup_text001'),
  65. onManager: this.onManager,
  66. ok: async ids => {
  67. try {
  68. const response = await this.manager.batchPerformAction({
  69. ids,
  70. action: 'leave-group',
  71. data: {
  72. cloudgroup_id: this.resId,
  73. },
  74. })
  75. this.list.refresh()
  76. this.$bus.$emit('CloudgroupListSingleRefresh', this.resId)
  77. return response
  78. } finally {}
  79. },
  80. })
  81. },
  82. meta: () => {
  83. if (!this.isOwner()) {
  84. return {
  85. validate: false,
  86. tooltip: this.$t('common_614'),
  87. }
  88. }
  89. return this.$getDeleteResult(this.list.selectedItems)
  90. },
  91. },
  92. ],
  93. singleActions: [
  94. {
  95. label: this.$t('common.remove'),
  96. permission: 'clouduser_perform_leave_group',
  97. action: (obj) => {
  98. this.createDialog('DeleteResDialog', {
  99. vm: this,
  100. data: [obj],
  101. columns: this.columns,
  102. title: this.$t('common.remove'),
  103. name: this.$t('cloudenv.coludgroup_text001'),
  104. onManager: this.onManager,
  105. ok: async ids => {
  106. try {
  107. const response = await this.manager.batchPerformAction({
  108. ids,
  109. action: 'leave-group',
  110. data: {
  111. cloudgroup_id: this.resId,
  112. },
  113. })
  114. this.list.refresh()
  115. this.$bus.$emit('CloudgroupListSingleRefresh', this.resId)
  116. return response
  117. } finally {}
  118. },
  119. })
  120. },
  121. meta: (obj) => {
  122. if (!this.isOwner()) {
  123. return {
  124. validate: false,
  125. tooltip: this.$t('common_614'),
  126. }
  127. }
  128. return this.$getDeleteResult(obj)
  129. },
  130. },
  131. ],
  132. }
  133. },
  134. destroyed () {
  135. this.manager = null
  136. },
  137. created () {
  138. this.list.fetchData()
  139. this.manager = new this.$Manager('cloudusers', 'v1')
  140. this.$bus.$on('CloudgroupSidepageClouduserListRefresh', () => {
  141. this.list.refresh()
  142. }, this)
  143. },
  144. methods: {
  145. getParam () {
  146. const ret = {
  147. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  148. }
  149. return ret
  150. },
  151. isOwner () {
  152. return this.$store.getters.isAdminMode || (this.data && this.data.domain_id === this.$store.getters.userInfo.projectDomainId)
  153. },
  154. },
  155. }
  156. </script>