columns.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import i18n from '@/locales'
  2. import { sizestr } from '@/utils/utils'
  3. import {
  4. getCopyWithContentTableColumn,
  5. } from '@/utils/common/tableColumn'
  6. import { DISK_TYPES } from '../constants'
  7. export const getDiskSizeTableColumn = () => {
  8. return {
  9. field: 'disk_size_mb',
  10. title: i18n.t('compute.disk_size'),
  11. minWidth: 70,
  12. formatter: ({ row }) => {
  13. return sizestr(row.disk_size_mb, 'M', 1024)
  14. },
  15. }
  16. }
  17. export const getSizeMbTableColumn = () => {
  18. return {
  19. field: 'size_mb',
  20. title: i18n.t('compute.backup_size'),
  21. minWidth: 70,
  22. formatter: ({ row }) => {
  23. return sizestr(row.size_mb, 'M', 1024)
  24. },
  25. }
  26. }
  27. export const getDiskTypeTableColumn = () => {
  28. return {
  29. field: 'disk_type',
  30. title: i18n.t('table.title.disk_type'),
  31. width: 80,
  32. formatter: ({ row }) => {
  33. return DISK_TYPES[row.disk_type] || row.disk_type
  34. },
  35. }
  36. }
  37. export const getDiskNameTableColumn = () => {
  38. return getCopyWithContentTableColumn({
  39. field: 'disk_name',
  40. title: i18n.t('res.disk'),
  41. hideField: true,
  42. slotCallback: (row) => {
  43. return row.disk_name
  44. },
  45. })
  46. }
  47. export const getBackupStorageNameTableColumn = () => {
  48. return getCopyWithContentTableColumn({
  49. field: 'backup_storage_name',
  50. title: i18n.t('compute.backup_storage'),
  51. hideField: true,
  52. slotCallback: (row) => {
  53. return row.backup_storage_name
  54. },
  55. })
  56. }