Commit c054d7f8 authored by rocosen's avatar rocosen

fix:bug

parent b08567c0
...@@ -12,16 +12,20 @@ import AddIcon from "@mui/icons-material/Add"; ...@@ -12,16 +12,20 @@ import AddIcon from "@mui/icons-material/Add";
import AddProject from "@/views/Project/components/AddProject"; import AddProject from "@/views/Project/components/AddProject";
import React, { useState } from "react"; import React, { useState } from "react";
import MyButton from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
import { toJS } from "mobx";
import { observer } from "mobx-react-lite";
import { useStores } from "@/store/index";
const NoProject = () => { const NoProject = observer((props: any) => {
// 新建弹窗显示控制 // 新建弹窗显示控制
const [addOpen, setAddOpen] = useState(false); const [addOpen, setAddOpen] = useState(false);
const { currentProjectStore } = useStores();
let projectList = toJS(currentProjectStore.projectList)
return ( return (
<div className={style.noProject}> <div className={style.noProject}>
<img src={noData} alt="" className={style.noDataImg} /> <img src={noData} alt="" className={style.noDataImg} />
<div className={style.text1}>当前产品暂无项目</div> <div className={style.text1}>{projectList.length > 0 ? "当前未选中任何项目" : "当前产品暂无项目"}</div>
<div className={style.text2}>请先创建项目</div> <div className={style.text2}>{projectList.length > 0 ? "或创建新项目" : "请先创建项目"}</div>
<MyButton <MyButton
text='创建项目' text='创建项目'
variant="contained" variant="contained"
...@@ -35,6 +39,6 @@ const NoProject = () => { ...@@ -35,6 +39,6 @@ const NoProject = () => {
<AddProject addOpen={addOpen} setAddOpen={setAddOpen} /> <AddProject addOpen={addOpen} setAddOpen={setAddOpen} />
</div> </div>
); );
}; });
export default NoProject; export default NoProject;
...@@ -11,7 +11,8 @@ import Switch, { SwitchProps } from "@mui/material/Switch"; ...@@ -11,7 +11,8 @@ import Switch, { SwitchProps } from "@mui/material/Switch";
import { ThemeProvider, createTheme } from "@mui/material/styles"; import { ThemeProvider, createTheme } from "@mui/material/styles";
interface IMySwitchProps extends SwitchProps { interface IMySwitchProps extends SwitchProps {
value: boolean; value?: boolean;
defaultChecked?: boolean;
onChange?: any; onChange?: any;
disabled?: boolean; disabled?: boolean;
} }
...@@ -52,12 +53,13 @@ const theme = createTheme({ ...@@ -52,12 +53,13 @@ const theme = createTheme({
}); });
const MySwitch = (props: IMySwitchProps) => { const MySwitch = (props: IMySwitchProps) => {
const { value, onChange, disabled = false, size, ...other } = props; const { value, defaultChecked, onChange, disabled = false, size, ...other } = props;
return ( return (
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<Switch <Switch
checked={value} checked={value}
disabled={disabled} disabled={disabled}
defaultChecked={defaultChecked}
onChange={onChange} onChange={onChange}
sx={ sx={
size === "medium" size === "medium"
......
...@@ -276,20 +276,20 @@ const BaseInfo = observer(() => { ...@@ -276,20 +276,20 @@ const BaseInfo = observer(() => {
const projectList = await getProjectList(); const projectList = await getProjectList();
currentProjectStore.setProjectList(projectList); currentProjectStore.setProjectList(projectList);
// 项目删完了 // 项目删完了
if (projectList.length === 0) { // if (projectList.length === 0) {
currentProjectStore.changeProject({}); currentProjectStore.changeProject({});
localStorage.setItem("fileServerEndPoint", ""); localStorage.setItem("fileServerEndPoint", "");
setProjectInfo({}); setProjectInfo({});
} else { // } else {
projectList[0].filetoken = getFiletokenAccordingToId(projectList[0].id); // projectList[0].filetoken = getFiletokenAccordingToId(projectList[0].id);
currentProjectStore.changeProject(projectList[0]); // currentProjectStore.changeProject(projectList[0]);
setFileServerEndPointLocalStorage(projectList[0].zoneId); // setFileServerEndPointLocalStorage(projectList[0].zoneId);
getFiletokenAccordingToId(projectList[0].id).then((res) => { // getFiletokenAccordingToId(projectList[0].id).then((res) => {
projectList[0].filetoken = res; // projectList[0].filetoken = res;
currentProjectStore.changeProject(projectList[0]); // currentProjectStore.changeProject(projectList[0]);
}); // });
setProjectInfo(projectList[0]); // setProjectInfo(projectList[0]);
} // }
}, },
}); });
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
} }
.templateLi { .templateLi {
height: 146px; height: 170px;
box-sizing: border-box; box-sizing: border-box;
padding: 16px 20px; padding: 16px 20px;
cursor: pointer; /* cursor: pointer; */
border: 1px solid rgba(235, 237, 240, 1); border: 1px solid rgba(235, 237, 240, 1);
border-radius: 4px; border-radius: 4px;
min-width: 20%; min-width: 20%;
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
} }
.templateLiCustom { .templateLiCustom {
height: 194px; height: 170px;
} }
.templateLiHidden { .templateLiHidden {
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
} }
.addCustomTemplate { .addCustomTemplate {
height: 194px; height: 170px;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
justify-content: center; justify-content: center;
...@@ -112,5 +112,5 @@ ...@@ -112,5 +112,5 @@
.templateLiEditBox { .templateLiEditBox {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
margin-top: 16px; /* margin-top: 16px; */
} }
...@@ -6,6 +6,7 @@ import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfB ...@@ -6,6 +6,7 @@ import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfB
import SearchIcon from "@mui/icons-material/Search"; import SearchIcon from "@mui/icons-material/Search";
import MyButton from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
import OutlinedInput from "@mui/material/OutlinedInput"; import OutlinedInput from "@mui/material/OutlinedInput";
import MySwitch from "@/components/mui/MySwitch";
import FullScreenDrawer from "@/components/CommonComponents/FullScreenDrawer"; import FullScreenDrawer from "@/components/CommonComponents/FullScreenDrawer";
import Checkbox from "@mui/material/Checkbox"; import Checkbox from "@mui/material/Checkbox";
import useMyRequest from "@/hooks/useMyRequest"; import useMyRequest from "@/hooks/useMyRequest";
...@@ -17,6 +18,7 @@ import { useMessage } from "@/components/MySnackbar"; ...@@ -17,6 +18,7 @@ import { useMessage } from "@/components/MySnackbar";
import { import {
getAddWorkbenchTemplate, getAddWorkbenchTemplate,
addWorkbenchTemplate, addWorkbenchTemplate,
deleteWorkbenchTemplate,
} from "@/api/workbench_api"; } from "@/api/workbench_api";
type IAddTemplateProps = { type IAddTemplateProps = {
...@@ -50,9 +52,6 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -50,9 +52,6 @@ const AddTemplate = (props: IAddTemplateProps) => {
const [templateType, setTemplateType] = useState("public"); const [templateType, setTemplateType] = useState("public");
// 滚轮是否到顶,判断是否显示阴影
const [isTop, setIsTop] = useState(true)
const handleRadio = (value: string) => { const handleRadio = (value: string) => {
setTemplateType(value); setTemplateType(value);
}; };
...@@ -71,25 +70,36 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -71,25 +70,36 @@ const AddTemplate = (props: IAddTemplateProps) => {
// 项目管理员-添加工作流模板-提交 // 项目管理员-添加工作流模板-提交
const { run: addTemplate } = useMyRequest(addWorkbenchTemplate, { const { run: addTemplate } = useMyRequest(addWorkbenchTemplate, {
onSuccess: (result: any) => { onSuccess: (result: any) => {
Message.success("添加成功"); // Message.success("添加成功");
setSelectTemplateData([]); // setSelectTemplateData([]);
setShowAddTemplate(); // setShowAddTemplate();
getTemplateInfo({ // getTemplateInfo({
projectId: projectId as string, // projectId: projectId as string,
}); // });
}, },
}); });
const handleAddTemplate = () => { // 删除模板
if (selectTemplateData.length === 0) { const { run: delTemplate } = useMyRequest(deleteWorkbenchTemplate, {
Message.error("请选择要添加的模板"); onSuccess: (result: any) => {
} else { // setOpenDialog(false);
addTemplate({ // getTemplateInfo({
projectId: projectId as string, // projectId: currentProjectStore.currentProjectInfo.id as string,
workflowSpecIds: selectTemplateData, // title: templateName,
// });
},
}); });
}
}; // const handleAddTemplate = () => {
// if (selectTemplateData.length === 0) {
// Message.error("请选择要添加的模板");
// } else {
// addTemplate({
// projectId: projectId as string,
// workflowSpecIds: selectTemplateData,
// });
// }
// };
// 添加工作流模板-获取模板列表 // 添加工作流模板-获取模板列表
const { run: getAddTemplateList } = useMyRequest(getAddWorkbenchTemplate, { const { run: getAddTemplateList } = useMyRequest(getAddWorkbenchTemplate, {
...@@ -150,6 +160,23 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -150,6 +160,23 @@ const AddTemplate = (props: IAddTemplateProps) => {
title, title,
]); ]);
//模板启用切换
const templateSwitch = (e: any, id: string) => {
if (e.target.checked) {
let arr = []
arr.push(id)
addTemplate({
projectId: projectId as string,
workflowSpecIds: arr,
});
} else {
delTemplate({
projectId: projectId as string,
workflowSpecId: id,
});
}
}
useEffect(() => { useEffect(() => {
getAddTemplateListFun(); getAddTemplateListFun();
}, [getAddTemplateListFun]); }, [getAddTemplateListFun]);
...@@ -164,24 +191,9 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -164,24 +191,9 @@ const AddTemplate = (props: IAddTemplateProps) => {
return arr; return arr;
}, [addTemplateList, templateType]); }, [addTemplateList, templateType]);
// 滚动滚轮时监听是否到顶
const onscroll = (e: any) => {
if (e.target.scrollTop <= 0) {
setIsTop(true)
} else {
setIsTop(false)
}
}
return ( return (
<FullScreenDrawer handleClose={setShowAddTemplate}> <FullScreenDrawer handleClose={setShowAddTemplate}>
<div className={style.content}> <div className={style.content}>
<div
className={classNames({
[style.headerBox]: true,
[style.headerBoxShadow]: !isTop,
})}
>
<Typography <Typography
sx={{ fontSize: "18px", fontWeight: "600", color: "#1E2633" }} sx={{ fontSize: "18px", fontWeight: "600", color: "#1E2633" }}
> >
...@@ -192,8 +204,7 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -192,8 +204,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
display: "flex", display: "flex",
justifyContent: "space-between", justifyContent: "space-between",
alignItems: "center", alignItems: "center",
paddingBottom: "20px", marginBottom: "20px",
paddingTop: "20px",
}} }}
> >
<OutlinedInput <OutlinedInput
...@@ -203,7 +214,7 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -203,7 +214,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
}} }}
placeholder="输入关键词搜索" placeholder="输入关键词搜索"
size="small" size="small"
sx={{ width: 340, height: 32 }} sx={{ width: 340, height: 32, marginTop: "20px" }}
endAdornment={<SearchIcon style={{ color: "#8A9099" }} />} endAdornment={<SearchIcon style={{ color: "#8A9099" }} />}
/> />
<Box <Box
...@@ -218,7 +229,7 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -218,7 +229,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
radioOptions={radioOptions} radioOptions={radioOptions}
handleRadio={handleRadio} handleRadio={handleRadio}
></RadioGroupOfButtonStyle> ></RadioGroupOfButtonStyle>
<MyButton {/* <MyButton
onClick={handleAddTemplate} onClick={handleAddTemplate}
size={"small"} size={"small"}
style={{ style={{
...@@ -230,11 +241,9 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -230,11 +241,9 @@ const AddTemplate = (props: IAddTemplateProps) => {
? "" ? ""
: `(${selectTemplateData.length})`) : `(${selectTemplateData.length})`)
} }
/> /> */}
</Box> </Box>
</Box> </Box>
</div>
<div className={style.templateBox} onScroll={onscroll} >
{templateType === "public" && addTemplateList.length === 0 && ( {templateType === "public" && addTemplateList.length === 0 && (
<Box <Box
sx={{ sx={{
...@@ -282,11 +291,11 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -282,11 +291,11 @@ const AddTemplate = (props: IAddTemplateProps) => {
> >
<div className={style.templateLiTop}> <div className={style.templateLiTop}>
<span className={style.templateTitle}>{item.title}</span> <span className={style.templateTitle}>{item.title}</span>
<Checkbox {/* <Checkbox
size="small" size="small"
sx={{ padding: "0px" }} sx={{ padding: "0px" }}
checked={selectTemplateData.includes(item.id)} checked={selectTemplateData.includes(item.id)}
/> /> */}
</div> </div>
<div className={style.templateLiInfo}> <div className={style.templateLiInfo}>
<span <span
...@@ -300,8 +309,17 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -300,8 +309,17 @@ const AddTemplate = (props: IAddTemplateProps) => {
</span> </span>
</div> </div>
<div className={style.templateLiDesc}>{item.description}</div> <div className={style.templateLiDesc}>{item.description}</div>
{templateType !== "public" && (
<div className={style.templateLiEditBox}> <div className={style.templateLiEditBox}>
<MySwitch
defaultChecked={item.favorited}
onChange={(e: any) =>
templateSwitch(e, item.id)
}
></MySwitch>
</div>
{/* {templateType !== "public" && (
<MyButton <MyButton
onClick={() => handleEditTemplate(item)} onClick={() => handleEditTemplate(item)}
size={"small"} size={"small"}
...@@ -312,7 +330,7 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -312,7 +330,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
text="编辑模板" text="编辑模板"
/> />
</div> </div>
)} )} */}
</div> </div>
); );
})} })}
...@@ -331,7 +349,6 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -331,7 +349,6 @@ const AddTemplate = (props: IAddTemplateProps) => {
})} })}
</div> </div>
</div> </div>
</div>
{customTemplateInfo?.show ? ( {customTemplateInfo?.show ? (
<WorkFlowEdit <WorkFlowEdit
id={customTemplateInfo.id || ""} id={customTemplateInfo.id || ""}
......
...@@ -182,7 +182,15 @@ const ProjectMembers = observer(() => { ...@@ -182,7 +182,15 @@ const ProjectMembers = observer(() => {
{showAddTemplate && ( {showAddTemplate && (
<AddTemplate <AddTemplate
setShowAddTemplate={() => setShowAddTemplate(false)} setShowAddTemplate={
() => {
setShowAddTemplate(false)
getTemplateInfo({
projectId: projectIdData as string,
title: templateName,
});
}
}
getTemplateInfo={getTemplateInfo} getTemplateInfo={getTemplateInfo}
productId={productId as string} productId={productId as string}
projectId={projectIdData as string} projectId={projectIdData as string}
......
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