<%@ 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">
                <label class="layui-form-label"><i class="mark">*</i>变更类型：</label>
                <div class="layui-input-block ">
                    <select id="rectification" name="rectification" lay-filter="rectification" required>
                        <option value="" rel=""></option>
                        <c:forEach items="${list}" var="ins">
                            <option value="${ins.columns.id}" rel="${ins.columns.status}">${ins.columns.name}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="layui-col-xs11 mb-10">
                <label class="layui-form-label">变更后状态：</label>
                <div class="layui-input-block">
                    <input type="text" id="status" name="name" value="" autocomplete="off" class="layui-input layui-bg-gray" disabled="disabled">
                </div>
            </div>
            <div class="layui-col-xs11 mb-10" >
                <label class="layui-form-label">申请原因：</label>
                <div class="layui-input-block">
                    <textarea id="applyReasonName" class="idea-text f-l layui-col-xs12" style="height: 100px;padding: 10px"></textarea>
                </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 ids = "${ids}";
        var refuseFlag = true;
        $('#refuseInDoc').click(function(){
            if(!refuseFlag){
                return;
            }

            var rectificationId = $('#rectification').val();

            var applyReasonName = $('#applyReasonName').val();

            if (isBlank(rectificationId)) {
                layer.msg('请选择变更类型', {icon: 2});
                return;
            }

            refuseFlag = false;
            $.ajax({
                url:"${ctx}/customerEntry/saveApplyChange",
                type:"POST",
                data: {
                    ids: ids,
                    rectificationId: rectificationId,
                    applyReasonName: applyReasonName
                }
                , success: function (result) {
                    if (result.code == '200') {
                        parent.layer.msg('操作成功', {icon: 1});
                        closeSelf();
                        parent.searchOrder();
                    } else {
                        layer.msg(result.errMsg, {icon: 2});
                    }
                }
            })
        });

        form.on('select(rectification)',function(data){
            var status = $(data.elem).find("option:selected").attr("rel");
            var rs = "";
            if (status == "0") {
                rs = "暂存";
            } else if (status == "1") {
                rs = "设计审核"
            } else if (status == "2") {
                rs = "待安装"
            } else if (status == "3") {
                rs = "待安装验收"
            } else if (status == "4") {
                rs = "待并网"
            } else if (status == "5") {
                rs = "待上传发票"
            } else if (status == "6") {
                rs = "待签署合同"
            } else if (status == "7") {
                rs = "待并网验收"
            }
            $("#status").val(rs);
        })

    });


    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>
