Commit 0392e98c authored by chenshouchao's avatar chenshouchao

feat: 任务结果联调

parent 1e253dc3
...@@ -61,6 +61,25 @@ ...@@ -61,6 +61,25 @@
background-color: rgba(247, 248, 250, 1); background-color: rgba(247, 248, 250, 1);
margin-bottom: 24px; margin-bottom: 24px;
} }
.outputLi {
display: flex;
justify-content: space-between;
align-items: center;
margin: 6px 0;
}
.outputLiLeft {
display: flex;
align-items: center;
color: rgba(19, 112, 255, 1);
font-size: 14px;
}
.outputLiLeftImg {
margin-right: 15px;
}
.outputLiRight {
color: rgba(138, 144, 153, 1);
font-size: 12px;
}
.notResults { .notResults {
background-color: rgba(247, 248, 250, 1); background-color: rgba(247, 248, 250, 1);
padding: 54px 0; padding: 54px 0;
......
...@@ -19,6 +19,8 @@ import jobStop from "@/assets/project/jobStop.svg"; ...@@ -19,6 +19,8 @@ import jobStop from "@/assets/project/jobStop.svg";
import jobRun from "@/assets/project/jobRun.svg"; import jobRun from "@/assets/project/jobRun.svg";
import CloudEController from "@/api/fileserver/CloudEController"; import CloudEController from "@/api/fileserver/CloudEController";
import jobFail from "@/assets/project/jobFail.svg"; import jobFail from "@/assets/project/jobFail.svg";
import fileIcon from "@/assets/project/fileIcon.svg";
import dataSetIcon from "@/assets/project/dataSetIcon.svg";
import { useStores } from "@/store"; import { useStores } from "@/store";
import { toJS } from "mobx"; import { toJS } from "mobx";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
...@@ -44,6 +46,7 @@ const statusMap = { ...@@ -44,6 +46,7 @@ const statusMap = {
}; };
type IStatus = "Done" | "Running" | "Failed" | "Pending"; type IStatus = "Done" | "Running" | "Failed" | "Pending";
let randerOutputs: Array<any> = [];
const ProjectSubmitWork = observer(() => { const ProjectSubmitWork = observer(() => {
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
...@@ -55,12 +58,14 @@ const ProjectSubmitWork = observer(() => { ...@@ -55,12 +58,14 @@ const ProjectSubmitWork = observer(() => {
const [overviewActive, setOverviewActive] = useState(true); const [overviewActive, setOverviewActive] = useState(true);
const [activeFlowIndex, setActiveFlowIndex] = useState<number>(0); const [activeFlowIndex, setActiveFlowIndex] = useState<number>(0);
const [showOptions, setShowOptions] = useState<boolean>(false); const [showOptions, setShowOptions] = useState<boolean>(false);
const [randerOutputs1, setRanderOutputs] = useState<Array<any>>([]);
const location: any = useLocation(); const location: any = useLocation();
const navigate = useNavigate(); const navigate = useNavigate();
/** 获取模版数据 */ /** 获取模版数据 */
const { run } = useMyRequest(fetchWorkFlowJob, { const { run } = useMyRequest(fetchWorkFlowJob, {
onSuccess: (res: IResponse<ITaskInfo>) => { onSuccess: (res: IResponse<ITaskInfo>) => {
getOutouts(res.data.outputs);
setWorkFlowJobInfo(res.data); setWorkFlowJobInfo(res.data);
}, },
}); });
...@@ -68,14 +73,12 @@ const ProjectSubmitWork = observer(() => { ...@@ -68,14 +73,12 @@ const ProjectSubmitWork = observer(() => {
useEffect(() => { useEffect(() => {
const locationInfo: any = location?.state; const locationInfo: any = location?.state;
run({ run({
// id: locationInfo.taskId, id: locationInfo.taskId,
id: "89a00e93-8bba-45ee-85b0-63c5cd42c570",
}); });
}, [location?.state, run]); }, [location?.state, run]);
const { run: getworkFlowTaskInfoRun } = useMyRequest(getworkFlowTaskInfo, { const { run: getworkFlowTaskInfoRun } = useMyRequest(getworkFlowTaskInfo, {
onSuccess: (res) => { onSuccess: (res) => {
console.log(res);
setPatchInfo(res.data); setPatchInfo(res.data);
}, },
}); });
...@@ -86,52 +89,81 @@ const ProjectSubmitWork = observer(() => { ...@@ -86,52 +89,81 @@ const ProjectSubmitWork = observer(() => {
}); });
}; };
// const outputs = useMemo(() => { const getOutouts = (outputs: any) => {
// if (workFlowJobInfo?.outputs) { if (outputs) {
// let result = Object.keys(workFlowJobInfo?.outputs); let result = Object.keys(outputs);
// let arr = result.map((item) => { let arr = result.map((item) => {
// let type = "file"; let type = "file";
// if (workFlowJobInfo?.outputs[item].indexOf("dataset") !== -1) { if (outputs[item].indexOf("dataset") !== -1) {
// type = "dataset"; type = "dataset";
// } }
// return { return {
// name: item, name: item,
// type, type,
// path: workFlowJobInfo?.outputs[item], path: outputs[item],
// }; size: 0,
// }); };
// arr.forEach(async (item) => { });
// if (item.type === "dataset") { arr.forEach(async (item, index) => {
// await getDataSetSize(item); if (item.type === "dataset") {
// } else { await getDataSetSize(item, index);
// await getFileSize(item); } else {
// } await getFileSize(item, index);
// }); }
// } else { });
// return []; randerOutputs = arr;
// } setRanderOutputs([...randerOutputs]);
// }, [workFlowJobInfo]); } else {
randerOutputs = [];
setRanderOutputs([]);
}
};
// const getDataSetSize = async (item: any) => { const getDataSetSize = async (item: any, index: number) => {
// const res = await getDataFind({ let path = item.path.slice(13);
// projectId: projectId as string, const lastIndex = path.lastIndexOf("/");
// path: item.path, if (lastIndex === -1) {
// }); path = "/";
// item.size = res.data[0].size; } else {
// }; path = path.slice(0, lastIndex + 1);
}
const res = await getDataFind({
projectId: projectId as string,
path: path,
});
res.data.forEach((item1: any) => {
if (item1.name === item.path.slice(item.path.lastIndexOf("/") + 1)) {
randerOutputs[index].size = `${item1.size}条`;
setRanderOutputs([...randerOutputs]);
}
});
};
// const getFileSize = (item: any) => { const getFileSize = (item: any, index: number) => {
// CloudEController.JobOutFileList( let path = item.path.slice(13);
// item.path, const lastIndex = path.lastIndexOf("/");
// fileToken as string, if (lastIndex === -1) {
// projectId as string, path = "/";
// false } else {
// )?.then((res) => { path = path.slice(0, lastIndex + 1);
// if (Array.isArray(res.data)) { }
// item.size = res.data[0].size; CloudEController.JobOutFileList(
// } path,
// }); fileToken as string,
// }; projectId as string,
false
)?.then((res) => {
if (Array.isArray(res.data)) {
res.data.forEach((item1) => {
if (item1.name === item.path.slice(item.path.lastIndexOf("/") + 1)) {
console.log(9999);
randerOutputs[index].size = item1.size;
setRanderOutputs([...randerOutputs]);
}
});
}
});
};
const handleBatch = (id: string) => { const handleBatch = (id: string) => {
setActivePatchId(id); setActivePatchId(id);
...@@ -208,7 +240,25 @@ const ProjectSubmitWork = observer(() => { ...@@ -208,7 +240,25 @@ const ProjectSubmitWork = observer(() => {
<div className={styles.taskInfo}> <div className={styles.taskInfo}>
<div className={styles.title}>任务结果</div> <div className={styles.title}>任务结果</div>
{workFlowJobInfo?.outputs && ( {workFlowJobInfo?.outputs && (
<div className={styles.taskResults}>任务结果</div> <div className={styles.taskResults}>
{randerOutputs1.map((item, index) => {
return (
<div key={index} className={styles.outputLi}>
<div className={styles.outputLiLeft}>
<img
className={styles.outputLiLeftImg}
src={item.type === "file" ? fileIcon : dataSetIcon}
alt=""
/>
{item.name}
</div>
<span className={styles.outputLiRight}>
{item.size}
</span>
</div>
);
})}
</div>
)} )}
{!workFlowJobInfo?.outputs && ( {!workFlowJobInfo?.outputs && (
<div className={styles.notResults}>暂无结果文件</div> <div className={styles.notResults}>暂无结果文件</div>
......
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