index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <base-side-page
  3. @cancel="cancelSidePage"
  4. :title="isApplyType ? $t('aice.app_llm') : $t('aice.llm')"
  5. icon="res-vminstance"
  6. :res-name="detailData.name"
  7. :current-tab="params.windowData.currentTab"
  8. :tabs="detailTabs"
  9. :loaded="loaded"
  10. @tab-change="handleTabChange">
  11. <template v-slot:actions>
  12. <actions
  13. :options="singleActions"
  14. :row="rowWithCmpInfo"
  15. button-type="link"
  16. button-size="small" />
  17. </template>
  18. <component
  19. :is="params.windowData.currentTab"
  20. :res-id="data.id"
  21. :monitorResId="detailData.cmp_id"
  22. :id="listId"
  23. :data="childPageData"
  24. :getParams="getParams"
  25. :on-manager="onManager"
  26. :columns="columns"
  27. taskResource="clouddesktop-tasks" />
  28. </base-side-page>
  29. </template>
  30. <script>
  31. import SidePageMixin from '@/mixins/sidePage'
  32. import WindowsMixin from '@/mixins/windows'
  33. import Actions from '@/components/PageList/Actions'
  34. // import InstantAppIndex from '@K8S/views/llm-instantmodel/components/List.vue'
  35. import Monitor from '@Compute/views/vminstance-container/sidepage/Monitor'
  36. import Log from '@Compute/views/pod-container/sidepage/Log'
  37. import SingleActionsMixin from '../mixins/singleActions'
  38. import ColumnsMixin from '../mixins/columns'
  39. import Detail from './Detail'
  40. import Model from './Model'
  41. export default {
  42. name: 'LlmSidePage',
  43. components: {
  44. Detail,
  45. Log,
  46. // InstantAppIndex,
  47. Actions,
  48. Monitor,
  49. Model,
  50. },
  51. mixins: [SidePageMixin, WindowsMixin, ColumnsMixin, SingleActionsMixin],
  52. data () {
  53. return {
  54. cmpInfo: null,
  55. }
  56. },
  57. computed: {
  58. rowWithCmpInfo () {
  59. return { ...this.detailData, cmp_info: this.cmpInfo }
  60. },
  61. childPageData () {
  62. return { guest_id: this.detailData.cmp_id, ...this.rowWithCmpInfo }
  63. },
  64. isApplyType () {
  65. return this.$route.path.includes('app-llm')
  66. },
  67. detailTabs () {
  68. const ret = [
  69. { label: this.$t('aice.detail'), key: 'detail' },
  70. { label: this.$t('aice.model'), key: 'model' },
  71. // { label: this.$t('aice.instant_app'), key: 'instant-app-index' },
  72. { label: this.$t('compute.text_608'), key: 'monitor' },
  73. { label: this.$t('k8s.text_325'), key: 'log' },
  74. // { label: this.$t('table.title.task'), key: 'task-drawer' },
  75. { label: this.$t('aice.event'), key: 'event-drawer' },
  76. ]
  77. if (this.isApplyType) {
  78. return ret.filter(item => item.key !== 'model')
  79. }
  80. return ret
  81. },
  82. getParams () {
  83. if (this.params.windowData.currentTab === 'task-drawer') {
  84. return {
  85. is_root: true,
  86. }
  87. } else if (this.params.windowData.currentTab === 'backup-list') {
  88. return {
  89. desktop_id: this.data.id,
  90. }
  91. } else if (this.params.windowData.currentTab === 'phone-app-index') {
  92. return {
  93. desktop_id: this.data.id,
  94. }
  95. }
  96. return null
  97. },
  98. listId () {
  99. switch (this.params.windowData.currentTab) {
  100. case 'task-drawer':
  101. return 'TaskListForDesktopSidePage'
  102. case 'event-drawer':
  103. return 'EventListForDesktopSidePage'
  104. case 'backup-list':
  105. return 'BackupListForDesktopSidePage'
  106. case 'phone-app-index':
  107. return 'DesktopAppIndexForDesktopSidePage'
  108. default:
  109. return ''
  110. }
  111. },
  112. },
  113. watch: {
  114. // 列表侧同步刷新 this.data.data 时不会再走 fetchDataCallback,需监听 cmp_id
  115. 'data.data.cmp_id': {
  116. handler (cmpId) {
  117. this.fetchCmpServerInfo(cmpId)
  118. },
  119. },
  120. },
  121. methods: {
  122. // SidePageMixin.fetchData 在详情 get 成功后会 await 此方法(此时已有 detailData)
  123. async fetchDataCallback () {
  124. await this.fetchCmpServerInfo(this.detailData.cmp_id)
  125. },
  126. async fetchCmpServerInfo (cmpId) {
  127. if (!cmpId) {
  128. this.cmpInfo = null
  129. return
  130. }
  131. try {
  132. const params = {
  133. scope: 'system',
  134. show_fail_reason: true,
  135. show_emulated: true,
  136. system: true,
  137. }
  138. const { data } = await new this.$Manager('servers').get({ id: cmpId, params })
  139. if (this._isDestroyed) return
  140. this.cmpInfo = data || null
  141. } catch (e) {
  142. this.cmpInfo = null
  143. }
  144. },
  145. },
  146. }
  147. </script>