diff --git a/packages/web/projects/vgpu/views/poll/admin/index.vue b/packages/web/projects/vgpu/views/poll/admin/index.vue index a2abdda..10afe76 100644 --- a/packages/web/projects/vgpu/views/poll/admin/index.vue +++ b/packages/web/projects/vgpu/views/poll/admin/index.vue @@ -7,11 +7,16 @@
- {{ poolName }} +
+ {{ poolName }} + + {{ ['单机单卡', '单机多卡', '多机多卡'][poolType] || '未知类型' }} + +
节点数量  {{ nodeNum }} CPU数  {{ cpuCores }}核 @@ -27,9 +32,7 @@ 配置
@@ -38,27 +41,38 @@
- - 资源池名称 -
+ + 资源池类型 + + + + + + +
选择节点 已选{{ nodeSelect.length - }}个节点 + }}个节点
-
+
+ v-for="{ nodeIp, cpuCores, gpuNum, gpuMemory, totalMemory, diskSize } in filteredNodeList" + :key="nodeIp">
- + + {{ nodeIp }}
@@ -75,7 +89,7 @@
@@ -111,6 +125,12 @@ import useParentAction from '~/vgpu/hooks/useParentAction'; const { sendRouteChange } = useParentAction(); +const typeColorMap = { + 0: 'success', // 绿色 - 单机单卡 + 1: 'warning', // 橙色 - 单机多卡 + 2: '' // 蓝色 - 多机多卡 +} + // 数据列表相关 const list = ref([]) const loading = ref(true) @@ -124,6 +144,7 @@ const total = ref(0) const dialogVisible = ref(false) const editId = ref(null) const input = ref('') +const poolType = ref(null) // 默认不选择 const btnLoading = ref(false) // 节点选择相关 @@ -137,6 +158,19 @@ const paginatedList = computed(() => { return list.value.slice(start, end) }) +// 根据类型过滤节点列表 +const filteredNodeList = computed(() => { + if (!poolType.value) return [] + + if (poolType.value === '1') { + // 单机多卡:过滤掉只有1张显卡的节点 + return nodeList.value.filter(node => node.gpuNum > 1) + } + + // 单机单卡(0)和多机多卡(2):显示所有节点 + return nodeList.value +}) + // 分页大小变化 const handleSizeChange = (val) => { pageSize.value = val @@ -157,6 +191,13 @@ const handleOk = async () => { }) return; } + if (!poolType.value) { + ElMessage({ + message: '请选择资源池类型', + type: 'warning', + }) + return; + } if (!nodeSelect.value.length) { ElMessage({ message: '请选择节点', @@ -172,11 +213,13 @@ const handleOk = async () => { res = await pollApi.update({ pool_id: editId.value, pool_name: input.value, + pool_type: poolType.value, nodes }) } else { res = await pollApi.create({ pool_name: input.value, + pool_type: poolType.value, nodes }) } @@ -191,6 +234,27 @@ const handleOk = async () => { btnLoading.value = false; } +// 编辑处理 +const handleEdit = (poolId, poolName, nodes, type) => { + dialogVisible.value = true; + editId.value = poolId; + input.value = poolName; + nodeSelect.value = nodes.map(e => e.nodeIp); + // 设置资源池类型 + poolType.value = type.toString(); +} + +// 类型变化处理 +const handleTypeChange = () => { + // 类型改变时清空已选择的节点 + nodeSelect.value = []; +} + +// 单选变化 +const handleRadioChange = (ip) => { + nodeSelect.value = [ip]; +} + // 复选框变化 const handleCheckboxChange = (ip) => { const index = nodeSelect.value.indexOf(ip);