CloudgroupList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. :expand-config="{ lazy: true, loadMethod: loadPolicy }" />
  9. </template>
  10. <script>
  11. import * as R from 'ramda'
  12. import ColumnsMixin from '@Cloudenv/views/cloudgroup/mixins/columns'
  13. import { getNameFilter, getBrandFilter } from '@/utils/common/tableFilter'
  14. import WindowsMixin from '@/mixins/windows'
  15. import ListMixin from '@/mixins/list'
  16. export default {
  17. name: 'CloudgroupListForClouduserSidepage',
  18. mixins: [WindowsMixin, ListMixin, ColumnsMixin],
  19. props: {
  20. getParams: {
  21. type: Object,
  22. default: () => ({}),
  23. },
  24. resId: String,
  25. },
  26. data () {
  27. return {
  28. list: this.$list.createList(this, {
  29. id: 'CloudgroupListForClouduserSidepage',
  30. resource: 'cloudgroups',
  31. apiVersion: 'v1',
  32. getParams: this.getParam,
  33. filterOptions: {
  34. name: getNameFilter(),
  35. provider: getBrandFilter(),
  36. },
  37. }),
  38. exportDataOptions: {
  39. items: [
  40. { label: 'ID', key: 'id' },
  41. { label: this.$t('table.title.name'), key: 'name' },
  42. { label: this.$t('table.title.brand'), key: 'brand' },
  43. ],
  44. },
  45. groupActions: [
  46. {
  47. label: this.$t('common.delete'),
  48. permission: 'clouduser_perform_leave_group',
  49. action: () => {
  50. this.createDialog('DeleteResDialog', {
  51. vm: this,
  52. data: this.list.selectedItems,
  53. columns: this.columns,
  54. title: this.$t('cloudenv.cloudgroup_delete_tip'),
  55. name: this.$t('dictionary.cloudgroup'),
  56. onManager: this.onManager,
  57. ok: async ids => {
  58. try {
  59. const response = await this.manager.batchPerformAction({
  60. ids,
  61. action: 'remove-user',
  62. data: {
  63. clouduser_id: this.resId,
  64. },
  65. })
  66. this.list.refresh()
  67. return response
  68. } finally {}
  69. },
  70. })
  71. },
  72. meta: () => {
  73. if (this.list.selectedItems.length < 0) {
  74. return {
  75. validate: false,
  76. }
  77. }
  78. if (!this.$store.getters.isAdminMode) {
  79. if (this.list.selectedItems.some(item => item.domain_id !== this.$store.getters.userInfo.domain.id)) {
  80. return {
  81. validate: false,
  82. }
  83. }
  84. }
  85. return this.$getDeleteResult(this.list.selectedItems)
  86. },
  87. },
  88. ],
  89. singleActions: [
  90. {
  91. label: this.$t('common.delete'),
  92. permission: 'clouduser_perform_leave_group',
  93. action: (obj) => {
  94. this.createDialog('DeleteResDialog', {
  95. vm: this,
  96. data: [obj],
  97. columns: this.columns,
  98. title: this.$t('cloudenv.cloudgroup_delete_tip'),
  99. name: this.$t('dictionary.cloudgroup'),
  100. onManager: this.onManager,
  101. ok: async ids => {
  102. try {
  103. const response = await this.manager.batchPerformAction({
  104. ids,
  105. action: 'remove-user',
  106. data: {
  107. clouduser_id: this.resId,
  108. },
  109. })
  110. this.list.refresh()
  111. return response
  112. } finally {}
  113. },
  114. })
  115. },
  116. meta: (obj) => {
  117. if (!this.$store.getters.isAdminMode) {
  118. if (obj.domain_id !== this.$store.getters.userInfo.domain.id) {
  119. return {
  120. validate: false,
  121. }
  122. }
  123. }
  124. return this.$getDeleteResult(obj)
  125. },
  126. },
  127. ],
  128. }
  129. },
  130. destroyed () {
  131. this.manager = null
  132. },
  133. created () {
  134. this.list.fetchData()
  135. this.$bus.$on('CloudgroupListForClouduserSidepageRefresh', () => {
  136. this.list.refresh()
  137. }, this)
  138. this.manager = new this.$Manager('cloudgroups', 'v1')
  139. },
  140. methods: {
  141. getParam () {
  142. const ret = {
  143. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  144. }
  145. return ret
  146. },
  147. },
  148. }
  149. </script>