List.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions">
  7. <template v-slot:group-actions-append>
  8. <cluster-namespace :getParams.sync="list.getParams" :ignoreNamespace="true" @refresh="fetchData" class="ml-3" />
  9. </template>
  10. </page-list>
  11. </template>
  12. <script>
  13. import ColumnsMixin from '../mixins/columns'
  14. import SingleActionsMixin from '../mixins/singleActions'
  15. import ClusterNamespace from '@K8S/sections/ClusterNamespace'
  16. import { getNameFilter } from '@/utils/common/tableFilter'
  17. import WindowsMixin from '@/mixins/windows'
  18. import ListMixin from '@/mixins/list'
  19. import expectStatus from '@/constants/expectStatus'
  20. export default {
  21. name: 'K8sStorageclassesList',
  22. components: {
  23. ClusterNamespace,
  24. },
  25. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  26. props: {
  27. id: String,
  28. getParams: {
  29. type: Object,
  30. default: () => ({}),
  31. },
  32. },
  33. data () {
  34. return {
  35. list: this.$list.createList(this, {
  36. id: this.id,
  37. resource: 'storageclasses',
  38. apiVersion: 'v1',
  39. getParams: this.getParams,
  40. filterOptions: {
  41. name: getNameFilter(),
  42. },
  43. steadyStatus: {
  44. status: Object.values(expectStatus.k8s_resource).flat(),
  45. },
  46. }),
  47. groupActions: [
  48. {
  49. label: this.$t('k8s.create'),
  50. permission: 'k8s_storageclasses_create',
  51. action: () => {
  52. this.$router.push({ path: '/k8s-storageclass/create' })
  53. },
  54. meta: () => ({
  55. buttonType: 'primary',
  56. }),
  57. },
  58. {
  59. label: this.$t('k8s.text_201'),
  60. permission: 'k8s_storageclasses_delete',
  61. action: () => {
  62. this.createDialog('DeleteResDialog', {
  63. vm: this,
  64. data: this.list.selectedItems,
  65. columns: this.columns,
  66. title: this.$t('k8s.text_347'),
  67. name: this.$t('k8s.text_22'),
  68. onManager: this.onManager,
  69. requestData: {
  70. cluster: this.list.selectedItems[0].clusterID,
  71. },
  72. requestParams: {
  73. id: this.list.selectedItems.map(item => item.id),
  74. },
  75. })
  76. },
  77. meta: () => {
  78. if (this.list.selectedItems.length > 0) {
  79. const namespaces = this.list.selectedItems.map(v => v.namespace)
  80. const unique = Array.from(new Set(namespaces))
  81. if (unique.length > 1) {
  82. return {
  83. validate: false,
  84. tooltip: this.$t('k8s.text_203'),
  85. }
  86. }
  87. return {
  88. validate: true,
  89. tooltip: '',
  90. }
  91. } else {
  92. return {
  93. validate: false,
  94. tooltip: this.$t('k8s.text_204'),
  95. }
  96. }
  97. },
  98. },
  99. ],
  100. }
  101. },
  102. created () {
  103. this.fetchData()
  104. },
  105. methods: {
  106. fetchData () {
  107. if (this.list.getParams.cluster) {
  108. this.list.fetchData()
  109. }
  110. },
  111. handleOpenSidepage (row) {
  112. this.sidePageTriggerHandle(this, 'K8SStorageclassSidePage', {
  113. id: row.id,
  114. resource: 'storageclasses',
  115. apiVersion: 'v1',
  116. getParams: this.list.getParams,
  117. }, {
  118. list: this.list,
  119. })
  120. },
  121. },
  122. }
  123. </script>