Disk.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :single-actions="singleActions"
  6. :group-actions="groupActions" />
  7. </template>
  8. <script>
  9. import {
  10. getCopyWithContentTableColumn,
  11. getStatusTableColumn,
  12. getRegionTableColumn,
  13. } from '@/utils/common/tableColumn'
  14. import WindowsMixin from '@/mixins/windows'
  15. import ListMixin from '@/mixins/list'
  16. import { sizestr } from '@/utils/utils'
  17. import expectStatus from '@/constants/expectStatus'
  18. export default {
  19. name: 'DiskListForVmSnapshotPolicySidePage',
  20. mixins: [WindowsMixin, ListMixin],
  21. props: {
  22. resId: String,
  23. data: {
  24. type: Object,
  25. required: true,
  26. },
  27. },
  28. data () {
  29. return {
  30. list: this.$list.createList(this, {
  31. id: 'DiskListForVmSnapshotPolicySidePage',
  32. resource: 'disks',
  33. steadyStatus: Object.values(expectStatus.disk).flat(),
  34. getParams: { ...this.getParams, 'filter.0': 'disk_type.notin(volume)', snapshotpolicy_id: this.resId },
  35. filterOptions: {
  36. name: {
  37. label: this.$t('compute.text_228'),
  38. filter: true,
  39. formatter: val => {
  40. return `name.contains("${val}")`
  41. },
  42. },
  43. },
  44. }),
  45. columns: [
  46. getCopyWithContentTableColumn({
  47. field: 'name',
  48. title: this.$t('compute.text_228'),
  49. hideField: true,
  50. slotCallback: row => {
  51. return [<side-page-trigger permission="disks_get" name="DiskSidePage" id={row.id} vm={this}>{ row.name }</side-page-trigger>]
  52. },
  53. }),
  54. {
  55. field: 'disk_size',
  56. title: this.$t('compute.text_397'),
  57. minWidth: 50,
  58. formatter: ({ cellValue }) => {
  59. return sizestr(cellValue, 'M', 1024)
  60. },
  61. },
  62. getStatusTableColumn({ statusModule: 'disk' }),
  63. {
  64. field: 'disk_type',
  65. title: this.$t('compute.text_381'),
  66. width: 70,
  67. formatter: ({ cellValue }) => {
  68. return cellValue === 'sys' ? this.$t('compute.text_49') : this.$t('compute.text_50')
  69. },
  70. },
  71. getRegionTableColumn(),
  72. {
  73. field: 'guest',
  74. title: this.$t('dictionary.server'),
  75. minWidth: 100,
  76. showOverflow: 'ellipsis',
  77. slots: {
  78. default: ({ row }, h) => {
  79. return [
  80. <div class='text-truncate'>
  81. {row.guest}
  82. {row.guest_status ? <status status={ row.guest_status } statusModule='server'/> : ''}
  83. </div>,
  84. ]
  85. },
  86. },
  87. },
  88. ],
  89. groupActions: [
  90. {
  91. label: this.$t('compute.text_723'),
  92. action: () => {
  93. this.createDialog('UnbindResourcesDialog', {
  94. data: this.list.selectedItems,
  95. resourceType: 'disk',
  96. columns: this.columns,
  97. title: this.$t('compute.text_723'),
  98. resId: this.resId,
  99. onManager: this.onManager,
  100. refresh: this.refresh,
  101. })
  102. },
  103. meta: () => {
  104. return {
  105. validate: this.list.selectedItems.length > 0,
  106. }
  107. },
  108. },
  109. ],
  110. singleActions: [
  111. {
  112. label: this.$t('compute.text_723'),
  113. action: obj => {
  114. this.createDialog('UnbindResourcesDialog', {
  115. data: [obj],
  116. resourceType: 'disk',
  117. columns: this.columns,
  118. title: this.$t('compute.text_723'),
  119. resId: this.resId,
  120. onManager: this.onManager,
  121. refresh: this.refresh,
  122. })
  123. },
  124. meta: obj => {
  125. const ret = {
  126. validate: true,
  127. tooltip: null,
  128. }
  129. return ret
  130. },
  131. },
  132. ],
  133. }
  134. },
  135. created () {
  136. this.list.fetchData()
  137. },
  138. }
  139. </script>