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 (
<TextField <ThemeProvider theme={theme}>
{...props} <TextField
error={error} error={error}
helperText={helperText} size={size}
sx={{ ...inputSx }} placeholder={placeholder}
id={id} fullWidth={fullWidth}
label={label} label={label}
variant={variant} {...other}
onChange={onChange} />
onFocus={onFocus} </ThemeProvider>
size={size}
placeholder={placeholder}
fullWidth={fullWidth}
InputProps={{
...InputProps,
}}
disabled={disabled}
value={value}
/>
); );
}; };
......
...@@ -2,90 +2,135 @@ ...@@ -2,90 +2,135 @@
* @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;
value: string; value: string;
disabled?: boolean; disabled?: boolean;
} }
export const optionsTransform = ( export const optionsTransform = (
arr: Array<any>, arr: Array<any>,
labelKey: string = "label", labelKey: string = "label",
valueKey: string = "value", valueKey: string = "value",
disabledKey: string = "disabled" disabledKey: string = "disabled"
): Array<IOption> => { ): Array<IOption> => {
return arr.map((item: any) => { return arr.map((item: any) => {
return { return {
label: item[labelKey], label: item[labelKey],
value: item[valueKey], value: item[valueKey],
disabled: item[disabledKey], disabled: item[disabledKey],
}; };
}); });
}; };
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 */
title?: string; title?: string;
/** 是否显示title */ /** 是否显示title */
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: {
if (onChange) { root: {
onChange(newValue[0] || { label: "", value: "" }); height: "36px",
} },
}; },
},
return ( MuiOutlinedInput: {
<Box sx={{ minWidth: 120 }}> styleOverrides: {
<FormControl fullWidth variant={variant}> root: {
{isTitle ? ( ":hover": {
<InputLabel id="demo-simple-select-label"> "& .MuiOutlinedInput-notchedOutline": {
{title || "请选择"} borderColor: "#1370ff",
</InputLabel> },
) : null} },
<Select },
labelId="demo-simple-select-label" },
id="demo-simple-select" },
label={title || "请选择"}
size="small" MuiInputLabel: {
{...props} styleOverrides: {
value={value?.value} root: {
onChange={handleChange} top: "-9px",
> },
{options.length },
? options?.map((item: IOption) => { },
return (
<MenuItem value={item.value} disabled={item?.disabled}> MuiSelect: {
{item.label} styleOverrides: {
</MenuItem> select: {
); padding: "6.5px 14px",
}) fontSize: "14px",
: null} },
</Select> },
</FormControl> },
</Box> },
); });
const handleChange = (e: SelectChangeEvent<unknown>) => {
onChange && onChange(e.target.value as string);
};
return (
<ThemeProvider theme={theme}>
<FormControl fullWidth variant={variant}>
{isTitle ? (
<InputLabel id="demo-simple-select-label">
{title || "请选择"}
</InputLabel>
) : null}
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
label={title || ""}
size="small"
multiple={multiple}
{...other}
value={value || ""}
onChange={handleChange}
>
{options.length
? options?.map((item: IOption) => {
return (
<MenuItem value={item.value} disabled={item?.disabled}>
{item.label}
</MenuItem>
);
})
: null}
</Select>
</FormControl>
</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
*/ */
...@@ -17,42 +17,39 @@ import { observer } from "mobx-react-lite"; ...@@ -17,42 +17,39 @@ import { observer } from "mobx-react-lite";
import { toJS } from "mobx"; import { toJS } from "mobx";
const TranSferList = observer(() => { const TranSferList = observer(() => {
const uploadInfoStore = toJS(useGlobalStore("fileListStore")); const uploadInfoStore = toJS(useGlobalStore("fileListStore"));
return ( return (
<Box style={{ width: 520, padding: 20 }}> <Box style={{ width: 520, padding: 20 }}>
<MyTitle title="传输列表" /> <MyTitle title="传输列表" />
<Box <Box
style={{ style={{
display: "flex", display: "flex",
justifyContent: "space-between", justifyContent: "space-between",
alignItems: "center", alignItems: "center",
}} }}
> >
<Box style={{ color: "#8A9099" }}>请勿在上传过程中刷新页面!</Box> <Box style={{ color: "#8A9099" }}>请勿在上传过程中刷新页面!</Box>
<MySelect <MySelect
variant="standard" variant="standard"
value={{ value={"default"}
label: "默认线路", onChange={() => console.log(11)}
value: "default", options={[
}} {
onChange={() => console.log(11)} label: "默认线路",
options={[ value: "default",
{ },
label: "默认线路", ]}
value: "default", size="small"
}, />
]} </Box>
size="small" <Box style={{ height: 400, overflowY: "auto" }}>
/> {uploadInfoStore?.fileList.map((item) => {
</Box> return <FileItem fileItemInfo={item} key={item.id} />;
<Box style={{ height: 400, overflowY: "auto" }}> })}
{uploadInfoStore?.fileList.map((item) => { </Box>
return <FileItem fileItemInfo={item} key={item.id} />; </Box>
})} );
</Box>
</Box>
);
}); });
export default memo(TranSferList); export default memo(TranSferList);
...@@ -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