mirror of https://github.com/jeecgboot/jeecg-boot
支持多字段默认排序defSort数组
parent
b474e9e5a5
commit
83bb0a0a6a
|
@ -238,12 +238,20 @@ export function useDataSource(
|
|||
|
||||
const { sortInfo = {}, filterInfo } = searchState;
|
||||
|
||||
// 扩展默认排序多字段数组写法
|
||||
let defSortInfo: Recordable<any> | undefined = {};
|
||||
if (defSort && Array.isArray(defSort) && defSort.length > 0) {
|
||||
defSortInfo['defSortString'] = JSON.stringify(defSort);
|
||||
} else {
|
||||
defSortInfo = defSort;
|
||||
}
|
||||
|
||||
let params: Recordable = {
|
||||
...pageParams,
|
||||
// 由于 getFieldsValue 返回的不是逗号分割的数据,所以改用 validate
|
||||
...(useSearchForm ? await validate() : {}),
|
||||
...searchInfo,
|
||||
...defSort,
|
||||
...defSortInfo,
|
||||
...(opt?.searchInfo ?? {}),
|
||||
...sortInfo,
|
||||
...filterInfo,
|
||||
|
|
|
@ -190,7 +190,7 @@ export interface BasicTableProps<T = any> {
|
|||
// 额外的请求参数
|
||||
searchInfo?: Recordable;
|
||||
// 默认的排序参数
|
||||
defSort?: Recordable;
|
||||
defSort?: Recordable | Recordable[];
|
||||
// 使用搜索表单
|
||||
useSearchForm?: boolean;
|
||||
// 表单配置
|
||||
|
|
|
@ -123,11 +123,17 @@
|
|||
style: { textAlign: 'left' },
|
||||
},
|
||||
},
|
||||
//自定义默认排序
|
||||
defSort: {
|
||||
column: 'createTime,sex',
|
||||
//自定义默认多字段排序
|
||||
defSort: [
|
||||
{
|
||||
column: 'name',
|
||||
order: 'desc',
|
||||
},
|
||||
{
|
||||
column: 'sex',
|
||||
order: 'asc',
|
||||
},
|
||||
],
|
||||
striped: true,
|
||||
useSearchForm: true,
|
||||
showTableSetting: true,
|
||||
|
|
Loading…
Reference in New Issue