Network.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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
  11. :is="currentComponent"
  12. :getParams="params"
  13. :id="id"
  14. :resId="resId"
  15. :serverColumns="serverColumns"
  16. :data="data" />
  17. </keep-alive>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import NetworkList from '@Compute/views/networks/components/List'
  23. import EipList from './EipList'
  24. export default {
  25. name: 'NetworkIndex',
  26. components: {
  27. NetworkList,
  28. EipList,
  29. },
  30. props: {
  31. resId: String,
  32. getParams: {
  33. type: [Function, Object],
  34. },
  35. data: {
  36. type: Object,
  37. required: true,
  38. },
  39. serverColumns: {
  40. type: Array,
  41. default: () => ([]),
  42. },
  43. },
  44. data () {
  45. return {
  46. currentComponent: 'NetworkList',
  47. tabs: [
  48. {
  49. key: 'NetworkList',
  50. label: this.$t('compute.private_network'),
  51. },
  52. {
  53. key: 'EipList',
  54. label: this.$t('compute.text_107'),
  55. },
  56. ],
  57. }
  58. },
  59. computed: {
  60. id () {
  61. switch (this.currentComponent) {
  62. case 'NetworkList':
  63. return 'NetworkListForVminstanceSidepage'
  64. default:
  65. return 'EipListForVminstanceSidepage'
  66. }
  67. },
  68. params () {
  69. const params = {
  70. ...this.getParams,
  71. }
  72. if (this.currentComponent === 'NetworkList') {
  73. delete params.associate_id
  74. }
  75. return params
  76. },
  77. },
  78. methods: {
  79. callback (key) {
  80. this.currentComponent = key
  81. },
  82. },
  83. }
  84. </script>