List.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :export-data-options="exportDataOptions"
  6. :group-actions="groupActions"
  7. :showSearchbox="showSearchbox"
  8. :showGroupActions="showGroupActions"
  9. :single-actions="singleActions" />
  10. </template>
  11. <script>
  12. import * as R from 'ramda'
  13. import ListMixin from '@/mixins/list'
  14. import expectStatus from '@/constants/expectStatus'
  15. import { getStatusFilter } from '@/utils/common/tableFilter'
  16. import WindowsMixin from '@/mixins/windows'
  17. import GlobalSearchMixin from '@/mixins/globalSearch'
  18. import SingleActionsMixin from '../mixins/singleActions'
  19. import ColumnsMixin from '../mixins/columns'
  20. export default {
  21. name: 'MountTargetList',
  22. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin],
  23. props: {
  24. id: String,
  25. getParams: {
  26. type: [Function, Object],
  27. },
  28. data: {
  29. type: Object,
  30. },
  31. hiddenActions: {
  32. type: Array,
  33. default: () => ([]),
  34. },
  35. },
  36. data () {
  37. return {
  38. list: this.$list.createList(this, {
  39. id: this.id,
  40. resource: 'mount_targets',
  41. getParams: this.getParam,
  42. steadyStatus: Object.values(expectStatus.mountTarget).flat(),
  43. filterOptions: {
  44. id: {
  45. label: this.$t('table.title.id'),
  46. },
  47. status: getStatusFilter('mountTarget'),
  48. },
  49. responseData: this.responseData,
  50. hiddenColumns: ['name', 'created_at'],
  51. }),
  52. exportDataOptions: {
  53. items: [
  54. { label: this.$t('common.network.type'), key: 'network_type' },
  55. { label: 'ID', key: 'id' },
  56. { label: this.$t('storage.text_41'), key: 'status' },
  57. { label: this.$t('dictionary.vpc'), key: 'vpc' },
  58. { label: this.$t('dictionary.network'), key: 'network' },
  59. { label: this.$t('dictionary.access_group'), key: 'access_group' },
  60. { label: this.$t('storage.mount.target.domain.name'), key: 'domain_name' },
  61. { label: this.$t('storage.created_at'), key: 'created_at' },
  62. ],
  63. },
  64. groupActions: [
  65. {
  66. label: this.$t('storage.text_31'),
  67. permission: 'mount_targets_create',
  68. action: () => {
  69. this.createDialog('MountTargetCreateDialog', {
  70. title: this.$t('storage.text_31'),
  71. data: this.data,
  72. refresh: this.refresh,
  73. onManager: this.onManager,
  74. })
  75. },
  76. meta: () => {
  77. if (this.data.status !== 'available') {
  78. return {
  79. validate: false,
  80. tooltip: this.$t('storage.filesystem.not.available.tooltip'),
  81. }
  82. }
  83. if (this.data.mount_target_count_limit > 0 && this.list.total >= this.data.mount_target_count_limit) {
  84. return {
  85. validate: false,
  86. tooltip: this.$t('storage.mount.target.max.count', [this.data.mount_target_count_limit]),
  87. }
  88. }
  89. const ret = { ...this.$isOwner(this.data), buttonType: 'primary' }
  90. if (!ret.validate) return ret
  91. return ret
  92. },
  93. hidden: () => this.hiddenActions.includes('create'),
  94. },
  95. ],
  96. }
  97. },
  98. created () {
  99. this.initSidePageTab('mount-target-detail')
  100. this.list.fetchData()
  101. },
  102. methods: {
  103. getParam () {
  104. const ret = {
  105. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  106. detail: true,
  107. }
  108. return ret
  109. },
  110. handleOpenSidepage (row) {
  111. this.sidePageTriggerHandle(this, 'MountTargetSidePage', {
  112. id: row.id,
  113. resource: 'mount_targets',
  114. getParams: this.getParam,
  115. }, {
  116. list: this.list,
  117. })
  118. },
  119. },
  120. }
  121. </script>