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