columns.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // import { chargeTypeColumn } from '../utils'
  2. import {
  3. getEnabledTableColumn,
  4. getNameDescriptionTableColumn,
  5. getStatusTableColumn,
  6. getBrandTableColumn,
  7. getRegionTableColumn,
  8. getTimeTableColumn,
  9. } from '@/utils/common/tableColumn'
  10. import { sizestr } from '@/utils/utils'
  11. import i18n from '@/locales'
  12. export default {
  13. computed: {
  14. columns () {
  15. const columns = [
  16. getNameDescriptionTableColumn({
  17. onManager: this.onManager,
  18. hideField: true,
  19. edit: false,
  20. slotCallback: row => {
  21. return (
  22. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row) }>{ row.name }</side-page-trigger>
  23. )
  24. },
  25. }),
  26. getStatusTableColumn({ title: i18n.t('compute.sku.prepaid_status'), field: 'prepaid_status', statusModule: 'sku' }),
  27. getStatusTableColumn({ title: i18n.t('compute.sku.postpaid_status'), field: 'postpaid_status', statusModule: 'sku' }),
  28. {
  29. field: 'cpu_core_count',
  30. title: i18n.t('compute.text_1051'),
  31. width: 100,
  32. formatter: ({ cellValue }) => {
  33. return cellValue + i18n.t('compute.text_167')
  34. },
  35. },
  36. {
  37. field: 'memory_size_mb',
  38. title: i18n.t('compute.text_1052'),
  39. width: 100,
  40. formatter: ({ cellValue }) => {
  41. return sizestr(cellValue, 'M', 1024)
  42. },
  43. },
  44. {
  45. field: 'total_guest_count',
  46. title: this.$t('compute.text_699', [this.$t('dictionary.server')]),
  47. width: 120,
  48. slots: {
  49. default: ({ row }) => {
  50. if (row.total_guest_count === undefined) return [<data-loading />]
  51. if (row.total_guest_count <= 0) return row.total_guest_count
  52. const options = { cloudEnv: this.cloudEnv }
  53. return [<side-page-trigger name='SkuSidePage' id={row.id} tab='vminstance-list' vm={this} options={ options }>{ row.total_guest_count }</side-page-trigger>]
  54. },
  55. },
  56. },
  57. getEnabledTableColumn(),
  58. getBrandTableColumn({ field: 'provider' }),
  59. getTimeTableColumn(),
  60. ]
  61. if (this.cloudEnv === 'public') {
  62. columns.push(
  63. getRegionTableColumn(),
  64. // chargeTypeColumn(),
  65. )
  66. }
  67. return columns
  68. },
  69. },
  70. }