List.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <page-list
  3. show-tag-filter
  4. show-tag-columns
  5. show-tag-columns2
  6. show-tag-config
  7. :list="list"
  8. :columns="columns"
  9. :group-actions="groupActions"
  10. :single-actions="singleActions"
  11. :tag-config-params="tagConfigParams"
  12. tag-filter-resource="credentials" />
  13. </template>
  14. <script>
  15. import WindowsMixin from '@/mixins/windows'
  16. import ListMixin from '@/mixins/list'
  17. import { getNameFilter } from '@/utils/common/tableFilter'
  18. import SingleActionsMixin from '../mixins/singleActions'
  19. import ColumnsMixin from '../mixins/columns'
  20. const credentialIdFilterFormatter = (val) => `id.equals('${val}')`
  21. export default {
  22. name: 'ContainerSecretList',
  23. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  24. props: {
  25. id: String,
  26. getParams: {
  27. type: Object,
  28. },
  29. type: {
  30. type: String,
  31. default: 'container_secret',
  32. },
  33. },
  34. data () {
  35. return {
  36. list: this.$list.createList(this, {
  37. id: this.id,
  38. resource: 'credentials',
  39. apiVersion: 'v1',
  40. getParams: this.getParam,
  41. filterOptions: {
  42. id: {
  43. label: this.$t('table.title.id'),
  44. filter: true,
  45. formatter: credentialIdFilterFormatter,
  46. },
  47. name: getNameFilter(),
  48. },
  49. hiddenColumns: [],
  50. }),
  51. tagConfigParams: {
  52. resource: 'credentials',
  53. },
  54. groupActions: [
  55. {
  56. label: this.$t('common.create'),
  57. action: () => {
  58. this.createDialog('ContainerSecretCreateDialog', {
  59. callback: () => {
  60. this.list.refresh()
  61. },
  62. })
  63. },
  64. meta: () => ({
  65. buttonType: 'primary',
  66. validate: true,
  67. }),
  68. hidden: this.type === 'container_image',
  69. },
  70. {
  71. label: this.$t('table.action.delete'),
  72. action: () => {
  73. this.createDialog('DeleteResDialog', {
  74. vm: this,
  75. data: this.list.selectedItems,
  76. columns: this.columns,
  77. title: this.$t('table.action.delete'),
  78. name: this.$t('aice.container_secret'),
  79. onManager: this.onManager,
  80. })
  81. },
  82. meta: () => ({
  83. validate: this.list.selected.length,
  84. }),
  85. },
  86. ],
  87. }
  88. },
  89. created () {
  90. this.initSidePageTab('detail')
  91. const q = this.$route.query || {}
  92. if (this.type === 'container_image' && q.type === 'container_image' && q.id) {
  93. const idStr = String(Array.isArray(q.id) ? q.id[0] : q.id).trim()
  94. if (idStr) {
  95. this.list.changeFilter({
  96. id: [idStr],
  97. __condition_id: 'equals',
  98. })
  99. } else {
  100. this.list.fetchData()
  101. }
  102. } else {
  103. this.list.fetchData()
  104. }
  105. },
  106. methods: {
  107. getParam () {
  108. const ret = {
  109. ...this.getParams,
  110. 'filter.0': `type.equals(${this.type})`,
  111. }
  112. if (this.$store.getters.scope === 'project') {
  113. const uid = this.$store.getters.userInfo?.id
  114. if (uid) ret['filter.1'] = `user_id.equals(${uid})`
  115. }
  116. return ret
  117. },
  118. handleOpenSidepage (row) {
  119. this.sidePageTriggerHandle(this, 'ContainerSecretSidePage', {
  120. id: row.id,
  121. resource: 'credentials',
  122. apiVersion: 'v1',
  123. getParams: () => ({}),
  124. }, {
  125. list: this.list,
  126. })
  127. },
  128. },
  129. }
  130. </script>