<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改人员离职')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <div id="examineusername" style="display: none;">[[${sysuser.userName}]]</div>
    <form class="form-horizontal m" id="form-leave-edit" th:object="${leaveuser}">
        <input name="id" th:field="*{id}" type="hidden">
        <input name="userId" type="hidden" th:value="*{userId}" id="userId"/>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">提交人:</label>
                    <div class="col-sm-8">
                        <input disabled name="userName" th:field="*{userName}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">离职状态:</label>
                    <div class="col-sm-8">
                        <select name="leavestate" required class="form-control m-b"  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>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">脱密期:</label>
                    <div class="col-sm-8">
                        <input name="country" required th:field="*{country}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">工作交接:</label>
                    <div class="col-sm-8">
                        <select name="workstate" required class="form-control m-b"  th:with="type=${@dict.getType('sys_user_work')}">
                            <option value="">---请选择---</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">领导意见:</label>
                    <div class="col-sm-8">
                        <select name="examinestate" required class="form-control m-b"  th:with="type=${@dict.getType('sys_examine_state')}">
                            <option value="">---请选择---</option>
                            <option th:each="dict : ${type}" th:if="${dict.dictValue != '2'}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label">离职原因:</label>
                    <div class="col-xs-10">
                        <textarea name="leavereason" readonly class="form-control">[[*{leavereason}]]</textarea>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "system/leave";
    $("#form-leave-edit").validate({
        focusCleanup: true
    });
    /* 用户管理-新增-选择部门树 */
    function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        var url = ctx + "system/user/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }
    function doSubmit(index, layero){
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }
    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-leave-edit").serializeArray();
            var examinedate = new Date().toLocaleDateString().replace(/\//g, '-');
            var examinename = document.querySelector('#examineusername').innerHTML;
            data.push({"name": "examinedate", "value": examinedate});
            data.push({"name": "examinename", "value": examinename});
            $.operate.save(prefix + "/examine", data);
        }
    }

    $("input[name='leavedate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='examinedate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>