fix: sorter for datetime and number
This commit is contained in:
parent
0900296ea3
commit
611ce0d759
@ -65,6 +65,7 @@ class ApiClient {
|
||||
options.params['filter'] = JSON.stringify(filter);
|
||||
}
|
||||
if (sorter) {
|
||||
sort = [];
|
||||
const arr = Array.isArray(sorter) ? sorter : [sorter];
|
||||
arr.forEach(({ order, field }) => {
|
||||
if (order === 'descend') {
|
||||
|
@ -221,7 +221,7 @@ export function Table(props: any) {
|
||||
params,
|
||||
} = useRequest(
|
||||
(params = {}, ...args) => {
|
||||
const { current, pageSize, sorter, filter, ...restParams } = params;
|
||||
const { current, pageSize, sorter, filter, ...restParams } = params as any;
|
||||
console.log('paramsparamsparamsparamsparams', params, args);
|
||||
return api
|
||||
.resource(resourceName)
|
||||
@ -472,6 +472,7 @@ export function Table(props: any) {
|
||||
columns={fields2columns(fields, { associatedKey, refresh })}
|
||||
pagination={false}
|
||||
onChange={(pagination, filters, sorter, extra) => {
|
||||
console.log({sorter});
|
||||
run({ ...params[0], sorter });
|
||||
}}
|
||||
expandable={expandable}
|
||||
|
@ -97,6 +97,9 @@ export function fields2columns(fields = [], ctx: any = {}) {
|
||||
if (!field.dataIndex) {
|
||||
field.dataIndex = field.name.split('.');
|
||||
}
|
||||
if (['datetime', 'number'].includes(field.interface)) {
|
||||
field.sorter = true;
|
||||
}
|
||||
field.render = (value, record, index) =>
|
||||
field.interface === 'sort' ? (
|
||||
<DragHandle />
|
||||
|
Loading…
Reference in New Issue
Block a user