AkSkList.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :single-actions="singleActions"
  6. :group-actions="groupActions" />
  7. </template>
  8. <script>
  9. import * as R from 'ramda'
  10. import DialogMixin from '@/mixins/dialog'
  11. import WindowsMixin from '@/mixins/windows'
  12. import ListMixin from '@/mixins/list'
  13. import {
  14. getTimeTableColumn,
  15. } from '@/utils/common/tableColumn'
  16. export default {
  17. name: 'AkSkListForClouduserSidepage',
  18. mixins: [DialogMixin, WindowsMixin, ListMixin],
  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: 'AkSkListForClouduserSidepage',
  30. idKey: 'access_key',
  31. resource: 'access-keys',
  32. ctx: [['cloudusers', this.resId]],
  33. apiVersion: 'v1',
  34. getParams: this.getParam,
  35. filterOptions: {},
  36. }),
  37. columns: [
  38. {
  39. field: 'access_key',
  40. title: this.$t('cloudenv.aksk'),
  41. formatter: ({ row }) => {
  42. return row.access_key
  43. },
  44. },
  45. {
  46. field: 'name',
  47. title: this.$t('cloudenv.text_331'),
  48. formatter: ({ row }) => {
  49. return row.name
  50. },
  51. },
  52. {
  53. field: 'status',
  54. title: this.$t('cloudenv.text_98'),
  55. slots: {
  56. default: ({ row }, h) => {
  57. return [
  58. <div class='text-truncate'>
  59. <status status={ row.status === 'active' } statusModule='enabled' />
  60. </div>,
  61. ]
  62. },
  63. },
  64. },
  65. getTimeTableColumn(),
  66. ],
  67. singleActions: [
  68. {
  69. label: this.$t('common.delete'),
  70. action: (obj) => {
  71. this.createDialog('DeleteResDialog', {
  72. vm: this,
  73. data: [obj],
  74. columns: this.columns,
  75. title: this.$t('common.delete'),
  76. name: this.$t('cloudenv.aksk'),
  77. idKey: 'access_key',
  78. onManager: this.onManager,
  79. ok: async ids => {
  80. try {
  81. const manager = new this.$Manager('cloudusers')
  82. const response = await manager.performAction({
  83. id: this.resId,
  84. action: 'delete-access-key',
  85. data: {
  86. access_key: ids[0],
  87. },
  88. })
  89. this.list.refresh()
  90. return response
  91. } finally {}
  92. },
  93. })
  94. },
  95. },
  96. ],
  97. groupActions: [
  98. {
  99. label: this.$t('common.create'),
  100. action: () => {
  101. this.createDialog('AkSkCreateDialog', {
  102. cloudaccountId: this.resId,
  103. callback: (data) => {
  104. this.createDialog('AkskDownloadDialog', {
  105. data: data,
  106. })
  107. this.list.fetchData()
  108. },
  109. })
  110. },
  111. meta: () => {
  112. return {
  113. validate: this.list.total < 2,
  114. buttonType: 'primary',
  115. }
  116. },
  117. },
  118. ],
  119. }
  120. },
  121. created () {
  122. this.list.fetchData()
  123. },
  124. methods: {
  125. getParam () {
  126. const ret = {
  127. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  128. }
  129. return ret
  130. },
  131. },
  132. }
  133. </script>
  134. <style>
  135. </style>