|
156 | 156 |
|
157 | 157 | <script setup> |
158 | 158 | import { Container } from '../admin_component' |
159 | | - import { ref, onMounted, computed } from 'vue' |
| 159 | + import { ref, onMounted, computed, nextTick } from 'vue' |
160 | 160 | import useFetchApi from '../../../packs/useFetchApi' |
161 | 161 | import { ElMessage } from 'element-plus' |
162 | 162 | import { useRoute, useRouter } from 'vue-router' |
|
172 | 172 | const resources = ref([]) |
173 | 173 | const runtimeFrameworks = ref([]) |
174 | 174 | const availableQuantizations = ref([]) |
| 175 | + const isEditing = computed(() => !!route.params.id) |
175 | 176 |
|
176 | 177 | const breadcrumbsTitle = computed(() => |
177 | 178 | route.params.id |
|
310 | 311 | ).json() |
311 | 312 | if (data.value?.data) { |
312 | 313 | const result = data.value.data |
313 | | - const currentResource = resources.value.find( |
314 | | - (item) => item.id == result.sku |
315 | | - ) |
| 314 | + const currentResource = resources.value |
| 315 | + .flatMap(group => group.options) |
| 316 | + .find(item => item.id == result.sku) |
| 317 | + |
316 | 318 | const maxReplica = result.max_replica || 0 |
317 | 319 | const minReplica = result.min_replica || 0 |
| 320 | +
|
| 321 | + |
| 322 | + const resourceId = currentResource ? `${currentResource.id}/${currentResource.order_detail_id}` : `${result.sku}` |
| 323 | + dataForm.value.resource_id = resourceId |
| 324 | + await nextTick() |
318 | 325 | const runtimeFrameworkId = filterFrameworks.value.find( |
319 | 326 | (item) => item.frame_name.toLowerCase() === result.runtime_framework.toLowerCase() && item.compute_type === currentResource?.type |
320 | 327 | )?.id |
321 | | - const resourceId = currentResource ? `${currentResource.id}/${currentResource.order_detail_id}` : `${result.sku}` |
322 | 328 | dataForm.value = { |
323 | 329 | ...result, |
324 | 330 | max_replica: maxReplica, |
|
347 | 353 | const categoryResources = await fetchResourcesInCategory(dataForm.value.cluster_id) |
348 | 354 | const firstAvailableResource = categoryResources.flatMap(item => item.options).find((item) => item.is_available) |
349 | 355 | resources.value = categoryResources |
| 356 | + if (isEditing.value) { |
| 357 | + return |
| 358 | + } |
350 | 359 | if (firstAvailableResource) { |
351 | 360 | dataForm.value.resource_id = `${firstAvailableResource.id}/${firstAvailableResource.order_detail_id}` |
352 | 361 | resetCurrentRuntimeFramework() |
|
0 commit comments