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
6095cb54
Commit
6095cb54
authored
Mar 10, 2021
by
Vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(table): ensure that the height calculation is normal close #349
parent
2c6aa852
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
useTableScroll.ts
src/components/Table/src/hooks/useTableScroll.ts
+16
-14
No files found.
src/components/Table/src/hooks/useTableScroll.ts
View file @
6095cb54
...
@@ -23,7 +23,7 @@ export function useTableScroll(
...
@@ -23,7 +23,7 @@ export function useTableScroll(
const
modalFn
=
useModalContext
();
const
modalFn
=
useModalContext
();
// Greater than animation time 280
// Greater than animation time 280
const
[
debounceRedoHeight
]
=
useDebounce
(
redoHeight
,
2
00
);
const
[
debounceRedoHeight
]
=
useDebounce
(
redoHeight
,
1
00
);
const
getCanResize
=
computed
(()
=>
{
const
getCanResize
=
computed
(()
=>
{
const
{
canResize
,
scroll
}
=
unref
(
propsRef
);
const
{
canResize
,
scroll
}
=
unref
(
propsRef
);
...
@@ -41,11 +41,9 @@ export function useTableScroll(
...
@@ -41,11 +41,9 @@ export function useTableScroll(
);
);
function
redoHeight
()
{
function
redoHeight
()
{
if
(
unref
(
getCanResize
))
{
nextTick
(()
=>
{
nextTick
(()
=>
{
calcTableHeight
();
calcTableHeight
();
});
});
}
}
}
function
setHeight
(
heigh
:
number
)
{
function
setHeight
(
heigh
:
number
)
{
...
@@ -63,15 +61,23 @@ export function useTableScroll(
...
@@ -63,15 +61,23 @@ export function useTableScroll(
const
{
resizeHeightOffset
,
pagination
,
maxHeight
}
=
unref
(
propsRef
);
const
{
resizeHeightOffset
,
pagination
,
maxHeight
}
=
unref
(
propsRef
);
const
tableData
=
unref
(
getDataSourceRef
);
const
tableData
=
unref
(
getDataSourceRef
);
if
(
!
unref
(
getCanResize
)
||
tableData
.
length
===
0
)
return
;
await
nextTick
();
//Add a delay to get the correct bottomIncludeBody paginationHeight footerHeight headerHeight
const
table
=
unref
(
tableElRef
);
const
table
=
unref
(
tableElRef
);
if
(
!
table
)
return
;
if
(
!
table
)
return
;
const
tableEl
:
Element
=
table
.
$el
;
const
tableEl
:
Element
=
table
.
$el
;
if
(
!
tableEl
)
return
;
if
(
!
tableEl
)
return
;
if
(
!
bodyEl
)
{
bodyEl
=
tableEl
.
querySelector
(
'
.ant-table-body
'
);
}
bodyEl
!
.
style
.
height
=
'
unset
'
;
if
(
!
unref
(
getCanResize
)
||
tableData
.
length
===
0
)
return
;
await
nextTick
();
//Add a delay to get the correct bottomIncludeBody paginationHeight footerHeight headerHeight
const
headEl
=
tableEl
.
querySelector
(
'
.ant-table-thead
'
);
const
headEl
=
tableEl
.
querySelector
(
'
.ant-table-thead
'
);
if
(
!
headEl
)
return
;
if
(
!
headEl
)
return
;
...
@@ -124,10 +130,6 @@ export function useTableScroll(
...
@@ -124,10 +130,6 @@ export function useTableScroll(
height
=
(
height
>
maxHeight
!
?
(
maxHeight
as
number
)
:
height
)
??
height
;
height
=
(
height
>
maxHeight
!
?
(
maxHeight
as
number
)
:
height
)
??
height
;
setHeight
(
height
);
setHeight
(
height
);
if
(
!
bodyEl
)
{
bodyEl
=
tableEl
.
querySelector
(
'
.ant-table-body
'
);
}
bodyEl
!
.
style
.
height
=
`
${
height
}
px`
;
bodyEl
!
.
style
.
height
=
`
${
height
}
px`
;
}
}
useWindowSizeFn
(
calcTableHeight
,
280
);
useWindowSizeFn
(
calcTableHeight
,
280
);
...
...
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