Commit 27b686a0 authored by chenshouchao's avatar chenshouchao

feat: 添加setShowCpuList设置时机

parent d2ceda89
......@@ -93,38 +93,6 @@ const QueueSelect = (props: IQueueSelectProps) => {
];
}, [originalCpuList, originalGpuList]);
useEffect(() => {
let resultList: Array<IShowCPULi> = [];
originalCpuList.forEach((item) => {
const targetIndex = resultList.findIndex((resultLi) => {
return resultLi.name === item.name;
});
if (targetIndex === -1) {
resultList.push({
name: item.name,
picUrl: item.picUrl,
cpuName: item.cpuName,
coreNum: item.coreNum,
partition: item.partition,
memoryList: [
{
memory: item.memory,
total: item.total,
partition: item.partition,
},
],
});
} else {
resultList[targetIndex].memoryList.push({
memory: item.memory,
total: item.total,
partition: item.partition,
});
}
});
setShowCpuList(resultList);
}, [originalCpuList]);
const cpuHeadCells = [
{
id: "type",
......@@ -168,31 +136,54 @@ const QueueSelect = (props: IQueueSelectProps) => {
// 有初始值的话显示初始值
useEffect(() => {
let resultList: Array<IShowCPULi> = [];
originalCpuList.forEach((item) => {
const targetIndex = resultList.findIndex((resultLi) => {
return resultLi.name === item.name;
});
if (targetIndex === -1) {
resultList.push({
name: item.name,
picUrl: item.picUrl,
cpuName: item.cpuName,
coreNum: item.coreNum,
partition: item.partition,
memoryList: [
{
memory: item.memory,
total: item.total,
partition: item.partition,
},
],
});
} else {
resultList[targetIndex].memoryList.push({
memory: item.memory,
total: item.total,
partition: item.partition,
});
}
});
if (open && value) {
console.log(open, "open");
console.log(value, "value");
const cpuActivePartitionIndex = originalCpuList.findIndex(
(li) => li.partition === value
);
console.log(cpuActivePartitionIndex, "cpuActivePartitionIndex");
let cpuActivePartitionName = "";
if (cpuActivePartitionIndex !== -1) {
cpuActivePartitionName = originalCpuList[cpuActivePartitionIndex].name;
}
const showCpuListClone: Array<IShowCPULi> = cloneDeep(showCpuList);
if (cpuActivePartitionIndex !== -1) {
showCpuListClone.forEach((li, index) => {
resultList.forEach((li, index) => {
if (li.name === cpuActivePartitionName) {
console.log(value);
showCpuListClone[index].partition = value;
resultList[index].partition = value;
}
});
setShowCpuList(showCpuListClone);
}
setActivePartition(value);
}
setShowCpuList(resultList);
// eslint-disable-next-line
}, [open, value]);
}, [open, value, originalCpuList]);
const renderType = (item: IShowCPULi) => {
return (
......
......@@ -93,8 +93,10 @@ const ProjectSubmitWork = observer(() => {
: String(parameter.defaultValue);
} else if ((parameter.domType || "").toLowerCase() === "radio") {
value = false;
} else if ((parameter.domType || "").toLowerCase() === "partition") {
value = false;
} else {
value = "";
value = parameter.defaultValue;
}
parameter.value = value;
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment