Snapshot.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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" />
  11. </keep-alive>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import DiskSnapshotList from '@Compute/views/snapshot/components/List'
  17. import InstanceSnapshotList from '@Compute/views/snapshot-instance/components/List'
  18. import { hasSetupKey } from '@/utils/auth'
  19. import { isScopedPolicyMenuHidden } from '@/utils/scopedPolicy'
  20. export default {
  21. name: 'SnapshotIndex',
  22. components: {
  23. DiskSnapshotList,
  24. InstanceSnapshotList,
  25. },
  26. props: {
  27. getParams: {
  28. type: [Function, Object],
  29. },
  30. },
  31. data () {
  32. return {
  33. currentComponent: 'DiskSnapshotList',
  34. }
  35. },
  36. computed: {
  37. id () {
  38. switch (this.currentComponent) {
  39. case 'InstanceSnapshotList':
  40. return 'InstanceSnapshotListForVminstanceSidepage'
  41. default:
  42. return 'DiskSnapshotListForVminstanceSidepage'
  43. }
  44. },
  45. tabs () {
  46. const ret = []
  47. if (!isScopedPolicyMenuHidden('sub_hidden_menus.disk_snapshot') && hasSetupKey(['onestack', 'private', 'public'])) {
  48. ret.push({
  49. key: 'DiskSnapshotList',
  50. label: this.$t('compute.text_101'),
  51. })
  52. }
  53. if (!isScopedPolicyMenuHidden('sub_hidden_menus.instance_snapshot') && hasSetupKey(['onestack', 'vmware'])) {
  54. ret.push({
  55. key: 'InstanceSnapshotList',
  56. label: this.$t('compute.text_102'),
  57. })
  58. }
  59. return ret
  60. },
  61. },
  62. methods: {
  63. callback (key) {
  64. this.currentComponent = key
  65. },
  66. },
  67. }
  68. </script>