Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
540423ec
Commit
540423ec
authored
Jul 08, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(table): add `headerTop` slot
为表格添加`headerTop`插槽(表格头部的标题之上),以及相关演示 close: #881
parent
9cf070dd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
19 deletions
+59
-19
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
TableHeader.vue
src/components/Table/src/components/TableHeader.vue
+21
-12
useTableHeader.ts
src/components/Table/src/hooks/useTableHeader.ts
+5
-0
FormTable.vue
src/views/demo/table/FormTable.vue
+30
-5
tableData.tsx
src/views/demo/table/tableData.tsx
+2
-2
No files found.
CHANGELOG.zh_CN.md
View file @
540423ec
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
-
**Table**
-
**Table**
-
修复滚动条样式问题
-
修复滚动条样式问题
-
修复树形表格的带有展开图标的单元格的内容对齐问题
-
修复树形表格的带有展开图标的单元格的内容对齐问题
-
新增
`headerTop`
插槽
-
**AppSearch**
修复可能会搜索隐藏菜单的问题
-
**AppSearch**
修复可能会搜索隐藏菜单的问题
-
**其它**
-
**其它**
-
修复菜单默认折叠的配置不起作用的问题
-
修复菜单默认折叠的配置不起作用的问题
...
...
src/components/Table/src/components/TableHeader.vue
View file @
540423ec
<
template
>
<
template
>
<slot
name=
"tableTitle"
v-if=
"$slots.tableTitle"
></slot>
<div
style=
"width: 100%"
>
<div
v-if=
"$slots.headerTop"
style=
"margin: 5px"
>
<TableTitle
:helpMessage=
"titleHelpMessage"
:title=
"title"
v-if=
"!$slots.tableTitle && title"
/>
<slot
name=
"headerTop"
></slot>
</div>
<div
:class=
"`$
{prefixCls}__toolbar`">
<div
style=
"width: 100%; display: flex"
>
<slot
name=
"toolbar"
></slot>
<slot
name=
"tableTitle"
v-if=
"$slots.tableTitle"
></slot>
<Divider
type=
"vertical"
v-if=
"$slots.toolbar && showTableSetting"
/>
<TableTitle
<TableSetting
:helpMessage=
"titleHelpMessage"
:setting=
"tableSetting"
:title=
"title"
v-if=
"showTableSetting"
v-if=
"!$slots.tableTitle && title"
@
columns-change=
"handleColumnChange"
/>
/>
<div
:class=
"`$
{prefixCls}__toolbar`">
<slot
name=
"toolbar"
></slot>
<Divider
type=
"vertical"
v-if=
"$slots.toolbar && showTableSetting"
/>
<TableSetting
:setting=
"tableSetting"
v-if=
"showTableSetting"
@
columns-change=
"handleColumnChange"
/>
</div>
</div>
</div>
</div>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
...
...
src/components/Table/src/hooks/useTableHeader.ts
View file @
540423ec
...
@@ -41,6 +41,11 @@ export function useTableHeader(
...
@@ -41,6 +41,11 @@ export function useTableHeader(
tableTitle
:
()
=>
getSlot
(
slots
,
'
tableTitle
'
),
tableTitle
:
()
=>
getSlot
(
slots
,
'
tableTitle
'
),
}
}
:
{}),
:
{}),
...(
slots
.
headerTop
?
{
headerTop
:
()
=>
getSlot
(
slots
,
'
headerTop
'
),
}
:
{}),
}
}
),
),
};
};
...
...
src/views/demo/table/FormTable.vue
View file @
540423ec
<
template
>
<
template
>
<BasicTable
@
register=
"registerTable"
>
<BasicTable
@
register=
"registerTable"
:rowSelection=
"
{ type: 'checkbox', selectedRowKeys: checkedKeys, onChange: onSelectChange }"
>
<template
#form-custom
>
custom-slot
</
template
>
<template
#form-custom
>
custom-slot
</
template
>
<
template
#headerTop
>
<a-alert
type=
"info"
show-icon
>
<template
#message
>
<template
v-if=
"checkedKeys.length > 0"
>
<span>
已选中
{{
checkedKeys
.
length
}}
条记录(可跨页)
</span>
<a-button
type=
"link"
@
click=
"checkedKeys = []"
size=
"small"
>
清空
</a-button>
</
template
>
<
template
v-else
>
<span>
未选中任何项目
</span>
</
template
>
</template>
</a-alert>
</template>
<
template
#toolbar
>
<
template
#toolbar
>
<a-button
type=
"primary"
@
click=
"getFormValues"
>
获取表单数据
</a-button>
<a-button
type=
"primary"
@
click=
"getFormValues"
>
获取表单数据
</a-button>
</
template
>
</
template
>
</BasicTable>
</BasicTable>
</template>
</template>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
defineComponent
,
ref
}
from
'
vue
'
;
import
{
BasicTable
,
useTable
}
from
'
/@/components/Table
'
;
import
{
BasicTable
,
useTable
}
from
'
/@/components/Table
'
;
import
{
getBasicColumns
,
getFormConfig
}
from
'
./tableData
'
;
import
{
getBasicColumns
,
getFormConfig
}
from
'
./tableData
'
;
import
{
Alert
}
from
'
ant-design-vue
'
;
import
{
demoListApi
}
from
'
/@/api/demo/table
'
;
import
{
demoListApi
}
from
'
/@/api/demo/table
'
;
export
default
defineComponent
({
export
default
defineComponent
({
components
:
{
BasicTable
},
components
:
{
BasicTable
,
AAlert
:
Alert
},
setup
()
{
setup
()
{
const
checkedKeys
=
ref
<
Array
<
string
|
number
>>
([]);
const
[
registerTable
,
{
getForm
}]
=
useTable
({
const
[
registerTable
,
{
getForm
}]
=
useTable
({
title
:
'
开启搜索区域
'
,
title
:
'
开启搜索区域
'
,
api
:
demoListApi
,
api
:
demoListApi
,
...
@@ -24,16 +41,24 @@
...
@@ -24,16 +41,24 @@
useSearchForm
:
true
,
useSearchForm
:
true
,
formConfig
:
getFormConfig
(),
formConfig
:
getFormConfig
(),
showTableSetting
:
true
,
showTableSetting
:
true
,
rowSelection
:
{
type
:
'
checkbox
'
},
showIndexColumn
:
false
,
rowKey
:
'
id
'
,
});
});
function
getFormValues
()
{
function
getFormValues
()
{
console
.
log
(
getForm
().
getFieldsValue
());
console
.
log
(
getForm
().
getFieldsValue
());
}
}
function
onSelectChange
(
selectedRowKeys
:
(
string
|
number
)[])
{
console
.
log
(
selectedRowKeys
);
checkedKeys
.
value
=
selectedRowKeys
;
}
return
{
return
{
registerTable
,
registerTable
,
getFormValues
,
getFormValues
,
checkedKeys
,
onSelectChange
,
};
};
},
},
});
});
...
...
src/views/demo/table/tableData.tsx
View file @
540423ec
...
@@ -31,13 +31,13 @@ export function getBasicColumns(): BasicColumn[] {
...
@@ -31,13 +31,13 @@ export function getBasicColumns(): BasicColumn[] {
},
},
{
{
title
:
'
开始时间
'
,
title
:
'
开始时间
'
,
width
:
1
2
0
,
width
:
1
5
0
,
sorter
:
true
,
sorter
:
true
,
dataIndex
:
'
beginTime
'
,
dataIndex
:
'
beginTime
'
,
},
},
{
{
title
:
'
结束时间
'
,
title
:
'
结束时间
'
,
width
:
1
2
0
,
width
:
1
5
0
,
sorter
:
true
,
sorter
:
true
,
dataIndex
:
'
endTime
'
,
dataIndex
:
'
endTime
'
,
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment