List.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. </template>
  9. <script>
  10. import get from 'lodash/get'
  11. import * as R from 'ramda'
  12. import { mapGetters } from 'vuex'
  13. import WindowsMixin from '@/mixins/windows'
  14. import ListMixin from '@/mixins/list'
  15. import expectStatus from '@/constants/expectStatus'
  16. import { getDistinctFieldFilter } from '@/utils/common/tableFilter'
  17. import ColumnsMixin from '../mixins/columns'
  18. import SingleActionsMixin from '../mixins/singleActions'
  19. export default {
  20. name: 'ClouduserList',
  21. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  22. props: {
  23. id: String,
  24. getParams: {
  25. type: [Object, Function],
  26. default: () => ({}),
  27. },
  28. cloudaccount: Object,
  29. },
  30. data () {
  31. return {
  32. list: this.$list.createList(this, {
  33. id: this.id,
  34. resource: 'cloudusers',
  35. apiVersion: 'v1',
  36. getParams: this.getParam,
  37. steadyStatus: Object.values(expectStatus.clouduser).flat(),
  38. filterOptions: {
  39. name: {
  40. label: this.$t('cloudenv.clouduser_list_t1'),
  41. },
  42. owner_name: {
  43. label: this.$t('cloudenv.clouduser_list_t4'),
  44. },
  45. cloudaccount: getDistinctFieldFilter({
  46. field: 'account',
  47. type: 'extra_field',
  48. label: this.$t('common.text00108'),
  49. }),
  50. },
  51. }),
  52. groupActions: [
  53. {
  54. label: this.$t('common.create'),
  55. permission: 'clouduser_create',
  56. action: () => {
  57. this.createDialog('ClouduserCreateDialog', {
  58. onManager: this.onManager,
  59. cloudaccount: this.cloudaccount,
  60. defaultDomainId: this.userInfo.projectDomainId,
  61. defaultProjectId: this.userInfo.projectId,
  62. userId: this.userInfo.id,
  63. })
  64. },
  65. meta: () => {
  66. return {
  67. validate: (this.$store.getters.isAdminMode || get(this.cloudaccount, 'domain_id') === this.$store.getters.userInfo.projectDomainId) && this.isNormalStatus(),
  68. buttonType: 'primary',
  69. }
  70. },
  71. },
  72. {
  73. label: this.$t('common.batchAction'),
  74. actions: () => {
  75. return [
  76. {
  77. label: this.$t('common.delete'),
  78. permission: 'clouduser_delete',
  79. action: () => {
  80. this.createDialog('DeleteResDialog', {
  81. vm: this,
  82. data: this.list.selectedItems,
  83. columns: this.columns,
  84. title: this.$t('common.delete'),
  85. name: this.$t('dictionary.clouduser'),
  86. onManager: this.onManager,
  87. })
  88. },
  89. meta: () => this.$getDeleteResult(this.list.selectedItems),
  90. },
  91. {
  92. label: this.$t('iam.enable_console_login'),
  93. permission: 'clouduser_perform_enable_console_login',
  94. action: (obj) => {
  95. this.createDialog('ClouduserSetConsoleLoginDialog', {
  96. vm: this,
  97. data: this.list.selectedItems,
  98. columns: this.columns,
  99. title: this.$t('iam.enable_console_login'),
  100. name: this.$t('dictionary.clouduser'),
  101. onManager: this.onManager,
  102. action: 'enable-console-login',
  103. })
  104. },
  105. meta: (obj) => {
  106. return {
  107. validate: this.list.selectedItems.length && this.list.selectedItems.some(item => !item.is_console_login),
  108. }
  109. },
  110. hidden: () => !this.$appConfig.isPrivate,
  111. },
  112. {
  113. label: this.$t('iam.disable_console_login'),
  114. permission: 'clouduser_disable_console_login',
  115. action: (obj) => {
  116. this.createDialog('ClouduserSetConsoleLoginDialog', {
  117. vm: this,
  118. data: this.list.selectedItems,
  119. columns: this.columns,
  120. title: this.$t('iam.disable_console_login'),
  121. name: this.$t('dictionary.clouduser'),
  122. onManager: this.onManager,
  123. action: 'disable-console-login',
  124. })
  125. },
  126. meta: (obj) => {
  127. return {
  128. validate: this.list.selectedItems.length && this.list.selectedItems.some(item => item.is_console_login),
  129. }
  130. },
  131. hidden: () => !this.$appConfig.isPrivate,
  132. },
  133. ]
  134. },
  135. meta: () => {
  136. return {
  137. validate: this.list.selectedItems && this.list.selectedItems.length > 0 && (this.$store.getters.isAdminMode || get(this.cloudaccount, 'domain_id') === this.$store.getters.userInfo.projectDomainId) && this.isNormalStatus(),
  138. }
  139. },
  140. },
  141. ],
  142. }
  143. },
  144. computed: {
  145. ...mapGetters(['userInfo']),
  146. exportDataOptions () {
  147. return {
  148. title: this.$t('dictionary.clouduser'),
  149. downloadType: 'local',
  150. items: [
  151. { field: 'id', title: 'ID' },
  152. ...this.columns,
  153. { field: 'manager', title: this.$t('common_624', [this.$t('dictionary.cloudprovider')]) },
  154. ],
  155. }
  156. },
  157. },
  158. created () {
  159. this.initSidePageTab('clouduser-detail')
  160. this.list.fetchData()
  161. },
  162. methods: {
  163. getParam () {
  164. const ret = {
  165. details: true,
  166. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  167. }
  168. return ret
  169. },
  170. },
  171. }
  172. </script>