UNPKG

super-ui-plus

Version:

Page level components developed based on Element Plus.

25 lines (22 loc) 607 B
import { ref, computed } from 'vue'; const useSelection = (rowKey = "id", emit) => { const isSelected = ref(false); const selectedList = ref([]); const selectedListIds = computed(() => { let ids = []; selectedList.value.forEach((item) => ids.push(item[rowKey])); return ids; }); const selectionChange = (rowArr) => { rowArr.length ? isSelected.value = true : isSelected.value = false; selectedList.value = rowArr; emit("selectionChange", rowArr); }; return { isSelected, selectedList, selectedListIds, selectionChange }; }; export { useSelection };