Commit 27b686a0 authored by chenshouchao's avatar chenshouchao

feat: 添加setShowCpuList设置时机

parent d2ceda89
...@@ -93,38 +93,6 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -93,38 +93,6 @@ const QueueSelect = (props: IQueueSelectProps) => {
]; ];
}, [originalCpuList, originalGpuList]); }, [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 = [ const cpuHeadCells = [
{ {
id: "type", id: "type",
...@@ -168,31 +136,54 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -168,31 +136,54 @@ const QueueSelect = (props: IQueueSelectProps) => {
// 有初始值的话显示初始值 // 有初始值的话显示初始值
useEffect(() => { 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) { if (open && value) {
console.log(open, "open");
console.log(value, "value");
const cpuActivePartitionIndex = originalCpuList.findIndex( const cpuActivePartitionIndex = originalCpuList.findIndex(
(li) => li.partition === value (li) => li.partition === value
); );
console.log(cpuActivePartitionIndex, "cpuActivePartitionIndex");
let cpuActivePartitionName = ""; let cpuActivePartitionName = "";
if (cpuActivePartitionIndex !== -1) { if (cpuActivePartitionIndex !== -1) {
cpuActivePartitionName = originalCpuList[cpuActivePartitionIndex].name; cpuActivePartitionName = originalCpuList[cpuActivePartitionIndex].name;
} }
const showCpuListClone: Array<IShowCPULi> = cloneDeep(showCpuList);
if (cpuActivePartitionIndex !== -1) { if (cpuActivePartitionIndex !== -1) {
showCpuListClone.forEach((li, index) => { resultList.forEach((li, index) => {
if (li.name === cpuActivePartitionName) { if (li.name === cpuActivePartitionName) {
console.log(value); resultList[index].partition = value;
showCpuListClone[index].partition = value;
} }
}); });
setShowCpuList(showCpuListClone);
} }
setActivePartition(value); setActivePartition(value);
} }
setShowCpuList(resultList);
// eslint-disable-next-line // eslint-disable-next-line
}, [open, value]); }, [open, value, originalCpuList]);
const renderType = (item: IShowCPULi) => { const renderType = (item: IShowCPULi) => {
return ( return (
......
...@@ -93,8 +93,10 @@ const ProjectSubmitWork = observer(() => { ...@@ -93,8 +93,10 @@ const ProjectSubmitWork = observer(() => {
: String(parameter.defaultValue); : String(parameter.defaultValue);
} else if ((parameter.domType || "").toLowerCase() === "radio") { } else if ((parameter.domType || "").toLowerCase() === "radio") {
value = false; value = false;
} else if ((parameter.domType || "").toLowerCase() === "partition") {
value = false;
} else { } else {
value = ""; value = parameter.defaultValue;
} }
parameter.value = value; 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