广丰卷烟厂数采质量分析系统
zhuguifei
2026-03-02 80ff784bf60637cd348ae665fc907f7b1e527dd8
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
<script setup lang="ts">
import { $t } from '@/locales';
 
defineOptions({
  name: 'TableHeaderOperation'
});
 
interface Props {
  itemAlign?: NaiveUI.Align;
  disabledDelete?: boolean;
  disableAdd?: boolean;
  loading?: boolean;
  showAdd?: boolean;
  showDelete?: boolean;
  showExport?: boolean;
  showRefresh?: boolean;
}
 
withDefaults(defineProps<Props>(), {
  itemAlign: undefined,
  showAdd: true,
  showDelete: true,
  showExport: false,
  showRefresh: true
});
 
interface Emits {
  (e: 'add'): void;
  (e: 'delete'): void;
  (e: 'refresh'): void;
  (e: 'export'): void;
}
 
const emit = defineEmits<Emits>();
 
const columns = defineModel<NaiveUI.TableColumnCheck[]>('columns', {
  default: () => []
});
 
function add() {
  emit('add');
}
 
function batchDelete() {
  emit('delete');
}
 
function refresh() {
  emit('refresh');
}
 
function handleExport() {
  emit('export');
}
</script>
 
<template>
  <NSpace :align="itemAlign" wrap justify="end" class="lt-sm:w-200px">
    <slot name="prefix"></slot>
    <slot name="default">
      <NButton v-if="showAdd" :disabled="disableAdd" size="small" ghost type="primary" @click="add">
        <template #icon>
          <icon-material-symbols-add class="text-icon" />
        </template>
        {{ $t('common.add') }}
      </NButton>
      <NPopconfirm v-if="showDelete" @positive-click="batchDelete">
        <template #trigger>
          <NButton size="small" ghost type="error" :disabled="disabledDelete">
            <template #icon>
              <icon-material-symbols-delete-outline class="text-icon" />
            </template>
            {{ $t('common.batchDelete') }}
          </NButton>
        </template>
        {{ $t('common.confirmDelete') }}
      </NPopconfirm>
      <NButton v-if="showExport" size="small" ghost @click="handleExport">
        <template #icon>
          <icon-material-symbols-download-rounded class="text-icon" />
        </template>
        {{ $t('common.export') }}
      </NButton>
    </slot>
    <slot name="after"></slot>
    <NButton v-if="showRefresh" size="small" @click="refresh">
      <template #icon>
        <icon-material-symbols-refresh-rounded class="text-icon" :class="{ 'animate-spin': loading }" />
      </template>
      {{ $t('common.refresh') }}
    </NButton>
    <TableColumnSetting v-model:columns="columns" />
    <slot name="suffix"></slot>
  </NSpace>
</template>
 
<style scoped></style>