columns.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { sizestr } from '@/utils/utils'
  2. import {
  3. getNameDescriptionTableColumn,
  4. getBrandTableColumn,
  5. getStatusTableColumn,
  6. getProjectTableColumn,
  7. getTimeTableColumn,
  8. getCopyWithContentTableColumn,
  9. getTagTableColumn,
  10. getRegionTableColumn,
  11. getAccountTableColumn,
  12. getOsArch,
  13. } from '@/utils/common/tableColumn'
  14. import i18n from '@/locales'
  15. import { getStorageTypeTableColumn } from '../utils/columns'
  16. import { DISK_TYPES } from '../constants'
  17. export default {
  18. created () {
  19. this.columns = [
  20. getNameDescriptionTableColumn({
  21. onManager: this.onManager,
  22. hideField: true,
  23. addEncrypt: true,
  24. slotCallback: row => {
  25. return (
  26. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row) }>{ row.name }</side-page-trigger>
  27. )
  28. },
  29. hidden: () => {
  30. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.name')
  31. },
  32. }),
  33. getStatusTableColumn({
  34. statusModule: 'snapshot',
  35. vm: this,
  36. hidden: () => {
  37. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.status')
  38. },
  39. }),
  40. getTagTableColumn({
  41. onManager: this.onManager,
  42. resource: 'snapshots',
  43. columns: () => this.columns,
  44. hidden: () => {
  45. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.metadata')
  46. },
  47. }),
  48. getOsArch({
  49. hidden: () => {
  50. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.os_arch')
  51. },
  52. }),
  53. {
  54. field: 'size',
  55. title: i18n.t('table.title.snapshot_size'),
  56. width: 70,
  57. formatter: ({ row }) => {
  58. return sizestr(row.size, 'M', 1024)
  59. },
  60. hidden: () => {
  61. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.size')
  62. },
  63. },
  64. {
  65. field: 'disk_type',
  66. title: i18n.t('table.title.disk_type'),
  67. width: 70,
  68. formatter: ({ row }) => {
  69. return DISK_TYPES[row.disk_type] || row.disk_type
  70. },
  71. hidden: () => {
  72. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.disk_type')
  73. },
  74. },
  75. getCopyWithContentTableColumn({
  76. field: 'disk_name',
  77. title: i18n.t('res.disk'),
  78. hideField: true,
  79. slotCallback: (row) => {
  80. if (this.isPreLoad && !row.disk_name) return [<data-loading />]
  81. return row.disk_name
  82. },
  83. formatter: ({ row }) => {
  84. return row.disk_name
  85. },
  86. hidden: () => {
  87. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.disk_name')
  88. },
  89. }),
  90. getStorageTypeTableColumn({
  91. vm: this,
  92. hidden: () => {
  93. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.storage_type')
  94. },
  95. }),
  96. {
  97. field: 'guest',
  98. title: i18n.t('res.server'),
  99. minWidth: 70,
  100. showOverflow: 'ellipsis',
  101. slots: {
  102. default: ({ row }, h) => {
  103. if (this.isPreLoad && !row.guest) return [<data-loading />]
  104. return [
  105. <div class='text-truncate'>
  106. {row.guest ? <list-body-cell-wrap copy field='guest' row={row} /> : '-'}
  107. {row.guest_status ? <status status={ row.guest_status } statusModule='server'/> : ''}
  108. </div>,
  109. ]
  110. },
  111. },
  112. formatter: ({ row }) => {
  113. return row.guest || '-'
  114. },
  115. hidden: () => {
  116. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.guest')
  117. },
  118. },
  119. getBrandTableColumn({
  120. hidden: () => {
  121. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.brand')
  122. },
  123. }),
  124. getAccountTableColumn({
  125. vm: this,
  126. hidden: () => {
  127. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.account')
  128. },
  129. }),
  130. getTimeTableColumn({
  131. hidden: () => {
  132. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.created_at')
  133. },
  134. }),
  135. getProjectTableColumn({
  136. hidden: () => {
  137. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.tenant')
  138. },
  139. }),
  140. getRegionTableColumn({
  141. vm: this,
  142. hidden: () => {
  143. return this.$isScopedPolicyMenuHidden('snapshot_hidden_columns.region')
  144. },
  145. }),
  146. ]
  147. },
  148. }