List.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 expectStatus from '@/constants/expectStatus'
  15. import WindowsMixin from '@/mixins/windows'
  16. import { getNameFilter, getIpFilter, getOsTypeFilter, getBrandFilter, getHostFilter } from '@/utils/common/tableFilter'
  17. import ListMixin from '@/mixins/list'
  18. import ResTemplateListMixin from '@/mixins/resTemplateList'
  19. import GlobalSearchMixin from '@/mixins/globalSearch'
  20. import SingleActionsMixin from '../mixins/singleActions'
  21. import ColumnsMixin from '../mixins/columns'
  22. export default {
  23. name: 'ServerRecoveryList',
  24. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
  25. props: {
  26. id: String,
  27. getParams: {
  28. type: Object,
  29. default: () => ({}),
  30. },
  31. },
  32. data () {
  33. return {
  34. list: this.$list.createList(this, {
  35. ctx: this,
  36. id: this.id,
  37. resource: 'servers',
  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. id: getNameFilter({ field: 'id', label: 'ID' }),
  45. external_id: getNameFilter({ field: 'external_id', label: this.$t('table.title.external_id') }),
  46. ip: getIpFilter(),
  47. status: {
  48. label: this.$t('compute.text_268'),
  49. dropdown: true,
  50. multiple: true,
  51. items: [
  52. { label: this.$t('compute.text_574'), key: 'running' },
  53. { label: this.$t('compute.text_273'), key: 'ready' },
  54. { label: this.$t('compute.text_339'), key: 'unknown' },
  55. { label: this.$t('compute.text_720'), key: 'sched_fail' },
  56. ],
  57. filter: true,
  58. formatter: val => {
  59. return `status.in(${val.join(',')})`
  60. },
  61. },
  62. brand: getBrandFilter(),
  63. os_type: getOsTypeFilter(),
  64. host: getHostFilter(),
  65. },
  66. responseData: this.responseData,
  67. }),
  68. exportDataOptions: {
  69. items: [
  70. { label: 'ID', key: 'id' },
  71. { label: this.$t('table.title.external_id'), key: 'external_id' },
  72. { label: this.$t('compute.text_228'), key: 'name' },
  73. { label: this.$t('compute.text_263'), key: 'ips' },
  74. { label: this.$t('compute.text_1036'), key: 'eip' },
  75. { label: 'CPU', key: 'vcpu_count' },
  76. { label: this.$t('compute.text_264'), key: 'vmem_size' },
  77. { label: this.$t('compute.text_265'), key: 'disk' },
  78. { label: this.$t('compute.text_266'), key: 'instance_type' },
  79. { label: this.$t('compute.text_267'), key: 'os_distribution' },
  80. { label: this.$t('compute.text_268'), key: 'status' },
  81. { label: this.$t('dictionary.project'), key: 'tenant' },
  82. { label: this.$t('compute.text_176'), key: 'hypervisor' },
  83. { label: this.$t('compute.text_111'), key: 'host' },
  84. { label: this.$t('compute.text_269'), key: 'manager' },
  85. { label: this.$t('compute.text_177'), key: 'region' },
  86. { label: this.$t('compute.text_270'), key: 'zone' },
  87. { label: this.$t('compute.text_498'), key: 'billing_type' },
  88. { label: this.$t('compute.text_271'), key: 'user_tags' },
  89. ],
  90. },
  91. groupActions: [
  92. {
  93. label: this.$t('compute.text_477'),
  94. permission: 'server_delete',
  95. action: () => {
  96. this.createDialog('ServerRecoveryDeleteDialog', {
  97. vm: this,
  98. data: this.list.selectedItems,
  99. columns: this.columns,
  100. title: this.$t('compute.text_477'),
  101. name: this.$t('dictionary.server'),
  102. requestParams: { override_pending_delete: true },
  103. onManager: this.onManager,
  104. success: () => {
  105. this.list.selectedItems.map(obj => {
  106. this.list.singleRefresh(obj.id, ['deleting'])
  107. })
  108. },
  109. })
  110. },
  111. meta: () => {
  112. return {
  113. validate: this.list.allowDelete(),
  114. }
  115. },
  116. },
  117. {
  118. label: this.$t('compute.text_478'),
  119. permission: 'server_perform_cancel_delete',
  120. action: () => {
  121. this.createDialog('ServerRestoreDialog', {
  122. title: this.$t('compute.text_478'),
  123. data: this.list.selectedItems,
  124. columns: this.columns,
  125. refresh: this.refresh,
  126. })
  127. },
  128. meta: () => {
  129. if (this.list.selectedItems.length > 0 && this.list.selectedItems.find(v => v.status === 'deleting') === undefined) {
  130. return {
  131. validate: true,
  132. }
  133. }
  134. return {
  135. validate: false,
  136. }
  137. },
  138. },
  139. ],
  140. }
  141. },
  142. created () {
  143. this.list.fetchData()
  144. },
  145. methods: {
  146. getParam () {
  147. return {
  148. details: true,
  149. with_meta: true,
  150. pending_delete: true,
  151. ...this.getParams,
  152. }
  153. },
  154. handleOpenSidepage (row) {
  155. this.sidePageTriggerHandle(this, 'VminstanceRecoverySidePage', {
  156. id: row.id,
  157. resource: 'servers',
  158. getParams: this.getParam,
  159. }, {
  160. list: this.list,
  161. })
  162. },
  163. },
  164. }
  165. </script>