Skip to content

Commit

Permalink
fix(frontend): 编辑规格添加机型问题修复 #8110
Browse files Browse the repository at this point in the history
  • Loading branch information
jinquantianxia committed Nov 22, 2024
1 parent 4e83765 commit d6d3474
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d6d3474

Please sign in to comment.