<template>
    <div>
        <el-popconfirm confirm-button-text='确认' cancel-button-text='取消' icon="el-icon-info" icon-color="red"
            title="确认删除当前数据？" @confirm="deleteRow(rowIndex)">
            <el-button v-if="fillType === 'preFill'" slot="reference" type="text" size="small" class="delete-button">
                删除
            </el-button>
            
        </el-popconfirm>
        <template v-if="fillType === 'actFill'">
            <el-button  type="text" size="small" @click = "onSubPackage">分装</el-button>
            <el-button  type="text" size="small" @click = "onStartConfig">开始配置</el-button>
            <el-button  type="text" size="small" @click = "onConfigComplete">配置完成</el-button>
            <el-button  type="text" size="small" @click = "onPrintLabel">打印标签</el-button>
        </template>
    </div>
</template>

<script>
export default {
    name: "TableOpertaion",
    props: {
        row: {
            type: Object,
            default: () => { },
        },
        rowIndex: {
            type: Number,
            default: 0,
        },
        fillType: {
            type: String,
            default: "preFill",
        },
    },
    methods: {
        // 开始配置
        onStartConfig() {
            this.$emit("startConfig", this.row)
        },
        // 配置完成
        onConfigComplete() {
            this.$emit("configComplete", this.row)
        },
        // 打印标签
        onPrintLabel() {
            this.$emit("printLabel", this.row)
        },
        // 分装
        onSubPackage() {
            this.$emit("subPackage", this.row)
        },
        // 删除行
        deleteRow(index) {
            this.$emit("deleteRow", index)
        }
    }
}
</script>

<style lang="scss" scoped>
.delete-button{
  color: red;
}
</style>