import {approveInterence} from '@/api/modules/approve.js'
const filterNodes = (arr,hasDisabled)=>{
    arr.length &&arr.forEach((item) => {
        hasDisabled&&(item.disabled = item.HasFlow)
        item.Children.length && filterNodes(item.Children,hasDisabled);
        if (!item.Children.length) {
            delete item.Children;
        }
    })
}

export default{
    data(){
        return {
            classifyTree:[],
        }
    },
    methods:{
        getClassifyTree(){
            approveInterence.getReportClassifyTree().then(res=>{
                if(res.Ret!==200) return 
                this.classifyTree = res.Data||[]
                const hasDisabled = window.location.pathname.startsWith('/approveEdit')
                filterNodes(this.classifyTree,hasDisabled)
                if(this.getFlowDetail){
                    this.getFlowDetail()
                }
            })
        },
    }
}