columns.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import i18n from '@/locales'
  2. import { sizestr } from '@/utils/utils'
  3. import {
  4. getCopyWithContentTableColumn,
  5. } from '@/utils/common/tableColumn'
  6. import SystemIcon from '@/sections/SystemIcon'
  7. export const getBackupStorageNameTableColumn = () => {
  8. return getCopyWithContentTableColumn({
  9. field: 'backup_storage_name',
  10. title: i18n.t('compute.backup_storage'),
  11. hideField: true,
  12. slotCallback: (row) => {
  13. return row.backup_storage_name
  14. },
  15. })
  16. }
  17. export const getGuestTableColumn = () => {
  18. return {
  19. field: 'guest',
  20. title: i18n.t('compute.text_91'),
  21. slot: {
  22. default: (row) => {
  23. return row.guest
  24. },
  25. },
  26. }
  27. }
  28. export const getOsTypeTableColumn = () => {
  29. return {
  30. field: 'os_type',
  31. title: i18n.t('table.title.os'),
  32. width: 50,
  33. slots: {
  34. default: ({ row }, h) => {
  35. let name = row.os_type || ''
  36. const tooltip = row.os_type
  37. if (name.includes('Windows') || name.includes('windows')) {
  38. name = 'Windows'
  39. } else if (name.includes('Linux') || name.includes('linux')) {
  40. name = 'Linux'
  41. }
  42. return [
  43. <SystemIcon tooltip={ tooltip } name={ name } />,
  44. ]
  45. },
  46. },
  47. }
  48. }
  49. export const getSizeMbTableColumn = () => {
  50. return {
  51. field: 'size_mb',
  52. title: i18n.t('compute.backup_size'),
  53. minWidth: 70,
  54. slots: {
  55. default: ({ row }, h) => {
  56. return sizestr(row.size_mb, 'M', 1024)
  57. },
  58. },
  59. }
  60. }