From ff0dc7e6b8d9910b38da2809c415e56cd3e508ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=98=8E=E6=98=9F?= <321212099@qq.com> Date: Fri, 26 Sep 2025 11:34:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=B1=A0=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E5=88=9B=E5=BB=BA/=E7=BC=96=E8=BE=91=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=B1=A0=E6=97=B6=E5=A2=9E=E5=8A=A0=E2=80=9C=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E2=80=9D=E8=AE=BE=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/vgpu/views/poll/admin/index.vue | 90 ++++++++++++++++--- 1 file changed, 77 insertions(+), 13 deletions(-) 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);