From 5968e7aa187e6719de462372d63872b8dae12a05 Mon Sep 17 00:00:00 2001 From: Austin <1344583166@qq.com> Date: Fri, 22 Nov 2024 14:16:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E7=BC=96=E8=BE=91=E8=A7=84?= =?UTF-8?q?=E6=A0=BC=E6=B7=BB=E5=8A=A0=E6=9C=BA=E5=9E=8B=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20#8110?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-ui/frontend/src/types/auto-imports.d.ts | 2 +- .../components/SpecDevice.vue | 40 +++++++++++++------ 2 files changed, 28 insertions(+), 14 deletions(-) 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;