Disk.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns" />
  5. </template>
  6. <script>
  7. import { ALL_STORAGE } from '@Compute/constants'
  8. import { getCopyWithContentTableColumn, getStatusTableColumn } from '@/utils/common/tableColumn'
  9. import WindowsMixin from '@/mixins/windows'
  10. import { sizestr } from '@/utils/utils'
  11. import expectStatus from '@/constants/expectStatus'
  12. export default {
  13. name: 'DiskListForBaremetalSidepage',
  14. mixins: [WindowsMixin],
  15. props: {
  16. resId: String,
  17. data: {
  18. type: Object,
  19. required: true,
  20. },
  21. getParams: {
  22. type: Object,
  23. },
  24. },
  25. data () {
  26. return {
  27. list: this.$list.createList(this, {
  28. id: 'DiskListForBaremetalSidepage',
  29. resource: 'disks',
  30. ctx: [['servers', this.resId]],
  31. idKey: 'disk_id',
  32. steadyStatus: Object.values(expectStatus.disk).flat(),
  33. getParams: this.getParams,
  34. filterOptions: {
  35. network: {
  36. label: this.$t('compute.text_228'),
  37. filter: true,
  38. formatter: val => {
  39. return `network.contains("${val}")`
  40. },
  41. },
  42. },
  43. }),
  44. columns: [
  45. {
  46. field: 'index',
  47. title: this.$t('compute.text_375'),
  48. width: 50,
  49. formatter: ({ row }) => {
  50. return row.index ? row.index : '0'
  51. },
  52. },
  53. getCopyWithContentTableColumn({ field: 'disk', title: this.$t('compute.text_376') }),
  54. {
  55. field: 'disk_size',
  56. title: this.$t('compute.text_377'),
  57. sortable: true,
  58. showOverflow: 'ellipsis',
  59. minWidth: 60,
  60. formatter: ({ row }) => {
  61. return sizestr(row.disk_size, 'M', 1024)
  62. },
  63. },
  64. {
  65. field: 'driver',
  66. title: this.$t('compute.text_378'),
  67. width: 80,
  68. },
  69. {
  70. field: 'cache_mode',
  71. title: this.$t('compute.text_379'),
  72. width: 150,
  73. formatter: ({ row }) => {
  74. return row.cache_mode ? row.cache_mode : '-'
  75. },
  76. },
  77. getStatusTableColumn({ statusModule: 'disk' }),
  78. {
  79. field: 'storage_type',
  80. title: this.$t('compute.text_380'),
  81. width: 80,
  82. formatter: ({ row }) => {
  83. if (row.storage_type) {
  84. if (row.storage_type === 'baremetal') return this.$t('compute.text_92')
  85. return (ALL_STORAGE[row.storage_type] && ALL_STORAGE[row.storage_type].label) || row.storage_type
  86. }
  87. return '-'
  88. },
  89. },
  90. {
  91. field: 'disk_type',
  92. title: this.$t('compute.text_381'),
  93. width: 80,
  94. formatter: ({ row }) => {
  95. const diskType = {
  96. sys: this.$t('compute.text_49'),
  97. data: this.$t('compute.text_50'),
  98. }
  99. if (row.disk_type) {
  100. return diskType[row.disk_type] || row.disk_type
  101. }
  102. return '-'
  103. },
  104. },
  105. ],
  106. }
  107. },
  108. created () {
  109. this.list.fetchData()
  110. },
  111. }
  112. </script>