Virtualmachine.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <vxe-grid :data="responseData.data || []" :columns="columns" resizable />
  3. </template>
  4. <script>
  5. import * as R from 'ramda'
  6. import WindowsMixin from '@/mixins/windows'
  7. export default {
  8. name: 'VmReleaseVirtualmachineSidepage',
  9. mixins: [WindowsMixin],
  10. props: {
  11. responseData: {
  12. type: Object,
  13. default: () => ({ data: [] }),
  14. },
  15. },
  16. data () {
  17. return {
  18. columns: [
  19. {
  20. field: 'name',
  21. title: this.$t('helm.text_16'),
  22. minWidth: 100,
  23. slots: {
  24. default: ({ row }) => {
  25. const text = row.name || '-'
  26. return [
  27. <list-body-cell-wrap copy hideField={true} field='name' row={row} message={text}>
  28. <side-page-trigger name='VmInstanceSidePage' id={row.externalInfo.id} vm={this}>{text}</side-page-trigger>
  29. </list-body-cell-wrap>,
  30. ]
  31. },
  32. },
  33. },
  34. {
  35. field: 'status',
  36. title: this.$t('k8s.text_35'),
  37. width: 100,
  38. slots: {
  39. default: ({ row }, h) => {
  40. const warning = row.reason
  41. let warnTooltip = null
  42. if (warning && row.status === 'Invalid') {
  43. warnTooltip = (
  44. <a-tooltip placement="top">
  45. <template slot="title">
  46. { warning }
  47. </template>
  48. <div class='text-truncate'>
  49. <a-icon type="bulb" theme="twoTone" twoToneColor="#f5222d" class="mr-2" />
  50. <span>{ this.$t('k8s.text_402') }</span>
  51. </div>
  52. </a-tooltip>
  53. )
  54. }
  55. return [
  56. <div class='text-truncate'>
  57. <status status={ row.status } statusModule='vmReleaseVirtualmachine'>
  58. { warnTooltip }
  59. </status>
  60. </div>,
  61. ]
  62. },
  63. },
  64. },
  65. {
  66. field: 'tryTimes',
  67. title: this.$t('helm.text_105'),
  68. formatter: ({ row }) => {
  69. if (R.is(Number, +row.tryTimes) && !Number.isNaN(+row.tryTimes)) return row.tryTimes
  70. return '-'
  71. },
  72. },
  73. {
  74. field: 'ips',
  75. title: 'IP',
  76. minWidth: 120,
  77. slots: {
  78. default: ({ row }) => {
  79. if (!row.externalInfo || !row.externalInfo.ips) return '-'
  80. return row.externalInfo.ips.map(val => <list-body-cell-wrap copy hideField={true} message={val}>{val}</list-body-cell-wrap>)
  81. },
  82. },
  83. },
  84. {
  85. field: 'eip',
  86. title: this.$t('dictionary.eip'),
  87. minWidth: 120,
  88. slots: {
  89. default: ({ row }) => {
  90. if (!row.externalInfo || !row.externalInfo.eip) return '-'
  91. const val = row.externalInfo.eip
  92. return [<list-body-cell-wrap copy hideField={true} message={val}>{val}</list-body-cell-wrap>]
  93. },
  94. },
  95. },
  96. {
  97. field: 'instanceType',
  98. title: this.$t('helm.text_99'),
  99. },
  100. ],
  101. }
  102. },
  103. }
  104. </script>