Commit c054d7f8 authored by rocosen's avatar rocosen

fix:bug

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