BackupList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <page-list
  3. :columns="columns"
  4. :group-actions="groupActions"
  5. :list="list"
  6. :single-actions="singleActions" />
  7. </template>
  8. <script>
  9. import { sizestr } from '@/utils/utils'
  10. import { getStatusTableColumn, getRegionTableColumn, getBrandTableColumn, getNameDescriptionTableColumn } from '@/utils/common/tableColumn'
  11. import WindowsMixin from '@/mixins/windows'
  12. import ListMixin from '@/mixins/list'
  13. import expectStatus from '@/constants/expectStatus'
  14. import { HYPERVISORS_MAP } from '@/constants'
  15. import { getNameFilter, getStatusFilter } from '@/utils/common/tableFilter'
  16. export default {
  17. name: 'RedisBackupList',
  18. mixins: [WindowsMixin, ListMixin],
  19. props: {
  20. params: {
  21. type: Object,
  22. },
  23. data: {
  24. type: Object,
  25. },
  26. },
  27. data () {
  28. return {
  29. list: this.$list.createList(this, {
  30. id: 'RedisBackupListForRedisSidePage',
  31. resource: 'elasticcachebackups',
  32. getParams: this.params,
  33. steadyStatus: Object.values(expectStatus.redisBackup).flat(),
  34. filterOptions: {
  35. name: getNameFilter(),
  36. status: getStatusFilter('redisBackup'),
  37. // brand: {
  38. // label: '平台',
  39. // dropdown: true,
  40. // multiple: true,
  41. // items: [
  42. // { label: '阿里云', key: 'Aliyun' },
  43. // { label: '华为云', key: 'Huawei' },
  44. // ],
  45. // },
  46. backup_mode: {
  47. label: this.$t('db.text_36'),
  48. dropdown: true,
  49. multiple: true,
  50. items: [
  51. { label: this.$t('db.text_316'), key: 'manual' },
  52. { label: this.$t('db.text_317'), key: 'automated' },
  53. ],
  54. },
  55. },
  56. }),
  57. columns: [
  58. getNameDescriptionTableColumn({
  59. onManager: this.onManager,
  60. }),
  61. {
  62. field: 'backup_mode',
  63. title: this.$t('db.text_36'),
  64. width: 100,
  65. slots: {
  66. default: ({ row }) => {
  67. return row.backup_mode === 'manual' ? this.$t('db.text_316') : this.$t('db.text_317')
  68. },
  69. },
  70. },
  71. {
  72. field: 'engine',
  73. title: this.$t('db.text_112'),
  74. width: 100,
  75. slots: {
  76. default: ({ row }) => {
  77. return `${row.engine} ${row.engine_version}`
  78. },
  79. },
  80. },
  81. {
  82. field: 'backup_size_mb',
  83. title: this.$t('db.text_38'),
  84. width: 100,
  85. slots: {
  86. default: ({ row }) => {
  87. return sizestr(row.backup_size_mb, 'M', 1024)
  88. },
  89. },
  90. },
  91. getBrandTableColumn(),
  92. getStatusTableColumn({ statusModule: 'redisBackup' }),
  93. {
  94. title: this.$t('db.text_39'),
  95. minWidth: 150,
  96. slots: {
  97. default: ({ row }) => {
  98. if (row.start_time && row.end_time) {
  99. return [
  100. <div>{this.$moment(row.start_time).format()}</div>,
  101. <div>{this.$moment(row.end_time).format()}</div>,
  102. ]
  103. }
  104. return '-'
  105. },
  106. },
  107. },
  108. getRegionTableColumn(),
  109. ],
  110. groupActions: [
  111. {
  112. label: this.$t('db.text_41'),
  113. permission: 'redis_elasticcachebackups_create',
  114. action: () => {
  115. this.createDialog('BackupListCreate', {
  116. list: this.list,
  117. redisItem: this.data,
  118. })
  119. },
  120. meta: () => {
  121. let validate = true
  122. let tooltip = ''
  123. // if (this.data.brand === 'Huawei' && this.data.local_category === 'single') {
  124. // validate = false
  125. // tooltip = '华为云基础版不支持此操作'
  126. // }
  127. if (this.data.brand === 'Huawei') {
  128. validate = false
  129. tooltip = this.$t('db.text_318')
  130. }
  131. if (this.data.status !== 'running') {
  132. validate = false
  133. tooltip = this.$t('db.text_156')
  134. }
  135. if ((this.data.brand === HYPERVISORS_MAP.aws.brand || this.data.brand === HYPERVISORS_MAP.azure.brand) && validate) {
  136. validate = false
  137. tooltip = this.$t('db.text_384', [this.data.brand])
  138. }
  139. return {
  140. buttonType: 'primary',
  141. validate,
  142. tooltip,
  143. }
  144. },
  145. },
  146. ],
  147. singleActions: [
  148. {
  149. label: this.$t('db.text_45'),
  150. permission: 'redis_elasticcachebackups_perform_restore_instance',
  151. action: (obj) => {
  152. this.createDialog('RedisBackupResumeDialog', {
  153. data: [obj],
  154. columns: this.columns,
  155. list: this.list,
  156. })
  157. },
  158. meta: (row) => {
  159. let validate = true
  160. let tooltip = ''
  161. if (this.data.brand === 'Huawei' && this.data.arch_type === 'single') {
  162. validate = false
  163. tooltip = this.$t('db.text_319')
  164. }
  165. if (row.status !== 'running' && row.status !== 'success') {
  166. validate = false
  167. tooltip = this.$t('db.text_320')
  168. }
  169. if (this.data.brand === 'Qcloud') {
  170. validate = false
  171. tooltip = this.$t('db.text_356')
  172. }
  173. return {
  174. validate,
  175. tooltip,
  176. }
  177. },
  178. },
  179. ],
  180. }
  181. },
  182. computed: {
  183. commonMeta () {
  184. const isHuawei = this.data.brand === 'Huawei'
  185. return {
  186. validate: !isHuawei,
  187. tooltip: isHuawei ? this.$t('db.text_321') : null,
  188. }
  189. },
  190. },
  191. created () {
  192. this.list.fetchData()
  193. },
  194. }
  195. </script>