refactor(components):重构参数表格组件命名与逻辑

- 将 EndNodeTable 组件重命名为 ParamsTable
-为 maxTime 参数项禁用编辑功能
-限制 maxTime 默认值输入类型为数字
- 隐藏 maxTime项的删除按钮
- 更新组件接口名称以匹配新用途
master
钟良源 4 months ago
parent da34978f6c
commit e274937a19

@ -13,15 +13,15 @@ interface TableDataItem {
[key: string]: any; // 允许其他自定义字段
}
interface EndNodeTableProps {
interface ParamsTableProps {
initialData: TableDataItem[];
onUpdateData: (data: TableDataItem[]) => void;
}
const EndNodeTable: React.FC<EndNodeTableProps> = ({
initialData,
onUpdateData
}) => {
const ParamsTable: React.FC<ParamsTableProps> = ({
initialData,
onUpdateData
}) => {
const [data, setData] = useState<TableDataItem[]>([]);
useEffect(() => {
@ -52,23 +52,31 @@ const EndNodeTable: React.FC<EndNodeTableProps> = ({
title: '标识',
dataIndex: 'id',
render: (_: any, record: TableDataItem) => (
<Input
value={record.id}
onChange={(value) => handleSave({ ...record, id: value })}
/>
record.id === 'maxTime' ? (
<span>{record.id}</span>
) : (
<Input
value={record.id}
onChange={(value) => handleSave({ ...record, id: value })}
/>
)
)
},
{
title: '数据类型',
dataIndex: 'dataType',
render: (_: any, record: TableDataItem) => (
<Select
autoWidth={{ minWidth: 200, maxWidth: 500 }}
options={dataTypeOptions}
value={record.dataType}
onChange={(value) => handleSave({ ...record, dataType: value })}
placeholder="请选择数据类型"
/>
record.id === 'maxTime' ? (
<span>{record.dataType === 'INTEGER' ? '整数' : record.dataType}</span>
) : (
<Select
autoWidth={{ minWidth: 200, maxWidth: 500 }}
options={dataTypeOptions}
value={record.dataType}
onChange={(value) => handleSave({ ...record, dataType: value })}
placeholder="请选择数据类型"
/>
)
)
},
{
@ -92,27 +100,41 @@ const EndNodeTable: React.FC<EndNodeTableProps> = ({
title: '描述',
dataIndex: 'desc',
render: (_: any, record: TableDataItem) => (
<Input
value={record.desc}
onChange={(value) => handleSave({ ...record, desc: value })}
/>
record.id === 'maxTime' ? (
<span>{record.desc}</span>
) : (
<Input
value={record.desc}
onChange={(value) => handleSave({ ...record, desc: value })}
/>
)
)
},
{
title: '默认值',
dataIndex: 'defaultValue',
render: (_: any, record: TableDataItem) => (
<Input
value={record.defaultValue}
onChange={(value) => handleSave({ ...record, defaultValue: value })}
/>
record.id === 'maxTime' ? (
<Input
type="number"
min="1"
step="1"
value={record.defaultValue}
onChange={(value) => handleSave({ ...record, defaultValue: value })}
/>
) : (
<Input
value={record.defaultValue}
onChange={(value) => handleSave({ ...record, defaultValue: value })}
/>
)
)
},
{
title: '操作',
dataIndex: 'op',
render: (_: any, record: TableDataItem) => (
<Button onClick={() => removeRow(record.key)} type="text" status="danger">
record.id !== 'maxTime' && <Button onClick={() => removeRow(record.key)} type="text" status="danger">
<IconDelete />
</Button>
)
@ -168,4 +190,4 @@ const EndNodeTable: React.FC<EndNodeTableProps> = ({
);
};
export default EndNodeTable;
export default ParamsTable;
Loading…
Cancel
Save