<!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="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>人员姓名：</label>
                                <input type="text" name="usernName"/>
                            </li>
                            <li>
                                <label>离职时间：</label>
                                <input type="text" class="time-input" placeholder="请选择离职时间" name="leavedate"/>
                            </li>
                            <li>
                                <label>离职状态：</label>
                                <select name="leavestate" th:with="type=${@dict.getType('sys_user_leave')}">
                                    <option value="">---请选择---</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>审核意见：</label>
                                <select name="examinestate" th:with="type=${@dict.getType('sys_examine_state')}">
                                    <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="system:leave:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:leave:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:leave:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:leave: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('system:leave:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:leave:remove')}]];
        var PrintFlag = [[${@permission.hasPermi('system:leave:print')}]];
        var downloadFlag = [[${@permission.hasPermi('system:leave:examine')}]];
        var examinestateDatas = [[${@dict.getType('sys_examine_state')}]];
        var leavestateData = [[${@dict.getType('sys_user_leave')}]];
        var workstateData = [[${@dict.getType('sys_user_work')}]];
        var prefix = ctx + "system/leave";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "人员离职",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'userId',
                    title: 'userId',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '人员姓名'
                },
                {
                    field: 'areaname',
                    title: '地区'
                },
                {
                    field: 'leavereason',
                    title: '离职原因'
                },
                {
                    field: 'depart',
                    title: '所属单位'
                },
                {
                    field: 'leavedate',
                    title: '离职时间'
                },
                {
                    field: 'workstate',
                    title: '工作交接',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(workstateData, value);
                    }
                },
                {
                    field: 'leavestate',
                    title: '离职状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(leavestateData, value);
                    }
                },
                {
                    field: 'examinename',
                    title: '审核人'
                },
                {
                    field: 'examinedate',
                    title: '审核日期'
                },
                {
                    field: 'examinestate',
                    title: '审核意见',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(examinestateDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.examinestate === '2'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + downloadFlag + '" href="javascript:void(0)" onclick="leaveAuditing(\'' + row.id +  '\')"><i class="fa fa-edit"></i>审核</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + PrintFlag + '" href="javascript:void(0)" onclick="auditingPrint(\'' + row.id + '/' + row.userId + '\')"><i class="fa fa-download"></i>打印</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else{
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a disabled class="btn btn-success btn-xs ' + downloadFlag + '" href="javascript:void(0)"><i class="fa fa-edit"></i>审核</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + PrintFlag + '" href="javascript:void(0)" onclick="auditingPrint(\'' + row.id + '/' + row.userId + '\')"><i class="fa fa-download"></i>打印</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function leaveAuditing(id) {
            var url ='/system/leave/examine/' + id;
            $.modal.open("涉密人员离职审核", url);
        }
        function auditingPrint(id,userId){
            var url ='/system/leave/print/' + id;
            $.modal.openTab("打印", url);
        }
    </script>
</body>
</html>
