8 changed files with 102 additions and 2 deletions
@ -0,0 +1,36 @@ |
|||
<template> |
|||
<Alert :class="prefixCls" type="info" :message="message"> |
|||
<template #closeText> |
|||
<Button type="link" @click="handleDeSelect">{{ t('component.table.deSelected') }}</Button> |
|||
</template> |
|||
</Alert> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import { Alert, Button } from 'ant-design-vue'; |
|||
import { useDesign } from '/@/hooks/web/useDesign'; |
|||
import { useI18n } from '/@/hooks/web/useI18n'; |
|||
|
|||
defineProps({ |
|||
message: { |
|||
type: String, |
|||
default: '', |
|||
}, |
|||
}); |
|||
const emits = defineEmits(['onDeSelect']); |
|||
|
|||
const { t } = useI18n(); |
|||
const { prefixCls } = useDesign('basic-table-alert'); |
|||
|
|||
function handleDeSelect() { |
|||
emits('onDeSelect'); |
|||
} |
|||
</script> |
|||
|
|||
<style lang="less"> |
|||
@prefix-cls: ~'@{namespace}-basic-table-alert'; |
|||
|
|||
.@{prefix-cls} { |
|||
margin: 6px 0 3px 0; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,33 @@ |
|||
import type { ComputedRef } from 'vue'; |
|||
import type { BasicTableProps } from '../types/table'; |
|||
|
|||
import { computed, unref } from 'vue'; |
|||
import {} from '/@/hooks/web/useI18n'; |
|||
import { useI18n } from 'vue-i18n'; |
|||
|
|||
export function useTableAlert( |
|||
propsRef: ComputedRef<BasicTableProps>, |
|||
getSelectRowKeys: () => string[] |
|||
) { |
|||
const { t } = useI18n(); |
|||
|
|||
const getAlertEnabled = computed(() => { |
|||
const props = unref(propsRef); |
|||
if (!props.useSelectedAlert) { |
|||
return false; |
|||
} |
|||
const selectedKeys = getSelectRowKeys(); |
|||
return selectedKeys.length > 0; |
|||
}); |
|||
|
|||
const getAlertMessage = computed(() => { |
|||
const selectedKeys = getSelectRowKeys(); |
|||
console.log(selectedKeys); |
|||
return t('component.table.selectedRows', { count: selectedKeys.length }); |
|||
}); |
|||
|
|||
return { |
|||
getAlertEnabled, |
|||
getAlertMessage, |
|||
}; |
|||
} |
|||
Loading…
Reference in new issue