List.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions" />
  7. </template>
  8. <script>
  9. import WindowsMixin from '@/mixins/windows'
  10. import ListMixin from '@/mixins/list'
  11. import {
  12. getNameFilter,
  13. getCreatedAtFilter,
  14. } from '@/utils/common/tableFilter'
  15. import ColumnsMixin from '../mixins/columns'
  16. import SingleActionsMixin from '../mixins/singleActions'
  17. export default {
  18. name: 'K8sReposList',
  19. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  20. props: {
  21. id: String,
  22. getParams: {
  23. type: Object,
  24. default: () => ({}),
  25. },
  26. },
  27. data () {
  28. return {
  29. list: this.$list.createList(this, {
  30. id: this.id,
  31. resource: 'container_registries',
  32. apiVersion: 'v1',
  33. getParams: this.getParams,
  34. filterOptions: {
  35. name: getNameFilter(),
  36. url: {
  37. label: this.$t('k8s.repo.url'),
  38. },
  39. created_at: getCreatedAtFilter(),
  40. },
  41. }),
  42. groupActions: [
  43. {
  44. label: this.$t('common.create'),
  45. permission: 'k8s_container_registries_create',
  46. action: () => {
  47. this.createDialog('ReposCreateDialog', {
  48. refresh: this.refresh,
  49. })
  50. },
  51. meta: () => {
  52. return {
  53. buttonType: 'primary',
  54. validate: true,
  55. }
  56. },
  57. },
  58. {
  59. label: this.$t('table.action.delete'),
  60. permission: 'k8s_container_registries_delete',
  61. action: () => {
  62. this.createDialog('DeleteResDialog', {
  63. vm: this,
  64. data: this.list.selectedItems,
  65. columns: this.columns,
  66. title: this.$t('table.action.delete'),
  67. name: this.$t('k8s.text_158'),
  68. onManager: this.onManager,
  69. })
  70. },
  71. meta: () => {
  72. const ret = { validate: this.list.selected.length }
  73. if (this.list.selectedItems.some(item => !item.can_delete)) {
  74. ret.validate = false
  75. return ret
  76. }
  77. return ret
  78. },
  79. },
  80. ],
  81. }
  82. },
  83. created () {
  84. this.initSidePageTab('detail')
  85. this.list.fetchData()
  86. },
  87. methods: {
  88. getParam () {
  89. const ret = {
  90. ...this.getParams,
  91. details: true,
  92. }
  93. return ret
  94. },
  95. handleOpenSidepage (row) {
  96. this.sidePageTriggerHandle(this, 'K8sReposSidePage', {
  97. id: row.id,
  98. resource: 'container_registries',
  99. apiVersion: 'v1',
  100. getParams: this.getParam,
  101. }, {
  102. list: this.list,
  103. })
  104. },
  105. },
  106. }
  107. </script>