Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
491ba9a3
提交
491ba9a3
authored
10月 25, 2020
作者:
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add the parameter sortFn to the table
上级
d09406e3
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
43 行增加
和
6 行删除
+43
-6
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+2
-0
BasicTable.vue
src/components/Table/src/BasicTable.vue
+13
-3
const.ts
src/components/Table/src/const.ts
+10
-0
useDataSource.ts
src/components/Table/src/hooks/useDataSource.ts
+2
-0
props.ts
src/components/Table/src/props.ts
+12
-2
table.ts
src/components/Table/src/types/table.ts
+4
-1
没有找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
491ba9a3
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
-
面包屑支持显示图标
-
面包屑支持显示图标
-
新增 tinymce 富文本组件
-
新增 tinymce 富文本组件
-
表单新增 submitOnReset 控制是否在重置时重新发起请求
### 🎫 Chores
### 🎫 Chores
...
@@ -21,6 +22,7 @@
...
@@ -21,6 +22,7 @@
-
修复菜单没有子节点时显示折叠的问题
-
修复菜单没有子节点时显示折叠的问题
-
修复面包屑显示样式问题
-
修复面包屑显示样式问题
-
修复 modal 在 destroyOnClose=true 时多次打开拖拽失效
-
修复 modal 在 destroyOnClose=true 时多次打开拖拽失效
-
修复表格出现多个 action 列
# 2.0.0-rc.4 (2020-10-21)
# 2.0.0-rc.4 (2020-10-21)
...
...
src/components/Table/src/BasicTable.vue
浏览文件 @
491ba9a3
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
import
{
ROW_KEY
}
from
'./const'
;
import
{
ROW_KEY
}
from
'./const'
;
import
{
PaginationProps
}
from
'./types/pagination'
;
import
{
PaginationProps
}
from
'./types/pagination'
;
import
{
deepMerge
}
from
'/@/utils'
;
import
{
deepMerge
}
from
'/@/utils'
;
import
{
TableCustomRecord
}
from
'ant-design-vue/types/table/table'
;
import
{
SorterResult
,
TableCustomRecord
}
from
'ant-design-vue/types/table/table'
;
import
{
useEvent
}
from
'/@/hooks/event/useEvent'
;
import
{
useEvent
}
from
'/@/hooks/event/useEvent'
;
import
'./style/index.less'
;
import
'./style/index.less'
;
...
@@ -216,12 +216,22 @@
...
@@ -216,12 +216,22 @@
fetch
({
searchInfo
:
info
,
page
:
1
});
fetch
({
searchInfo
:
info
,
page
:
1
});
}
}
function
handleTableChange
(
pagination
:
PaginationProps
)
{
function
handleTableChange
(
const
{
clearSelectOnPageChange
}
=
unref
(
getMergeProps
);
pagination
:
PaginationProps
,
filters
:
Partial
<
Record
<
string
,
string
[]
>>
,
sorter
:
SorterResult
<
any
>
)
{
const
{
clearSelectOnPageChange
,
sortFn
}
=
unref
(
getMergeProps
);
if
(
clearSelectOnPageChange
)
{
if
(
clearSelectOnPageChange
)
{
clearSelectedRowKeys
();
clearSelectedRowKeys
();
}
}
setPagination
(
pagination
);
setPagination
(
pagination
);
if
(
sorter
&&
isFunction
(
sortFn
))
{
const
sortInfo
=
sortFn
(
sorter
);
fetch
({
sortInfo
});
return
;
}
fetch
();
fetch
();
}
}
...
...
src/components/Table/src/const.ts
浏览文件 @
491ba9a3
import
{
SorterResult
}
from
'ant-design-vue/types/table/table'
;
export
const
ROW_KEY
=
'key'
;
export
const
ROW_KEY
=
'key'
;
export
const
PAGE_SIZE_OPTIONS
=
[
'10'
,
'50'
,
'80'
,
'100'
];
export
const
PAGE_SIZE_OPTIONS
=
[
'10'
,
'50'
,
'80'
,
'100'
];
...
@@ -10,3 +12,11 @@ export const FETCH_SETTING = {
...
@@ -10,3 +12,11 @@ export const FETCH_SETTING = {
listField
:
'items'
,
listField
:
'items'
,
totalField
:
'total'
,
totalField
:
'total'
,
};
};
export
function
DEFAULT_SORT_FN
(
sortInfo
:
SorterResult
<
any
>
)
{
const
{
field
,
order
}
=
sortInfo
;
return
{
field
,
order
,
};
}
src/components/Table/src/hooks/useDataSource.ts
浏览文件 @
491ba9a3
...
@@ -98,6 +98,8 @@ export function useDataSource(
...
@@ -98,6 +98,8 @@ export function useDataSource(
...(
useSearchForm
?
getFieldsValue
()
:
{}),
...(
useSearchForm
?
getFieldsValue
()
:
{}),
...
searchInfo
,
...
searchInfo
,
...(
opt
?
opt
.
searchInfo
:
{}),
...(
opt
?
opt
.
searchInfo
:
{}),
...(
opt
?
opt
.
sortInfo
:
{}),
...(
opt
?
opt
.
filterInfo
:
{}),
};
};
if
(
beforeFetch
&&
isFunction
(
beforeFetch
))
{
if
(
beforeFetch
&&
isFunction
(
beforeFetch
))
{
params
=
beforeFetch
(
params
)
||
params
;
params
=
beforeFetch
(
params
)
||
params
;
...
...
src/components/Table/src/props.ts
浏览文件 @
491ba9a3
import
type
{
PropType
}
from
'vue'
;
import
type
{
PropType
}
from
'vue'
;
import
type
{
PaginationProps
}
from
'./types/pagination'
;
import
type
{
PaginationProps
}
from
'./types/pagination'
;
import
type
{
BasicColumn
,
FetchSetting
,
TableSetting
}
from
'./types/table'
;
import
type
{
BasicColumn
,
FetchSetting
,
TableSetting
}
from
'./types/table'
;
import
type
{
TableCustomRecord
,
TableRowSelection
}
from
'ant-design-vue/types/table/table'
;
import
type
{
SorterResult
,
TableCustomRecord
,
TableRowSelection
,
}
from
'ant-design-vue/types/table/table'
;
import
type
{
FormProps
}
from
'/@/components/Form/index'
;
import
type
{
FormProps
}
from
'/@/components/Form/index'
;
import
{
FETCH_SETTING
}
from
'./const'
;
import
{
DEFAULT_SORT_FN
,
FETCH_SETTING
}
from
'./const'
;
// 注释看 types/table
// 注释看 types/table
export
const
basicProps
=
{
export
const
basicProps
=
{
tableSetting
:
{
tableSetting
:
{
type
:
Object
as
PropType
<
TableSetting
>
,
type
:
Object
as
PropType
<
TableSetting
>
,
},
},
sortFn
:
{
type
:
Function
as
PropType
<
(
sortInfo
:
SorterResult
<
any
>
)
=>
any
>
,
default
:
DEFAULT_SORT_FN
,
},
showTableSetting
:
{
showTableSetting
:
{
type
:
Boolean
as
PropType
<
boolean
>
,
type
:
Boolean
as
PropType
<
boolean
>
,
default
:
false
,
default
:
false
,
...
...
src/components/Table/src/types/table.ts
浏览文件 @
491ba9a3
...
@@ -28,6 +28,8 @@ export interface RenderEditableCellParams {
...
@@ -28,6 +28,8 @@ export interface RenderEditableCellParams {
export
interface
FetchParams
{
export
interface
FetchParams
{
searchInfo
?:
any
;
searchInfo
?:
any
;
page
?:
number
;
page
?:
number
;
sortInfo
?:
any
;
filterInfo
?:
any
;
}
}
export
interface
GetColumnsParams
{
export
interface
GetColumnsParams
{
...
@@ -75,6 +77,8 @@ export interface TableSetting {
...
@@ -75,6 +77,8 @@ export interface TableSetting {
}
}
export
interface
BasicTableProps
<
T
=
any
>
{
export
interface
BasicTableProps
<
T
=
any
>
{
// 自定义排序方法
sortFn
?:
(
sortInfo
:
SorterResult
<
any
>
)
=>
any
;
// 显示表格设置
// 显示表格设置
showTableSetting
?:
boolean
;
showTableSetting
?:
boolean
;
tableSetting
?:
TableSetting
;
tableSetting
?:
TableSetting
;
...
@@ -106,7 +110,6 @@ export interface BasicTableProps<T = any> {
...
@@ -106,7 +110,6 @@ export interface BasicTableProps<T = any> {
emptyDataIsShowTable
?:
boolean
;
emptyDataIsShowTable
?:
boolean
;
// 额外的请求参数
// 额外的请求参数
searchInfo
?:
any
;
searchInfo
?:
any
;
// 使用搜索表单
// 使用搜索表单
useSearchForm
?:
boolean
;
useSearchForm
?:
boolean
;
// 表单配置
// 表单配置
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论