feat(component): 完善 表格 穿梭狂 组件
This commit is contained in:
parent
5584b9886a
commit
19302af243
@ -115,7 +115,7 @@ const allLeftChange = function ({ checked }: any) {
|
|||||||
watch(
|
watch(
|
||||||
leftSelectedKeys,
|
leftSelectedKeys,
|
||||||
function () {
|
function () {
|
||||||
if (leftDataSource.value.length === leftSelectedKeys.value.length) {
|
if (leftDataSource.value.length === leftSelectedKeys.value.length && leftDataSource.value.length != 0) {
|
||||||
allLeftChecked.value = true
|
allLeftChecked.value = true
|
||||||
} else {
|
} else {
|
||||||
allLeftChecked.value = false
|
allLeftChecked.value = false
|
||||||
@ -138,7 +138,7 @@ const allRightChange = function ({ checked }: any) {
|
|||||||
watch(
|
watch(
|
||||||
rightSelectedKeys,
|
rightSelectedKeys,
|
||||||
function () {
|
function () {
|
||||||
if (rightDataSource.value.length === rightSelectedKeys.value.length) {
|
if (rightDataSource.value.length === rightSelectedKeys.value.length && rightDataSource.value.length != 0) {
|
||||||
allRightChecked.value = true
|
allRightChecked.value = true
|
||||||
} else {
|
} else {
|
||||||
allRightChecked.value = false
|
allRightChecked.value = false
|
||||||
@ -149,15 +149,30 @@ watch(
|
|||||||
|
|
||||||
const add = function () {
|
const add = function () {
|
||||||
// 删除 leftDataSource 选中的元素
|
// 删除 leftDataSource 选中的元素
|
||||||
|
if(leftSelectedKeys.value.length === 0){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
rightDataSource.value = leftDataSource.value.filter(
|
rightDataSource.value = leftDataSource.value.filter(
|
||||||
(item) => leftSelectedKeys.value.indexOf(item.id) != -1
|
(item) => leftSelectedKeys.value.indexOf(item.id) != -1
|
||||||
)
|
)
|
||||||
|
leftDataSource.value = leftDataSource.value.filter(
|
||||||
|
(item) => leftSelectedKeys.value.indexOf(item.id) === -1
|
||||||
|
)
|
||||||
|
leftSelectedKeys.value = []
|
||||||
}
|
}
|
||||||
|
|
||||||
const remove = function () {
|
const remove = function () {
|
||||||
// 删除 rightDataSource 选中的元素
|
// 删除 rightDataSource 选中的元素
|
||||||
|
if(rightSelectedKeys.value.length === 0){
|
||||||
|
return
|
||||||
|
}
|
||||||
leftDataSource.value = rightDataSource.value.filter(
|
leftDataSource.value = rightDataSource.value.filter(
|
||||||
(item) => rightSelectedKeys.value.indexOf(item.id) != -1
|
(item) => rightSelectedKeys.value.indexOf(item.id) != -1
|
||||||
)
|
)
|
||||||
|
rightDataSource.value = rightDataSource.value.filter(
|
||||||
|
(item) => rightSelectedKeys.value.indexOf(item.id) === -1
|
||||||
|
)
|
||||||
|
rightSelectedKeys.value = []
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user