Commit d0c51ac4 authored by 吴永生#A02208's avatar 吴永生#A02208

fix: Myselect组件样式修改

parent a04fa626
...@@ -97,6 +97,14 @@ const theme = createTheme({ ...@@ -97,6 +97,14 @@ const theme = createTheme({
elevation: {}, elevation: {},
}, },
}, },
MuiMenuItem: {
styleOverrides: {
root: {
"&:hover": { backgroundColor: "#ECF4FF " },
},
},
},
}, },
}); });
......
...@@ -2,66 +2,73 @@ ...@@ -2,66 +2,73 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-07-05 14:00:37 * @Date: 2022-07-05 14:00:37
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-07-06 11:45:10 * @LastEditTime: 2022-07-20 20:33:09
* @FilePath: /bkunyun/src/components/mui/MyInput.tsx * @FilePath: /bkunyun/src/components/mui/MyInput.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
import TextField, { TextFieldProps } from "@mui/material/TextField"; import TextField, { TextFieldProps } from "@mui/material/TextField";
import { ThemeProvider, createTheme } from "@mui/material/styles";
interface MyInputProps extends Omit<TextFieldProps, "value"> { interface MyInputProps extends Omit<TextFieldProps, "value"> {
value?: any; value?: string;
inputSx?: any;
onChange?: any;
onFocus?: any;
label?: string;
variant?: "standard" | "filled" | "outlined"; variant?: "standard" | "filled" | "outlined";
id?: string;
size?: "small" | "medium"; size?: "small" | "medium";
placeholder?: string; placeholder?: string;
fullWidth?: boolean; // 宽度是否和容器一致 fullWidth?: boolean; // 宽度是否和容器一致
InputProps?: any; // input加前后icon可以用这个
error?: boolean; error?: boolean;
helperText?: string;
} }
const MyInput = (props: MyInputProps) => { const MyInput = (props: MyInputProps) => {
const { const {
inputSx = {},
value,
onChange,
onFocus,
label,
id,
variant,
size = "small", size = "small",
placeholder = "请输入", placeholder = "请输入",
fullWidth = true, fullWidth = true,
InputProps,
error = false, error = false,
helperText, label,
disabled, ...other
} = props; } = props;
const theme = createTheme({
components: {
MuiInputBase: {
styleOverrides: {
root: {
height: "36px",
// width: "40px",
// boxSizing: "border-box",
// padding: "0",
},
},
},
MuiOutlinedInput: {
styleOverrides: {
root: {
height: "36px",
lineHeight: "36px",
},
input: {
padding: "6.5px 14px",
verticalAlign: "middle",
},
notchedOutline: {
height: "36px",
},
},
},
},
});
return ( return (
<ThemeProvider theme={theme}>
<TextField <TextField
{...props}
error={error} error={error}
helperText={helperText}
sx={{ ...inputSx }}
id={id}
label={label}
variant={variant}
onChange={onChange}
onFocus={onFocus}
size={size} size={size}
placeholder={placeholder} placeholder={placeholder}
fullWidth={fullWidth} fullWidth={fullWidth}
InputProps={{ label={label}
...InputProps, {...other}
}}
disabled={disabled}
value={value}
/> />
</ThemeProvider>
); );
}; };
......
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2021-12-04 15:46:25 * @Date: 2021-12-04 15:46:25
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-11 18:22:50 * @LastEditTime: 2022-07-21 15:54:59
* @FilePath: /lionet-slb-pc/src/components/SearchView/components/Collapse.tsx * @FilePath: /lionet-slb-pc/src/components/SearchView/components/Collapse.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
import * as React from "react";
import Box from "@mui/material/Box";
import InputLabel from "@mui/material/InputLabel"; import InputLabel from "@mui/material/InputLabel";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl"; import FormControl from "@mui/material/FormControl";
import Select, { SelectProps } from "@mui/material/Select"; import Select, { SelectChangeEvent, SelectProps } from "@mui/material/Select";
import { createTheme, ThemeProvider } from "@mui/material";
export interface IOption { export interface IOption {
label: string; label: string;
...@@ -36,9 +35,9 @@ export const optionsTransform = ( ...@@ -36,9 +35,9 @@ export const optionsTransform = (
interface IProps interface IProps
extends Omit<SelectProps, "value" | "options" | "onChange" | "title"> { extends Omit<SelectProps, "value" | "options" | "onChange" | "title"> {
value?: IOption; value?: string;
options: IOption[]; options: IOption[];
onChange?: (val: IOption) => void; onChange?: (val: string) => void;
/** 类型变种 */ /** 类型变种 */
variant?: "standard" | "outlined" | "filled"; variant?: "standard" | "outlined" | "filled";
/** title */ /** title */
...@@ -47,19 +46,64 @@ interface IProps ...@@ -47,19 +46,64 @@ interface IProps
isTitle?: boolean; isTitle?: boolean;
} }
export default function MySelect(props: IProps) { export default function MySelect(props: IProps) {
const { value, options, onChange, title, isTitle = false, variant } = props; const {
value,
options,
title,
isTitle = false,
variant = "outlined",
multiple = false,
onChange,
...other
} = props;
const handleChange = (event: any) => { const theme = createTheme({
const newValue = options?.filter((item) => { components: {
return item.value === event.target.value; MuiInputBase: {
styleOverrides: {
root: {
height: "36px",
},
},
},
MuiOutlinedInput: {
styleOverrides: {
root: {
":hover": {
"& .MuiOutlinedInput-notchedOutline": {
borderColor: "#1370ff",
},
},
},
},
},
MuiInputLabel: {
styleOverrides: {
root: {
top: "-9px",
},
},
},
MuiSelect: {
styleOverrides: {
select: {
padding: "6.5px 14px",
fontSize: "14px",
},
},
},
},
}); });
if (onChange) {
onChange(newValue[0] || { label: "", value: "" }); const handleChange = (e: SelectChangeEvent<unknown>) => {
} onChange && onChange(e.target.value as string);
}; };
return ( return (
<Box sx={{ minWidth: 120 }}> <ThemeProvider theme={theme}>
<FormControl fullWidth variant={variant}> <FormControl fullWidth variant={variant}>
{isTitle ? ( {isTitle ? (
<InputLabel id="demo-simple-select-label"> <InputLabel id="demo-simple-select-label">
...@@ -69,10 +113,11 @@ export default function MySelect(props: IProps) { ...@@ -69,10 +113,11 @@ export default function MySelect(props: IProps) {
<Select <Select
labelId="demo-simple-select-label" labelId="demo-simple-select-label"
id="demo-simple-select" id="demo-simple-select"
label={title || "请选择"} label={title || ""}
size="small" size="small"
{...props} multiple={multiple}
value={value?.value} {...other}
value={value || ""}
onChange={handleChange} onChange={handleChange}
> >
{options.length {options.length
...@@ -86,6 +131,6 @@ export default function MySelect(props: IProps) { ...@@ -86,6 +131,6 @@ export default function MySelect(props: IProps) {
: null} : null}
</Select> </Select>
</FormControl> </FormControl>
</Box> </ThemeProvider>
); );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-10 18:05:21 * @Date: 2022-06-10 18:05:21
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-16 21:15:59 * @LastEditTime: 2022-07-21 11:28:21
* @FilePath: /bkunyun/src/views/ConsoleLayout/components/TransferList/index.tsx * @FilePath: /bkunyun/src/views/ConsoleLayout/components/TransferList/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -32,10 +32,7 @@ const TranSferList = observer(() => { ...@@ -32,10 +32,7 @@ const TranSferList = observer(() => {
<Box style={{ color: "#8A9099" }}>请勿在上传过程中刷新页面!</Box> <Box style={{ color: "#8A9099" }}>请勿在上传过程中刷新页面!</Box>
<MySelect <MySelect
variant="standard" variant="standard"
value={{ value={"default"}
label: "默认线路",
value: "default",
}}
onChange={() => console.log(11)} onChange={() => console.log(11)}
options={[ options={[
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-05-31 10:18:13 * @Date: 2022-05-31 10:18:13
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-15 19:04:11 * @LastEditTime: 2022-07-21 11:25:07
* @FilePath: /bkunyun/src/views/Project/ProjectSetting/index.tsx * @FilePath: /bkunyun/src/views/Project/ProjectSetting/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -39,9 +39,9 @@ const AddMember = observer((props: IProps) => { ...@@ -39,9 +39,9 @@ const AddMember = observer((props: IProps) => {
const Message = useMessage(); const Message = useMessage();
const changePermission = useCallback( const changePermission = useCallback(
(val: IOption, index: number) => { (val: string, index: number) => {
const tableDataIndex = tableData[index] as any; const tableDataIndex = tableData[index] as any;
const newVal = { ...tableDataIndex, projectRole: val.value }; const newVal = { ...tableDataIndex, projectRole: val };
const newTableData = _.cloneDeep(tableData); const newTableData = _.cloneDeep(tableData);
newTableData.splice(index, 1, newVal); newTableData.splice(index, 1, newVal);
setTableData(newTableData); setTableData(newTableData);
...@@ -64,11 +64,7 @@ const AddMember = observer((props: IProps) => { ...@@ -64,11 +64,7 @@ const AddMember = observer((props: IProps) => {
return ( return (
<MySelect <MySelect
input={<OutlinedInput />} input={<OutlinedInput />}
value={ value={defaultValue?.length ? defaultValue[0]?.value : "VIEWER"}
defaultValue?.length
? defaultValue[0]
: { value: "VIEWER", label: "查看者" }
}
onChange={(val) => changePermission(val, index)} onChange={(val) => changePermission(val, index)}
options={selectOptions} options={selectOptions}
size="small" size="small"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-05-31 10:18:13 * @Date: 2022-05-31 10:18:13
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-11 15:25:23 * @LastEditTime: 2022-07-21 11:34:55
* @FilePath: /bkunyun/src/views/Project/ProjectSetting/index.tsx * @FilePath: /bkunyun/src/views/Project/ProjectSetting/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -32,7 +32,7 @@ const ChangePermission = observer((props: IProps) => { ...@@ -32,7 +32,7 @@ const ChangePermission = observer((props: IProps) => {
const http = useHttp(); const http = useHttp();
const [selectOptions, setSelectOptions] = useState<IOption[]>([]); const [selectOptions, setSelectOptions] = useState<IOption[]>([]);
const [selectValue, setSelectValue] = useState<IOption | undefined>(); const [selectValue, setSelectValue] = useState<string | undefined>();
useEffect(() => { useEffect(() => {
if (permissionDialog?.isShow) { if (permissionDialog?.isShow) {
...@@ -62,7 +62,7 @@ const ChangePermission = observer((props: IProps) => { ...@@ -62,7 +62,7 @@ const ChangePermission = observer((props: IProps) => {
.put<IResponse<any>>( .put<IResponse<any>>(
`/cpp/project/updateuserrole?id=${projectInfo?.id || ""}&username=${ `/cpp/project/updateuserrole?id=${projectInfo?.id || ""}&username=${
permissionDialog.username permissionDialog.username
}&role=${selectValue?.value}` }&role=${selectValue}`
) )
.then((res) => { .then((res) => {
const { errorCode } = res; const { errorCode } = res;
...@@ -79,9 +79,9 @@ const ChangePermission = observer((props: IProps) => { ...@@ -79,9 +79,9 @@ const ChangePermission = observer((props: IProps) => {
(every) => every.value === permissionDialog?.projectRole (every) => every.value === permissionDialog?.projectRole
); );
if (defaultValue?.length) { if (defaultValue?.length) {
setSelectValue(defaultValue[0]); setSelectValue(defaultValue[0]?.value);
} else { } else {
setSelectValue({ value: "VIEWER", label: "查看者" }); setSelectValue("VIEWER");
} }
}, [permissionDialog, selectOptions]); }, [permissionDialog, selectOptions]);
return ( return (
...@@ -95,6 +95,7 @@ const ChangePermission = observer((props: IProps) => { ...@@ -95,6 +95,7 @@ const ChangePermission = observer((props: IProps) => {
<div style={{ marginTop: 12 }}> <div style={{ marginTop: 12 }}>
<MySelect <MySelect
title="项目权限" title="项目权限"
isTitle={true}
value={selectValue} value={selectValue}
onChange={changePermission} onChange={changePermission}
options={selectOptions} options={selectOptions}
......
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