<template>
    <div class="btn-list">
        <a-button :class="item.className" v-for="item in buttons" :key="item.code" @click.stop="onClick(item)">
            {{ item.lable }}
        </a-button>
    </div>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import { BtnListType } from './interface';

export default defineComponent({
    name: 'MtpTableButton',
    emits: ['click'],
    props: {
        buttons: {
            type: Array as PropType<BtnListType[]>,
            default: [],
        },
        record: {
            type: Object,
            default: {},
        },
    },
    setup(props, context) {
        // 调用父级点击事件
        const onClick = (item: BtnListType) => {
            context.emit('click', item, props.record);
        };

        return {
            onClick,
        };
    },
});
</script>