<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
    <meta name="decorator" content="base" />
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/formSelects-v4.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css">
    <style>
        html{background-color: #fff;padding-bottom: 50px;}
    </style>
</head>
<body>
<div class="layui-form">
    <div class="layui-card">
        <div class="layui-card-body ">
            <div class="layui-col-xs11 mb-10">
                <input type="hidden" name="entryId" id="entryId" value="${id}">
                <input type="hidden" name="step" id="step" value="${step}">
                <div class="layui-form-item " style="margin-bottom: 15px;">
                    <label class="layui-form-label w-130"><i class="red">*</i>附件类型：</label>
                    <div class="layui-input-block ml-130">
                        <select id="fileCodeS" name="fileCodeS"  xm-select="fileCodeS" xm-select-type="1" xm-select-height="40px" xm-select-show-count="6" xm-select-search>
                            <option value=""></option>
                            <c:forEach items="${fileCode}" var="tra">
                                <option value="${tra.code}" >${tra.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="operate-footer">
        <input type="button" class="layui-btn" id="refuseInDoc" value="提交"/>
        <input type="button" class="layui-btn layui-btn-primary" onclick="closeSelf();" value="取消"/>
    </div>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/lib/formSelects-v4.js"></script>
<script>


    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','laydate','jquery','layer', 'formSelects'], function () {
        $ = layui.$
            , form = layui.form
            , layer = layui.layer
            ,formSelects = layui.formSelects
            ,laydate = layui.laydate;
        //执行实例

        var refuseFlag = false;
        $('#refuseInDoc').click(function(){
            if(refuseFlag){
                return;
            }

            var entryId = $('#entryId').val();
            var step = $('#step').val();
            var fileCodeS =  formSelects.value('fileCodeS', 'valStr');
            if (isBlank(fileCodeS)) {
                layer.msg('请选择上传附件', {icon: 2});
                return;
            }
            refuseFlag = true;
            var index= layer.load(2, {shade: [0.5,'#fff'], content:''});
            $.ajax({
                type:"POST",
                url:"${ctx}/customerEntry/updateHRFiles",
                data:{
                    entryId:entryId,
                    step:step,
                    fileCode:fileCodeS
                },
                success:function(res){
                    if(res.code=="200"){
                        let frameIndex = parent.layer.getFrameIndex(window.name);//获取当前弹出层的层级
                        layer.msg('操作成功，补充资料已提交！', {icon: 1, time: 1000}, function () {
                            layer.close(index);
                            parent.layer.close(frameIndex);
                            // parent.searchOrder();
                        });
                    } else{
                        layer.close(index);
                        layer.msg(res.errMsg,{time:2000});
                    }
                    refuseFlag = false;
                },
                error:function (data) {
                    layer.close(index);
                    refuseFlag = false;
                }
            }) ;
        });
    });


    window.closeSelf = function () {
        var index = parent.layer.getFrameIndex(window.name);
        // window.parent.location.reload();//刷新父级页面
        parent.layer.close(index);//关闭当前页
    }

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }

</script>
</body>
</html>
