Commit 9e0409f7 authored by chenshouchao's avatar chenshouchao

feat: myButton集成loadingbutton功能, mydialog组件增加loading功能

parent 54e669a0
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
ExtendButtonBase, ExtendButtonBase,
ButtonTypeMap, ButtonTypeMap,
} from "@mui/material"; } from "@mui/material";
import LoadingButton from "@mui/lab/LoadingButton";
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown"; import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
interface ButtonTagProps interface ButtonTagProps
...@@ -35,6 +36,8 @@ interface ButtonTagProps ...@@ -35,6 +36,8 @@ interface ButtonTagProps
disabled?: boolean; //是否禁用 disabled?: boolean; //是否禁用
style?: any; //按钮自定义样式 style?: any; //按钮自定义样式
img?: JSX.Element; //图标按钮中的图标 img?: JSX.Element; //图标按钮中的图标
isLoadingButton?: boolean; // 是否是loadingbutton
loading?: boolean; // 是否处于loading状态
selectCallBack?: (item: any, key: number) => void; //选择按钮的回调 selectCallBack?: (item: any, key: number) => void; //选择按钮的回调
} }
...@@ -51,6 +54,9 @@ const theme = createTheme({ ...@@ -51,6 +54,9 @@ const theme = createTheme({
color: "rgba(255, 78, 78, 1)", color: "rgba(255, 78, 78, 1)",
border: "1px solid rgba(255, 78, 78, 1)", border: "1px solid rgba(255, 78, 78, 1)",
}, },
"& .MuiLoadingButton-loadingIndicator": {
color: "#fff",
},
}, },
contained: { contained: {
backgroundColor: "#1370FF", backgroundColor: "#1370FF",
...@@ -75,6 +81,12 @@ const theme = createTheme({ ...@@ -75,6 +81,12 @@ const theme = createTheme({
"&:hover": { backgroundColor: "#ECF4FF " }, "&:hover": { backgroundColor: "#ECF4FF " },
}, },
containedPrimary: {
"&.Mui-disabled": {
backgroundColor: "#A6D3FF",
},
},
containedSecondary: { containedSecondary: {
backgroundColor: "#FF4E4E", backgroundColor: "#FF4E4E",
"&:hover": { "&:hover": {
...@@ -136,7 +148,7 @@ const theme = createTheme({ ...@@ -136,7 +148,7 @@ const theme = createTheme({
}, },
}); });
const ButtonComponent = (props: ButtonTagProps) => { const MyButton = (props: ButtonTagProps) => {
const { const {
size, size,
disabled, disabled,
...@@ -145,6 +157,8 @@ const ButtonComponent = (props: ButtonTagProps) => { ...@@ -145,6 +157,8 @@ const ButtonComponent = (props: ButtonTagProps) => {
img, img,
select, select,
selectCallBack, selectCallBack,
isLoadingButton,
loading,
...other ...other
} = props; } = props;
const { classes, cx } = useStyles({}); const { classes, cx } = useStyles({});
...@@ -173,6 +187,38 @@ const ButtonComponent = (props: ButtonTagProps) => { ...@@ -173,6 +187,38 @@ const ButtonComponent = (props: ButtonTagProps) => {
return ( return (
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
{isLoadingButton && (
<LoadingButton
size={size || "medium"}
variant={variant || "contained"}
color={color || "primary"}
disableRipple={true}
disableFocusRipple={true}
disabled={disabled || false}
style={{ ...props.style }}
onClick={props.select ? handleClick : props.onClick || defaultClick}
loading={loading}
{...other}
>
{img || ""}
<Typography style={{ fontSize: props.fontSize }}>
{props.text}
</Typography>
{((props.select && props.select.length > 0) || props.drop) && (
<ArrowDropDownIcon
classes={{
root: cx({
[classes.ArrowDropDownIconRoot]: true,
[classes.ArrowDropDownIconRootOpen]: Boolean(
props.dropValue || anchorEl
),
}),
}}
/>
)}
</LoadingButton>
)}
{!isLoadingButton && (
<Button <Button
size={size || "medium"} size={size || "medium"}
variant={variant || "contained"} variant={variant || "contained"}
...@@ -201,6 +247,8 @@ const ButtonComponent = (props: ButtonTagProps) => { ...@@ -201,6 +247,8 @@ const ButtonComponent = (props: ButtonTagProps) => {
/> />
)} )}
</Button> </Button>
)}
<Menu <Menu
id="simple-menu" id="simple-menu"
anchorEl={anchorEl} anchorEl={anchorEl}
...@@ -235,4 +283,4 @@ const useStyles = makeStyles<{}>()((theme) => ({ ...@@ -235,4 +283,4 @@ const useStyles = makeStyles<{}>()((theme) => ({
ArrowDropDownIconRootOpen: { color: "#8A9099", transform: "rotate(180deg)" }, ArrowDropDownIconRootOpen: { color: "#8A9099", transform: "rotate(180deg)" },
})); }));
export default ButtonComponent; export default MyButton;
...@@ -43,6 +43,7 @@ export interface IDialogProps { ...@@ -43,6 +43,7 @@ export interface IDialogProps {
clickMaskClose?: boolean; clickMaskClose?: boolean;
/** 确认按钮样式*/ /** 确认按钮样式*/
okSx?: any; okSx?: any;
loading?: boolean; // 确认按钮是否处于loading状态
} }
const MyDialog: React.FunctionComponent<IDialogProps> = (props) => { const MyDialog: React.FunctionComponent<IDialogProps> = (props) => {
...@@ -64,6 +65,7 @@ const MyDialog: React.FunctionComponent<IDialogProps> = (props) => { ...@@ -64,6 +65,7 @@ const MyDialog: React.FunctionComponent<IDialogProps> = (props) => {
okText, okText,
disabledConfirm, disabledConfirm,
clickMaskClose = false, clickMaskClose = false,
loading = false,
okSx = {}, okSx = {},
} = props; } = props;
...@@ -99,6 +101,8 @@ const MyDialog: React.FunctionComponent<IDialogProps> = (props) => { ...@@ -99,6 +101,8 @@ const MyDialog: React.FunctionComponent<IDialogProps> = (props) => {
variant="contained" variant="contained"
size="small" size="small"
disabled={disabledConfirm} disabled={disabledConfirm}
isLoadingButton={true}
loading={loading}
style={{ ...okSx }} style={{ ...okSx }}
/> />
) : null} ) : null}
...@@ -140,7 +144,7 @@ const MyDialog: React.FunctionComponent<IDialogProps> = (props) => { ...@@ -140,7 +144,7 @@ const MyDialog: React.FunctionComponent<IDialogProps> = (props) => {
</div> </div>
</DialogTitle> </DialogTitle>
)} )}
<DialogContent style={{ minWidth: 400 }}>{children}</DialogContent> <DialogContent style={{ minWidth: 388 }}>{children}</DialogContent>
{Footer()} {Footer()}
</Dialog> </Dialog>
); );
......
...@@ -4,7 +4,7 @@ import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfB ...@@ -4,7 +4,7 @@ import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfB
import MyMultipleMenu, { IOption } from "@/components/mui/MyMultipleMenu"; import MyMultipleMenu, { IOption } from "@/components/mui/MyMultipleMenu";
import MySelect from "@/components/mui/MySelect"; import MySelect from "@/components/mui/MySelect";
import MyInput from "@/components/mui/MyInput"; import MyInput from "@/components/mui/MyInput";
import ButtonComponent from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
import SearchIcon from "@mui/icons-material/Search"; import SearchIcon from "@mui/icons-material/Search";
import MyPagination from "@/components/mui/MyPagination"; import MyPagination from "@/components/mui/MyPagination";
import NglView from "@/components/BusinessComponents/NglView"; import NglView from "@/components/BusinessComponents/NglView";
...@@ -240,13 +240,13 @@ const SeeDataset = observer((props: ISeeDatasetProps) => { ...@@ -240,13 +240,13 @@ const SeeDataset = observer((props: ISeeDatasetProps) => {
height: "32px", height: "32px",
}} }}
></MyInput> ></MyInput>
<ButtonComponent <MyButton
text="确认" text="确认"
style={{ width: "68px" }} style={{ width: "68px" }}
onClick={() => { onClick={() => {
getList(); getList();
}} }}
></ButtonComponent> ></MyButton>
</div> </div>
</div> </div>
</div> </div>
...@@ -366,19 +366,19 @@ const SeeDataset = observer((props: ISeeDatasetProps) => { ...@@ -366,19 +366,19 @@ const SeeDataset = observer((props: ISeeDatasetProps) => {
</div> </div>
<div className={style.foot}> <div className={style.foot}>
{isCadd && ( {isCadd && (
<ButtonComponent <MyButton
variant="outlined" variant="outlined"
text={`下载(${selectItems.length})`} text={`下载(${selectItems.length})`}
style={{ marginRight: "12px" }} style={{ marginRight: "12px" }}
disabled={selectItems.length === 0} disabled={selectItems.length === 0}
onClick={() => setDownloadOpen(true)} onClick={() => setDownloadOpen(true)}
></ButtonComponent> ></MyButton>
)} )}
<ButtonComponent <MyButton
disabled={selectItems.length === 0} disabled={selectItems.length === 0}
text={`另存为(${selectItems.length})`} text={`另存为(${selectItems.length})`}
onClick={() => setSaveOpen(true)} onClick={() => setSaveOpen(true)}
></ButtonComponent> ></MyButton>
</div> </div>
{saveOpen && ( {saveOpen && (
<Save <Save
......
...@@ -14,7 +14,7 @@ import { useLocation, useNavigate } from "react-router-dom"; ...@@ -14,7 +14,7 @@ import { useLocation, useNavigate } from "react-router-dom";
import ArrowBackIosNewIcon from "@mui/icons-material/ArrowBackIosNew"; import ArrowBackIosNewIcon from "@mui/icons-material/ArrowBackIosNew";
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
import ButtonComponent from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
import useMyRequest from "@/hooks/useMyRequest"; import useMyRequest from "@/hooks/useMyRequest";
import { fetchWorkFlowJob, getworkFlowTaskInfo } from "@/api/project_api"; import { fetchWorkFlowJob, getworkFlowTaskInfo } from "@/api/project_api";
import { IResponse } from "@/api/http"; import { IResponse } from "@/api/http";
...@@ -352,7 +352,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -352,7 +352,7 @@ const ProjectSubmitWork = observer(() => {
state === "RUNNING" ? onStopJob() : onDeleteJob(); state === "RUNNING" ? onStopJob() : onDeleteJob();
}} }}
> */} > */}
<ButtonComponent <MyButton
text={state === "RUNNING" ? "终止" : "删除"} text={state === "RUNNING" ? "终止" : "删除"}
variant="outlined" variant="outlined"
color="secondary" color="secondary"
...@@ -365,7 +365,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -365,7 +365,7 @@ const ProjectSubmitWork = observer(() => {
) )
} }
// click={onStopJob} // click={onStopJob}
></ButtonComponent> ></MyButton>
{/* </MyPopconfirm> */} {/* </MyPopconfirm> */}
</div> </div>
)} )}
......
...@@ -16,7 +16,7 @@ import moment from "moment"; ...@@ -16,7 +16,7 @@ import moment from "moment";
import ConfigForm from "./ConfigForm"; import ConfigForm from "./ConfigForm";
import WorkFlow from "./WorkFlow"; import WorkFlow from "./WorkFlow";
import ButtonComponent from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
import { ITemplateConfig } from "./interface"; import { ITemplateConfig } from "./interface";
import useMyRequest from "@/hooks/useMyRequest"; import useMyRequest from "@/hooks/useMyRequest";
import { fetchTemplateConfigInfo, submitWorkFlow } from "@/api/project_api"; import { fetchTemplateConfigInfo, submitWorkFlow } from "@/api/project_api";
...@@ -272,12 +272,12 @@ const ProjectSubmitWork = observer(() => { ...@@ -272,12 +272,12 @@ const ProjectSubmitWork = observer(() => {
title="提交前请先确认参数填写无误,确认提交吗?" title="提交前请先确认参数填写无误,确认提交吗?"
onConfirm={handleSubmitForm} onConfirm={handleSubmitForm}
> */} > */}
<ButtonComponent <MyButton
text="提交任务" text="提交任务"
onClick={(e: any) => onClick={(e: any) =>
handleShowPopper(e, "提交前请先确认参数填写无误,确认提交吗?") handleShowPopper(e, "提交前请先确认参数填写无误,确认提交吗?")
} }
></ButtonComponent> ></MyButton>
{/* </MyPopconfirm> */} {/* </MyPopconfirm> */}
</div> </div>
</div> </div>
......
...@@ -14,7 +14,7 @@ import { observer } from "mobx-react-lite"; ...@@ -14,7 +14,7 @@ import { observer } from "mobx-react-lite";
import MyPopconfirm from "@/components/mui/MyPopconfirm"; import MyPopconfirm from "@/components/mui/MyPopconfirm";
import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfButtonStyle"; import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfButtonStyle";
import ButtonComponent from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
import OperatorList from "./components/OperatorList"; import OperatorList from "./components/OperatorList";
import Flow from "../Project/components/Flow"; import Flow from "../Project/components/Flow";
import ParameterSetting from "./components/ParameterSetting"; import ParameterSetting from "./components/ParameterSetting";
...@@ -181,10 +181,7 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -181,10 +181,7 @@ const WorkFlowEdit = observer((props: IProps) => {
</IconButton> </IconButton>
</div> </div>
<div className={styles.swHeaderRight}> <div className={styles.swHeaderRight}>
<ButtonComponent <MyButton text="保存" onClick={() => handlePreserve()}></MyButton>
text="保存"
onClick={() => handlePreserve()}
></ButtonComponent>
</div> </div>
</div> </div>
<div className={styles.swContent}> <div className={styles.swContent}>
......
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