ny
昨天 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<script lang="ts">
import type { PropType } from 'vue';
 
import type { ColumnChangeParam, TableSetting } from '../types/table';
 
import { defineComponent } from 'vue';
 
import { Space } from 'ant-design-vue';
 
import TableSettingComponent from './settings/index.vue';
import TableTitle from './TableTitle.vue';
 
export default defineComponent({
  components: {
    ASpace: Space,
    TableSetting: TableSettingComponent,
    TableTitle,
  },
  emits: ['columnsChange'],
  inheritAttrs: false,
  name: 'BasicTableHeader',
  props: {
    showTableSetting: {
      type: Boolean,
    },
    tableSetting: {
      type: Object as PropType<TableSetting>,
    },
    title: {
      type: [Function, String] as PropType<((data: Recordable) => string) | string>,
    },
    titleHelpMessage: {
      default: '',
      type: [String, Array] as PropType<string | string[]>,
    },
  },
  setup(_, { emit }) {
    const prefixCls = 'jnpf-vxe-table-header';
    function handleColumnChange(data: ColumnChangeParam[]) {
      emit('columnsChange', data);
    }
    return { handleColumnChange, prefixCls };
  },
});
</script>
<template>
  <div class="flex-shrink-0">
    <div v-if="$slots.headerTop" class="m-[5px]">
      <slot name="headerTop"></slot>
    </div>
    <div :class="prefixCls" class="flex items-center">
      <div v-if="$slots.tableTitle" :class="`${prefixCls}__action`">
        <ASpace :size="10">
          <slot name="tableTitle"></slot>
        </ASpace>
      </div>
      <TableTitle v-if="!$slots.tableTitle && title" :help-message="titleHelpMessage" :title="title" />
      <div :class="`${prefixCls}__toolbar`">
        <slot name="toolbar"></slot>
        <TableSetting v-if="showTableSetting" :setting="tableSetting" @columns-change="handleColumnChange" />
        <div class="table-settings">
          <slot name="toolbarAfter"></slot>
        </div>
      </div>
    </div>
  </div>
</template>
<style lang="scss">
.jnpf-vxe-table-header {
  height: 60px;
  padding: 0 10px;
 
  &__toolbar {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: flex-end;
 
    svg {
      width: 1.3em;
      height: 1.3em;
      cursor: pointer;
    }
  }
 
  &__action {
    display: flex;
    align-items: center;
 
    .ant-btn + .ant-btn {
      margin-left: 10px;
    }
 
    .ant-btn-link {
      padding: 4px 0;
    }
  }
}
</style>