AssociatedInstances.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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" :resId="resId" />
  11. </keep-alive>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import Server from './Servers'
  17. import VmContainer from './VmContainer'
  18. export default {
  19. name: 'AssociatedGpusIndex',
  20. components: {
  21. Server,
  22. VmContainer,
  23. },
  24. props: {
  25. data: {
  26. type: Object,
  27. required: true,
  28. },
  29. getParams: {
  30. type: [Function, Object],
  31. },
  32. resId: {
  33. type: String,
  34. required: true,
  35. },
  36. },
  37. data () {
  38. return {
  39. currentComponent: 'Server',
  40. }
  41. },
  42. computed: {
  43. id () {
  44. switch (this.currentComponent) {
  45. case 'Server':
  46. return 'ServerForSecGroupSidePage'
  47. case 'VmContainer':
  48. return 'VmContainerForSecGroupSidePage'
  49. default:
  50. return 'DefaultSecGroupSidePage'
  51. }
  52. },
  53. tabs () {
  54. const ret = [
  55. {
  56. key: 'Server',
  57. label: this.$t('dictionary.server'),
  58. },
  59. {
  60. key: 'VmContainer',
  61. label: this.$t('dictionary.server_container'),
  62. },
  63. ]
  64. return ret
  65. },
  66. },
  67. methods: {
  68. callback (key) {
  69. this.currentComponent = key
  70. },
  71. },
  72. }
  73. </script>
  74. <style>
  75. </style>