<%@ 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}/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}">
<%--                <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="returnType" name="returnType">--%>
<%--                            <option value="">请选择</option>--%>
<%--                            <option value="10">终止进件</option>--%>
<%--                            <option value="20">退回合规</option>--%>
<%--                            <option value="30">退回完工</option>--%>
<%--                        </select>--%>
<%--                    </div>--%>
<%--                </div>--%>
                <div class="layui-inline layui-col-xs12">
                    <label class="layui-form-label w-130"><i class="red">*</i>终止原因：</label>
                    <div class="layui-input-block ">
                        <textarea name="reason" id="reason" placeholder="" class="layui-textarea"></textarea>
                    </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>


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

        var refuseFlag = false;
        $('#refuseInDoc').click(function(){
            if(refuseFlag){
                return;
            }
            var entryId = $('#entryId').val();
            // var returnType = $('#returnType').val();
            // if (isBlank(returnType)) {
            //     layer.msg('请选择退回类型', {icon: 2});
            //     return;
            // }
            var reason = $('#reason').val();
            if (isBlank(reason)) {
                layer.msg('请输入终止进件原因', {icon: 2});
                return;
            }
            refuseFlag = true;
            var index= layer.load(2, {shade: [0.5,'#fff'], content:''});
            $.ajax({
                type:"POST",
                url:"${ctx}/customerEntry/cancelGFApply",
                data:{
                    entryId:entryId,
                    // returnType:returnType,
                    returnType:'10',
                    reason:reason
                },
                success:function(res){
                    if(res.code=="200"){
                        layer.msg('操作成功！', {icon: 1, time: 1000}, function () {
                            layer.close(index);
                            closeSelf();
                            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>
