ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script lang="ts">
import type { PropType } from 'vue';
 
import { computed, defineComponent } from 'vue';
 
import { BasicTitle } from '@jnpf/ui';
import { isFunction } from '@jnpf/utils';
 
export default defineComponent({
  components: { BasicTitle },
  name: 'BasicTableTitle',
  props: {
    getSelectRows: {
      type: Function as PropType<() => Recordable[]>,
    },
    helpMessage: {
      type: [String, Array] as PropType<string | string[]>,
    },
    title: {
      type: [Function, String] as PropType<((data: Recordable) => string) | string>,
    },
  },
  setup(props) {
    const prefixCls = 'jnpf-basic-table-title';
 
    const getTitle = computed(() => {
      const { getSelectRows = () => {}, title } = props;
      let tit = title;
 
      if (isFunction(title)) {
        tit = title({
          selectRows: getSelectRows(),
        });
      }
      return tit;
    });
 
    return { getTitle, prefixCls };
  },
});
</script>
<template>
  <BasicTitle v-if="getTitle" :class="prefixCls" :help-message="helpMessage">
    {{ getTitle }}
  </BasicTitle>
</template>
<style lang="scss">
.jnpf-basic-table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
</style>