List.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <page-list
  3. show-tag-columns
  4. show-tag-filter
  5. :list="list"
  6. :columns="columns"
  7. :group-actions="groupActions"
  8. :single-actions="singleActions"
  9. :export-data-options="exportDataOptions"
  10. :showSearchbox="showSearchbox"
  11. :showGroupActions="showGroupActions"
  12. :tableOverviewIndexs="tableOverviewIndexs" />
  13. </template>
  14. <script>
  15. import WindowsMixin from '@/mixins/windows'
  16. import ListMixin from '@/mixins/list'
  17. import {
  18. getNameFilter,
  19. getStatusFilter,
  20. getInBrandFilter,
  21. getDomainFilter,
  22. getTenantFilter,
  23. } from '@/utils/common/tableFilter'
  24. import expectStatus from '@/constants/expectStatus'
  25. import SingleActionsMixin from '../mixins/singleActions'
  26. import ColumnsMixin from '../mixins/columns'
  27. export default {
  28. name: 'DiskBackupList',
  29. mixins: [WindowsMixin, ListMixin, SingleActionsMixin, ColumnsMixin],
  30. props: {
  31. id: String,
  32. getParams: {
  33. type: [Function, Object],
  34. },
  35. cloudEnv: String,
  36. },
  37. data () {
  38. return {
  39. deleteResProps: {
  40. force: false,
  41. },
  42. list: this.$list.createList(this, {
  43. id: this.id,
  44. resource: 'diskbackups',
  45. getParams: this.getParam,
  46. steadyStatus: Object.values(expectStatus.diskBackup).flat(),
  47. filterOptions: {
  48. id: {
  49. label: this.$t('table.title.id'),
  50. },
  51. name: getNameFilter(),
  52. status: getStatusFilter('diskBackup'),
  53. brand: getInBrandFilter('brands', ['OneCloud']),
  54. projects: getTenantFilter(),
  55. project_domains: getDomainFilter(),
  56. },
  57. responseData: this.responseData,
  58. hiddenColumns: ['created_at'],
  59. }),
  60. groupActions: [
  61. {
  62. label: this.$t('compute.perform_sync_status'),
  63. permission: 'diskbackups_perform_syncstatus',
  64. action: () => {
  65. this.onManager('batchPerformAction', {
  66. steadyStatus: ['running', 'ready'],
  67. managerArgs: {
  68. action: 'syncstatus',
  69. },
  70. })
  71. },
  72. meta: () => ({
  73. validate: this.list.selected.length,
  74. }),
  75. },
  76. {
  77. label: this.$t('table.action.set_tag'),
  78. permission: 'diskbackups_perform_set_user_metadata',
  79. action: () => {
  80. this.createDialog('SetTagDialog', {
  81. data: this.list.selectedItems,
  82. columns: this.columns,
  83. onManager: this.onManager,
  84. mode: 'add',
  85. params: {
  86. resources: 'diskbackups',
  87. },
  88. tipName: this.$t('compute.text_462'),
  89. })
  90. },
  91. meta: () => {
  92. return {
  93. validate: this.list.selected.length,
  94. tooltip: null,
  95. }
  96. },
  97. },
  98. {
  99. label: this.$t('compute.perform_delete'),
  100. permission: 'diskbackups_delete',
  101. action: () => {
  102. this.createDialog('DeleteResDialog', {
  103. vm: this,
  104. data: this.list.selectedItems,
  105. columns: this.columns,
  106. onManager: this.onManager,
  107. title: this.$t('compute.perform_delete'),
  108. name: this.$t('compute.text_462'),
  109. })
  110. },
  111. meta: () => {
  112. const ret = {
  113. validate: this.list.selected.length,
  114. tooltip: null,
  115. }
  116. if (this.list.selectedItems.some(item => !item.can_delete)) {
  117. ret.validate = false
  118. return ret
  119. }
  120. return ret
  121. },
  122. },
  123. ],
  124. }
  125. },
  126. computed: {
  127. exportDataOptions () {
  128. return {
  129. title: this.$t('compute.disk_backup'),
  130. downloadType: 'local',
  131. items: [
  132. { label: 'ID', key: 'id' },
  133. ...this.columns,
  134. ],
  135. fixedItems: [
  136. { key: 'disk_size_mb', label: this.$t('compute.disk_size') + '(M)' },
  137. { key: 'size_mb', label: this.$t('compute.backup_size') + '(M)' },
  138. ],
  139. }
  140. },
  141. },
  142. watch: {
  143. cloudEnv (val) {
  144. this.$nextTick(() => {
  145. this.list.fetchData(0)
  146. })
  147. },
  148. },
  149. created () {
  150. this.initSidePageTab('disk-backup-detail')
  151. this.list.fetchData()
  152. },
  153. methods: {
  154. getParam () {
  155. const ret = {
  156. details: true,
  157. with_meta: true,
  158. is_instance_backup: false,
  159. ...this.getParams,
  160. }
  161. if (this.cloudEnv) ret.cloud_env = this.cloudEnv
  162. return ret
  163. },
  164. handleOpenSidepage (row, tab) {
  165. this.sidePageTriggerHandle(this, 'DiskBackupSidePage', {
  166. id: row.id,
  167. resource: 'diskbackups',
  168. getParams: this.getParam,
  169. steadyStatus: this.list.steadyStatus,
  170. }, {
  171. list: this.list,
  172. tab,
  173. })
  174. },
  175. },
  176. }
  177. </script>