@@ -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);