66 lines
1.4 KiB
Vue
66 lines
1.4 KiB
Vue
<template>
|
|
<el-dropdown
|
|
trigger="click"
|
|
split-button
|
|
size="small"
|
|
:disabled="disabled || loading"
|
|
@click="emit('action', defaultAction)"
|
|
@command="emit('action', $event)"
|
|
>
|
|
{{ label }}
|
|
<template #dropdown>
|
|
<el-dropdown-menu>
|
|
<el-dropdown-item
|
|
v-for="item in resolvedItems"
|
|
:key="item.action"
|
|
:command="item.action"
|
|
:divided="item.divided"
|
|
>
|
|
{{ item.label }}
|
|
</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</el-dropdown>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
|
|
export interface ExportDropdownItem {
|
|
label: string
|
|
action: string
|
|
divided?: boolean
|
|
}
|
|
|
|
const DEFAULT_ITEMS: ExportDropdownItem[] = [
|
|
{ label: '不含明细', action: 'handleExportWaybill' },
|
|
{ label: '含明细', action: 'handleExportItem', divided: true }
|
|
]
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
label?: string
|
|
loading?: boolean
|
|
disabled?: boolean
|
|
defaultAction?: string
|
|
items?: ExportDropdownItem[]
|
|
}>(),
|
|
{
|
|
label: '导出',
|
|
loading: false,
|
|
disabled: false,
|
|
defaultAction: 'handleExportWaybill',
|
|
items: () => []
|
|
}
|
|
)
|
|
|
|
const resolvedItems = computed(() => {
|
|
if (props.items && props.items.length > 0) return props.items
|
|
return DEFAULT_ITEMS
|
|
})
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'action', action: string): void
|
|
}>()
|
|
</script>
|