Merge pull request #623 from smartxworks/fix/dry

bugfix
This commit is contained in:
yz-yu 2022-10-14 08:51:42 +08:00 committed by GitHub
commit 0fb888fff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -32,7 +32,7 @@ const TableStateSpec = Type.Object({
clickedRow: Type.Optional(Type.Any()), clickedRow: Type.Optional(Type.Any()),
selectedRows: Type.Array(Type.Any()), selectedRows: Type.Array(Type.Any()),
selectedRowKeys: Type.Array(Type.String()), selectedRowKeys: Type.Array(Type.String()),
filterRule: Type.Any(), filterRule: Type.Record(Type.String(), Type.Array(Type.String())),
sortRule: Type.Object({ sortRule: Type.Object({
field: Type.Optional(Type.String()), field: Type.Optional(Type.String()),
direction: Type.Optional(Type.String()), direction: Type.Optional(Type.String()),
@ -46,8 +46,6 @@ type SortRule = {
direction?: 'ascend' | 'descend'; direction?: 'ascend' | 'descend';
}; };
type FilterRule = Partial<Record<string, string[]>>;
type ColumnProperty = Static<typeof ColumnSpec> & ColumnProps; type ColumnProperty = Static<typeof ColumnSpec> & ColumnProps;
type filterDropdownParam = { type filterDropdownParam = {
@ -483,7 +481,7 @@ export const Table = implementRuntimeComponent({
const handleChange = ( const handleChange = (
pagination: PaginationProps, pagination: PaginationProps,
sorter: { field?: string; direction?: 'descend' | 'ascend' }, sorter: { field?: string; direction?: 'descend' | 'ascend' },
filters: FilterRule, filters: Partial<Record<string, string[]>>,
extra: { currentData: any[]; action: 'paginate' | 'sort' | 'filter' } extra: { currentData: any[]; action: 'paginate' | 'sort' | 'filter' }
) => { ) => {
const { current } = pagination; const { current } = pagination;
@ -508,7 +506,7 @@ export const Table = implementRuntimeComponent({
break; break;
case 'filter': case 'filter':
if (!useDefaultFilter) { if (!useDefaultFilter) {
mergeState({ filterRule: filters }); mergeState({ filterRule: filters as Record<string, string[]> });
callbackMap?.onFilter?.(); callbackMap?.onFilter?.();
} }
break; break;

View File

@ -20,7 +20,7 @@ declare module '../../types/widget' {
export const NumberField: React.FC<WidgetProps<NumberFieldType>> = props => { export const NumberField: React.FC<WidgetProps<NumberFieldType>> = props => {
const { value, onChange } = props; const { value, onChange } = props;
const [stringValue, setStringValue] = React.useState(''); const [stringValue, setStringValue] = React.useState(String(value));
const numValue = useRef<number>(value); const numValue = useRef<number>(value);
useEffect(() => { useEffect(() => {