<template>
  <div class="container">
    <div class="search-ctn">
        <searchs></searchs>
    </div>
    <folder-list
        v-for="(folderListItem, folderListIndex) of currentList"
        :key="folderListIndex"
        :list="folderListItem.list"
        :list-title="folderListItem.listTitle"
        @folderClick="intoFolder">
    </folder-list>
  </div>
</template>

<script>
export default {
    name: 'SchoolResources',
    components: {
        Searchs: () => import('./../myResources/components/Searchs'),
        FolderList: () => import('./../myResources/components/FolderList')
    },
    data () {
        return {
            currentList: {},
            listData: {
                firstLevel: [
                    {
                        list: [
                            {
                                title: '教案文件夹',
                                descript: '常规文件夹 共10个文档',
                                isFolder: true,
                                nextIsFolder: true,
                                folderData: 'secondLevel'
                            },
                            {
                                title: '方案文件夹',
                                descript: '常规文件夹 共10个文档',
                                isFolder: true,
                                nextIsFolder: true,
                                folderData: 'secondLevel'
                            },
                            {
                                title: '总结',
                                descript: '任务文件夹 共10个文档',
                                isFolder: true,
                                nextIsFolder: true,
                                folderData: 'secondLevel'
                            }
                        ]
                    }
                ]
            }

        }
    },
    methods: {
        intoFolder (item) {
            /* 点击文件夹进入下一级 */
            if (item.isFolder) {
                let routerName
                let routerPath
                if (item.nextIsFolder) {
                    routerPath = '/education/schoolResources/folderLevel'
                    routerName = 'schoolFolderLevel'
                } else {
                    routerPath = '/education/schoolResources/fileLevel'
                    routerName = 'schoolFileLevel'
                }
                this.$router.push({
                    name: routerName,
                    path: routerPath,
                    query: {
                        folder: item.folderData,
                        title: item.title
                    }
                })
            }
        }
    },
    mounted () {
        this.currentList = this.listData.firstLevel
    }
}
</script>

<style lang="less" scoped>
.container {
    .search-ctn {
        padding: 20px 15px 10px 15px;
    }
}
</style>
