🐛(component): 修复文档缺陷

This commit is contained in:
就眠儀式
2022-09-15 02:12:11 +08:00
parent 72fab7c9a5
commit 9e52d2401a
4 changed files with 257 additions and 33 deletions

View File

@@ -35,7 +35,7 @@ const props = withDefaults(defineProps<LayTransferProps>(), {
height: "360px",
});
const emits = defineEmits(['update:modelValue','change'])
const emits = defineEmits(["update:modelValue", "change"]);
const leftDataSource: Ref<any[]> = ref([...props.dataSource]);
const rightDataSource: Ref<any[]> = ref([]);
@@ -62,28 +62,30 @@ const allLeftChange = (isChecked: boolean) => {
}
};
watch(() => props.modelValue, () => {
watch(
() => props.modelValue,
() => {
let targetDataSource: any[] = [];
let targetDataSource: any[] = [];
props.dataSource.forEach((ds) => {
if (props.modelValue.includes(ds[props.id])) {
targetDataSource.push(ds);
}
});
props.dataSource.forEach(ds => {
if(props.modelValue.includes(ds[props.id])) {
targetDataSource.push(ds);
}
})
leftDataSource.value = props.dataSource.filter(
(item) => !props.modelValue.includes(item[props.id])
);
leftDataSource.value = props.dataSource.filter(
(item) => !props.modelValue.includes(item[props.id])
);
_leftDataSource.value = props.dataSource.filter(
(item) => !props.modelValue.includes(item[props.id])
);
_leftDataSource.value = props.dataSource.filter(
(item) => !props.modelValue.includes(item[props.id])
);
rightDataSource.value = [...targetDataSource];
_rightDataSource.value = [...targetDataSource];
}, {immediate: true})
rightDataSource.value = [...targetDataSource];
_rightDataSource.value = [...targetDataSource];
},
{ immediate: true }
);
watch(
leftSelectedKeys,
@@ -143,7 +145,6 @@ watch(
);
const add = () => {
if (leftSelectedKeys.value.length === 0) {
return;
}
@@ -158,10 +159,10 @@ const add = () => {
rightDataSource.value.forEach((item) => {
targetKeys.push(item[props.id]);
})
});
emits("change", targetKeys)
emits("update:modelValue", targetKeys)
emits("change", targetKeys);
emits("update:modelValue", targetKeys);
leftSelectedKeys.value = [];
};
@@ -179,8 +180,8 @@ const remove = () => {
}
});
emits("change", targetKeys)
emits("update:modelValue", targetKeys)
emits("change", targetKeys);
emits("update:modelValue", targetKeys);
rightSelectedKeys.value = [];
};