<template>
    <el-tree
        ref="ElTreeRef" v-loaing="treeLoaing"
        :class="ui"
        :data="ElTreeData"
        :indent="0"
        :props="ElTreeProps"
        accordion
        class="hc-tree-node tree-line"
        highlight-current
        node-key="id"
        show-checkbox
    >
        <template #default="{ node, data }">
            <div :id="`'entry-sampling-'${data.id}`" class="data-custom-tree-node">
                <div class="label">
                    <span> {{ data.nodeName }}</span>
                    <span v-if="data.nodeInfo" class="text-orange text-sm">（该目录已分属XX专家，如需调整，请联系该专家进行转让）</span>
                </div>
            </div>
        </template>
    </el-tree>
</template>

<script setup>
import { onMounted, ref } from 'vue'
//import dataFillQuery from '~api/data-fill/query';
import { getArrValue, getObjValue } from 'js-fast-way'
import initialgApi from '~api/initial/initial'

//参数
const props = defineProps({
    ui: {
        type: String,
        default: '',
    },
    projectId: {
        type: [String, Number],
        default: '',
    },
    contractId: {
        type: [String, Number],
        default: '',
    },
    types:{
        type: [String, Number],
        default: '',
    },
})
const projectId = ref(props.projectId)
const types = ref(props.types)

onMounted(()=>{
    getElTreeData()
})
//变量
const ElTreeRef = ref(null)
const ElTreeProps = ref({
    children: 'children',
    label: 'nodeName',
})
const treeLoaing = ref(false)
const getElTreeData = async ()=>{
    treeLoaing.value = true
    const { error, code, data } = await initialgApi.getUnitAllNode({
        projectId: projectId.value,
        types:types.value,
    })
    treeLoaing.value = false
    if (!error && code === 200) {
        console.log(data, 'data')
        ElTreeData.value = getArrValue(data)
    } else {
        ElTreeData.value = []
     
    }
}
const ElTreeData = ref( [])
</script>

<style lang="scss" scoped>
@import "../../../../styles/app/tree.scss";
</style>
