<!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="project-form">
                <div class="select-list">
                    <ul>
                        <li>
                            项目编号：<input type="text" name="projectCode"/>
                        </li>
                        <li>
                            项目名称：<input type="text" name="projectName"/>
                        </li>
                        <li>
                            风险等级：
                            <select name="riskLevel">
                                <option value="">所有</option>
                                <option value="1">低</option>
                                <option value="2">中</option>
                                <option value="3">高</option>
                            </select>
                        </li>
                        <li>
                            项目状态：
                            <select name="projectStatus">
                                <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:project:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="risk:project:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="risk:project:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="risk:project: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:project:edit')}]];
    var removeFlag = [[${@permission.hasPermi('risk:project:remove')}]];
    var prefix = ctx + "risk/project";
    var projectTypes = [
        {"dictValue":"1","dictLabel":"股权投资"},
        {"dictValue":"2","dictLabel":"债权投资"},
        {"dictValue":"3","dictLabel":"并购重组"},
        {"dictValue":"4","dictLabel":"基金投后"}
    ];
    var riskLevels = [
        {"dictValue":"1","dictLabel":"低"},
        {"dictValue":"2","dictLabel":"中"},
        {"dictValue":"3","dictLabel":"高"}
    ];
    var projectStatuses = [
        {"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: "dueDate",
            sortOrder: "asc",
            columns: [{
                checkbox: true
            },
            {
                field: 'projectId',
                title: '项目ID',
                visible: false
            },
            {
                field: 'projectCode',
                title: '项目编号'
            },
            {
                field: 'projectName',
                title: '项目名称',
                formatter: function(value, row, index) {
                    return '<a href="javascript:void(0)" onclick="$.operate.edit(\'' + row.projectId + '\')">' + value + '</a>';
                }
            },
            {
                field: 'projectType',
                title: '项目类型',
                formatter: function(value) {
                    return $.table.selectDictLabel(projectTypes, value);
                }
            },
            {
                field: 'orgName',
                title: '所属机构'
            },
            {
                field: 'assessor',
                title: '评估师'
            },
            {
                field: 'riskLevel',
                title: '风险等级',
                formatter: function(value) {
                    return $.table.selectDictLabel(riskLevels, value);
                }
            },
            {
                field: 'dueDate',
                title: '截止日期',
                sortable: true
            },
            {
                field: 'projectStatus',
                title: '项目状态',
                formatter: function(value) {
                    return $.table.selectDictLabel(projectStatuses, 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.projectId + '\')"><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.projectId + '\')"><i class="fa fa-remove"></i>删除</a>');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
