List.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="templateListColumns || columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :export-data-options="exportDataOptions"
  8. :showSearchbox="showSearchbox"
  9. :showGroupActions="showGroupActions"
  10. :show-single-actions="!isTemplate"
  11. :show-page="!isTemplate" />
  12. </template>
  13. <script>
  14. import * as R from 'ramda'
  15. import expectStatus from '@/constants/expectStatus'
  16. import { getNameFilter, getStatusFilter, getBrandFilter, getTenantFilter, getFilter } from '@/utils/common/tableFilter'
  17. import WindowsMixin from '@/mixins/windows'
  18. import ListMixin from '@/mixins/list'
  19. import ResTemplateListMixin from '@/mixins/resTemplateList'
  20. import GlobalSearchMixin from '@/mixins/globalSearch'
  21. import SingleActionsMixin from '../mixins/singleActions'
  22. import ColumnsMixin from '../mixins/columns'
  23. export default {
  24. name: 'DiskRecoveryList',
  25. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
  26. props: {
  27. id: String,
  28. getParams: {
  29. type: [Function, Object],
  30. },
  31. },
  32. data () {
  33. return {
  34. list: this.$list.createList(this, {
  35. ctx: this,
  36. id: this.id,
  37. resource: 'disks',
  38. getParams: this.getParam,
  39. isTemplate: this.isTemplate,
  40. templateLimit: this.templateLimit,
  41. steadyStatus: Object.values(expectStatus.server).flat(),
  42. filterOptions: {
  43. name: getNameFilter(),
  44. brand: getBrandFilter(),
  45. status: getStatusFilter('disk'),
  46. projects: getTenantFilter(),
  47. // guest: getFilter({ field: 'guest', title: '虚拟机' }),
  48. disk_type: getFilter({
  49. field: 'guest',
  50. title: this.$t('compute.text_175'),
  51. items: [
  52. { label: this.$t('compute.text_49'), key: 'sys' },
  53. { label: this.$t('compute.text_50'), key: 'data' },
  54. ],
  55. }),
  56. storage: {
  57. label: this.$t('compute.text_99'),
  58. jointFilter: true,
  59. },
  60. },
  61. responseData: this.responseData,
  62. }),
  63. exportDataOptions: {
  64. items: [
  65. { label: 'ID', key: 'id' },
  66. { label: this.$t('compute.text_228'), key: 'name' },
  67. { label: this.$t('compute.text_397'), key: 'disk_size' },
  68. { label: this.$t('compute.text_398'), key: 'disk_format' },
  69. { label: this.$t('compute.text_381'), key: 'disk_type' },
  70. { label: this.$t('table.title.disk_mounted'), key: 'unused' },
  71. { label: this.$t('dictionary.server'), key: 'guest' },
  72. { label: this.$t('table.title.disk_storage'), key: 'storage' },
  73. { label: this.$t('compute.text_243'), key: 'created_at' },
  74. { label: this.$t('compute.text_268'), key: 'status' },
  75. { label: this.$t('dictionary.project'), key: 'tenant' },
  76. { label: this.$t('compute.text_176'), key: 'provider' },
  77. { label: this.$t('compute.text_177'), key: 'region' },
  78. { label: this.$t('compute.text_270'), key: 'zone' },
  79. { label: this.$t('table.title.disk_medium_type'), key: 'medium_type' },
  80. ],
  81. },
  82. groupActions: [
  83. {
  84. label: this.$t('compute.text_477'),
  85. permission: 'disks_delete',
  86. action: () => {
  87. this.createDialog('DeleteResDialog', {
  88. vm: this,
  89. data: this.list.selectedItems,
  90. columns: this.columns,
  91. title: this.$t('compute.text_477'),
  92. name: this.$t('dictionary.disk'),
  93. requestParams: { override_pending_delete: true },
  94. onManager: this.onManager,
  95. })
  96. },
  97. meta: () => {
  98. return {
  99. validate: this.list.allowDelete(),
  100. }
  101. },
  102. },
  103. {
  104. label: this.$t('compute.text_478'),
  105. permission: 'disks_perform_cancel_delete',
  106. action: () => {
  107. this.createDialog('DiskRestoreDialog', {
  108. title: this.$t('compute.text_478'),
  109. data: this.list.selectedItems,
  110. columns: this.columns,
  111. refresh: this.refresh,
  112. })
  113. },
  114. meta: () => {
  115. return {
  116. validate: this.list.selectedItems.length > 0,
  117. }
  118. },
  119. },
  120. ],
  121. }
  122. },
  123. created () {
  124. this.list.fetchData()
  125. },
  126. methods: {
  127. getParam () {
  128. return {
  129. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  130. details: true,
  131. with_meta: true,
  132. pending_delete: true,
  133. }
  134. },
  135. handleOpenSidepage (row) {
  136. this.sidePageTriggerHandle(this, 'DiskRecoverySidePage', {
  137. id: row.id,
  138. resource: 'disks',
  139. getParams: this.getParam,
  140. }, {
  141. list: this.list,
  142. })
  143. },
  144. },
  145. }
  146. </script>