<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('模型对象列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>模型名称：</label>
                                <input type="text" name="modelName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="model:modelProject:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="model:modelProject:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="model:modelProject:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="model:modelProject:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var modelDbsFlag = [[${@permission.hasPermi('model:modelDbs:view')}]];
        var modelVersionFlag = [[${@permission.hasPermi('model:modelVersion:view')}]];
        var dataTypeFlag = [[${@permission.hasPermi('model:dataType:view')}]];
        var defaultFieldFlag = [[${@permission.hasPermi('model:defaultField:view')}]];
        var modelEntityFlag = [[${@permission.hasPermi('model:modelEntity:view')}]];
        var editFlag = [[${@permission.hasPermi('model:modelProject:edit')}]];
        var removeFlag = [[${@permission.hasPermi('model:modelProject:remove')}]];
        var prefix = ctx + "model/modelProject";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "模型对象",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: true
                },
                {
                    field: 'modelName',
                    title: '模型名称'
                },
                {
                    field: 'modelRemark',
                    title: '模型描述'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + modelEntityFlag + '" href="javascript:void(0)" onclick="modelEntity(\'' + row.id + '\',\'' + row.modelName + '\')"><i class="fa fa-list"></i> 数据表 </a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        var more = [];
                        actions.push("<a class='btn btn-warning btn-xs " + modelVersionFlag + "' href='javascript:void(0)' onclick='modelVersion(" + row.id + ")'><i class='fa fa-list'></i>模型版本</a> ");
                        actions.push("<a class='btn btn-warning btn-xs " + modelDbsFlag + "' href='javascript:void(0)' onclick='modelDbs(" + row.id + ")'><i class='fa fa-list'></i>数据库连接</a> ");
                        actions.push("<a class='btn btn-warning btn-xs " + dataTypeFlag + "' href='javascript:void(0)' onclick='dataType(" + row.id + "," + row.versionId + ")'><i class='fa fa-list'></i>数据类型</a> ");
                        actions.push("<a class='btn btn-primary btn-xs " + defaultFieldFlag + "' href='javascript:void(0)' onclick='defaultField(" + row.id + ")'><i class='fa fa-list'></i>默认字段</a> ");

                        // actions.push('<a tabindex="0" class="btn btn-info btn-xs" role="button" data-container="body" data-placement="left" data-toggle="popover" data-html="true" data-trigger="hover" data-content="' + more.join('') + '"><i class="fa fa-chevron-circle-right"></i>更多操作</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /** 数据库连接 */
        function modelDbs(projectId) {
            var url = ctx + 'model/modelDbs?projectId=' + projectId;
            $.modal.openTab("数据库连接", url);
        }
        /** 数据类型 */
        function dataType(projectId, versionId) {
            var url = ctx + "model/dataType?projectId=" + projectId + "&versionId=0";
            $.modal.openTab("数据类型", url);
        }
        /** 默认字段 */
        function defaultField(projectId) {
            var url = ctx + "model/modelField?projectId=" + projectId + "&entityId=0&versionId=0";
            $.modal.openTab("默认字段", url);
        }
        /** 数据表 */
        function modelEntity(projectId) {
            var url = ctx + 'model/modelEntity?projectId=' + projectId + "&versionId=0";
            $.modal.openTab("数据表一览", url);
        }
        /** 模型版本 */
        function modelVersion(projectId) {
            var url = ctx + 'model/modelVersion/versionLine/' + projectId;
            $.modal.openTab("模型版本", url);
        }
    </script>
</body>
</html>