columns.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import {
  2. getNameDescriptionTableColumn,
  3. getTagTableColumn,
  4. getStatusTableColumn,
  5. getBrandTableColumn,
  6. getAccountTableColumn,
  7. getTimeTableColumn,
  8. getBillingTableColumn,
  9. getProjectTableColumn,
  10. } from '@/utils/common/tableColumn'
  11. import i18n from '@/locales'
  12. import { sizestr } from '@/utils/utils'
  13. export const getFileSystemTypeColumn = ({
  14. field = 'file_system_type',
  15. title = i18n.t('storage.filesystem.type'),
  16. } = {}) => {
  17. return {
  18. field,
  19. title,
  20. formatter: ({ row }) => {
  21. switch (row.file_system_type) {
  22. case 'standard':
  23. return i18n.t('storage.filesystem.type.standard')
  24. case 'extreme':
  25. return i18n.t('storage.filesystem.type.extreme')
  26. case 'cpfs':
  27. return 'CPFS'
  28. default:
  29. return row.file_system_type
  30. }
  31. },
  32. }
  33. }
  34. export const getFileSystemStorageTypeColumn = ({
  35. field = 'storage_type',
  36. title = i18n.t('storage.filesystem.storage.type'),
  37. } = {}) => {
  38. return {
  39. field,
  40. title,
  41. formatter: ({ row }) => {
  42. switch (row.storage_type) {
  43. case 'advance_200':
  44. return i18n.t('storage.filesystem.storage.type.advance.200')
  45. case 'advance_100':
  46. return i18n.t('storage.filesystem.storage.type.advance.100')
  47. case 'standard':
  48. return i18n.t('storage.filesystem.storage.type.standard')
  49. case 'advance':
  50. return i18n.t('storage.filesystem.storage.type.advance')
  51. case 'performance':
  52. return i18n.t('storage.filesystem.storage.type.performance')
  53. case 'capacity':
  54. return i18n.t('storage.filesystem.storage.type.capacity')
  55. case 'standard.enhanced':
  56. return i18n.t('storage.filesystem.storage.type.standard.enhanced')
  57. case 'performance.enhanced':
  58. return i18n.t('storage.filesystem.storage.type.performance.enhanced')
  59. default:
  60. return row.storage_type
  61. }
  62. },
  63. }
  64. }
  65. export const getFileSystemProtocolColumn = ({
  66. field = 'protocol',
  67. title = i18n.t('storage.filesystem.protocol'),
  68. } = {}) => {
  69. return {
  70. field,
  71. title,
  72. formatter: ({ row }) => {
  73. if (row.protocol) {
  74. return row.protocol.toUpperCase()
  75. }
  76. return '-'
  77. },
  78. }
  79. }
  80. export const getCapacityColumn = () => {
  81. return {
  82. field: 'capacity',
  83. title: i18n.t('storage.capacity'),
  84. sortable: true,
  85. formatter: ({ row }) => {
  86. return sizestr(row.capacity, 'G', 1024)
  87. },
  88. }
  89. }
  90. export default {
  91. created () {
  92. this.columns = [
  93. getNameDescriptionTableColumn({
  94. onManager: this.onManager,
  95. hideField: true,
  96. addLock: true,
  97. slotCallback: row => {
  98. return (
  99. <side-page-trigger onTrigger={() => this.handleOpenSidepage(row)}>{row.name}</side-page-trigger>
  100. )
  101. },
  102. }),
  103. getTagTableColumn({ onManager: this.onManager, resource: 'file_system', columns: () => this.columns }),
  104. getStatusTableColumn({ statusModule: 'nas', vm: this }),
  105. getCapacityColumn(),
  106. getFileSystemTypeColumn(),
  107. getFileSystemStorageTypeColumn(),
  108. getFileSystemProtocolColumn(),
  109. getBillingTableColumn({ vm: this }),
  110. getBrandTableColumn(),
  111. getAccountTableColumn(),
  112. getProjectTableColumn(),
  113. getTimeTableColumn(),
  114. {
  115. field: 'region',
  116. title: i18n.t('storage.text_47'),
  117. width: 150,
  118. },
  119. ]
  120. },
  121. }