<template>
  <div class="table-actions">
    <el-button v-if="showEdit" type="primary" link size="small" @click="$emit('edit')"> 编辑 </el-button>
    <el-button v-if="showDelete" type="danger" link size="small" @click="$emit('delete')"> 删除 </el-button>
    <el-button v-if="showView" type="primary" link size="small" @click="$emit('view')"> 查看 </el-button>
    <slot></slot>
  </div>
</template>

<script setup lang="ts">
withDefaults(
  defineProps<{
    showEdit?: boolean;
    showDelete?: boolean;
    showView?: boolean;
  }>(),
  {
    showEdit: true,
    showDelete: true,
    showView: false
  }
);

defineEmits<{
  edit: [];
  delete: [];
  view: [];
}>();
</script>

<style scoped lang="scss">
.table-actions {
  display: inline-flex;
  gap: 4px;
}
</style>
