diff --git a/dbm-ui/frontend/src/types/auto-imports.d.ts b/dbm-ui/frontend/src/types/auto-imports.d.ts index 7021ac5101..d0c217f6f1 100644 --- a/dbm-ui/frontend/src/types/auto-imports.d.ts +++ b/dbm-ui/frontend/src/types/auto-imports.d.ts @@ -71,6 +71,6 @@ declare global { // for type re-export declare global { // @ts-ignore - export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue' + export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue' import('vue') } diff --git a/dbm-ui/frontend/src/views/resource-manage/spec/components/spec-form-item/spec-device-or-cpu-mem/components/SpecDevice.vue b/dbm-ui/frontend/src/views/resource-manage/spec/components/spec-form-item/spec-device-or-cpu-mem/components/SpecDevice.vue index 3d0fa4c4bc..e26a374e38 100644 --- a/dbm-ui/frontend/src/views/resource-manage/spec/components/spec-form-item/spec-device-or-cpu-mem/components/SpecDevice.vue +++ b/dbm-ui/frontend/src/views/resource-manage/spec/components/spec-form-item/spec-device-or-cpu-mem/components/SpecDevice.vue @@ -124,13 +124,15 @@ device_type: '', }; - const deviceListMap: Record< - string, - { - cpu: number; - mem: number; - } - > = {}; + const deviceListMap = ref< + Record< + string, + { + cpu: number; + mem: number; + } + > + >({}); const selectedCpuMem = { cpu: { @@ -154,17 +156,29 @@ let isAppend = false; let oldData: string[] = []; - const { loading: isLoading, run: getDeviceClassList } = useRequest(fetchDeviceClass, { - manual: true, + useRequest(fetchDeviceClass, { + defaultParams: [ + { + offset: 0, + limit: -1, + }, + ], onSuccess(data) { - scrollLoading.value = false; - const deviceList: DeviceClassListItem[] = []; data.results.forEach((item) => { - deviceListMap[item.device_type] = { + deviceListMap.value[item.device_type] = { cpu: item.cpu, mem: item.mem, }; + }); + }, + }); + const { loading: isLoading, run: getDeviceClassList } = useRequest(fetchDeviceClass, { + manual: true, + onSuccess(data) { + scrollLoading.value = false; + const deviceList: DeviceClassListItem[] = []; + data.results.forEach((item) => { deviceList.push({ label: item.device_type, cpu: item.cpu, @@ -219,7 +233,7 @@ const handleSelectChange = (list: string[]) => { list.forEach((item) => { - const itemInfo = deviceListMap[item]; + const itemInfo = deviceListMap.value[item]; selectedCpuMem.cpu.min = itemInfo.cpu < selectedCpuMem.cpu.min ? itemInfo.cpu : selectedCpuMem.cpu.min; selectedCpuMem.cpu.max = itemInfo.cpu > selectedCpuMem.cpu.max ? itemInfo.cpu : selectedCpuMem.cpu.max; selectedCpuMem.mem.min = itemInfo.mem < selectedCpuMem.mem.min ? itemInfo.mem : selectedCpuMem.mem.min;