<template>
    <el-table :data="tableData2" highlight-current-row :height="height" @current-change="handleCurrentChange"
        ref="singleTableRef">
        <el-table-column label="已有脚本">
            <template #default="scope">
                <el-button type="warning" round>{{ scope.row.scriptName}}</el-button>
            </template>
        </el-table-column>
        <el-table-column align="right">
            <template #default="scope">
                <el-button type="primary">编辑</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
    import {
        read
    } from "@/api/report";

    export default {
        props: {
            height: {
                type: String,
                default: () => {
                    return '';
                },
            },
        },
        data() {
            return {
                tableData2: [],
                childCurrentRow: {},

            }
        },
        mounted() {
            this.getData()
        },
        methods: {
            getData() {
                read().then(res => {
                    console.log("res:", res.data)
                    this.$emit("getExistingData", res.data)
                    this.tableData2 = res.data
                });
            },
            handleCurrentChange(val) {
                this.$emit("getExistingData", val)
                this.childCurrentRow = val;
                //清除父组件的行选择
                this.tableRow()
                this.setTableRow(val)
            },
            setTableRow(row) {
                this.$refs.singleTableRef.setCurrentRow(row)
            },
            tableRow() {

            }
        }
    }
</script>



<style scoped lang="less">

</style>