List.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. </template>
  13. <script>
  14. import WindowsMixin from '@/mixins/windows'
  15. import ListMixin from '@/mixins/list'
  16. import {
  17. getNameFilter,
  18. getStatusFilter,
  19. getInBrandFilter,
  20. getDomainFilter,
  21. getTenantFilter,
  22. } from '@/utils/common/tableFilter'
  23. import expectStatus from '@/constants/expectStatus'
  24. import SingleActionsMixin from '../mixins/singleActions'
  25. import ColumnsMixin from '../mixins/columns'
  26. export default {
  27. name: 'InstanceBackupList',
  28. mixins: [WindowsMixin, ListMixin, SingleActionsMixin, ColumnsMixin],
  29. props: {
  30. id: String,
  31. getParams: {
  32. type: [Function, Object],
  33. },
  34. cloudEnv: String,
  35. },
  36. data () {
  37. return {
  38. deleteResProps: {
  39. force: false,
  40. },
  41. list: this.$list.createList(this, {
  42. id: this.id,
  43. resource: 'instancebackups',
  44. getParams: this.getParam,
  45. steadyStatus: Object.values(expectStatus.instanceBackup).flat(),
  46. filterOptions: {
  47. id: {
  48. label: this.$t('table.title.id'),
  49. },
  50. name: getNameFilter(),
  51. status: getStatusFilter('instanceBackup'),
  52. brand: getInBrandFilter('brands', ['OneCloud']),
  53. projects: getTenantFilter(),
  54. project_domains: getDomainFilter(),
  55. },
  56. responseData: this.responseData,
  57. hiddenColumns: ['created_at'],
  58. }),
  59. exportDataOptions: {
  60. items: [
  61. { label: 'ID', key: 'id' },
  62. { label: this.$t('table.title.name'), key: 'name' },
  63. { label: this.$t('common.status'), key: 'status' },
  64. { label: this.$t('table.title.user_tag'), key: 'user_tags' },
  65. { label: this.$t('table.title.create_time'), key: 'created_at' },
  66. { label: this.$t('compute.backup_storage'), key: 'backup_storage_name' },
  67. { label: this.$t('compute.backup_size'), key: 'size_mb' },
  68. { label: this.$t('compute.text_91'), key: 'guest' },
  69. { label: this.$t('table.title.os_arch'), key: 'os_arch' },
  70. { label: this.$t('table.title.os'), key: 'os_type' },
  71. { label: this.$t('table.title.brand'), key: 'provider' },
  72. { label: this.$t('res.project'), key: 'tenant' },
  73. ],
  74. },
  75. groupActions: [
  76. {
  77. label: this.$t('compute.text_679'),
  78. action: () => {
  79. this.createDialog('ImportUnpackDialog', {
  80. data: this.list.selectedItems,
  81. onManager: this.onManager,
  82. refresh: this.refresh,
  83. })
  84. },
  85. meta: () => {
  86. return {
  87. buttonType: 'primary',
  88. }
  89. },
  90. },
  91. {
  92. label: this.$t('compute.text_275'),
  93. actions: () => {
  94. return [
  95. {
  96. label: this.$t('compute.perform_sync_status'),
  97. permission: 'instancebackups_perform_syncstatus',
  98. action: () => {
  99. this.onManager('batchPerformAction', {
  100. steadyStatus: ['running', 'ready'],
  101. managerArgs: {
  102. action: 'syncstatus',
  103. },
  104. })
  105. },
  106. meta: () => ({
  107. validate: this.list.selected.length,
  108. }),
  109. },
  110. {
  111. label: this.$t('table.action.set_tag'),
  112. permission: 'instancebackups_perform_set_user_metadata',
  113. action: () => {
  114. this.createDialog('SetTagDialog', {
  115. data: this.list.selectedItems,
  116. columns: this.columns,
  117. onManager: this.onManager,
  118. mode: 'add',
  119. params: {
  120. resources: 'instancebackups',
  121. },
  122. tipName: this.$t('compute.text_462'),
  123. })
  124. },
  125. meta: () => {
  126. return {
  127. validate: this.list.selected.length,
  128. tooltip: null,
  129. }
  130. },
  131. },
  132. {
  133. label: this.$t('compute.perform_delete'),
  134. permission: 'instancebackups_delete',
  135. action: () => {
  136. this.createDialog('DeleteResDialog', {
  137. vm: this,
  138. data: this.list.selectedItems,
  139. columns: this.columns,
  140. onManager: this.onManager,
  141. title: this.$t('compute.perform_delete'),
  142. name: this.$t('compute.text_462'),
  143. alert: this.$t('compute.instance_backup_delete_alert'),
  144. content: () => {
  145. const change = (bool) => {
  146. this.deleteResProps.force = bool
  147. }
  148. return <a-checkbox onInput={ change }>{ this.$t('compute.text_655') }</a-checkbox>
  149. },
  150. requestParams: this.deleteResProps,
  151. })
  152. },
  153. meta: () => {
  154. const ret = {
  155. validate: this.list.selected.length,
  156. tooltip: null,
  157. }
  158. if (this.list.selectedItems.some(item => !item.can_delete)) {
  159. ret.validate = false
  160. return ret
  161. }
  162. return ret
  163. },
  164. },
  165. ]
  166. },
  167. },
  168. ],
  169. }
  170. },
  171. watch: {
  172. cloudEnv (val) {
  173. this.$nextTick(() => {
  174. this.list.fetchData(0)
  175. })
  176. },
  177. },
  178. created () {
  179. this.initSidePageTab('instance-backup-detail')
  180. this.list.fetchData()
  181. },
  182. methods: {
  183. getParam () {
  184. const ret = {
  185. details: true,
  186. with_meta: true,
  187. ...this.getParams,
  188. }
  189. if (this.cloudEnv) ret.cloud_env = this.cloudEnv
  190. return ret
  191. },
  192. handleOpenSidepage (row, tab) {
  193. this.sidePageTriggerHandle(this, 'InstanceBackupSidePage', {
  194. id: row.id,
  195. resource: 'instancebackups',
  196. getParams: this.getParam,
  197. steadyStatus: this.list.steadyStatus,
  198. }, {
  199. list: this.list,
  200. tab,
  201. })
  202. },
  203. },
  204. }
  205. </script>