<!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="report-form">
                <div class="select-list">
                    <ul>
                        <li>
                            报告编号：<input type="text" name="reportCode"/>
                        </li>
                        <li>
                            报告名称：<input type="text" name="reportName"/>
                        </li>
                        <li>
                            报告类型：
                            <select name="reportType">
                                <option value="">所有</option>
                                <option value="1">尽调报告</option>
                                <option value="2">风险评估</option>
                                <option value="3">投后跟踪</option>
                                <option value="4">复核意见</option>
                            </select>
                        </li>
                        <li>
                            报告状态：
                            <select name="reportStatus">
                                <option value="">所有</option>
                                <option value="0">草稿</option>
                                <option value="1">审核中</option>
                                <option value="2">已发布</option>
                                <option value="3">已归档</option>
                            </select>
                        </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="risk:report:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="risk:report:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="risk:report:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="risk:report: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 editFlag = [[${@permission.hasPermi('risk:report:edit')}]];
    var removeFlag = [[${@permission.hasPermi('risk:report:remove')}]];
    var prefix = ctx + "risk/report";
    var reportTypes = [
        {"dictValue":"1","dictLabel":"尽调报告"},
        {"dictValue":"2","dictLabel":"风险评估"},
        {"dictValue":"3","dictLabel":"投后跟踪"},
        {"dictValue":"4","dictLabel":"复核意见"}
    ];
    var reportStatuses = [
        {"dictValue":"0","dictLabel":"草稿"},
        {"dictValue":"1","dictLabel":"审核中"},
        {"dictValue":"2","dictLabel":"已发布"},
        {"dictValue":"3","dictLabel":"已归档"}
    ];

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "报告",
            sortName: "publishDate",
            sortOrder: "desc",
            columns: [{
                checkbox: true
            },
            {
                field: 'reportId',
                title: '报告ID',
                visible: false
            },
            {
                field: 'reportCode',
                title: '报告编号'
            },
            {
                field: 'reportName',
                title: '报告名称',
                formatter: function(value, row, index) {
                    return '<a href="javascript:void(0)" onclick="$.operate.edit(\'' + row.reportId + '\')">' + value + '</a>';
                }
            },
            {
                field: 'projectName',
                title: '所属项目'
            },
            {
                field: 'reportType',
                title: '报告类型',
                formatter: function(value) {
                    return $.table.selectDictLabel(reportTypes, value);
                }
            },
            {
                field: 'versionNo',
                title: '版本号'
            },
            {
                field: 'reviewer',
                title: '复核人'
            },
            {
                field: 'publishDate',
                title: '发布时间'
            },
            {
                field: 'reportStatus',
                title: '报告状态',
                formatter: function(value) {
                    return $.table.selectDictLabel(reportStatuses, value);
                }
            },
            {
                title: '操作',
                align: 'center',
                formatter: function(value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.reportId + '\')"><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.reportId + '\')"><i class="fa fa-remove"></i>删除</a>');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
