AssociatedInstances.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div>
  3. <a-tabs :defaultActiveKey="currentComponent" @change="callback" :animated="false">
  4. <template v-for="obj of tabs">
  5. <a-tab-pane :tab="obj.label" :key="obj.key" />
  6. </template>
  7. </a-tabs>
  8. <div class="mt-2">
  9. <keep-alive>
  10. <component :is="currentComponent" :getParams="getParams" :id="id" :data="data" />
  11. </keep-alive>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import Server from './Server'
  17. import LB from './LB'
  18. import RDS from './RDS'
  19. import Redis from './Redis'
  20. import VmContainer from './VmContainer'
  21. import Network from './Network'
  22. export default {
  23. name: 'AssociatedSecgroupsIndex',
  24. components: {
  25. Server,
  26. LB,
  27. RDS,
  28. Redis,
  29. VmContainer,
  30. Network,
  31. },
  32. props: {
  33. data: {
  34. type: Object,
  35. required: true,
  36. },
  37. getParams: {
  38. type: [Function, Object],
  39. },
  40. },
  41. data () {
  42. return {
  43. currentComponent: 'Server',
  44. }
  45. },
  46. computed: {
  47. id () {
  48. switch (this.currentComponent) {
  49. case 'Server':
  50. return 'ServerForSecGroupSidePage'
  51. case 'LB':
  52. return 'LBForSecGroupSidePage'
  53. case 'RDS':
  54. return 'RDSForSecGroupSidePage'
  55. case 'Redis':
  56. return 'RedisForSecGroupSidePage'
  57. case 'VmContainer':
  58. return 'VmContainerForSecGroupSidePage'
  59. case 'Network':
  60. return 'NetworkForSecGroupSidePage'
  61. default:
  62. return 'DefaultSecGroupSidePage'
  63. }
  64. },
  65. tabs () {
  66. const ret = [
  67. {
  68. key: 'Server',
  69. label: this.$t('dictionary.server'),
  70. },
  71. {
  72. key: 'VmContainer',
  73. label: this.$t('dictionary.server_container'),
  74. },
  75. {
  76. key: 'LB',
  77. label: this.$t('dictionary.elb'),
  78. },
  79. {
  80. key: 'RDS',
  81. label: 'RDS',
  82. },
  83. {
  84. key: 'Redis',
  85. label: 'Redis',
  86. },
  87. {
  88. key: 'Network',
  89. label: this.$t('compute.nic'),
  90. },
  91. ]
  92. return ret
  93. },
  94. },
  95. methods: {
  96. callback (key) {
  97. this.currentComponent = key
  98. },
  99. },
  100. }
  101. </script>
  102. <style>
  103. </style>