useBatchOperation.ts 573 B

1234567891011121314151617181920212223
  1. import { computed } from 'vue';
  2. import { TableActionType } from '/@//components/Table';
  3. const useBatchOperation = (
  4. getRowSelection: TableActionType['getRowSelection'],
  5. setSelectedRowKeys: TableActionType['setSelectedRowKeys']
  6. ) => {
  7. const isExistOption = computed(() => {
  8. const rowSelection = getRowSelection();
  9. return !!rowSelection.selectedRowKeys?.length;
  10. });
  11. const resetSelectedOptions = () => {
  12. setSelectedRowKeys([]);
  13. };
  14. return {
  15. isExistOption,
  16. resetSelectedOptions,
  17. };
  18. };
  19. export { useBatchOperation };