List.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 ColumnsMixin from '../mixins/columns'
  10. import SingleActionsMixin from '../mixins/singleActions'
  11. import WindowsMixin from '@/mixins/windows'
  12. import ListMixin from '@/mixins/list'
  13. import { getNameFilter } from '@/utils/common/tableFilter'
  14. export default {
  15. name: 'K8SRepoList',
  16. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  17. props: {
  18. id: String,
  19. getParams: {
  20. type: Object,
  21. default: () => ({}),
  22. },
  23. },
  24. data () {
  25. return {
  26. list: this.$list.createList(this, {
  27. id: this.id,
  28. resource: 'repos',
  29. apiVersion: 'v1',
  30. getParams: this.getParams,
  31. filterOptions: {
  32. name: getNameFilter(),
  33. },
  34. }),
  35. groupActions: [
  36. {
  37. label: this.$t('helm.text_68'),
  38. permission: 'k8s_repos_create',
  39. action: () => {
  40. this.createDialog('ChartCreateDialog', {
  41. onManager: this.onManager,
  42. formType: 'create',
  43. refresh: this.refresh,
  44. })
  45. },
  46. meta: () => ({
  47. buttonType: 'primary',
  48. validate: this.$store.getters.isAmdinMode,
  49. }),
  50. },
  51. {
  52. label: this.$t('helm.text_69'),
  53. permission: 'k8s_repos_delete',
  54. action: () => {
  55. const data = this.list.selectedItems
  56. this.createDialog('DeleteResDialog', {
  57. vm: this,
  58. data,
  59. columns: this.columns,
  60. title: this.$t('helm.text_69'),
  61. name: this.$t('helm.text_6'),
  62. onManager: this.onManager,
  63. })
  64. },
  65. meta: () => {
  66. const isAdmin = this.$store.getters.isAdminMode
  67. const validate = this.list.selectedItems.length > 0 && isAdmin && this.list.selectedItems.every(val => val.can_delete)
  68. let tooltip = ''
  69. if (!isAdmin) {
  70. tooltip = this.$t('helm.text_89')
  71. }
  72. return {
  73. validate,
  74. tooltip,
  75. }
  76. },
  77. },
  78. ],
  79. }
  80. },
  81. created () {
  82. this.fetchData()
  83. },
  84. methods: {
  85. fetchData () {
  86. this.list.fetchData()
  87. },
  88. handleOpenSidepage (row) {
  89. this.sidePageTriggerHandle(this, 'K8SRepoSidePage', {
  90. id: row.name,
  91. resource: 'repos',
  92. getParams: this.getParams,
  93. // idKey: 'name',
  94. apiVersion: 'v1',
  95. }, {
  96. list: this.list,
  97. })
  98. },
  99. },
  100. }
  101. </script>