Commit bc925de6 authored by chenshouchao's avatar chenshouchao

Merge branch 'feat-20220620-taskSubmission' into 'release'

Feat 20220620 task submission

See merge request !71
parents 9c5c3f37 edc2859f
...@@ -8,16 +8,23 @@ import MyTreeView from "@/components/mui/MyTreeView"; ...@@ -8,16 +8,23 @@ import MyTreeView from "@/components/mui/MyTreeView";
import classNames from "classnames"; import classNames from "classnames";
import bigFolderIcon from "@/assets/project/bigFolderIcon.svg"; import bigFolderIcon from "@/assets/project/bigFolderIcon.svg";
import folderIcon from "@/assets/project/folderIcon.svg"; import folderIcon from "@/assets/project/folderIcon.svg";
import dataSetIcon from "@/assets/project/dataSetIcon.svg";
import fileIcon from "@/assets/project/fileIcon.svg";
import useMyRequest from "@/hooks/useMyRequest";
import { getDataFind } from "@/api/project_api";
import style from "./index.module.css"; import style from "./index.module.css";
import _ from "lodash";
type FileSelectProps = { type FileSelectProps = {
open: boolean; open: boolean;
onConfirm: any; onConfirm: any;
onClose: any; onClose: any;
type?: "file" | "dataset" | "path";
}; };
const FileSelect = observer((props: FileSelectProps) => { const FileSelect = observer((props: FileSelectProps) => {
const { onConfirm } = props; const { onConfirm, type = "path" } = props;
// const { onConfirm, type = "dataset" } = props;
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const projectId = toJS(currentProjectStore.currentProjectInfo.id); const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken); const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken);
...@@ -25,6 +32,66 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -25,6 +32,66 @@ const FileSelect = observer((props: FileSelectProps) => {
const [rootActive, setRootActive] = useState(true); const [rootActive, setRootActive] = useState(true);
const [newPath, setNewPath] = useState("/"); const [newPath, setNewPath] = useState("/");
// 获取某路径下的数据集
const { run: getDataFindRun } = useMyRequest(getDataFind, {
onSuccess: (res: any) => {
const dataSetList = res.data.map((item: any) => {
return {
...item,
type: "dataset",
dir: `/${item.path}`,
subdirs: "",
};
});
let treeDataArr = _.cloneDeep(treeData);
if (newPath === "/") {
treeDataArr = _.uniqWith([...treeDataArr, ...dataSetList], _.isEqual);
setTreeData(treeDataArr);
} else {
let pathArr: Array<any> = newPath.split("/");
pathArr.shift();
let reduceResult = pathArr.reduce((result, path) => {
if (Array.isArray(result)) {
result.forEach((item: any, index: number) => {
if (item.name === path) {
result = result[index];
}
});
} else if (Array.isArray(result.subdirs)) {
result.subdirs.forEach((item: any, index: number) => {
if (item.name === path) {
result = result.subdirs[index];
}
});
} else {
result = result.subdirs;
}
return result;
}, treeDataArr);
if (Array.isArray(reduceResult.subdirs)) {
reduceResult.subdirs = _.uniqWith(
[...reduceResult.subdirs, ...dataSetList],
_.isEqual
);
} else {
reduceResult.subdirs = dataSetList;
}
treeDataArr = _.uniqWith(treeDataArr, _.isEqual);
setTreeData(treeDataArr);
}
},
});
useEffect(() => {
if (type === "dataset") {
getDataFindRun({
projectId: projectId as string,
path: newPath === "/" ? "/" : `${newPath}/`,
});
}
}, [newPath, getDataFindRun, projectId, type]);
useEffect(() => { useEffect(() => {
if (fileToken && projectId) { if (fileToken && projectId) {
CloudEController.JobOutFileDirtree( CloudEController.JobOutFileDirtree(
...@@ -38,15 +105,31 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -38,15 +105,31 @@ const FileSelect = observer((props: FileSelectProps) => {
} else { } else {
setTreeData([]); setTreeData([]);
} }
if (type === "dataset") {
getDataFindRun({
projectId: projectId as string,
path: "/",
// path: path === "/" ? "/" : `${path}/`,
});
}
}); });
} }
}, [projectId, fileToken]); }, [projectId, fileToken, type, getDataFindRun]);
const renderLabel = (labelNmae: string) => { // const renderLabel = (labelNmae: string) => {
const renderLabel = (node: any) => {
return ( return (
<span className={style.treeLabel}> <span className={style.treeLabel}>
<img className={style.labelFolderIcon} src={folderIcon} alt="" /> {node.type === "directory" && (
<span className={style.treeLabelText}>{labelNmae}</span> <img className={style.labelFolderIcon} src={folderIcon} alt="" />
)}
{node.type === "dataset" && (
<img className={style.labelFolderIcon} src={dataSetIcon} alt="" />
)}
{node.type !== "directory" && node.type !== "dataset" && (
<img className={style.labelFolderIcon} src={fileIcon} alt="" />
)}
<span className={style.treeLabelText}>{node.name}</span>
</span> </span>
); );
}; };
...@@ -75,6 +158,7 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -75,6 +158,7 @@ const FileSelect = observer((props: FileSelectProps) => {
open={props.open} open={props.open}
onClose={props.onClose} onClose={props.onClose}
onConfirm={fileSelectOnConfirm} onConfirm={fileSelectOnConfirm}
title={type}
> >
<div <div
className={classNames({ className={classNames({
......
...@@ -15,7 +15,7 @@ type MyTreeViewProps = { ...@@ -15,7 +15,7 @@ type MyTreeViewProps = {
onNodeFocus?: (event: object, value: string) => void; // 点击某一项的回调 onNodeFocus?: (event: object, value: string) => void; // 点击某一项的回调
onNodeSelect?: (event: object, value: Array<any> | string) => void; // 点击某一项的回调 onNodeSelect?: (event: object, value: Array<any> | string) => void; // 点击某一项的回调
onNodeToggle?: (event: object, nodeIds: Array<any>) => void; // 点击某一项的回调 onNodeToggle?: (event: object, nodeIds: Array<any>) => void; // 点击某一项的回调
renderLabel?: (labelNmae: string) => React.ReactNode; renderLabel?: (node: any) => React.ReactNode;
treeViewSx?: any; treeViewSx?: any;
defaultExpanded?: Array<string>; defaultExpanded?: Array<string>;
idKey?: string; idKey?: string;
...@@ -48,7 +48,7 @@ const MyTreeView = (props: MyTreeViewProps) => { ...@@ -48,7 +48,7 @@ const MyTreeView = (props: MyTreeViewProps) => {
nodeId={String( nodeId={String(
idFunc ? idFunc(nodes) : nodes.id || `${nodes.name}${index}` idFunc ? idFunc(nodes) : nodes.id || `${nodes.name}${index}`
)} )}
label={renderLabel === undefined ? nodes.name : renderLabel(nodes.name)} label={renderLabel === undefined ? nodes.name : renderLabel(nodes)}
disabled={nodes?.disabled ? true : false} disabled={nodes?.disabled ? true : false}
> >
{Array.isArray(nodes.subdirs) {Array.isArray(nodes.subdirs)
......
...@@ -12,7 +12,8 @@ import { useState, useMemo, useEffect } from "react"; ...@@ -12,7 +12,8 @@ import { useState, useMemo, useEffect } from "react";
import { Box } from "@mui/system"; import { Box } from "@mui/system";
import Tab from "@mui/material/Tab"; import Tab from "@mui/material/Tab";
import { TabContext, TabList, TabPanel } from "@mui/lab"; import { TabContext, TabList, TabPanel } from "@mui/lab";
import { Typography } from '@mui/material'; import { Typography } from "@mui/material";
import { useImperativeHandle } from "react";
interface ITabList { interface ITabList {
label: string; label: string;
...@@ -20,32 +21,50 @@ interface ITabList { ...@@ -20,32 +21,50 @@ interface ITabList {
component: JSX.Element; component: JSX.Element;
icon?: string; icon?: string;
iconed?: string; iconed?: string;
hide?: boolean hide?: boolean;
} }
interface IProps { interface IProps {
tabList: ITabList[]; tabList: ITabList[];
onRef?: any;
} }
const Tabs = (props: IProps) => { const Tabs = (props: IProps) => {
const { tabList } = props; const { tabList } = props;
const [value, setValue] = useState(tabList.filter(e => !e.hide)[0].value); const [value, setValue] = useState(tabList.filter((e) => !e.hide)[0].value);
const onChange = (val: string) => { const onChange = (val: string) => {
setValue(val); setValue(val);
}; };
const setActiveTab = (val: string) => {
onChange(val);
};
useImperativeHandle(props.onRef, () => {
return {
setActiveTab: setActiveTab,
};
});
const labelRender = (item: ITabList, key: number) => { const labelRender = (item: ITabList, key: number) => {
return ( return (
<Box style={{ display: "flex", alignItems: "center" }}> <Box style={{ display: "flex", alignItems: "center" }}>
{ {item.icon ? (
item.icon ? <img style={{ width: "14px", marginRight: "10px" }} src={value === item.value ? item.iconed : item.icon} alt="" /> <img
: "" style={{ width: "14px", marginRight: "10px" }}
} src={value === item.value ? item.iconed : item.icon}
<Typography sx={{ fontSize: "14px", fontWeight: '400' }} >{item.label}</Typography> alt=""
/>
) : (
""
)}
<Typography sx={{ fontSize: "14px", fontWeight: "400" }}>
{item.label}
</Typography>
</Box> </Box>
) );
} };
return ( return (
<TabContext value={value}> <TabContext value={value}>
...@@ -57,7 +76,7 @@ const Tabs = (props: IProps) => { ...@@ -57,7 +76,7 @@ const Tabs = (props: IProps) => {
aria-label="lab API tabs example" aria-label="lab API tabs example"
> >
{tabList?.map((item, key) => { {tabList?.map((item, key) => {
if (item.hide) return "" if (item.hide) return "";
return ( return (
<Tab <Tab
key={key} key={key}
......
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
.content { .content {
flex: 1; flex: 1;
height: calc(100vh - 57px); height: calc(100vh - 57px);
overflow: hidden; overflow: scroll;
/* ??????????? */
} }
.list { .list {
/* background-color: red; */ /* background-color: red; */
......
...@@ -301,11 +301,11 @@ const MoveFile = (props: any) => { ...@@ -301,11 +301,11 @@ const MoveFile = (props: any) => {
}); });
}; };
const renderLabel = (labelNmae: string) => { const renderLabel = (node: any) => {
return ( return (
<span className={style.treeLabel}> <span className={style.treeLabel}>
<img className={style.labelFolderIcon} src={folderIcon} alt="" /> <img className={style.labelFolderIcon} src={folderIcon} alt="" />
<span className={style.treeLabelText}>{labelNmae}</span> <span className={style.treeLabelText}>{node.name}</span>
</span> </span>
); );
}; };
......
...@@ -453,7 +453,10 @@ const ProjectData = observer(() => { ...@@ -453,7 +453,10 @@ const ProjectData = observer(() => {
// 下载文件 // 下载文件
const hanleDownloadFile = (item: any) => { const hanleDownloadFile = (item: any) => {
const downloadPath = path === "/" ? "/" : `${path}/${item.name}`; console.log(item);
const downloadPath =
path === "/" ? `/${item.name}` : `${path}/${item.name}`;
console.log(downloadPath);
CloudEController.JobFileDownload( CloudEController.JobFileDownload(
downloadPath, downloadPath,
fileToken as string, fileToken as string,
......
...@@ -112,6 +112,10 @@ ...@@ -112,6 +112,10 @@
position: relative; position: relative;
align-items: center; align-items: center;
} }
.taskInfoValueClick {
cursor: pointer;
color: rgba(19, 112, 255, 1);
}
.taskInfoDownload { .taskInfoDownload {
color: rgba(19, 112, 255, 1); color: rgba(19, 112, 255, 1);
cursor: pointer; cursor: pointer;
...@@ -170,7 +174,7 @@ ...@@ -170,7 +174,7 @@
color: rgba(19, 112, 255, 1); color: rgba(19, 112, 255, 1);
} }
.fullScreenBox{ .fullScreenBox {
position: absolute; position: absolute;
background-color: #fff; background-color: #fff;
cursor: pointer; cursor: pointer;
...@@ -179,6 +183,6 @@ ...@@ -179,6 +183,6 @@
bottom: 24px; bottom: 24px;
padding: 8px; padding: 8px;
} }
.fullScreenBox:hover{ .fullScreenBox:hover {
opacity: 0.6; opacity: 0.6;
} }
\ No newline at end of file
...@@ -34,6 +34,7 @@ import Flow from "../components/Flow"; ...@@ -34,6 +34,7 @@ import Flow from "../components/Flow";
import { cancelWorkflowJob, deleteWorkflowJob } from "@/api/workbench_api"; import { cancelWorkflowJob, deleteWorkflowJob } from "@/api/workbench_api";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import MyPopconfirm from "@/components/mui/MyPopconfirm"; import MyPopconfirm from "@/components/mui/MyPopconfirm";
import { storageUnitFromB } from "@/utils/util";
import styles from "./index.module.css"; import styles from "./index.module.css";
...@@ -97,11 +98,16 @@ const ProjectSubmitWork = observer(() => { ...@@ -97,11 +98,16 @@ const ProjectSubmitWork = observer(() => {
path = path.slice(13); path = path.slice(13);
if (path) { if (path) {
navigate(`/product/cadd/projectData`, { navigate(`/product/cadd/projectData`, {
state: { pathName: "path" }, state: { pathName: path },
}); });
} }
}; };
const outputPathTransform = (path: string) => {
path = path.slice(13);
return `ProjectData${path}`;
};
const getOutouts = (outputs: any) => { const getOutouts = (outputs: any) => {
if (outputs) { if (outputs) {
let result = Object.keys(outputs); let result = Object.keys(outputs);
...@@ -169,7 +175,9 @@ const ProjectSubmitWork = observer(() => { ...@@ -169,7 +175,9 @@ const ProjectSubmitWork = observer(() => {
if (Array.isArray(res.data)) { if (Array.isArray(res.data)) {
res.data.forEach((item1) => { res.data.forEach((item1) => {
if (item1.name === item.path.slice(item.path.lastIndexOf("/") + 1)) { if (item1.name === item.path.slice(item.path.lastIndexOf("/") + 1)) {
randerOutputs[index].size = item1.size; randerOutputs[index].size = `${
item1.size ? storageUnitFromB(Number(item1.size)) : "-"
}`;
setRanderOutputs([...randerOutputs]); setRanderOutputs([...randerOutputs]);
} }
}); });
...@@ -259,7 +267,11 @@ const ProjectSubmitWork = observer(() => { ...@@ -259,7 +267,11 @@ const ProjectSubmitWork = observer(() => {
<div className={styles.swHeaderLeft}> <div className={styles.swHeaderLeft}>
<IconButton <IconButton
color="primary" color="primary"
onClick={() => navigate(-1)} onClick={() =>
navigate("/product/cadd/projectWorkbench", {
state: { from: "detail" },
})
}
aria-label="upload picture" aria-label="upload picture"
component="span" component="span"
size="small" size="small"
...@@ -352,12 +364,17 @@ const ProjectSubmitWork = observer(() => { ...@@ -352,12 +364,17 @@ const ProjectSubmitWork = observer(() => {
<div className={styles.taskInfoLi}> <div className={styles.taskInfoLi}>
<div className={styles.taskInfoParams}>输出路径</div> <div className={styles.taskInfoParams}>输出路径</div>
<div <div
className={styles.taskInfoValue} className={classNames({
[styles.taskInfoValue]: true,
[styles.taskInfoValueClick]: true,
})}
onClick={() => onClick={() =>
goToProjectData(workFlowJobInfo?.outputPath as string) goToProjectData(workFlowJobInfo?.outputPath as string)
} }
> >
{workFlowJobInfo?.outputPath || "-"} {workFlowJobInfo?.outputPath
? outputPathTransform(workFlowJobInfo?.outputPath)
: "-"}
</div> </div>
</div> </div>
<div className={styles.taskInfoLi}> <div className={styles.taskInfoLi}>
......
...@@ -141,24 +141,28 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -141,24 +141,28 @@ const ConfigForm = (props: ConfigFormProps) => {
result.forEach((task) => { result.forEach((task) => {
let isCheck = true; let isCheck = true;
if (task.parameters.length > 0) { if (task.parameters.length > 0) {
task.parameters.forEach((parameter) => { task.parameters
const { error } = getCheckResult(parameter, parameter.value); .filter((parameter) => parameter.hidden === false)
if (error) { .forEach((parameter) => {
isCheck = false; const { error } = getCheckResult(parameter, parameter.value);
return; if (error) {
} isCheck = false;
}); return;
}
});
} }
if (task.flows.length > 0) { if (task.flows.length > 0) {
task.flows.forEach((flow) => { task.flows.forEach((flow) => {
if (flow.parameters.length > 0) { if (flow.parameters.length > 0) {
flow.parameters.forEach((parameter) => { flow.parameters
const { error } = getCheckResult(parameter, parameter.value); .filter((parameter) => parameter.hidden === false)
if (error) { .forEach((parameter) => {
isCheck = false; const { error } = getCheckResult(parameter, parameter.value);
return; if (error) {
} isCheck = false;
}); return;
}
});
} }
}); });
} }
...@@ -258,7 +262,7 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -258,7 +262,7 @@ const ConfigForm = (props: ConfigFormProps) => {
)} )}
{parameter.domType.toLowerCase() === "input" && ( {parameter.domType.toLowerCase() === "input" && (
<MyInput <MyInput
value={parameter.value} value={parameter.value || ""}
onChange={(e: any) => onChange={(e: any) =>
handleParameterChange(e, taskId, parameter.name || "") handleParameterChange(e, taskId, parameter.name || "")
} }
...@@ -449,11 +453,13 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -449,11 +453,13 @@ const ConfigForm = (props: ConfigFormProps) => {
</div> </div>
); );
})} })}
{fileSelectOpen && <FileSelect {fileSelectOpen && (
onClose={handleFileSelectOnClose} <FileSelect
open={fileSelectOpen} onClose={handleFileSelectOnClose}
onConfirm={onFileSelectConfirm} open={fileSelectOpen}
/>} onConfirm={onFileSelectConfirm}
/>
)}
</div> </div>
); );
}; };
......
...@@ -24,6 +24,7 @@ import { templateConfigJson } from "./mock"; ...@@ -24,6 +24,7 @@ import { templateConfigJson } from "./mock";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import { toJS } from "mobx"; import { toJS } from "mobx";
import { useStores } from "@/store"; import { useStores } from "@/store";
import moment from "moment";
import MyPopconfirm from "@/components/mui/MyPopconfirm"; import MyPopconfirm from "@/components/mui/MyPopconfirm";
const ProjectSubmitWork = () => { const ProjectSubmitWork = () => {
...@@ -37,8 +38,10 @@ const ProjectSubmitWork = () => { ...@@ -37,8 +38,10 @@ const ProjectSubmitWork = () => {
let configFormRef: any = React.createRef(); let configFormRef: any = React.createRef();
// 前往工作台 // 前往工作台
const goToWorkbench = () => { const goToWorkbench = (toWorkbenchList = false) => {
navigate("/product/cadd/projectWorkbench"); navigate("/product/cadd/projectWorkbench", {
state: { from: toWorkbenchList ? "submitWork" : "" },
});
}; };
// 返回 // 返回
...@@ -65,7 +68,7 @@ const ProjectSubmitWork = () => { ...@@ -65,7 +68,7 @@ const ProjectSubmitWork = () => {
const { run: submitWorkFlowRun } = useMyRequest(submitWorkFlow, { const { run: submitWorkFlowRun } = useMyRequest(submitWorkFlow, {
onSuccess: (res) => { onSuccess: (res) => {
Message.success("提交成功"); Message.success("提交成功");
goToWorkbench(); goToWorkbench(true);
}, },
}); });
...@@ -80,20 +83,22 @@ const ProjectSubmitWork = () => { ...@@ -80,20 +83,22 @@ const ProjectSubmitWork = () => {
result.tasks.forEach((tack) => { result.tasks.forEach((tack) => {
if (tack.id === taskId) { if (tack.id === taskId) {
let isCheck = true; let isCheck = true;
tack.parameters.forEach((parameter) => { tack.parameters
if (parameter.name === parameterName) { .filter((parameter) => parameter.hidden === false)
parameter.value = value; .forEach((parameter) => {
const checkResult = getCheckResult(parameter, value); if (parameter.name === parameterName) {
parameter.error = checkResult.error; parameter.value = value;
parameter.helperText = checkResult.helperText; const checkResult = getCheckResult(parameter, value);
} else { parameter.error = checkResult.error;
return; parameter.helperText = checkResult.helperText;
} } else {
if (getCheckResult(parameter, value).error === true) { return;
isCheck = false; }
} if (getCheckResult(parameter, value).error === true) {
tack.isCheck = isCheck; isCheck = false;
}); }
tack.isCheck = isCheck;
});
} else { } else {
return; return;
} }
...@@ -106,7 +111,6 @@ const ProjectSubmitWork = () => { ...@@ -106,7 +111,6 @@ const ProjectSubmitWork = () => {
const { name, outputPath, nameAndOutputPathCheck } = const { name, outputPath, nameAndOutputPathCheck } =
configFormRef.current.getNameAndPath(); configFormRef.current.getNameAndPath();
if (!nameAndOutputPathCheck) { if (!nameAndOutputPathCheck) {
console.log(123);
check = false; check = false;
} }
const result: ITemplateConfig = _.cloneDeep(templateConfigInfo); const result: ITemplateConfig = _.cloneDeep(templateConfigInfo);
...@@ -118,8 +122,6 @@ const ProjectSubmitWork = () => { ...@@ -118,8 +122,6 @@ const ProjectSubmitWork = () => {
parameter.error = checkResult.error; parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText; parameter.helperText = checkResult.helperText;
if (checkResult.error) { if (checkResult.error) {
console.log(tack);
console.log(parameter);
check = false; check = false;
} }
}); });
...@@ -205,7 +207,11 @@ const ProjectSubmitWork = () => { ...@@ -205,7 +207,11 @@ const ProjectSubmitWork = () => {
<div className={styles.swTemplateUpdateTimeBox}> <div className={styles.swTemplateUpdateTimeBox}>
<span className={styles.swHeaderLable}>更新时间:</span> <span className={styles.swHeaderLable}>更新时间:</span>
<span className={styles.swHeaderValue}> <span className={styles.swHeaderValue}>
{templateConfigInfo?.updateTime} {templateConfigInfo?.updateTime
? moment(templateConfigInfo?.updateTime).format(
"YYYY-MM-DD HH:mm:ss"
)
: "-"}
</span> </span>
</div> </div>
<div className={styles.swHeaderGoback}></div> <div className={styles.swHeaderGoback}></div>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* @FilePath: /bkunyun/src/views/Project/ProjectSetting/index.tsx * @FilePath: /bkunyun/src/views/Project/ProjectSetting/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
import { memo, useState, useMemo, useEffect } from "react"; import React, { memo, useState, useMemo, useEffect } from "react";
import { Box } from "@mui/system"; import { Box } from "@mui/system";
import { useStores } from "@/store/index"; import { useStores } from "@/store/index";
...@@ -17,76 +17,84 @@ import WorkbenchTemplate from "./workbenchTemplate"; ...@@ -17,76 +17,84 @@ import WorkbenchTemplate from "./workbenchTemplate";
import WorkbenchList from "./workbenchList"; import WorkbenchList from "./workbenchList";
import Tabs from "@/components/mui/Tabs"; import Tabs from "@/components/mui/Tabs";
import usePass from "@/hooks/usePass"; import usePass from "@/hooks/usePass";
import { useLocation } from "react-router-dom";
import Template from "@/assets/project/workbenchTemplate.svg" import Template from "@/assets/project/workbenchTemplate.svg";
import Template_select from "@/assets/project/workbenchTemplate_select.svg" import Template_select from "@/assets/project/workbenchTemplate_select.svg";
import List from "@/assets/project/workbenchList.svg" import List from "@/assets/project/workbenchList.svg";
import List_select from "@/assets/project/workbenchList_select.svg" import List_select from "@/assets/project/workbenchList_select.svg";
//ui //ui
import ButtonDemo from "@/views/mui_demo/button" // import ButtonDemo from "@/views/mui_demo/button";
import InputDemo from "@/views/mui_demo/input" // import InputDemo from "@/views/mui_demo/input";
const ProjectWorkbench = observer(() => { const ProjectWorkbench = observer(() => {
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const isPass = usePass(); const isPass = usePass();
const location = useLocation();
let tabsRef: any = React.createRef();
useEffect(() => { useEffect(() => {
console.log(isPass("PROJECT_WORKBENCH_FLOES_USE", 'USER'), "11111111111"); console.log(isPass("PROJECT_WORKBENCH_FLOES_USE", "USER"), "11111111111");
console.log(isPass("PROJECT_WORKBENCH_FLOES"), 'wwwwwwwwwww') console.log(isPass("PROJECT_WORKBENCH_FLOES"), "wwwwwwwwwww");
}, []) }, []);
const tabList = useMemo(() => { useEffect(() => {
return [ const locationInfo: any = location?.state;
{ const from = locationInfo?.from;
label: "工作流模版", // 如果是从详情页来的,tab展示为任务列表
value: "workbenchTemplate", if (from === "detail" || from === "submitWork") {
component: <WorkbenchTemplate />, tabsRef?.current?.setActiveTab("workbenchList");
hide: !isPass("PROJECT_WORKBENCH_FLOES"), }
icon: Template, }, [location, tabsRef]);
iconed: Template_select
},
{
label: "任务列表",
value: "workbenchList",
component: <WorkbenchList />,
hide: !isPass("PROJECT_WORKBENCH_JOBS"),
icon: List,
iconed: List_select
},
{
label: "按钮组件",
value: "MUI_BUTTON",
component: <ButtonDemo />,
icon: List,
iconed: List_select
},
{
label: "输入框组件",
value: "MUI_INPUT",
component: <InputDemo />,
icon: List,
iconed: List_select
},
];
}, []);
const tabList = useMemo(() => {
return [
{
label: "工作流模版",
value: "workbenchTemplate",
component: <WorkbenchTemplate />,
hide: !isPass("PROJECT_WORKBENCH_FLOES"),
icon: Template,
iconed: Template_select,
},
{
label: "任务列表",
value: "workbenchList",
component: <WorkbenchList />,
hide: !isPass("PROJECT_WORKBENCH_JOBS"),
icon: List,
iconed: List_select,
},
// {
// label: "按钮组件",
// value: "MUI_BUTTON",
// component: <ButtonDemo />,
// icon: List,
// iconed: List_select,
// },
// {
// label: "输入框组件",
// value: "MUI_INPUT",
// component: <InputDemo />,
// icon: List,
// iconed: List_select,
// },
];
}, []);
return ( return (
<div style={{ padding: 24 }}> <div style={{ padding: 24 }}>
<div style={{ display: "flex", alignItems: "center" }}> <div style={{ display: "flex", alignItems: "center" }}>
<img src={projectImg} alt="项目logo" /> <img src={projectImg} alt="项目logo" />
<span style={{ marginLeft: 12 }}> <span style={{ marginLeft: 12 }}>工作台</span>
工作台 </div>
</span> <Box sx={{ width: "100%", typography: "body1" }}>
</div> <Tabs onRef={tabsRef} tabList={tabList} />
<Box sx={{ width: "100%", typography: "body1" }}> </Box>
<Tabs tabList={tabList} /> </div>
</Box> );
</div>
);
}); });
export default memo(ProjectWorkbench); export default memo(ProjectWorkbench);
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