<template>
    <scTable ref="table" :data="dataList" row-key="id" @selection-change="selectionChange" stripe :paginationLayout="'prev, pager, next'">
        <el-table-column type="selection" width="50"></el-table-column>
        <el-table-column label="名称" prop="name" width="150"></el-table-column>
        <el-table-column label="键值" prop="code" width="150"></el-table-column>
        <el-table-column label="操作" fixed="right" align="right" width="120">
            <template #default="scope">
                <el-button-group>
                    <el-popconfirm title="确定删除吗？" @confirm="table_del(scope.row, scope.$index)">
                        <template #reference>
                            <el-button text type="primary" size="small">删除</el-button>
                        </template>
                    </el-popconfirm>
                </el-button-group>
            </template>
        </el-table-column>
    </scTable>
</template>

<script>
export default {
    props: {
        dataList: { type: Object, default: () => [] },
        parent: { type: Object, default: () => {} }
    },
    methods: {
        //删除明细
        async table_del(row, index){
            var reqData = {id: this.parent.id,key:index}
            var resp = await this.$API.dic.subDel.post(reqData);
            if (resp.code == 0) {
                return this.$message.error(resp.msg);
            }
            this.$message.success(resp.msg);
            this.$emit("success");
        },
    }
}
</script>