<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>确认交付</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
    <style>
        /*导入弹窗css*/

        html{
            background-color: #fff;
        }
        .main-box{padding: 20px 30px 0 10px;}

        /*导入弹窗css*/
    </style>
</head>
<body>
<div id="importCustomer" class="main-box">
    <form class="layui-form" action="">
        <blockquote class="layui-elem-quote">接入信息</blockquote>
        <div class="layui-row layui-col-space12 layui-form-item mt-20">
            <div class="layui-col-lg4 layui-col-sm4">
                <label class="layui-form-label"><i class="mark">*</i>电站名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="tenantNameAnother" lay-verify="required"
                           autocomplete="off" class="layui-input" value="${entry.tenantName}">
                </div>
            </div>
            <div class="layui-col-lg4 layui-col-sm4">
                <label class="layui-form-label"><i class="mark">*</i>电站类型：</label>
                <div class="layui-input-block">
                    <input type="text" name="regno" id="regno" lay-verify="required"
                           autocomplete="off" class="layui-input" value="${entry.regno}">
                </div>
            </div>
            <div class="layui-col-lg4 layui-col-sm4" >
                <div>
                    <label class="layui-form-label"><i class="mark">*</i>组件容量：</label>
                    <div class="layui-input-block">
                        <input type="text" name="mobileAnother" lay-verify="recevierMobile"
                               class="layui-input" autocomplete="off" value="${entry.mobile}">
                        <span class="pos-a h-32 lh-32 layui-span-unit">kWp</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space12 layui-form-item">
            <div class="layui-col-lg8 layui-col-sm8">
                <label class="layui-form-label"><i class="mark">*</i>安装地址：</label>
                <div class="layui-input-block">
                    <div class="layui-col-lg2 layui-col-sm2 pr-10">
                        <select name="provinceAnother" id="provinceAnother" lay-verify="required" lay-filter="provinceAnother" lay-search>
                            <option value="">请选择省</option>
                            <c:forEach items="${pros}" var="pro">
                                <option value="${pro.columns.ProvinceName}"
                                        title="${pro.columns.ProvinceID}"
                                        <c:if test="${entry.province eq pro.columns.ProvinceName}">selected</c:if>>${pro.columns.ProvinceName}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="layui-col-lg2 layui-col-sm2 pr-10">
                        <select name="cityAnother" id="cityAnother" lay-verify="required" lay-filter="cityAnother" lay-search>
                            <option value="">请选择市</option>
                            <option value="${entry.city}" selected>${entry.city}</option>
                        </select>
                    </div>
                    <div class="layui-col-lg2 layui-col-sm2 pr-10">
                        <select name="areaAnother" id="areaAnother" lay-verify="required" lay-search>
                            <option value="">请选择县/区</option>
                            <option value="${entry.area}" selected>${entry.area}</option>
                        </select>
                    </div>
                    <div class="layui-col-lg6 layui-col-sm6">
                        <div class="layui-inline" style="width: 100%">
                            <input type="text" name="customerAddressAnother" lay-verify="required"
                                   autocomplete="off" class="layui-input" value="${entry.address}">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-lg4 layui-col-sm4">
                <div>
                    <label class="layui-form-label"><i class="mark">*</i>电价：</label>
                    <div class="layui-input-block">
                        <input type="text" name="mobileAnother" lay-verify="recevierMobile"
                               class="layui-input" autocomplete="off" value="${entry.mobile}">
                        <span class="pos-a h-32 lh-32 layui-span-unit">元/kWp</span>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div class="operate-footer" >
        <div class="layui-form-item text-c" style="text-align: center;">
            <button type="button" class="layui-btn" id="sureDeliver">确认</button>
            <button type="button" onclick="closeSelf()" class="layui-btn layui-btn-primary ">取消</button>
        </div>
    </div>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="${ctxPlugin}/static/js/jquery-3.3.1.min.js"></script>
<script>
    var categorySelect;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        table = tableExt.getLayTable();


        $(function () {

            var deliverFlag = true;
            $('#sureDeliver').click(function(){
                if(!deliverFlag){
                    return;
                }

               /* var generatorNo = $("#generatorNo").val();
                if(isBlank(generatorNo)){
                    layer.msg('请输入发电户号');
                    return;
                }*/
                var uploadRet = $('input[name=uploadRet]').val();
                if (isBlank(uploadRet)) {
                    layer.msg('请上传交付签收表');
                    return;
                }
                deliverFlag = false;
                $.ajax({
                    type: 'post',
                    url: '${ctx}/customerEntry/accept',
                    data: {
                        id: '${id}',
                        deliverFile: uploadRet,
                        generatorNo:12
                    },
                    success: function(data){
                        if (data.code == '200') {
                            parent.layer.msg('操作成功', {time: 1000});
                            closeSelf();
                            parent.searchOrder();
                        } else if (data.code == '501') {
                            layer.msg(data.errMsg, {time: 1000});
                        } else {
                            layer.msg('操作失败', {time: 1000});
                        }
                    },
                    complete: function(){
                        deliverFlag = true;
                    }
                });
            });

            $('#deliverFile').change(function () {
                var file = $(this)[0].files[0];
                if (isBlank(file)) {
                    return;
                }
                var suffix = file.name.split('.')[1].toLowerCase();
                var arr = ['jpg', 'gif', 'png', 'jpeg', 'bpm'];
                if (arr.indexOf(suffix) === -1) {
                    layer.msg('请上传图片');
                    return;
                }
                var formData = new FormData();
                formData.append("file", file);
                $.ajax({
                    url: "${ctx}/common/uploadFile",
                    type: 'POST',
                    data: formData,
                    processData: false,
                    contentType: false,
                    success: function (data) {
                        $('#filename').val(file.name);
                        <%--$('#logo').attr('src', '${commonStaticImgPath}' + data.path);--%>
                        $('input[name=uploadRet]').val(data.path);
                    }
                });
            });
        })

        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>