List.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <page-list
  3. show-tag-columns
  4. show-tag-filter
  5. :columns="columns"
  6. :group-actions="groupActions"
  7. :list="list"
  8. :single-actions="singleActions"
  9. :export-data-options="exportDataOptions" />
  10. </template>
  11. <script>
  12. import ColumnsMixin from '../mixins/columns'
  13. import SingleActionsMixin from '../mixins/singleActions'
  14. import ListMixin from '@/mixins/list'
  15. import { getNameFilter, getFilter, getStatusFilter } from '@/utils/common/tableFilter'
  16. import WindowsMixin from '@/mixins/windows'
  17. import expectStatus from '@/constants/expectStatus'
  18. import { HYPERVISORS_MAP } from '@/constants'
  19. import i18n from '@/locales'
  20. const BACKUP_TYPE = {
  21. automated: i18n.t('db.text_33'),
  22. manual: i18n.t('db.text_34'),
  23. }
  24. export default {
  25. name: 'RDSBackupList',
  26. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  27. props: {
  28. id: String,
  29. params: {
  30. type: Object,
  31. },
  32. data: {
  33. type: Object,
  34. },
  35. },
  36. data () {
  37. return {
  38. list: this.$list.createList(this, {
  39. id: this.id,
  40. resource: 'dbinstancebackups',
  41. getParams: this.params,
  42. steadyStatus: Object.values(expectStatus.rdsBackup).flat(),
  43. filterOptions: {
  44. name: getNameFilter(),
  45. status: getStatusFilter('rdsBackup'),
  46. // dbinstance: getFilter({
  47. // field: 'dbinstance',
  48. // title: '实例名称',
  49. // }),
  50. dbinstance: {
  51. field: 'dbinstance',
  52. label: this.$t('db.text_35'),
  53. },
  54. engine: getFilter({
  55. field: 'engine',
  56. title: this.$t('db.text_57'),
  57. multiple: true,
  58. items: [
  59. { label: 'MySQL', key: 'MySQL' },
  60. { label: 'PostgreSQL', key: 'PostgreSQL' },
  61. { label: 'SQLServer', key: 'SQLServer' },
  62. ],
  63. }),
  64. backup_mode: getFilter({
  65. field: 'backup_mode',
  66. title: this.$t('db.text_36'),
  67. items: Object.keys(BACKUP_TYPE).map(key => {
  68. return { label: BACKUP_TYPE[key], key }
  69. }),
  70. }),
  71. },
  72. }),
  73. exportDataOptions: {
  74. items: [
  75. { label: 'ID', key: 'id' },
  76. { label: this.$t('db.text_60'), key: 'name' },
  77. { label: this.$t('db.text_35'), key: 'dbinstance' },
  78. { label: this.$t('db.text_36'), key: 'backup_mode' },
  79. { label: this.$t('db.text_57'), key: 'engine' },
  80. { label: this.$t('db.text_38'), key: 'backup_size_mb' },
  81. { label: this.$t('db.text_46'), key: 'status' },
  82. { label: this.$t('db.text_210'), key: 'start_time' },
  83. { label: this.$t('db.text_211'), key: 'end_time' },
  84. { label: this.$t('db.text_40'), key: 'region' },
  85. ],
  86. },
  87. groupActions: [
  88. {
  89. label: this.$t('db.text_41'),
  90. permission: 'rds_dbinstancebackups_create',
  91. action: () => {
  92. this.createDialog('RDSBackupCreate', {
  93. rdsItem: this.data,
  94. onManager: this.onManager,
  95. refresh: this.refresh,
  96. list: this.list,
  97. })
  98. },
  99. meta: () => {
  100. let validate = true
  101. let tooltip = ''
  102. if (this.data.status !== 'running') {
  103. validate = false
  104. tooltip = this.$t('db.text_212')
  105. }
  106. if (this.data.provider === 'Qcloud' && this.data.category === 'basic') {
  107. validate = false
  108. tooltip = this.$t('db.text_342')
  109. }
  110. if ((this.data.brand === HYPERVISORS_MAP.aws.brand || this.data.brand === HYPERVISORS_MAP.azure.brand) && validate) {
  111. validate = false
  112. tooltip = this.$t('db.text_384', [this.data.brand])
  113. }
  114. return {
  115. buttonType: 'primary',
  116. validate: validate,
  117. tooltip: tooltip,
  118. }
  119. },
  120. },
  121. {
  122. label: this.$t('db.text_213'),
  123. actions: () => {
  124. return [
  125. {
  126. label: this.$t('db.text_69'),
  127. permission: 'rds_dbinstancebackups_perform_syncstatus',
  128. action: () => {
  129. this.onManager('batchPerformAction', {
  130. steadyStatus: ['running', 'ready'],
  131. managerArgs: {
  132. action: 'syncstatus',
  133. },
  134. })
  135. },
  136. },
  137. {
  138. label: this.$t('db.text_42'),
  139. permission: 'rds_dbinstancebackups_delete',
  140. action: () => {
  141. this.createDialog('DeleteResDialog', {
  142. vm: this,
  143. name: this.$t('db.text_44'),
  144. title: this.$t('db.text_43'),
  145. data: this.list.selectedItems,
  146. columns: this.columns,
  147. onManager: this.onManager,
  148. refresh: this.refresh,
  149. })
  150. },
  151. meta: () => {
  152. if (this.data.brand === 'Aliyun') {
  153. return {
  154. validate: false,
  155. tooltip: this.$t('db.text_214'),
  156. }
  157. }
  158. return this.$getDeleteResult(this.list.selectedItems)
  159. },
  160. },
  161. ]
  162. },
  163. meta: () => {
  164. return {
  165. validate: this.list.selected.length,
  166. }
  167. },
  168. },
  169. ],
  170. }
  171. },
  172. created () {
  173. this.list.fetchData()
  174. this.initSidePageTab('rds-backup-detail')
  175. },
  176. methods: {
  177. handleOpenSidepage (row) {
  178. this.sidePageTriggerHandle(this, 'RDSBackupSidePage', {
  179. id: row.id,
  180. resource: 'dbinstancebackups',
  181. getParams: this.params,
  182. steadyStatus: Object.values(expectStatus.rdsBackup).flat(),
  183. }, {
  184. list: this.list,
  185. })
  186. },
  187. },
  188. }
  189. </script>