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
df0f0008
Commit
df0f0008
authored
Jun 29, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(table): fix rowSelection.onChange not work
修复为table提供rowSelection.onChange时,无法手动变更table的选中项的问题 fixed: #825
parent
99829c79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
useRowSelection.ts
src/components/Table/src/hooks/useRowSelection.ts
+13
-2
No files found.
src/components/Table/src/hooks/useRowSelection.ts
View file @
df0f0008
import
{
isFunction
}
from
'
/@/utils/is
'
;
import
type
{
BasicTableProps
,
TableRowSelection
}
from
'
../types/table
'
;
import
{
computed
,
ref
,
unref
,
ComputedRef
,
Ref
,
toRaw
}
from
'
vue
'
;
import
{
computed
,
ref
,
unref
,
ComputedRef
,
Ref
,
toRaw
,
watch
}
from
'
vue
'
;
import
{
ROW_KEY
}
from
'
../const
'
;
import
{
omit
}
from
'
lodash-es
'
;
export
function
useRowSelection
(
propsRef
:
ComputedRef
<
BasicTableProps
>
,
...
...
@@ -22,15 +24,24 @@ 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
,
});
},
...
(
rowSelection
===
undefined
?
{}
:
rowSelection
),
...
omit
(
rowSelection
===
undefined
?
{}
:
rowSelection
,
[
'
onChange
'
]
),
};
});
watch
(
()
=>
unref
(
propsRef
).
rowSelection
?.
selectedRowKeys
,
(
v
:
string
[])
=>
{
selectedRowKeysRef
.
value
=
v
;
}
);
const
getAutoCreateKey
=
computed
(()
=>
{
return
unref
(
propsRef
).
autoCreateKey
&&
!
unref
(
propsRef
).
rowKey
;
});
...
...
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