cmc-web/packages/common/hooks/useSelection.js

22 lines
539 B
JavaScript
Raw Permalink Normal View History

2024-08-20 12:11:31 +00:00
/*
* @Author: Haijun Zhang
* @Date: 2022-11-03 15:41:09
* @LastEditTime: 2022-12-08 15:37:40
* @LastEditors: Haijun Zhang
2024-08-21 01:17:14 +00:00
* @Description:
2024-08-20 12:11:31 +00:00
* @FilePath: \cmc-web\packages\common\hooks\useSelection.js
*/
import { ref, computed } from 'vue'
2024-08-21 01:17:14 +00:00
export default function () {
2024-08-20 12:11:31 +00:00
const selections = ref([])
function handleSelectionChange(selection) {
selections.value = selection
}
2024-08-21 01:17:14 +00:00
const selectionIds = computed(() => selections.value.map(item => item.id))
2024-08-20 12:11:31 +00:00
return {
selectionIds,
selections,
handleSelectionChange
}
}