resourceProps.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import {
  2. getNameDescriptionTableColumn,
  3. getStatusTableColumn,
  4. } from '@/utils/common/tableColumn'
  5. import {
  6. getNameFilter,
  7. } from '@/utils/common/tableFilter'
  8. import { sizestr, percentstr } from '@/utils/utils'
  9. import { BRAND_MAP } from '@/constants'
  10. export default {
  11. computed: {
  12. resourceProps () {
  13. return {
  14. list: this.$list.createList(this, {
  15. id: 'VmHostsListForTransferDialog',
  16. resource: 'hosts',
  17. getParams: {
  18. baremetal: false,
  19. brand: BRAND_MAP.OneCloud.key,
  20. },
  21. filterOptions: {
  22. id: {
  23. label: this.$t('table.title.id'),
  24. },
  25. name: getNameFilter(),
  26. any_ip: {
  27. label: 'IP',
  28. },
  29. },
  30. }),
  31. columns: [
  32. getNameDescriptionTableColumn({
  33. hideField: true,
  34. addLock: true,
  35. addBackup: true,
  36. edit: false,
  37. editDesc: false,
  38. minWidth: 120,
  39. slotCallback: row => {
  40. return [
  41. <list-body-cell-wrap field='name' row={row} />,
  42. ]
  43. },
  44. }),
  45. getStatusTableColumn({
  46. statusModule: 'host',
  47. minWidth: 100,
  48. }),
  49. {
  50. field: 'custom_ip',
  51. title: 'IP',
  52. minWidth: 200,
  53. showOverflow: 'ellipsis',
  54. slots: {
  55. default: ({ row }) => {
  56. const cellWrap = []
  57. if (row.access_ip) {
  58. if (row.ipmi_ip) {
  59. cellWrap.push(
  60. <div class="d-flex">
  61. <list-body-cell-wrap row={row} field="access_ip" copy><span class="text-color-help">{this.$t('compute.text_1319')}</span></list-body-cell-wrap>
  62. </div>,
  63. )
  64. } else {
  65. cellWrap.push(
  66. <div class="d-flex">
  67. <list-body-cell-wrap row={row} field="access_ip" copy></list-body-cell-wrap>
  68. </div>,
  69. )
  70. }
  71. }
  72. if (row.ipmi_ip) {
  73. if (row.access_ip) {
  74. cellWrap.push(
  75. <div class="d-flex">
  76. <list-body-cell-wrap row={row} field="ipmi_ip" copy><span class="text-color-help">{this.$t('compute.text_1320')}</span></list-body-cell-wrap>
  77. </div>,
  78. )
  79. } else {
  80. cellWrap.push(
  81. <div class="d-flex">
  82. <list-body-cell-wrap row={row} field="ipmi_ip" copy></list-body-cell-wrap>
  83. </div>,
  84. )
  85. }
  86. }
  87. return cellWrap
  88. },
  89. },
  90. },
  91. {
  92. field: 'cpu_count',
  93. title: this.$t('compute.text_563'),
  94. minWidth: 100,
  95. showOverflow: 'title',
  96. sortFields: ['cpu_count', ''],
  97. sortByList: ['', 'order_by_cpu_commit_rate'],
  98. slots: {
  99. default: ({ row }) => {
  100. if (row.cpu_commit_rate === undefined) return [<data-loading />]
  101. return row.cpu_count ? `${row.cpu_count}/${percentstr(row.cpu_commit_rate)}` : 'N/A'
  102. },
  103. },
  104. },
  105. {
  106. field: 'mem_size',
  107. title: this.$t('compute.text_564'),
  108. minWidth: 100,
  109. sortFields: ['mem_size', ''],
  110. sortByList: ['', 'order_by_mem_commit_rate'],
  111. slots: {
  112. default: ({ row }) => {
  113. if (row.mem_commit_rate === undefined) return [<data-loading />]
  114. return row.mem_size ? `${sizestr(row.mem_size, 'M', 1024)}/${percentstr(row.mem_commit_rate)}` : 'N/A'
  115. },
  116. },
  117. },
  118. {
  119. field: 'storage',
  120. title: this.$t('compute.text_565'),
  121. minWidth: 80,
  122. sortByList: ['order_by_storage', 'order_by_storage_commit_rate'],
  123. slots: {
  124. default: ({ row }) => {
  125. if (row.storage === undefined) return [<data-loading />]
  126. return row.storage ? `${sizestr(row.storage, 'M', 1024)}/${percentstr(row.storage_commit_rate)}` : 'N/A'
  127. },
  128. },
  129. },
  130. {
  131. field: 'model',
  132. title: this.$t('compute.text_580'),
  133. minWidth: 100,
  134. formatter: ({ cellValue, row }) => {
  135. return ((row.sys_info || {}).model) || '-'
  136. },
  137. },
  138. {
  139. field: 'nonsystem_guests',
  140. sortBy: 'order_by_server_count',
  141. title: '#VM',
  142. minWidth: 80,
  143. sortable: true,
  144. slots: {
  145. default: ({ row }, h) => {
  146. if (row.nonsystem_guests === undefined) return [<data-loading />]
  147. return `${row.nonsystem_guests}`
  148. },
  149. },
  150. },
  151. ],
  152. }
  153. },
  154. },
  155. methods: {},
  156. }