<!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="material-form">
                <div class="select-list">
                    <ul>
                        <li>
                            资料名称：<input type="text" name="materialName"/>
                        </li>
                        <li>
                            所属项目：<input type="text" name="projectName"/>
                        </li>
                        <li>
                            资料类型：
                            <select name="materialType">
                                <option value="">所有</option>
                                <option value="1">基础资料</option>
                                <option value="2">财务资料</option>
                                <option value="3">法务资料</option>
                                <option value="4">尽调附件</option>
                            </select>
                        </li>
                        <li>
                            资料状态：
                            <select name="materialStatus">
                                <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:material:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="risk:material:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="risk:material:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="risk:material: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:material:edit')}]];
    var removeFlag = [[${@permission.hasPermi('risk:material:remove')}]];
    var prefix = ctx + "risk/material";
    var materialTypes = [
        {"dictValue":"1","dictLabel":"基础资料"},
        {"dictValue":"2","dictLabel":"财务资料"},
        {"dictValue":"3","dictLabel":"法务资料"},
        {"dictValue":"4","dictLabel":"尽调附件"}
    ];
    var materialStatuses = [
        {"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: "submitDate",
            sortOrder: "desc",
            columns: [{
                checkbox: true
            },
            {
                field: 'materialId',
                title: '资料ID',
                visible: false
            },
            {
                field: 'materialName',
                title: '资料名称',
                formatter: function(value, row, index) {
                    return '<a href="javascript:void(0)" onclick="$.operate.edit(\'' + row.materialId + '\')">' + value + '</a>';
                }
            },
            {
                field: 'materialType',
                title: '资料类型',
                formatter: function(value) {
                    return $.table.selectDictLabel(materialTypes, value);
                }
            },
            {
                field: 'projectName',
                title: '所属项目'
            },
            {
                field: 'ownerName',
                title: '负责人'
            },
            {
                field: 'sourceChannel',
                title: '资料来源'
            },
            {
                field: 'submitDate',
                title: '提交日期'
            },
            {
                field: 'materialStatus',
                title: '资料状态',
                formatter: function(value) {
                    return $.table.selectDictLabel(materialStatuses, 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.materialId + '\')"><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.materialId + '\')"><i class="fa fa-remove"></i>删除</a>');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
