<template>
    <div>
        <div class="traBox">
            <span style="line-height:20px;text-align:center;">
                <img style="width: 20px;height: 20px;" src="../../../assets/icon/pice_set.png" alt="">
                一次接线方式</span>
            <el-tree style="width: 120px;margin: 0 auto;background-color: #F7F8FB;" :data="lineData" :props="defaultProps"
                @node-click="handleNodeClick" />
        </div>
    </div>
</template>

<script>
import { ref, onMounted, toRefs } from 'vue'
import litLine from '@/api/litLine'
import systemRow from '@/api/systemRow';
import LitLine from './LitLine.vue';
export default {
    setup(props, { emit }) {
        let lineData = ref([])//树形数据
        let defaultProps = ref({
            children: "children",
            label: "name",
            id: 'id'
        })
        let pushList = ref([])
        function searchLine() {
            litLine.getLineModel({ pageno: 1, pagesize: 10 }).then(res => {
                console.log(res, '987res');
            })
        }
        function searchFlashLel() {//拿到电压等级
            systemRow.getChildren({ code: "voltage_level" }).then(res => {
                lineData.value = res.data
            })
        }
        function handleNodeClick(e) {
            litLine.getAllLine({ vol_id: e.id - 0 }).then(res => {
                pushList.value = res.data
                emit("listBack", pushList.value)
            })
        }
        onMounted(() => {
            searchLine()
            searchFlashLel()
        })
        return {
            lineData,//树形数据
            searchLine,//获取数据
            defaultProps,
            searchFlashLel,
            handleNodeClick,
            pushList,
        }
    },
    components: {
        LitLine
    }
}
</script>

<style scoped>
.traBox {
    text-align: center;
}
</style>