Network.vue 1.8 KB

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