Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
8d7d0835
提交
8d7d0835
authored
1月 05, 2021
作者:
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(table): add summaryData prop #163
上级
31ff0559
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
30 行增加
和
12 行删除
+30
-12
TableAction.vue
src/components/Table/src/components/TableAction.vue
+1
-1
TableFooter.vue
src/components/Table/src/components/TableFooter.vue
+9
-2
useDataSource.ts
src/components/Table/src/hooks/useDataSource.ts
+3
-3
useTableFooter.ts
src/components/Table/src/hooks/useTableFooter.ts
+2
-2
props.ts
src/components/Table/src/props.ts
+6
-1
table.ts
src/components/Table/src/types/table.ts
+2
-0
MultipleHeader.vue
src/layouts/default/header/MultipleHeader.vue
+6
-2
FooterTable.vue
src/views/demo/table/FooterTable.vue
+1
-1
没有找到文件。
src/components/Table/src/components/TableAction.vue
浏览文件 @
8d7d0835
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
const
{
prefixCls
}
=
useDesign
(
'basic-table-action'
);
const
{
prefixCls
}
=
useDesign
(
'basic-table-action'
);
const
table
=
useTableContext
();
const
table
=
useTableContext
();
const
getActions
=
computed
(()
=>
{
const
getActions
=
computed
(()
=>
{
return
props
.
actions
.
map
((
action
)
=>
{
return
(
props
.
actions
||
[])
.
map
((
action
)
=>
{
const
{
popConfirm
}
=
action
;
const
{
popConfirm
}
=
action
;
return
{
return
{
type
:
'link'
,
type
:
'link'
,
...
...
src/components/Table/src/components/TableFooter.vue
浏览文件 @
8d7d0835
<
template
>
<
template
>
<Table
<Table
v-if=
"summaryFunc"
v-if=
"summaryFunc
|| summaryData
"
:showHeader=
"false"
:showHeader=
"false"
:bordered=
"false"
:bordered=
"false"
:pagination=
"false"
:pagination=
"false"
...
@@ -32,6 +32,9 @@
...
@@ -32,6 +32,9 @@
summaryFunc
:
{
summaryFunc
:
{
type
:
Function
as
PropType
<
Fn
>
,
type
:
Function
as
PropType
<
Fn
>
,
},
},
summaryData
:
{
type
:
Array
as
PropType
<
Recordable
[]
>
,
},
scroll
:
{
scroll
:
{
type
:
Object
as
PropType
<
Recordable
>
,
type
:
Object
as
PropType
<
Recordable
>
,
},
},
...
@@ -41,7 +44,11 @@
...
@@ -41,7 +44,11 @@
const
table
=
useTableContext
();
const
table
=
useTableContext
();
const
getDataSource
=
computed
(():
Recordable
[]
=>
{
const
getDataSource
=
computed
(():
Recordable
[]
=>
{
const
{
summaryFunc
}
=
props
;
const
{
summaryFunc
,
summaryData
}
=
props
;
if
(
summaryData
?.
length
)
{
summaryData
.
forEach
((
item
,
i
)
=>
(
item
[
props
.
rowKey
]
=
`
${
i
}
`
));
return
summaryData
;
}
if
(
!
isFunction
(
summaryFunc
))
{
if
(
!
isFunction
(
summaryFunc
))
{
return
[];
return
[];
}
}
...
...
src/components/Table/src/hooks/useDataSource.ts
浏览文件 @
8d7d0835
...
@@ -163,11 +163,11 @@ export function useDataSource(
...
@@ -163,11 +163,11 @@ export function useDataSource(
...
pageParams
,
...
pageParams
,
...(
useSearchForm
?
getFieldsValue
()
:
{}),
...(
useSearchForm
?
getFieldsValue
()
:
{}),
...
searchInfo
,
...
searchInfo
,
...(
opt
?
opt
.
searchInfo
:
{}),
...(
opt
?.
searchInfo
??
{}),
...(
opt
?
opt
.
sortInfo
:
{}),
...(
opt
?
opt
.
filterInfo
:
{}),
...
sortInfo
,
...
sortInfo
,
...
filterInfo
,
...
filterInfo
,
...(
opt
?.
sortInfo
??
{}),
...(
opt
?.
filterInfo
??
{}),
};
};
if
(
beforeFetch
&&
isFunction
(
beforeFetch
))
{
if
(
beforeFetch
&&
isFunction
(
beforeFetch
))
{
params
=
beforeFetch
(
params
)
||
params
;
params
=
beforeFetch
(
params
)
||
params
;
...
...
src/components/Table/src/hooks/useTableFooter.ts
浏览文件 @
8d7d0835
...
@@ -19,9 +19,9 @@ export function useTableFooter(
...
@@ -19,9 +19,9 @@ export function useTableFooter(
});
});
const
getFooterProps
=
computed
(():
Recordable
|
undefined
=>
{
const
getFooterProps
=
computed
(():
Recordable
|
undefined
=>
{
const
{
summaryFunc
,
showSummary
}
=
unref
(
propsRef
);
const
{
summaryFunc
,
showSummary
,
summaryData
}
=
unref
(
propsRef
);
return
showSummary
&&
!
unref
(
getIsEmptyData
)
return
showSummary
&&
!
unref
(
getIsEmptyData
)
?
()
=>
h
(
TableFooter
,
{
summaryFunc
,
scroll
:
unref
(
scrollRef
)
})
?
()
=>
h
(
TableFooter
,
{
summaryFunc
,
s
ummaryData
,
s
croll
:
unref
(
scrollRef
)
})
:
undefined
;
:
undefined
;
});
});
...
...
src/components/Table/src/props.ts
浏览文件 @
8d7d0835
...
@@ -44,6 +44,11 @@ export const basicProps = {
...
@@ -44,6 +44,11 @@ export const basicProps = {
default
:
null
,
default
:
null
,
},
},
summaryData
:
{
type
:
Array
as
PropType
<
Recordable
[]
>
,
default
:
null
,
},
canColDrag
:
propTypes
.
bool
.
def
(
true
),
canColDrag
:
propTypes
.
bool
.
def
(
true
),
api
:
{
api
:
{
type
:
Function
as
PropType
<
(...
arg
:
any
[])
=>
Promise
<
any
>>
,
type
:
Function
as
PropType
<
(...
arg
:
any
[])
=>
Promise
<
any
>>
,
...
@@ -73,7 +78,7 @@ export const basicProps = {
...
@@ -73,7 +78,7 @@ export const basicProps = {
emptyDataIsShowTable
:
propTypes
.
bool
.
def
(
true
),
emptyDataIsShowTable
:
propTypes
.
bool
.
def
(
true
),
// 额外的请求参数
// 额外的请求参数
searchInfo
:
{
searchInfo
:
{
type
:
Object
as
PropType
<
any
>
,
type
:
Object
as
PropType
<
Recordable
>
,
default
:
null
,
default
:
null
,
},
},
// 使用搜索表单
// 使用搜索表单
...
...
src/components/Table/src/types/table.ts
浏览文件 @
8d7d0835
...
@@ -143,6 +143,8 @@ export interface BasicTableProps<T = any> {
...
@@ -143,6 +143,8 @@ export interface BasicTableProps<T = any> {
autoCreateKey
?:
boolean
;
autoCreateKey
?:
boolean
;
// 计算合计行的方法
// 计算合计行的方法
summaryFunc
?:
(...
arg
:
any
)
=>
Recordable
[];
summaryFunc
?:
(...
arg
:
any
)
=>
Recordable
[];
// 自定义合计表格内容
summaryData
?:
Recordable
[];
// 是否显示合计行
// 是否显示合计行
showSummary
?:
boolean
;
showSummary
?:
boolean
;
// 是否可拖拽列
// 是否可拖拽列
...
...
src/layouts/default/header/MultipleHeader.vue
浏览文件 @
8d7d0835
...
@@ -70,10 +70,14 @@
...
@@ -70,10 +70,14 @@
const
getPlaceholderDomStyle
=
computed
(
const
getPlaceholderDomStyle
=
computed
(
():
CSSProperties
=>
{
():
CSSProperties
=>
{
let
height
=
0
;
let
height
=
0
;
if
((
unref
(
getShowFullHeaderRef
)
||
!
unref
(
getSplit
))
&&
unref
(
getShowHeader
))
{
if
(
(
unref
(
getShowFullHeaderRef
)
||
!
unref
(
getSplit
))
&&
unref
(
getShowHeader
)
&&
!
unref
(
getFullContent
)
)
{
height
+=
HEADER_HEIGHT
;
height
+=
HEADER_HEIGHT
;
}
}
if
(
unref
(
getShowMultipleTab
))
{
if
(
unref
(
getShowMultipleTab
)
&&
!
unref
(
getFullContent
)
)
{
height
+=
TABS_HEIGHT
;
height
+=
TABS_HEIGHT
;
}
}
headerHeightRef
.
value
=
height
;
headerHeightRef
.
value
=
height
;
...
...
src/views/demo/table/FooterTable.vue
浏览文件 @
8d7d0835
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
export
default
defineComponent
({
export
default
defineComponent
({
components
:
{
BasicTable
},
components
:
{
BasicTable
},
setup
()
{
setup
()
{
function
handleSummary
(
tableData
:
any
[])
{
function
handleSummary
(
tableData
:
Recordable
[])
{
const
totalNo
=
tableData
.
reduce
((
prev
,
next
)
=>
{
const
totalNo
=
tableData
.
reduce
((
prev
,
next
)
=>
{
prev
+=
next
.
no
;
prev
+=
next
.
no
;
return
prev
;
return
prev
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论