|
|
|
@ -1,5 +1,5 @@ |
|
|
|
import type { ComputedRef } from 'vue'; |
|
|
|
import type { BasicTableProps } from '../types/table'; |
|
|
|
import type { BasicTableProps, TableRowSelection } from '../types/table'; |
|
|
|
|
|
|
|
import { computed, unref } from 'vue'; |
|
|
|
import {} from '/@/hooks/web/useI18n'; |
|
|
|
@ -7,23 +7,29 @@ import { useI18n } from 'vue-i18n'; |
|
|
|
|
|
|
|
export function useTableAlert( |
|
|
|
propsRef: ComputedRef<BasicTableProps>, |
|
|
|
getSelectRowKeys: () => string[] |
|
|
|
rowSelectionRef: ComputedRef<TableRowSelection | null>, |
|
|
|
) { |
|
|
|
const { t } = useI18n(); |
|
|
|
|
|
|
|
const getSelectRowKeysCount = computed(() => { |
|
|
|
const rowSelection = unref(rowSelectionRef); |
|
|
|
if (!rowSelection?.selectedRowKeys) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
return rowSelection.selectedRowKeys.length; |
|
|
|
}); |
|
|
|
|
|
|
|
const getAlertEnabled = computed(() => { |
|
|
|
const props = unref(propsRef); |
|
|
|
if (!props.useSelectedAlert) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
const selectedKeys = getSelectRowKeys(); |
|
|
|
return selectedKeys.length > 0; |
|
|
|
|
|
|
|
return unref(getSelectRowKeysCount) > 0; |
|
|
|
}); |
|
|
|
|
|
|
|
const getAlertMessage = computed(() => { |
|
|
|
const selectedKeys = getSelectRowKeys(); |
|
|
|
console.log(selectedKeys); |
|
|
|
return t('component.table.selectedRows', { count: selectedKeys.length }); |
|
|
|
return t('component.table.selectedRows', { count: unref(getSelectRowKeysCount) }); |
|
|
|
}); |
|
|
|
|
|
|
|
return { |
|
|
|
|