<!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="template-form">
                <div class="select-list">
                    <ul>
                        <li>
                            模板名称：<input type="text" name="templateName"/>
                        </li>
                        <li>
                            模板类型：
                            <select name="templateType">
                                <option value="">所有</option>
                                <option value="1">尽调模板</option>
                                <option value="2">评估模板</option>
                                <option value="3">风控清单</option>
                                <option value="4">标准函件</option>
                            </select>
                        </li>
                        <li>
                            模板状态：
                            <select name="templateStatus">
                                <option value="">所有</option>
                                <option value="0">草稿</option>
                                <option value="1">已发布</option>
                                <option value="2">停用</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:template:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="risk:template:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="risk:template:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="risk:template: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:template:edit')}]];
    var removeFlag = [[${@permission.hasPermi('risk:template:remove')}]];
    var prefix = ctx + "risk/template";
    var templateTypes = [
        {"dictValue":"1","dictLabel":"尽调模板"},
        {"dictValue":"2","dictLabel":"评估模板"},
        {"dictValue":"3","dictLabel":"风控清单"},
        {"dictValue":"4","dictLabel":"标准函件"}
    ];
    var templateStatuses = [
        {"dictValue":"0","dictLabel":"草稿"},
        {"dictValue":"1","dictLabel":"已发布"},
        {"dictValue":"2","dictLabel":"停用"}
    ];

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "模板",
            sortName: "publishTime",
            sortOrder: "desc",
            columns: [{
                checkbox: true
            },
            {
                field: 'templateId',
                title: '模板ID',
                visible: false
            },
            {
                field: 'templateName',
                title: '模板名称',
                formatter: function(value, row, index) {
                    return '<a href="javascript:void(0)" onclick="$.operate.edit(\'' + row.templateId + '\')">' + value + '</a>';
                }
            },
            {
                field: 'templateType',
                title: '模板类型',
                formatter: function(value) {
                    return $.table.selectDictLabel(templateTypes, value);
                }
            },
            {
                field: 'versionNo',
                title: '版本号'
            },
            {
                field: 'applicableScene',
                title: '适用场景'
            },
            {
                field: 'maintainer',
                title: '维护人'
            },
            {
                field: 'publishTime',
                title: '发布时间'
            },
            {
                field: 'templateStatus',
                title: '模板状态',
                formatter: function(value) {
                    return $.table.selectDictLabel(templateStatuses, 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.templateId + '\')"><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.templateId + '\')"><i class="fa fa-remove"></i>删除</a>');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
