Commit 7f82c667 authored by chenshouchao's avatar chenshouchao

feat: 产品id动态获取

parent 387dff16
...@@ -77,11 +77,19 @@ const FileItem = observer((props: IProps) => { ...@@ -77,11 +77,19 @@ const FileItem = observer((props: IProps) => {
if (text === "查看文件") { if (text === "查看文件") {
if ( if (
location?.state?.pathName !== fileItemInfo?.path || location?.state?.pathName !== fileItemInfo?.path ||
location?.pathname !== "/product/cadd/projectData" location?.pathname !==
`/product/${
currentProjectStore.currentProductInfo.id || "cadd"
}/projectData`
) { ) {
navigate(`/product/cadd/projectData`, { navigate(
state: { pathName: fileItemInfo?.path }, `/product/${
}); currentProjectStore.currentProductInfo.id || "cadd"
}/projectData`,
{
state: { pathName: fileItemInfo?.path },
}
);
} }
} }
}; };
......
...@@ -10,6 +10,7 @@ import useMyRequest from "@/hooks/useMyRequest"; ...@@ -10,6 +10,7 @@ import useMyRequest from "@/hooks/useMyRequest";
import { useStores } from "@/store"; import { useStores } from "@/store";
import { toJS } from "mobx"; import { toJS } from "mobx";
import { ITask } from "@/views/Project/ProjectSubmitWork/interface"; import { ITask } from "@/views/Project/ProjectSubmitWork/interface";
import { observer } from "mobx-react-lite";
type IProps = { type IProps = {
operatorList: ITask[]; operatorList: ITask[];
...@@ -17,7 +18,7 @@ type IProps = { ...@@ -17,7 +18,7 @@ type IProps = {
setInputActive: any; setInputActive: any;
}; };
const OperatorList = (props: IProps) => { const OperatorList = observer((props: IProps) => {
const { operatorList, setOperatorList, setInputActive } = props; // 流程图中流算子列表 const { operatorList, setOperatorList, setInputActive } = props; // 流程图中流算子列表
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const [list, setList] = useState<ITask[]>([]); // 算子列表 const [list, setList] = useState<ITask[]>([]); // 算子列表
...@@ -249,6 +250,6 @@ const OperatorList = (props: IProps) => { ...@@ -249,6 +250,6 @@ const OperatorList = (props: IProps) => {
</div> </div>
</div> </div>
); );
}; });
export default OperatorList; export default OperatorList;
...@@ -187,11 +187,11 @@ const ProjectSubmitWork = observer(() => { ...@@ -187,11 +187,11 @@ const ProjectSubmitWork = observer(() => {
const goToProjectData = (path: string) => { const goToProjectData = (path: string) => {
path = path.slice(12); path = path.slice(12);
if (path) { if (path) {
navigate(`/product/cadd/projectData`, { navigate(`/product/${productId || "cadd"}/projectData`, {
state: { pathName: path }, state: { pathName: path },
}); });
} else { } else {
navigate(`/product/cadd/projectData`, { navigate(`/product/${productId || "cadd"}/projectData`, {
state: { pathName: "/" }, state: { pathName: "/" },
}); });
} }
...@@ -217,13 +217,13 @@ const ProjectSubmitWork = observer(() => { ...@@ -217,13 +217,13 @@ const ProjectSubmitWork = observer(() => {
/** 返回事件 */ /** 返回事件 */
const onBack = useCallback(() => { const onBack = useCallback(() => {
if (locationInfo.from === "projectOverview") { if (locationInfo.from === "projectOverview") {
navigate("/product/cadd/projectOverview"); navigate(`/product/${productId || "cadd"}/projectOverview`);
} else { } else {
navigate("/product/cadd/projectWorkbench", { navigate(`/product/${productId || "cadd"}/projectWorkbench`, {
state: { type: "workbenchList" }, state: { type: "workbenchList" },
}); });
} }
}, [navigate, locationInfo.from]); }, [navigate, locationInfo.from, productId]);
const getOutouts = (outputs: any) => { const getOutouts = (outputs: any) => {
if (outputs) { if (outputs) {
......
...@@ -2,6 +2,9 @@ import { useMemo, useCallback, useEffect, useState } from "react"; ...@@ -2,6 +2,9 @@ import { useMemo, useCallback, useEffect, useState } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import MyProgress from "@/components/mui/MyProgress"; import MyProgress from "@/components/mui/MyProgress";
import style from "./index.module.css"; import style from "./index.module.css";
import { useStores } from "@/store";
import { toJS } from "mobx";
import { observer } from "mobx-react-lite";
import runTime from "../../../../assets/project/runTime.svg"; import runTime from "../../../../assets/project/runTime.svg";
import jobCostImg from "../../../../assets/project/jobCost.svg"; import jobCostImg from "../../../../assets/project/jobCost.svg";
...@@ -38,6 +41,8 @@ const TaskCard = (props: TaskCardProps) => { ...@@ -38,6 +41,8 @@ const TaskCard = (props: TaskCardProps) => {
} = props; } = props;
const navigate = useNavigate(); const navigate = useNavigate();
const [displayTitleBlue, setDisplayTitleBlue] = useState<boolean>(false); const [displayTitleBlue, setDisplayTitleBlue] = useState<boolean>(false);
const { currentProjectStore } = useStores();
const productId = toJS(currentProjectStore.currentProductInfo.id); // 产品ID
const randerOutputs = useMemo(() => { const randerOutputs = useMemo(() => {
if (outputs) { if (outputs) {
...@@ -68,13 +73,13 @@ const TaskCard = (props: TaskCardProps) => { ...@@ -68,13 +73,13 @@ const TaskCard = (props: TaskCardProps) => {
path = path.slice(0, lastIndex); path = path.slice(0, lastIndex);
} }
path = path.slice(12); path = path.slice(12);
navigate(`/product/cadd/projectData`, { navigate(`/product/${productId || "cadd"}/projectData`, {
state: { pathName: path || "/", dataType: type }, state: { pathName: path || "/", dataType: type },
}); });
}; };
// 跳转详情页 // 跳转详情页
const gotoDetail = (id: string) => { const gotoDetail = (id: string) => {
navigate(`/product/cadd/projectJobDetail`, { navigate(`/product/${productId || "cadd"}/projectJobDetail`, {
state: { taskId: id, from: "projectOverview" }, state: { taskId: id, from: "projectOverview" },
}); });
}; };
......
...@@ -40,6 +40,7 @@ const BaseInfo = observer(() => { ...@@ -40,6 +40,7 @@ const BaseInfo = observer(() => {
const message = useMessage(); const message = useMessage();
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken); const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken);
const productId = toJS(currentProjectStore.currentProductInfo.id); // 产品ID
const [projectInfo, setProjectInfo] = useState<any>({}); const [projectInfo, setProjectInfo] = useState<any>({});
const [deleteProjectName, setDeleteProjectName] = useState(""); const [deleteProjectName, setDeleteProjectName] = useState("");
const [nameCheck, setNameCheck] = useState({ const [nameCheck, setNameCheck] = useState({
...@@ -258,7 +259,7 @@ const BaseInfo = observer(() => { ...@@ -258,7 +259,7 @@ const BaseInfo = observer(() => {
{ {
onSuccess: async (result: any) => { onSuccess: async (result: any) => {
message.success("修改成功"); message.success("修改成功");
const projectList = await getProjectList(); const projectList = await getProjectList(productId);
currentProjectStore.setProjectList(projectList); currentProjectStore.setProjectList(projectList);
projectInfo.filetoken = fileToken; projectInfo.filetoken = fileToken;
currentProjectStore.changeProject(projectInfo); currentProjectStore.changeProject(projectInfo);
...@@ -272,7 +273,7 @@ const BaseInfo = observer(() => { ...@@ -272,7 +273,7 @@ const BaseInfo = observer(() => {
checkName(projectInfo.name, true) && checkName(projectInfo.name, true) &&
checkBudget(projectInfo.projectBudget, true) checkBudget(projectInfo.projectBudget, true)
) { ) {
updateProjectRun({ ...projectInfo, product: "cadd" }); updateProjectRun({ ...projectInfo, product: `${productId || "cadd"}` });
} else { } else {
return; return;
} }
...@@ -282,7 +283,7 @@ const BaseInfo = observer(() => { ...@@ -282,7 +283,7 @@ const BaseInfo = observer(() => {
onSuccess: async (result: any) => { onSuccess: async (result: any) => {
message.success("删除成功"); message.success("删除成功");
setDialogOpen(false); setDialogOpen(false);
const projectList = await getProjectList(); const projectList = await getProjectList(productId);
currentProjectStore.setProjectList(projectList); currentProjectStore.setProjectList(projectList);
// 项目删完了 // 项目删完了
currentProjectStore.changeProject({}); currentProjectStore.changeProject({});
......
...@@ -34,6 +34,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -34,6 +34,7 @@ const ProjectSubmitWork = observer(() => {
const Message = useMessage(); const Message = useMessage();
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const projectId = toJS(currentProjectStore.currentProjectInfo.id); const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const productId = toJS(currentProjectStore.currentProductInfo.id); // 产品ID
const [templateConfigInfo, setTemplateConfigInfo] = const [templateConfigInfo, setTemplateConfigInfo] =
useState<ITemplateConfig>(); useState<ITemplateConfig>();
const location: any = useLocation(); const location: any = useLocation();
...@@ -46,7 +47,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -46,7 +47,7 @@ const ProjectSubmitWork = observer(() => {
// 前往工作台 // 前往工作台
const goToWorkbench = (toWorkbenchList = false) => { const goToWorkbench = (toWorkbenchList = false) => {
navigate("/product/cadd/projectWorkbench", { navigate(`/product/${productId || "cadd"}/projectWorkbench`, {
state: { type: toWorkbenchList ? "workbenchList" : "" }, state: { type: toWorkbenchList ? "workbenchList" : "" },
}); });
}; };
......
...@@ -7,18 +7,15 @@ ...@@ -7,18 +7,15 @@
* @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, useCallback, useEffect, useState } from "react"; import { memo, useCallback, useEffect, useState } from "react";
import _ from "lodash";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import OutlinedInput from "@mui/material/OutlinedInput"; import OutlinedInput from "@mui/material/OutlinedInput";
import { TablePagination } from "@mui/material";
import MyPagination from "@/components/mui/MyPagination"; import MyPagination from "@/components/mui/MyPagination";
import MySelect from "@/components/mui/MySelect"; import MySelect from "@/components/mui/MySelect";
import SimpleDialog from "./components/simpleDialog"; import SimpleDialog from "./components/simpleDialog";
import { useStores } from "@/store"; import { useStores } from "@/store";
import useMyRequest from "@/hooks/useMyRequest"; import useMyRequest from "@/hooks/useMyRequest";
import ActionsComponent from "../../../../components/Material.Ui/Table/ActionsComponent";
import runTime from "../../../../assets/project/runTime.svg"; import runTime from "../../../../assets/project/runTime.svg";
import jobCost from "../../../../assets/project/jobCost.svg"; import jobCost from "../../../../assets/project/jobCost.svg";
import jobSue from "../../../../assets/project/jobSue.svg"; import jobSue from "../../../../assets/project/jobSue.svg";
...@@ -77,6 +74,7 @@ const ProjectMembers = observer(() => { ...@@ -77,6 +74,7 @@ const ProjectMembers = observer(() => {
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const projectId = toJS(currentProjectStore.currentProjectInfo.id); const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const productId = toJS(currentProjectStore.currentProductInfo.id); // 产品ID
const isPass = usePass(); const isPass = usePass();
const [jobName, setJobName] = useState(""); const [jobName, setJobName] = useState("");
const [jobList, setJobList] = useState([]); const [jobList, setJobList] = useState([]);
...@@ -287,11 +285,11 @@ const ProjectMembers = observer(() => { ...@@ -287,11 +285,11 @@ const ProjectMembers = observer(() => {
/** 点击每一行 */ /** 点击每一行 */
const rowClick = useCallback( const rowClick = useCallback(
(id: string) => { (id: string) => {
navigate(`/product/cadd/projectJobDetail`, { navigate(`/product/${productId || "cadd"}/projectJobDetail`, {
state: { taskId: id, from: "workbenchList" }, state: { taskId: id, from: "workbenchList" },
}); });
}, },
[navigate] [navigate, productId]
); );
// 回车搜索 // 回车搜索
...@@ -312,7 +310,8 @@ const ProjectMembers = observer(() => { ...@@ -312,7 +310,8 @@ const ProjectMembers = observer(() => {
<SearchInput <SearchInput
onKeyUp={handleKeyWordChangeKeyUp} onKeyUp={handleKeyWordChangeKeyUp}
onBlur={handleKeyWordChangeBlur} onBlur={handleKeyWordChangeBlur}
sx={{ width: 340 }} /> sx={{ width: 340 }}
/>
{/* <Box className={styles.tabHeaderSelect}> {/* <Box className={styles.tabHeaderSelect}>
<TextField <TextField
select select
...@@ -463,7 +462,7 @@ const ProjectMembers = observer(() => { ...@@ -463,7 +462,7 @@ const ProjectMembers = observer(() => {
<Box className={styles.tabBoxJobOperate}> <Box className={styles.tabBoxJobOperate}>
{currentProjectStore.currentProjectInfo.projectRole === {currentProjectStore.currentProjectInfo.projectRole ===
"USER" && "USER" &&
item.creator !== item.creator !==
JSON.parse(localStorage.getItem("userInfo") || "{}") JSON.parse(localStorage.getItem("userInfo") || "{}")
?.name ? ( ?.name ? (
"" ""
......
...@@ -2,14 +2,19 @@ import MyDialog from "@/components/mui/MyDialog"; ...@@ -2,14 +2,19 @@ import MyDialog from "@/components/mui/MyDialog";
import MyButton from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
import { DialogActions } from "@mui/material"; import { DialogActions } from "@mui/material";
import style from "./index.module.css"; import style from "./index.module.css";
import { useStores } from "@/store";
import { observer } from "mobx-react-lite";
import { toJS } from "mobx";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
const RemindBudgetDialog = (props: any) => { const RemindBudgetDialog = observer((props: any) => {
const navigate = useNavigate(); const navigate = useNavigate();
const { rbOpen, rbClose, goToProjectSubmitWork, id, isParentUser, isOwner } = const { rbOpen, rbClose, goToProjectSubmitWork, id, isParentUser, isOwner } =
props; props;
const { currentProjectStore } = useStores();
const productId = toJS(currentProjectStore.currentProductInfo.id); // 产品ID
const goToprojectSetting = () => { const goToprojectSetting = () => {
navigate(`/product/cadd/projectSetting`, { navigate(`/product/${productId || "cadd"}/projectSetting`, {
state: { type: "baseInfo" }, state: { type: "baseInfo" },
}); });
}; };
...@@ -49,6 +54,6 @@ const RemindBudgetDialog = (props: any) => { ...@@ -49,6 +54,6 @@ const RemindBudgetDialog = (props: any) => {
</MyDialog> </MyDialog>
</> </>
); );
}; });
export default RemindBudgetDialog; export default RemindBudgetDialog;
...@@ -13,10 +13,15 @@ import MyButton from "@/components/mui/MyButton"; ...@@ -13,10 +13,15 @@ import MyButton from "@/components/mui/MyButton";
import usePass from "@/hooks/usePass"; import usePass from "@/hooks/usePass";
import RemindBudgetDialog from "./RemindBudgetDialog.tsx"; import RemindBudgetDialog from "./RemindBudgetDialog.tsx";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { toJS } from "mobx";
import { useStores } from "@/store";
import { observer } from "mobx-react-lite";
const TemplateBox = (props: any) => { const TemplateBox = observer((props: any) => {
const info = props.data; const info = props.data;
const { isParentUser, isOwner, greaterThan100 } = props; const { isParentUser, isOwner, greaterThan100 } = props;
const { currentProjectStore } = useStores();
const productId = toJS(currentProjectStore.currentProductInfo.id); // 产品ID
const isPass = usePass(); const isPass = usePass();
const navigate = useNavigate(); const navigate = useNavigate();
const [rbOpen, setRbOpen] = useState(false); const [rbOpen, setRbOpen] = useState(false);
...@@ -24,11 +29,11 @@ const TemplateBox = (props: any) => { ...@@ -24,11 +29,11 @@ const TemplateBox = (props: any) => {
const goToProjectSubmitWork = useCallback( const goToProjectSubmitWork = useCallback(
(id: string) => { (id: string) => {
navigate(`/product/cadd/projectSubmitWork`, { navigate(`/product/${productId || "cadd"}/projectSubmitWork`, {
state: { id }, state: { id },
}); });
}, },
[navigate] [navigate, productId]
); );
const handleJudgeBudget = useCallback( const handleJudgeBudget = useCallback(
...@@ -141,6 +146,6 @@ const TemplateBox = (props: any) => { ...@@ -141,6 +146,6 @@ const TemplateBox = (props: any) => {
)} )}
</> </>
); );
}; });
export default memo(TemplateBox); export default memo(TemplateBox);
...@@ -10,6 +10,8 @@ import { useMessage } from "@/components/MySnackbar"; ...@@ -10,6 +10,8 @@ import { useMessage } from "@/components/MySnackbar";
import { getProjectList } from "../../project"; import { getProjectList } from "../../project";
import { useStores } from "@/store"; import { useStores } from "@/store";
import { checkIsNumberLetterChinese } from "@/utils/util"; import { checkIsNumberLetterChinese } from "@/utils/util";
import { observer } from "mobx-react-lite";
import { toJS } from "mobx";
import { import {
setFileServerEndPointLocalStorage, setFileServerEndPointLocalStorage,
getFiletokenAccordingToId, getFiletokenAccordingToId,
...@@ -27,12 +29,13 @@ type IAddProjectProps = { ...@@ -27,12 +29,13 @@ type IAddProjectProps = {
setAddOpen: any; setAddOpen: any;
}; };
const AddProject = (props: IAddProjectProps) => { const AddProject = observer((props: IAddProjectProps) => {
const { addOpen, setAddOpen } = props; const { addOpen, setAddOpen } = props;
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const navigate = useNavigate(); const navigate = useNavigate();
const message = useMessage(); const message = useMessage();
const [name, setName] = useState(""); const [name, setName] = useState("");
const productId = toJS(currentProjectStore.currentProductInfo.id); // 产品ID
const [nameCheck, setNameCheck] = useState({ const [nameCheck, setNameCheck] = useState({
error: false, error: false,
help: "", help: "",
...@@ -62,7 +65,7 @@ const AddProject = (props: IAddProjectProps) => { ...@@ -62,7 +65,7 @@ const AddProject = (props: IAddProjectProps) => {
setAddOpen(false); setAddOpen(false);
setLoading(false); setLoading(false);
message.success("新建项目成功"); message.success("新建项目成功");
const projectList = await getProjectList(); const projectList = await getProjectList(productId);
currentProjectStore.setProjectList(projectList); currentProjectStore.setProjectList(projectList);
let project: any = {}; let project: any = {};
projectList.forEach((item: any) => { projectList.forEach((item: any) => {
...@@ -75,7 +78,7 @@ const AddProject = (props: IAddProjectProps) => { ...@@ -75,7 +78,7 @@ const AddProject = (props: IAddProjectProps) => {
project.filetoken = res; project.filetoken = res;
currentProjectStore.changeProject(project); currentProjectStore.changeProject(project);
}); });
navigate(`/product/cadd/projectOverview`); navigate(`/product/${productId || "cadd"}/projectOverview`);
} }
}, },
onError: () => { onError: () => {
...@@ -157,7 +160,7 @@ const AddProject = (props: IAddProjectProps) => { ...@@ -157,7 +160,7 @@ const AddProject = (props: IAddProjectProps) => {
name, name,
desc, desc,
zoneId, zoneId,
product: "cadd", product: productId || "cadd",
}); });
} else { } else {
return; return;
...@@ -232,6 +235,6 @@ const AddProject = (props: IAddProjectProps) => { ...@@ -232,6 +235,6 @@ const AddProject = (props: IAddProjectProps) => {
</div> </div>
</MyDialog> </MyDialog>
); );
}; });
export default AddProject; export default AddProject;
...@@ -12,8 +12,8 @@ import { ...@@ -12,8 +12,8 @@ import {
getDataFileToken, getDataFileToken,
} from "@/api/project_api"; } from "@/api/project_api";
export const getProjectList = async () => { export const getProjectList = async (id = 'cadd') => {
const res = await getProjectListApi({ product: "cadd" }); const res = await getProjectListApi({ product: id });
return res.data; return res.data;
}; };
......
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