diff --git a/dbm-ui/frontend/src/common/const/dbTypeInfos.ts b/dbm-ui/frontend/src/common/const/dbTypeInfos.ts index 7789d99bf4..b283340499 100644 --- a/dbm-ui/frontend/src/common/const/dbTypeInfos.ts +++ b/dbm-ui/frontend/src/common/const/dbTypeInfos.ts @@ -217,7 +217,20 @@ const bigdata: InfoType = { id: DBTypes.DORIS, name: 'Doris', moduleId: 'bigdata', - machineList: [], + machineList: [ + { + label: t('Follower节点'), + value: MachineTypes.DORIS_FOLLOWER, + }, + { + label: t('Observer节点'), + value: MachineTypes.DORIS_OBSERVER, + }, + { + label: t('冷/热节点'), + value: MachineTypes.DORIS_BACKEND, + }, + ], }, }; export const DBTypeInfos = { diff --git a/dbm-ui/frontend/src/common/const/machineTypes.ts b/dbm-ui/frontend/src/common/const/machineTypes.ts index dbe5ae20de..3474b1d2bb 100644 --- a/dbm-ui/frontend/src/common/const/machineTypes.ts +++ b/dbm-ui/frontend/src/common/const/machineTypes.ts @@ -68,7 +68,7 @@ export enum MachineTypes { } // doris export enum MachineTypes { - DORIS_FOLLOWER = 'doris_follower', - DORIS_OBSERVER = 'doris_observer', - DORIS_BACKEND = 'doris_backend', + DORIS_FOLLOWER = 'doris_follower', // Follower节点 + DORIS_OBSERVER = 'doris_observer', // Observer节点 + DORIS_BACKEND = 'doris_backend', // 冷/热节点 } diff --git a/dbm-ui/frontend/src/services/source/dbresourceResource.ts b/dbm-ui/frontend/src/services/source/dbresourceResource.ts index a02bbbae5c..1e7d81a36c 100644 --- a/dbm-ui/frontend/src/services/source/dbresourceResource.ts +++ b/dbm-ui/frontend/src/services/source/dbresourceResource.ts @@ -32,28 +32,15 @@ export function removeResource(params: { bk_host_ids: number[] }) { /** * 获取机型列表 */ -export function fetchDeviceClass(params: { offset?: number; limit?: number; name?: string }) { - return http.post< +export function fetchDeviceClass(params: { offset?: number; limit?: number; device_type?: string }) { + return http.get< ListBase< { - capacity_flag: number; // 容量标志 - comment: string; // 评论 - cpu: number; // CPU 核心数 - disk: number; // 磁盘大小 (GB) - enable_apply: boolean; // 是否启用申请 - enable_capacity: boolean; // 是否启用容量 - id: number; // 设备唯一标识 - label: { - device_group: string; // 设备组 - device_size: string; // 设备大小 - }; - mem: number; // 内存大小 (GB) - region: string; // 区域 - require_type: number; // 需求类型 - remark: string; // 备注 - score: number; // 评分 - zone: string; // 可用区 - device_type: string; // 设备类型 + cpu: number; + device_type: string; + disk: number; + id: number; + mem: number; }[] > >(`${path}/get_device_class/`, params); @@ -188,9 +175,9 @@ export function getSpecResourceCount(params: { */ export function updateResource(params: { bk_host_ids: number[]; - for_biz: number; + for_biz?: number; rack_id: string; - resource_type: string; + resource_type?: string; storage_device: Record; }) { return http.post(`${path}/update/`, params); diff --git a/dbm-ui/frontend/src/views/db-manage/common/apply-items/SpecSelector.vue b/dbm-ui/frontend/src/views/db-manage/common/apply-items/SpecSelector.vue index 5065510a91..d8909c960d 100644 --- a/dbm-ui/frontend/src/views/db-manage/common/apply-items/SpecSelector.vue +++ b/dbm-ui/frontend/src/views/db-manage/common/apply-items/SpecSelector.vue @@ -33,7 +33,15 @@ {{ t('可用主机数') }}: {{ item.count ?? 0 }} - - {{ - item === '-1' - ? t('无限制') - : deviceListMap[item]?.cpu - ? `${item}(${deviceListMap[item]?.cpu}${t('核')}${deviceListMap[item]?.mem}G)` - : `${item}` + deviceListMap[item]?.cpu + ? `${item}(${deviceListMap[item]?.cpu}${t('核')}${deviceListMap[item]?.mem}G)` + : `${item}` }} @@ -94,10 +88,16 @@ import { fetchDeviceClass } from '@services/source/dbresourceResource'; + export type DeviceClassCpuMemType = typeof selectedCpuMem; + interface Props { isEdit: boolean; } + interface Exposes { + getDeviceClassCpuMem: () => DeviceClassCpuMemType; + } + interface DeviceClassListItem { cpu: number; mem: number; @@ -121,7 +121,7 @@ const searchParams = { offset: 0, limit: 12, - name: '', + device_type: '', }; const deviceListMap: Record< @@ -132,6 +132,17 @@ } > = {}; + const selectedCpuMem = { + cpu: { + min: Number.MAX_SAFE_INTEGER, + max: -Number.MAX_SAFE_INTEGER, + }, + mem: { + min: Number.MAX_SAFE_INTEGER, + max: -Number.MAX_SAFE_INTEGER, + }, + }; + const rules = [ { required: true, @@ -173,13 +184,8 @@ watch( () => modelValue.value, () => { - if (modelValue.value.length > 0 && modelValue.value[0] !== '-1') { + if (modelValue.value.length > 0) { oldData = _.cloneDeep(modelValue.value); - // 批量查询已选中的机型 - searchParams.name = modelValue.value.join(','); - getDeviceClassList(searchParams); - searchParams.name = ''; - return; } getDeviceClassList(searchParams); @@ -206,28 +212,27 @@ const remoteMethod = (value: string) => { isAppend = false; - searchParams.name = value; + searchParams.device_type = value; searchParams.offset = 0; getDeviceClassList(searchParams); }; const handleSelectChange = (list: string[]) => { - if (list.length > 1) { - if (list[0] === '-1') { - // 先选的无限制,后续加选要去除无限制 - modelValue.value = list.slice(1); - return; - } - - if (list[list.length - 1] === '-1') { - // 最后选的无限制,前面选过的都要去除 - modelValue.value = ['-1']; - return; - } - } - + list.forEach((item) => { + const itemInfo = deviceListMap[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; + selectedCpuMem.mem.max = itemInfo.mem > selectedCpuMem.mem.max ? itemInfo.mem : selectedCpuMem.mem.max; + }); modelValue.value = list; }; + + defineExpose({ + getDeviceClassCpuMem() { + return selectedCpuMem; + }, + });