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"
...@@ -30,11 +34,11 @@ const NoProject = () => { ...@@ -30,11 +34,11 @@ const NoProject = () => {
onClick={() => setAddOpen(true)} onClick={() => setAddOpen(true)}
style={{ backgroundColor: "#1370ff", color: "#fff" }} style={{ backgroundColor: "#1370ff", color: "#fff" }}
/> />
<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,23 +53,24 @@ const theme = createTheme({ ...@@ -52,23 +53,24 @@ 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"
? { ? {
width: 44, width: 44,
height: 24, height: 24,
} }
: { : {
width: 40, width: 40,
height: 22, height: 22,
} }
} }
{...other} {...other}
/> />
......
...@@ -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; */
} }
\ No newline at end of file
...@@ -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,172 +191,162 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -164,172 +191,162 @@ 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 <Typography
className={classNames({ sx={{ fontSize: "18px", fontWeight: "600", color: "#1E2633" }}
[style.headerBox]: true,
[style.headerBoxShadow]: !isTop,
})}
> >
<Typography 添加工作流模版
sx={{ fontSize: "18px", fontWeight: "600", color: "#1E2633" }} </Typography>
> <Box
添加工作流模版 sx={{
</Typography> display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginBottom: "20px",
}}
>
<OutlinedInput
value={title}
onChange={(e: any) => {
setTitle(e.target.value);
}}
placeholder="输入关键词搜索"
size="small"
sx={{ width: 340, height: 32, marginTop: "20px" }}
endAdornment={<SearchIcon style={{ color: "#8A9099" }} />}
/>
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",
justifyContent: "space-between", justifyContent: "flex-end",
alignItems: "center", alignItems: "center",
paddingBottom: "20px",
paddingTop: "20px",
}} }}
> >
<OutlinedInput <RadioGroupOfButtonStyle
value={title} value={templateType}
onChange={(e: any) => { radioOptions={radioOptions}
setTitle(e.target.value); handleRadio={handleRadio}
}} ></RadioGroupOfButtonStyle>
placeholder="输入关键词搜索" {/* <MyButton
size="small" onClick={handleAddTemplate}
sx={{ width: 340, height: 32 }} size={"small"}
endAdornment={<SearchIcon style={{ color: "#8A9099" }} />} style={{
/> marginLeft: "12px",
<Box
sx={{
display: "flex",
justifyContent: "flex-end",
alignItems: "center",
}} }}
text={
"添加模版" +
(selectTemplateData.length === 0
? ""
: `(${selectTemplateData.length})`)
}
/> */}
</Box>
</Box>
{templateType === "public" && addTemplateList.length === 0 && (
<Box
sx={{
display: "flex",
alignItems: "center",
flexDirection: "column",
minHeight: "calc(100vh - 376px)",
justifyContent: "center",
}}
>
<img alt="" src={noData} />
<Typography
sx={{ fontSize: "12px", fontWeight: "400", color: "#8A9099" }}
> >
<RadioGroupOfButtonStyle 暂无相关模版
value={templateType} </Typography>
radioOptions={radioOptions}
handleRadio={handleRadio}
></RadioGroupOfButtonStyle>
<MyButton
onClick={handleAddTemplate}
size={"small"}
style={{
marginLeft: "12px",
}}
text={
"添加模版" +
(selectTemplateData.length === 0
? ""
: `(${selectTemplateData.length})`)
}
/>
</Box>
</Box> </Box>
</div> )}
<div className={style.templateBox} onScroll={onscroll} > <div className={style.templateList}>
{templateType === "public" && addTemplateList.length === 0 && ( {templateType !== "public" && (
<Box <div
sx={{ className={classNames({
display: "flex", [style.templateLi]: true,
alignItems: "center", [style.addCustomTemplate]: true,
flexDirection: "column", })}
minHeight: "calc(100vh - 376px)", onClick={handleAddCustomTemplate}
justifyContent: "center",
}}
> >
<img alt="" src={noData} /> <AddIcon />
<Typography <span className={style.addCustomTemplateText}>
sx={{ fontSize: "12px", fontWeight: "400", color: "#8A9099" }} 创建自定义模板
> </span>
暂无相关模版 </div>
</Typography>
</Box>
)} )}
<div className={style.templateList}> {addTemplateList.map((item: any, index) => {
{templateType !== "public" && ( return (
<div <div
className={classNames({ className={classNames({
[style.templateLi]: true, [style.templateLi]: true,
[style.addCustomTemplate]: true, [style.templateLiCustom]: templateType !== "public",
})} })}
onClick={handleAddCustomTemplate} key={index}
onClick={() => {
handleSelectTemplate(item.id);
}}
> >
<AddIcon /> <div className={style.templateLiTop}>
<span className={style.addCustomTemplateText}> <span className={style.templateTitle}>{item.title}</span>
创建自定义模板 {/* <Checkbox
</span> size="small"
sx={{ padding: "0px" }}
checked={selectTemplateData.includes(item.id)}
/> */}
</div>
<div className={style.templateLiInfo}>
<span
className={style.templateLiInfoText}
style={{ marginRight: "24px" }}
>
版本:{item.version}
</span>
<span className={style.templateLiInfoText}>
更新时间:{item.updatedTime}
</span>
</div>
<div className={style.templateLiDesc}>{item.description}</div>
<div className={style.templateLiEditBox}>
<MySwitch
defaultChecked={item.favorited}
onChange={(e: any) =>
templateSwitch(e, item.id)
}
></MySwitch>
</div>
{/* {templateType !== "public" && (
<MyButton
onClick={() => handleEditTemplate(item)}
size={"small"}
style={{
height: "32px",
}}
color="inherit"
text="编辑模板"
/>
</div>
)} */}
</div> </div>
)} );
{addTemplateList.map((item: any, index) => { })}
{hiddenBoxArr.length !== 4 &&
hiddenBoxArr.map((item, index) => {
return ( return (
<div <div
key={`-${index}`}
className={classNames({ className={classNames({
[style.templateLi]: true, [style.templateLi]: true,
[style.templateLiCustom]: templateType !== "public", [style.templateLiHidden]: true,
})} })}
key={index} />
onClick={() => {
handleSelectTemplate(item.id);
}}
>
<div className={style.templateLiTop}>
<span className={style.templateTitle}>{item.title}</span>
<Checkbox
size="small"
sx={{ padding: "0px" }}
checked={selectTemplateData.includes(item.id)}
/>
</div>
<div className={style.templateLiInfo}>
<span
className={style.templateLiInfoText}
style={{ marginRight: "24px" }}
>
版本:{item.version}
</span>
<span className={style.templateLiInfoText}>
更新时间:{item.updatedTime}
</span>
</div>
<div className={style.templateLiDesc}>{item.description}</div>
{templateType !== "public" && (
<div className={style.templateLiEditBox}>
<MyButton
onClick={() => handleEditTemplate(item)}
size={"small"}
style={{
height: "32px",
}}
color="inherit"
text="编辑模板"
/>
</div>
)}
</div>
); );
})} })}
{hiddenBoxArr.length !== 4 &&
hiddenBoxArr.map((item, index) => {
return (
<div
key={`-${index}`}
className={classNames({
[style.templateLi]: true,
[style.templateLiHidden]: true,
})}
/>
);
})}
</div>
</div> </div>
</div> </div>
{customTemplateInfo?.show ? ( {customTemplateInfo?.show ? (
......
...@@ -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