Ben Lin
2024-07-18 7cf58a4d2fff6b9cba9029d4d43ba9744dbef864
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<template>
  <a-alert type="info" showIcon :class="[prefixCls]">
    <template #message>
      <span v-if="props.count > 0">
        {{ t('component.table.selectionBarTips', { count: props.count }) }}
      </span>
      <span v-else>
        {{ t('component.table.selectionBarEmpty') }}
      </span>
      <a-button type="link" @click="clearSelectedRowKeys" size="small" v-show="props.count > 0">
        {{ t('component.table.selectionBarClear') }}
      </a-button>
    </template>
  </a-alert>
</template>
 
<script lang="ts" setup>
  import { useI18n } from '@/hooks/web/useI18n';
  import { useDesign } from '@/hooks/web/useDesign';
 
  import type { TableActionType } from '../types/table';
  import { Alert as AAlert } from 'ant-design-vue';
 
  const { t } = useI18n();
 
  const { prefixCls } = useDesign('table-select-bar');
 
  defineOptions({
    name: 'TableSelectBar',
  });
 
  const props = withDefaults(
    defineProps<{
      count?: number;
      //
      clearSelectedRowKeys: TableActionType['clearSelectedRowKeys'];
    }>(),
    {
      count: () => 0,
    },
  );
</script>
 
<style lang="less" scoped>
  @prefix-cls: ~'@{namespace}-table-select-bar';
 
  .@{prefix-cls} {
    flex-grow: 1;
    padding: 2px 8px;
 
    :deep(.ant-btn-link) {
      height: 20px;
      line-height: 20px;
    }
  }
</style>