Detail.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <detail
  3. :on-manager="onManager"
  4. :data="data"
  5. :base-info="baseInfo"
  6. :extra-info="extraInfo"
  7. status-module="sku"
  8. :nameProps="{
  9. edit: false,
  10. }" />
  11. </template>
  12. <script>
  13. import { sizestr } from '@/utils/utils'
  14. import { getEnabledTableColumn, getRegionTableColumn } from '@/utils/common/tableColumn'
  15. import { chargeTypeColumn } from '../utils'
  16. export default {
  17. name: 'SkuDetail',
  18. props: {
  19. data: {
  20. type: Object,
  21. required: true,
  22. },
  23. onManager: {
  24. type: Function,
  25. required: true,
  26. },
  27. cloudEnv: {
  28. type: String,
  29. },
  30. },
  31. data () {
  32. return {
  33. baseInfo: [
  34. getEnabledTableColumn(),
  35. {
  36. field: 'cpu_core_count',
  37. title: this.$t('compute.text_1058'),
  38. },
  39. {
  40. field: 'memory_size_mb',
  41. title: this.$t('compute.text_1059'),
  42. formatter: ({ cellValue }) => {
  43. return sizestr(cellValue, 'M', 1024) + 'B'
  44. },
  45. },
  46. {
  47. field: 'sys_disk_max_size_gb',
  48. title: this.$t('compute.system_disk_max'),
  49. formatter: ({ cellValue }) => {
  50. if (!cellValue) return this.$t('common_216')
  51. return cellValue + 'GB'
  52. },
  53. },
  54. {
  55. field: 'total_guest_count',
  56. title: this.$t('compute.text_699', [this.$t('dictionary.server')]),
  57. slots: {
  58. default: ({ row }) => {
  59. if (row.total_guest_count <= 0) return row.total_guest_count
  60. return [<a onClick={ () => this.$emit('tab-change', 'vminstance-list') }>{ row.total_guest_count }</a>]
  61. },
  62. },
  63. },
  64. {
  65. field: 'brand',
  66. title: this.$t('compute.text_176'),
  67. },
  68. ],
  69. }
  70. },
  71. computed: {
  72. extraInfo () {
  73. const extraInfo = [
  74. {
  75. title: this.$t('compute.text_497'),
  76. items: [
  77. {
  78. field: 'last_sync',
  79. title: this.$t('compute.text_1060'),
  80. formatter: ({ row }) => {
  81. return this.$moment(row.last_sync).format()
  82. },
  83. },
  84. ],
  85. },
  86. ]
  87. if (this.cloudEnv === 'public') {
  88. extraInfo[0].items.push(getRegionTableColumn(), chargeTypeColumn())
  89. }
  90. return extraInfo
  91. },
  92. },
  93. }
  94. </script>