index.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <base-side-page
  3. @cancel="cancelSidePage"
  4. :title="$t('dictionary.clouduser')"
  5. icon="res-cloudaccount"
  6. :res-name="detailData.name"
  7. :actions="params.actions"
  8. :current-tab="params.windowData.currentTab"
  9. :tabs="detailTabs"
  10. :loaded="loaded"
  11. @tab-change="handleTabChange">
  12. <template v-slot:actions>
  13. <actions :options="singleActions" :row="detailData" button-type="link" button-size="small" />
  14. </template>
  15. <component
  16. :is="params.windowData.currentTab"
  17. :data="detailData"
  18. :cloudaccount="cloudaccount"
  19. :on-manager="onManager"
  20. :res-id="data.id"
  21. resource="cloudaccounts"
  22. :getParams="getParams" />
  23. </base-side-page>
  24. </template>
  25. <script>
  26. import ColumnsMixin from '../mixins/columns'
  27. import SingleActionsMixin from '../mixins/singleActions'
  28. import ClouduserDetail from './Detail'
  29. import CloudgroupList from './CloudgroupList'
  30. import AkSkList from './AkSkList'
  31. import SidePageMixin from '@/mixins/sidePage'
  32. import WindowsMixin from '@/mixins/windows'
  33. import Actions from '@/components/PageList/Actions'
  34. import { HYPERVISORS_MAP } from '@/constants'
  35. export default {
  36. name: 'ClouduserSidePage',
  37. components: {
  38. ClouduserDetail,
  39. AkSkList,
  40. CloudgroupList,
  41. Actions,
  42. },
  43. mixins: [SidePageMixin, WindowsMixin, ColumnsMixin, SingleActionsMixin],
  44. data () {
  45. return {
  46. cloudaccount: {},
  47. }
  48. },
  49. computed: {
  50. isHuawei () {
  51. return this.detailData?.provider === HYPERVISORS_MAP.huawei.provider
  52. },
  53. detailTabs () {
  54. const detailTabs = [
  55. { label: this.$t('sidepage.tab.label.detail'), key: 'clouduser-detail' },
  56. { label: this.$t('dictionary.cloudgroup'), key: 'cloudgroup-list' },
  57. { label: this.$t('dictionary.actions'), key: 'event-drawer' },
  58. ]
  59. if (this.isHuawei) {
  60. detailTabs.splice(1, 0, { label: this.$t('cloudenv.aksk'), key: 'ak-sk-list' })
  61. }
  62. return detailTabs
  63. },
  64. getParams () {
  65. if (
  66. this.params.windowData.currentTab === 'cloudgroup-list'
  67. ) {
  68. return {
  69. clouduser_id: this.data.id,
  70. }
  71. }
  72. return null
  73. },
  74. },
  75. destroyed () {
  76. this.cm = null
  77. },
  78. created () {
  79. this.cm = new this.$Manager('cloudaccounts')
  80. },
  81. methods: {
  82. async fetchDataCallback () {
  83. try {
  84. const response = await this.cm.get({ id: this.detailData.cloudaccount_id })
  85. this.cloudaccount = response.data
  86. return response
  87. } catch (error) {
  88. throw error
  89. }
  90. },
  91. },
  92. }
  93. </script>