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
6f845b53
Commit
6f845b53
authored
Jun 30, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(table): selection-change not triggered on row click
修复selection-change事件在点击行来改变勾选时不会被触发的问题
parent
d509e897
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
useRowSelection.ts
src/components/Table/src/hooks/useRowSelection.ts
+19
-8
No files found.
src/components/Table/src/hooks/useRowSelection.ts
View file @
6f845b53
import
{
isFunction
}
from
'
/@/utils/is
'
;
import
type
{
BasicTableProps
,
TableRowSelection
}
from
'
../types/table
'
;
import
{
computed
,
ref
,
unref
,
ComputedRef
,
Ref
,
toRaw
,
watch
}
from
'
vue
'
;
import
{
computed
,
ref
,
unref
,
ComputedRef
,
Ref
,
toRaw
,
watch
,
nextTick
}
from
'
vue
'
;
import
{
ROW_KEY
}
from
'
../const
'
;
import
{
omit
}
from
'
lodash-es
'
;
...
...
@@ -24,12 +24,6 @@ export function useRowSelection(
onChange
:
(
selectedRowKeys
:
string
[],
selectedRows
:
Recordable
[])
=>
{
selectedRowKeysRef
.
value
=
selectedRowKeys
;
selectedRowRef
.
value
=
selectedRows
;
const
{
onChange
}
=
rowSelection
;
if
(
onChange
&&
isFunction
(
onChange
))
onChange
(
selectedRowKeys
,
selectedRows
);
emit
(
'
selection-change
'
,
{
keys
:
selectedRowKeys
,
rows
:
selectedRows
,
});
},
...
omit
(
rowSelection
===
undefined
?
{}
:
rowSelection
,
[
'
onChange
'
]),
};
...
...
@@ -38,7 +32,24 @@ export function useRowSelection(
watch
(
()
=>
unref
(
propsRef
).
rowSelection
?.
selectedRowKeys
,
(
v
:
string
[])
=>
{
selectedRowKeysRef
.
value
=
v
;
setSelectedRowKeys
(
v
);
}
);
watch
(
()
=>
unref
(
selectedRowKeysRef
),
()
=>
{
nextTick
(()
=>
{
const
{
rowSelection
}
=
unref
(
propsRef
);
if
(
rowSelection
)
{
const
{
onChange
}
=
rowSelection
;
if
(
onChange
&&
isFunction
(
onChange
))
onChange
(
getSelectRowKeys
(),
getSelectRows
());
}
emit
(
'
selection-change
'
,
{
keys
:
getSelectRowKeys
(),
rows
:
getSelectRows
(),
});
});
}
);
...
...
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