Commit ac56d4c1 by chenwq

```

feat(SearchForm): 调整搜索表单布局和样式

- 将默认布局从 inline 改为 vertical
- 移除字段宽度限制,改为 100% 自适应
- 添加网格布局样式支持响应式排列
- 修复重置按钮分页参数测试用例
- 移除角色管理页面的数据可见范围提示文本
```
1 parent 25309a95
Pipeline #314 for ac56d4c1 failed in 0 seconds
......@@ -23,7 +23,7 @@ export function SearchForm<T extends Record<string, unknown>>({
pagination,
onSearch,
onReset,
layout = 'inline',
layout = 'vertical',
className,
}: SearchFormProps<T>) {
const [form] = UForm.useForm();
......@@ -37,7 +37,7 @@ export function SearchForm<T extends Record<string, unknown>>({
placeholder: field.placeholder,
size: 'small' as const,
};
const width = field.width ?? (field.type === 'input' || field.type === 'textarea' ? 260 : 160);
const width = field.width ?? '100%';
if (field.type === 'select' || field.type === 'selectMultiple')
return (
<USelect
......@@ -66,16 +66,22 @@ export function SearchForm<T extends Record<string, unknown>>({
<UForm
form={form}
initialValues={initialValues}
layout={layout}
layout={layout === 'inline' ? 'vertical' : layout}
className={className}
style={searchFormStyle}
onFinish={(values) => onSearch(values as T, searchPagination)}
>
{fields.map((field) => (
<UFormItem key={field.name} name={field.name as string} label={field.label}>
<UFormItem
key={field.name}
name={field.name as string}
label={field.label}
style={{ marginBottom: 0, minWidth: 0 }}
>
{control(field)}
</UFormItem>
))}
<UFormItem>
<UFormItem style={searchActionsStyle}>
<UButton
type="default"
size="small"
......@@ -100,3 +106,16 @@ export function SearchForm<T extends Record<string, unknown>>({
</UForm>
);
}
const searchFormStyle = {
columnGap: 16,
display: 'grid',
gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
rowGap: 12,
};
const searchActionsStyle = {
display: 'flex',
gridColumn: '1 / -1',
justifyContent: 'flex-end',
marginBottom: 0,
};
......@@ -30,7 +30,7 @@ describe('SearchForm', () => {
fireEvent.change(input, { target: { value: '已修改' } });
fireEvent.click(screen.getByRole('button', { name: /重\s*置/ }));
expect(screen.getByLabelText('名称')).toHaveValue('初始值');
expect(onReset).toHaveBeenCalledWith({ name: '初始值' }, { current: 1, size: 20 });
expect(onReset).toHaveBeenCalledWith({ name: '初始值' }, { current: 1, size: 10 });
});
it('查询时传出页面配置的分页参数', async () => {
......
......@@ -153,9 +153,6 @@ export default function RoleManage() {
setQueryVersion((version) => version + 1);
}}
/>
<div style={{ marginTop: 12 }}>
<UText type="secondary">数据可见范围:全部数据(超级管理员)</UText>
</div>
</UCard>
<UCard size="small" styles={{ body: { padding: 0 } }}>
<DataTable<Row>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!