|
|
|
|
@ -23,6 +23,8 @@ const arrayTypeOptions = [
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
function EditableCell({ value, onChange, columnType, record, dataIndex }) {
|
|
|
|
|
const [error, setError] = useState('');
|
|
|
|
|
|
|
|
|
|
// 对于数组类型字段的特殊处理
|
|
|
|
|
if (dataIndex === 'generic') {
|
|
|
|
|
// 仅当数据类型为 ARRAY 时才可编辑
|
|
|
|
|
@ -43,6 +45,33 @@ function EditableCell({ value, onChange, columnType, record, dataIndex }) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (columnType === 'input') {
|
|
|
|
|
// 对于 ident 字段(名称列)添加验证
|
|
|
|
|
if (dataIndex === 'ident') {
|
|
|
|
|
const handleIdentChange = (val) => {
|
|
|
|
|
// 验证是否只包含英文字母、数字和下划线
|
|
|
|
|
const pattern = /^[a-zA-Z0-9_]*$/;
|
|
|
|
|
if (val && !pattern.test(val)) {
|
|
|
|
|
setError('只能包含英文字母、数字和下划线');
|
|
|
|
|
Message.error('参数名称只能包含英文字母、数字和下划线');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setError('');
|
|
|
|
|
onChange(val);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<Input
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={handleIdentChange}
|
|
|
|
|
placeholder="请输入(仅支持英文字母、数字和下划线)"
|
|
|
|
|
status={error ? 'error' : undefined}
|
|
|
|
|
/>
|
|
|
|
|
{error && <div style={{ color: '#f53f3f', fontSize: 12, marginTop: 4 }}>{error}</div>}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Input
|
|
|
|
|
value={value}
|
|
|
|
|
|