<!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="org-form">
                <div class="select-list">
                    <ul>
                        <li>
                            组织名称：<input type="text" name="orgName"/>
                        </li>
                        <li>
                            组织类别：
                            <select name="orgType">
                                <option value="">所有</option>
                                <option value="1">总部机构</option>
                                <option value="2">资管中心</option>
                                <option value="3">职能中心</option>
                                <option value="4">分支机构</option>
                            </select>
                        </li>
                        <li>
                            组织状态：
                            <select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></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:org:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="risk:org:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="risk:org:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="risk:org: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:org:edit')}]];
    var removeFlag = [[${@permission.hasPermi('risk:org:remove')}]];
    var statusDatas = [[${@dict.getType('sys_normal_disable')}]];
    var prefix = ctx + "risk/org";
    var orgTypes = [
        {"dictValue":"1","dictLabel":"总部机构"},
        {"dictValue":"2","dictLabel":"资管中心"},
        {"dictValue":"3","dictLabel":"职能中心"},
        {"dictValue":"4","dictLabel":"分支机构"}
    ];

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "组织机构",
            sortName: "sortNum",
            sortOrder: "asc",
            columns: [{
                checkbox: true
            },
            {
                field: 'orgId',
                title: '机构ID',
                visible: false
            },
            {
                field: 'orgName',
                title: '组织名称',
                formatter: function(value, row, index) {
                    return '<a href="javascript:void(0)" onclick="$.operate.edit(\'' + row.orgId + '\')">' + value + '</a>';
                }
            },
            {
                field: 'orgType',
                title: '组织类别',
                formatter: function(value) {
                    return $.table.selectDictLabel(orgTypes, value);
                }
            },
            {
                field: 'leader',
                title: '负责人'
            },
            {
                field: 'phone',
                title: '联系电话'
            },
            {
                field: 'email',
                title: '电子邮箱'
            },
            {
                field: 'status',
                title: '机构状态',
                formatter: function(value) {
                    return $.table.selectDictLabel(statusDatas, 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.orgId + '\')"><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.orgId + '\')"><i class="fa fa-remove"></i>删除</a>');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
