List.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 expectStatus from '@/constants/expectStatus'
  14. import { getNameFilter } from '@/utils/common/tableFilter'
  15. import WindowsMixin from '@/mixins/windows'
  16. import ListMixin from '@/mixins/list'
  17. import ColumnsMixin from '../mixins/columns'
  18. import SingleActionsMixin from '../mixins/singleActions'
  19. export default {
  20. name: 'CloudaccountList',
  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: 'samlusers',
  35. getParams: this.getParam,
  36. apiVersion: 'v1',
  37. steadyStatus: Object.values(expectStatus.samluser).flat(),
  38. filterOptions: {
  39. name: getNameFilter(),
  40. },
  41. }),
  42. groupActions: [
  43. {
  44. label: this.$t('cloudenv.text_104'),
  45. permission: 'samlusers_create',
  46. action: () => {
  47. this.createDialog('SamluserCreateDialog', {
  48. onManager: this.onManager,
  49. cloudaccount: this.cloudaccount,
  50. defaultDomainId: this.userInfo.projectDomainId,
  51. defaultProjectId: this.userInfo.projectId,
  52. userId: this.userInfo.id,
  53. })
  54. },
  55. meta: () => {
  56. return {
  57. validate: (this.$store.getters.isAdminMode || get(this.cloudaccount, 'domain_id') === this.$store.getters.userInfo.projectDomainId),
  58. buttonType: 'primary',
  59. }
  60. },
  61. },
  62. {
  63. label: this.$t('table.action.delete'),
  64. permission: 'samlusers_delete',
  65. action: () => {
  66. this.createDialog('DeleteResDialog', {
  67. vm: this,
  68. data: this.list.selectedItems,
  69. columns: this.columns,
  70. title: this.$t('table.action.delete'),
  71. name: this.$t('res.samlusers'),
  72. onManager: this.onManager,
  73. })
  74. },
  75. meta: () => this.$getDeleteResult(this.list.selectedItems),
  76. },
  77. ],
  78. }
  79. },
  80. computed: {
  81. ...mapGetters(['userInfo']),
  82. exportDataOptions () {
  83. return {
  84. title: this.$t('dictionary.samluser'),
  85. downloadType: 'local',
  86. items: [
  87. { field: 'id', title: 'ID' },
  88. ...this.columns,
  89. { field: 'manager', title: this.$t('common_624', [this.$t('dictionary.cloudprovider')]) },
  90. ],
  91. }
  92. },
  93. },
  94. watch: {
  95. cloudEnv (val) {
  96. this.$nextTick(() => {
  97. this.list.fetchData(0)
  98. })
  99. },
  100. },
  101. created () {
  102. this.initSidePageTab('samluser-detail')
  103. this.list.fetchData()
  104. },
  105. methods: {
  106. getParam () {
  107. const ret = {
  108. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  109. }
  110. if (this.cloudEnv) ret.cloud_env = this.cloudEnv
  111. return ret
  112. },
  113. handleOpenSidepage (row) {
  114. this.sidePageTriggerHandle(this, 'SamluserSidePage', {
  115. id: row.id,
  116. resource: 'samlusers',
  117. getParams: this.getParams,
  118. refresh: this.refresh,
  119. apiVersion: 'v1',
  120. }, {
  121. list: this.list,
  122. })
  123. },
  124. },
  125. }
  126. </script>