List.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 ColumnsMixin from '../mixins/columns'
  10. import SingleActionsMixin from '../mixins/singleActions'
  11. import ListMixin from '@/mixins/list'
  12. import WindowsMixin from '@/mixins/windows'
  13. import expectStatus from '@/constants/expectStatus'
  14. import { getNameFilter, getStatusFilter } from '@/utils/common/tableFilter'
  15. import { HYPERVISORS_MAP } from '@/constants'
  16. export default {
  17. name: 'RDSDatabaseList',
  18. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  19. props: {
  20. params: {
  21. type: Object,
  22. },
  23. data: {
  24. type: Object,
  25. },
  26. id: {
  27. type: String,
  28. },
  29. },
  30. data () {
  31. return {
  32. list: this.$list.createList(this, {
  33. id: this.id,
  34. resource: 'dbinstancedatabases',
  35. getParams: this.params,
  36. steadyStatus: Object.values(expectStatus.rdsAccount).flat(),
  37. filterOptions: {
  38. name: getNameFilter(),
  39. status: getStatusFilter('rdsDatabase'),
  40. },
  41. }),
  42. groupActions: [
  43. {
  44. label: this.$t('db.text_41'),
  45. action: () => {
  46. this.createDialog('RDSDatabaseCreateDialog', {
  47. title: this.$t('db.text_231'),
  48. rdsItem: this.data,
  49. onManager: this.onManager,
  50. refresh: this.refresh,
  51. })
  52. },
  53. meta: () => {
  54. return {
  55. buttonType: 'primary',
  56. ...this.commonMeta,
  57. }
  58. },
  59. },
  60. ],
  61. }
  62. },
  63. computed: {
  64. commonMeta () {
  65. const { status, provider, brand } = this.data
  66. const isRun = status === 'running'
  67. const isQcloud = provider === 'Qcloud'
  68. let tooltip = ''
  69. if (!isRun) {
  70. tooltip = this.$t('db.text_198')
  71. }
  72. if (isQcloud) {
  73. tooltip = this.$t('db.text_348')
  74. }
  75. const ret = {
  76. validate: isRun && !isQcloud,
  77. tooltip: tooltip,
  78. }
  79. if ((brand === HYPERVISORS_MAP.aws.brand || brand === HYPERVISORS_MAP.azure.brand) && ret.validate) {
  80. ret.validate = false
  81. ret.tooltip = this.$t('db.text_384', [brand])
  82. }
  83. return ret
  84. },
  85. },
  86. created () {
  87. this.list.fetchData()
  88. this.initSidePageTab('detail')
  89. },
  90. methods: {
  91. handleOpenSidepage (row) {
  92. this.sidePageTriggerHandle(this, 'RDSDatabaseSidePage', {
  93. id: row.id,
  94. resource: 'dbinstancedatabases',
  95. getParams: this.params,
  96. steadyStatus: Object.values(expectStatus.rdsDatabase).flat(),
  97. }, {
  98. list: this.list,
  99. })
  100. },
  101. },
  102. }
  103. </script>