Commit f74a51ad authored by chenshouchao's avatar chenshouchao

UI: 样式优化 select组件替换

parent 5cf52638
...@@ -82,12 +82,12 @@ const theme = createTheme({ ...@@ -82,12 +82,12 @@ const theme = createTheme({
}, },
}, },
outlinedSecondary: { outlinedSecondary: {
border: "1px solid #FF4E4E", border: "1px solid rgba(221, 225, 230, 1)",
boxShadow: "none !important", boxShadow: "none !important",
color: "#FF4E4E", color: "rgba(30, 38, 51, 1)",
"&:hover": { "&:hover": {
backgroundColor: "#FFEDED ", // backgroundColor: "#FFEDED ",
border: "1px solid #FF4E4E", // border: "1px solid rgba(30, 38, 51, 1)",
}, },
}, },
textSecondary: { textSecondary: {
......
...@@ -89,6 +89,7 @@ const MyDialog: React.FunctionComponent<IDialogProps> = (props) => { ...@@ -89,6 +89,7 @@ const MyDialog: React.FunctionComponent<IDialogProps> = (props) => {
onClick={onClose} onClick={onClose}
variant="outlined" variant="outlined"
size="small" size="small"
color="secondary"
/> />
) : null} ) : null}
{showConfirm ? ( {showConfirm ? (
......
import React, { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { TextField } from "@mui/material";
import MyDialog from "@/components/mui/MyDialog"; import MyDialog from "@/components/mui/MyDialog";
import { checkIsNumberLetterChinese } from "@/utils/util"; import { checkIsNumberLetterChinese } from "@/utils/util";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
......
...@@ -310,7 +310,15 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -310,7 +310,15 @@ const ConfigForm = (props: ConfigFormProps) => {
onBlur={() => setSelectedBatchNodeId("")} onBlur={() => setSelectedBatchNodeId("")}
value={parameter.value} value={parameter.value}
onChange={(e: any) => onChange={(e: any) =>
handleParameterChange(e, taskId, parameter.name || "") handleParameterChange(
{
target: {
value: e,
},
},
taskId,
parameter.name || ""
)
} }
error={parameter.error || false} error={parameter.error || false}
helpertext={parameter.helperText} helpertext={parameter.helperText}
...@@ -324,7 +332,15 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -324,7 +332,15 @@ const ConfigForm = (props: ConfigFormProps) => {
onBlur={() => setSelectedBatchNodeId("")} onBlur={() => setSelectedBatchNodeId("")}
value={parameter.value} value={parameter.value}
onChange={(e: any) => onChange={(e: any) =>
handleParameterChange(e, taskId, parameter.name || "") handleParameterChange(
{
target: {
value: e,
},
},
taskId,
parameter.name || ""
)
} }
multiple={true} multiple={true}
error={parameter.error || false} error={parameter.error || false}
......
import * as React from "react";
import InputLabel from "@mui/material/InputLabel";
import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl";
import FormHelperText from "@mui/material/FormHelperText";
import Select, { SelectProps } from "@mui/material/Select";
export interface IOption {
label: string;
value: string;
disabled?: boolean;
}
export const optionsTransform = (
arr: Array<any>,
labelKey: string = "label",
valueKey: string = "value",
disabledKey: string = "disabled"
): Array<IOption> => {
return arr.map((item: any) => {
return {
label: item[labelKey],
value: item[valueKey],
disabled: item[disabledKey],
};
});
};
interface IProps
extends Omit<SelectProps, "value" | "options" | "onChange" | "title"> {
value?: any;
options: IOption[];
onChange?: any;
/** 类型变种 */
variant?: "standard" | "outlined" | "filled";
/** title */
title?: string;
/** 是否显示title */
isTitle?: boolean;
size?: "small" | "medium";
multiple?: boolean; // 多选
error?: boolean;
helpertext?: string;
fullWidth?: boolean;
}
export default function MySelect(props: IProps) {
const {
value,
options,
onChange,
title,
isTitle = false,
variant,
size = "small",
multiple = false,
error = false,
helpertext,
fullWidth = true,
} = props;
return (
<FormControl fullWidth={fullWidth} variant={variant} error={error}>
{isTitle ? (
<InputLabel id="demo-simple-select-label">
{title || "请选择"}
</InputLabel>
) : null}
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
label={title || ""}
size={size}
{...props}
value={value}
onChange={onChange}
multiple={multiple}
>
{options.length
? options?.map((item: IOption) => {
return (
<MenuItem
key={item.value}
value={item.value}
disabled={item?.disabled}
>
{item.label}
</MenuItem>
);
})
: null}
</Select>
{helpertext && error && <FormHelperText>{helpertext}</FormHelperText>}
</FormControl>
);
}
...@@ -41,12 +41,16 @@ ...@@ -41,12 +41,16 @@
.projectlist { .projectlist {
flex: 1; flex: 1;
overflow-y: scroll; overflow-y: scroll;
border-top: 1px solid #f0f2f5;
} }
.projectli { .projectli {
cursor: pointer; cursor: pointer;
} }
.projectli:hover { .projectli:hover {
background-color: #f2f7ff; background-color: rgba(240, 242, 245, 1);
}
.projectliActive {
background-color: rgba(237, 244, 255, 1);
} }
.projectliBorderBox { .projectliBorderBox {
box-sizing: border-box; box-sizing: border-box;
...@@ -57,7 +61,7 @@ ...@@ -57,7 +61,7 @@
flex-direction: row; flex-direction: row;
justify-content: flex-start; justify-content: flex-start;
align-items: flex-start; align-items: flex-start;
border-top: 1px solid #f0f2f5; border-bottom: 1px solid #f0f2f5;
} }
.projectliLogo { .projectliLogo {
width: 24px; width: 24px;
......
...@@ -3,6 +3,7 @@ import style from "./index.module.css"; ...@@ -3,6 +3,7 @@ import style from "./index.module.css";
import { InputBase, IconButton } from "@mui/material"; import { InputBase, IconButton } from "@mui/material";
import SearchIcon from "@mui/icons-material/Search"; import SearchIcon from "@mui/icons-material/Search";
import AddIcon from "@mui/icons-material/Add"; import AddIcon from "@mui/icons-material/Add";
import classNames from "classnames";
import { useStores } from "@/store/index"; import { useStores } from "@/store/index";
import moment from "moment"; import moment from "moment";
import React, { useMemo, useState } from "react"; import React, { useMemo, useState } from "react";
...@@ -12,16 +13,19 @@ import { observer } from "mobx-react-lite"; ...@@ -12,16 +13,19 @@ import { observer } from "mobx-react-lite";
const ProjectListPopper = observer((props: any) => { const ProjectListPopper = observer((props: any) => {
const { handleChangeCurrentProject, handleClickOpen } = props; const { handleChangeCurrentProject, handleClickOpen } = props;
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const projectList = toJS(currentProjectStore.projectList);
const currentProjectName = toJS(currentProjectStore.currentProjectInfo.name);
// 通过名称本地搜索
const [name, setName] = useState(""); const [name, setName] = useState("");
const nameChange = (e: any) => { const nameChange = (e: any) => {
setName(e.target.value); setName(e.target.value);
}; };
const list = useMemo(() => { const list = useMemo(() => {
return toJS(currentProjectStore.projectList).filter((item: any) => { return projectList.filter((item: any) => {
return item.name?.indexOf(name) !== -1; return item.name?.indexOf(name) !== -1;
}); });
}, [currentProjectStore.projectList, name]); }, [projectList, name]);
const handleProjectBox = (e: React.SyntheticEvent) => { const handleProjectBox = (e: React.SyntheticEvent) => {
e.nativeEvent.stopImmediatePropagation(); e.nativeEvent.stopImmediatePropagation();
...@@ -35,7 +39,10 @@ const ProjectListPopper = observer((props: any) => { ...@@ -35,7 +39,10 @@ const ProjectListPopper = observer((props: any) => {
className={style.searchButton} className={style.searchButton}
aria-label="search" aria-label="search"
> >
<SearchIcon className={style.searchIcon} /> <SearchIcon
className={style.searchIcon}
style={{ color: "rgba(153, 153, 153, 1)" }}
/>
</IconButton> </IconButton>
<InputBase <InputBase
className={style.searchInput} className={style.searchInput}
...@@ -57,7 +64,10 @@ const ProjectListPopper = observer((props: any) => { ...@@ -57,7 +64,10 @@ const ProjectListPopper = observer((props: any) => {
{list.map((item: any) => { {list.map((item: any) => {
return ( return (
<div <div
className={style.projectli} className={classNames({
[style.projectli]: true,
[style.projectliActive]: item.name === currentProjectName,
})}
key={item.id} key={item.id}
onClick={() => handleChangeCurrentProject(item)} onClick={() => handleChangeCurrentProject(item)}
> >
......
...@@ -9,9 +9,6 @@ import { ...@@ -9,9 +9,6 @@ import {
import noTemplate from "@/assets/project/noTemplate.svg"; import noTemplate from "@/assets/project/noTemplate.svg";
import MyInput from "@/components/mui/MyInput"; import MyInput from "@/components/mui/MyInput";
import MyCheckBox from "@/components/mui/MyCheckBox"; import MyCheckBox from "@/components/mui/MyCheckBox";
// import MySelect, {
// optionsTransform,
// } from "../../../Project/ProjectSubmitWork/components/MySelect";
import MySelect from "@/components/mui/MySelect"; import MySelect from "@/components/mui/MySelect";
import FileSelect, { import FileSelect, {
FileSelectType, FileSelectType,
...@@ -491,7 +488,14 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -491,7 +488,14 @@ const ParameterSetting = (props: IParameterSettingProps) => {
<MySelect <MySelect
value={parameter.defaultValue} value={parameter.defaultValue}
onChange={(e: any) => onChange={(e: any) =>
handleParameterChange(e, parameter.name || "") handleParameterChange(
{
target: {
value: e,
},
},
parameter.name || ""
)
} }
error={parameter.error || false} error={parameter.error || false}
helpertext={parameter.helperText} helpertext={parameter.helperText}
...@@ -503,7 +507,14 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -503,7 +507,14 @@ const ParameterSetting = (props: IParameterSettingProps) => {
<MySelect <MySelect
value={parameter.defaultValue} value={parameter.defaultValue}
onChange={(e: any) => onChange={(e: any) =>
handleParameterChange(e, parameter.name || "") handleParameterChange(
{
target: {
value: e,
},
},
parameter.name || ""
)
} }
multiple={true} multiple={true}
error={parameter.error || false} error={parameter.error || false}
......
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