import {TagInterface,ClassifyInterface} from '@/api/modules/trainingApi'
export default{
    data() {
        return {
            tagList:[],
            classifyList:[],
        }
    },
    methods: {
        //获取分类列表
        getClassifyList(type=''){
            ClassifyInterface.getClassifyList({}).then(res=>{
                if(res.Ret!==200) return 
                this.classifyList = res.Data&&res.Data.List||[]
                this.filterNodes(this.classifyList)
                this.classifyList = this.classifyList.map(item=>{
                    if(!item.Children){
                        item.disabled = true
                    }
                    return item
                })
            })
        },
        filterNodes(arr) {
            arr.length && arr.forEach(item => {
                item.Children && item.Children.length && this.filterNodes(item.Children)
                if(item.Children && !item.Children.length) {
                    delete item.Children
                }
            })
        },
        //获取标签列表
        getTagList(keyword=''){
            TagInterface.getTagList({
                Keyword:keyword,
                PageSize:1000,
                CurrentIndex:1
            }).then(res=>{
                if(res.Ret!==200) return 
                this.tagList = res.Data&&res.Data.List||[]
            })
        }
    }
}