List.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :showSearchbox="showSearchbox"
  8. :showGroupActions="showGroupActions" />
  9. </template>
  10. <script>
  11. import * as R from 'ramda'
  12. import { getNameFilter, getCreatedAtFilter, getProjectDomainFilter, getStatusFilter } from '@/utils/common/tableFilter'
  13. import expectStatus from '@/constants/expectStatus'
  14. import WindowsMixin from '@/mixins/windows'
  15. import GlobalSearchMixin from '@/mixins/globalSearch'
  16. import ListMixin from '@/mixins/list'
  17. import SingleActionsMixin from '../mixins/singleActions'
  18. import ColumnsMixin from '../mixins/columns'
  19. export default {
  20. name: 'KubeclusterList',
  21. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin],
  22. props: {
  23. id: String,
  24. getParams: {
  25. type: [Function, Object],
  26. },
  27. },
  28. data () {
  29. const filter = {}
  30. if (this.$route.query.domain) {
  31. filter.domain = [this.$route.query.domain]
  32. }
  33. return {
  34. list: this.$list.createList(this, {
  35. id: this.id,
  36. resource: 'kubeclusters',
  37. apiVersion: 'v1',
  38. getParams: this.getParam,
  39. filterOptions: {
  40. id: {
  41. label: this.$t('table.title.id'),
  42. },
  43. name: getNameFilter(),
  44. mode: {
  45. label: this.$t('k8s.text_186'),
  46. items: [
  47. { label: this.$t('k8s.text_187'), key: 'customize' },
  48. { label: this.$t('k8s.text_143'), key: 'import' },
  49. ],
  50. dropdown: true,
  51. },
  52. status: getStatusFilter({ statusModule: 'kubecluster' }),
  53. project_domain: getProjectDomainFilter(),
  54. created_at: getCreatedAtFilter(),
  55. },
  56. filter,
  57. steadyStatus: {
  58. status: Object.values(expectStatus.kubecluster).flat(),
  59. sync_status: Object.values(expectStatus.kubecluster_sync_status).flat(),
  60. },
  61. hiddenColumns: ['created_at'],
  62. }),
  63. groupActions: [
  64. {
  65. label: this.$t('k8s.create'),
  66. permission: 'k8s_kubeclusters_create',
  67. action: () => {
  68. this.$router.push({ path: '/k8s-cluster/create' })
  69. },
  70. meta: () => ({
  71. buttonType: 'primary',
  72. }),
  73. },
  74. {
  75. label: this.$t('k8s.text_143'),
  76. permission: 'k8s_kubeclusters_create',
  77. action: () => {
  78. this.$router.push({ path: '/k8s-cluster/import' })
  79. },
  80. },
  81. ],
  82. }
  83. },
  84. created () {
  85. this.initSidePageTab('kube-machine-list')
  86. this.list.fetchData()
  87. },
  88. methods: {
  89. getParam () {
  90. const ret = { ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams) }
  91. return ret
  92. },
  93. handleOpenSidepage (row, tab) {
  94. if (tab) {
  95. this.initSidePageTab(tab)
  96. }
  97. this.sidePageTriggerHandle(this, 'K8SClusterSidePage', {
  98. id: row.id,
  99. resource: 'kubeclusters',
  100. apiVersion: 'v1',
  101. getParams: this.getParam,
  102. }, {
  103. list: this.list,
  104. })
  105. },
  106. },
  107. }
  108. </script>