<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>学科名称</title>
    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <script type="text/html" id="toolbarDemo">
            <!--            <div class="layui-btn-container">-->
            <!--                <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add">-->
            <!--                    <i class="layui-icon layui-icon-addition" style="font-size: 10px;"></i>新增-->
            <!--                </button>-->
            <!--                <button class="layui-btn layui-btn-sm data-add-btn" lay-event="delete">-->
            <!--                    <i class="layui-icon layui-icon-delete" style="font-size: 10px;"></i>删除-->
            <!--                </button>-->
            <!--            </div>-->
        </script>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <!--            <a class="layui-btn layui-btn-xs data-count-update" lay-event="update">-->
            <!--                <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>编辑-->
            <!--            </a>-->
            <!--            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delFlag">-->
            <!--                <i class="layui-icon layui-icon-delete" style="font-size: 10px;"></i>删除-->
            <!--            </a>-->
        </script>
    </div>
</div>
<script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
<script th:src="@{/lib/layui-v2.6.3/layui.js}" charset="utf-8"></script>
<script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
<script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
<script type="text/javascript" th:inline="javascript">
    AjaxUtil.ctx = /*[[@{/}]]*/'';
    layui.use(['form', 'table', 'treeTable'], function () {
        var form = layui.form,
            treeTable = layui.treeTable;
        var isShow = true;

        var insTb = treeTable.render({
            elem: '#currentTableId',
            url: AjaxUtil.ctx + 'baseSubjectname/list',
            skin: 'grid',
            tree: {
                treeColIndex: 1,
                treeSpid: "0",
                iconIndex: 0,           // 折叠图标显示在第几列
                isPidData: true,        // 是否是id、pid形式数据
                idName: 'id',  // id字段名称
                pidName: 'pid',     // pid字段名称
                arrowType: 'arrow2',
                getIcon: 'ew-tree-icon-style2'
            },
            treeDefaultClose: isShow,
            method: 'GET',
            page: false,
            toolbar: '#toolbarDemo',
            cols: [
                [
                    {field: 'name', width: '30%', title: '名称', align: 'left'},
                    {field: 'id', width: '10%', title: '编码', align: 'left'},
                    // {title: '操作', width: '15%', toolbar: '#currentTableBar', align: 'center'},
                    {title: '', width: '40%', title: '', fixed: 'right'}
                ]
            ]
        });

        //监听行选中
        treeTable.on('row(currentTableId)', function (obj) {
            obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
        });
    });
</script>
</body>
</html>