Commit f1b5424e authored by chenshouchao's avatar chenshouchao

feat: 完成参数设置的参数校验

parent de23a8e5
Pipeline #185 canceled with stages
...@@ -8,59 +8,61 @@ ...@@ -8,59 +8,61 @@
*/ */
import TextField, { TextFieldProps } from "@mui/material/TextField"; import TextField, { TextFieldProps } from "@mui/material/TextField";
interface MyInputProps extends Omit<TextFieldProps, "value"> { interface MyInputProps extends Omit<TextFieldProps, "value"> {
value: any; value: any;
inputSx?: any; inputSx?: any;
onChange?: any; onChange?: any;
onFocus?: any; onFocus?: any;
label?: string; label?: string;
variant?: "standard" | "filled" | "outlined"; variant?: "standard" | "filled" | "outlined";
id?: string; id?: string;
size?: "small" | "medium"; size?: "small" | "medium";
placeholder?: string; placeholder?: string;
fullWidth?: boolean; // 宽度是否和容器一致 fullWidth?: boolean; // 宽度是否和容器一致
InputProps?: any; // input加前后icon可以用这个 InputProps?: any; // input加前后icon可以用这个
error?: boolean; error?: boolean;
helperText?: string; helperText?: string;
}; }
const MyInput = (props: MyInputProps) => { const MyInput = (props: MyInputProps) => {
const { const {
inputSx = {}, inputSx = {},
value, value,
onChange, onChange,
onFocus, onFocus,
label, label,
id, id,
variant, variant,
size = "small", size = "small",
placeholder = "请输入", placeholder = "请输入",
fullWidth = true, fullWidth = true,
InputProps, InputProps,
error = false, error = false,
helperText, helperText,
} = props; disabled,
} = props;
return ( return (
<TextField <TextField
{...props} {...props}
error={error} error={error}
helperText={helperText} helperText={helperText}
sx={{ ...inputSx }} sx={{ ...inputSx }}
id={id} id={id}
label={label} label={label}
variant={variant} variant={variant}
onChange={onChange} onChange={onChange}
onFocus={onFocus} onFocus={onFocus}
size={size} size={size}
placeholder={placeholder} placeholder={placeholder}
fullWidth={fullWidth} fullWidth={fullWidth}
InputProps={{ InputProps={{
...InputProps, ...InputProps,
}} }}
value={value} disabled={disabled}
/> value={value}
); />
);
}; };
export default MyInput; export default MyInput;
...@@ -23,6 +23,12 @@ export const getCustomTemplateParameterCheckResult = ( ...@@ -23,6 +23,12 @@ export const getCustomTemplateParameterCheckResult = (
} }
} }
} }
if (error) {
return {
error,
helperText,
};
}
if (parameter.validators.length > 0) { if (parameter.validators.length > 0) {
parameter.validators.forEach((validator) => { parameter.validators.forEach((validator) => {
const reg = new RegExp(validator.regex); const reg = new RegExp(validator.regex);
......
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